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

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

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

enum  {
	DINO_CALLS_0_PROPERTY,
	DINO_CALLS_ID_PROPERTY,
	DINO_CALLS_NUM_PROPERTIES
};
static GParamSpec* dino_calls_properties[DINO_CALLS_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 _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _DinoCallsInitiateCallData DinoCallsInitiateCallData;
typedef struct _DinoCallsCanConversationDoCallsData DinoCallsCanConversationDoCallsData;
typedef struct _DinoCallsGetCallResourcesData DinoCallsGetCallResourcesData;
typedef struct _DinoCallsContainsJmiResourcesData DinoCallsContainsJmiResourcesData;
#define _qlite_statement_builder_unref0(var) ((var == NULL) ? NULL : (var = (qlite_statement_builder_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block7Data Block7Data;
typedef struct _Block8Data Block8Data;
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
enum  {
	DINO_CALLS_CALL_INCOMING_SIGNAL,
	DINO_CALLS_CALL_OUTGOING_SIGNAL,
	DINO_CALLS_CALL_TERMINATED_SIGNAL,
	DINO_CALLS_CONFERENCE_INFO_RECEIVED_SIGNAL,
	DINO_CALLS_NUM_SIGNALS
};
static guint dino_calls_signals[DINO_CALLS_NUM_SIGNALS] = {0};

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

struct _DinoCallsInitiateCallData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoCalls* self;
	DinoEntitiesConversation* conversation;
	gboolean video;
	DinoCallState* result;
	DinoEntitiesCall* call;
	DinoEntitiesCall* _tmp0_;
	DinoEntitiesCall* _tmp1_;
	DinoEntitiesCall* _tmp2_;
	DinoEntitiesAccount* _tmp3_;
	DinoEntitiesAccount* _tmp4_;
	DinoEntitiesCall* _tmp5_;
	XmppJid* _tmp6_;
	XmppJid* _tmp7_;
	XmppJid* _tmp8_;
	DinoStreamInteractor* _tmp9_;
	DinoModuleIdentity* _tmp10_;
	gpointer _tmp11_;
	DinoMucManager* _tmp12_;
	XmppJid* _tmp13_;
	XmppJid* _tmp14_;
	DinoEntitiesAccount* _tmp15_;
	DinoEntitiesAccount* _tmp16_;
	XmppJid* _tmp17_;
	XmppJid* _tmp18_;
	DinoEntitiesAccount* _tmp19_;
	DinoEntitiesAccount* _tmp20_;
	XmppJid* _tmp21_;
	XmppJid* _tmp22_;
	XmppJid* _tmp23_;
	DinoEntitiesCall* _tmp24_;
	DinoEntitiesCall* _tmp25_;
	DinoEntitiesCall* _tmp26_;
	DinoEntitiesCall* _tmp27_;
	GDateTime* _tmp28_;
	GDateTime* _tmp29_;
	DinoEntitiesCall* _tmp30_;
	DinoEntitiesCall* _tmp31_;
	DinoStreamInteractor* _tmp32_;
	DinoModuleIdentity* _tmp33_;
	gpointer _tmp34_;
	DinoCallStore* _tmp35_;
	DinoEntitiesCall* _tmp36_;
	DinoCallState* call_state;
	DinoEntitiesCall* _tmp37_;
	DinoStreamInteractor* _tmp38_;
	DinoCallState* _tmp39_;
	DinoCallState* _tmp40_;
	DinoCallState* _tmp41_;
	DinoCallState* _tmp42_;
	DinoEntitiesConversationType _tmp43_;
	DinoEntitiesConversationType _tmp44_;
	DinoEntitiesCall* _tmp45_;
	XmppJid* _tmp46_;
	XmppJid* _tmp47_;
	DinoPeerState* peer_state;
	DinoCallState* _tmp48_;
	XmppJid* _tmp49_;
	XmppJid* _tmp50_;
	DinoPeerState* _tmp51_;
	GeeHashMap* _tmp52_;
	DinoEntitiesCall* _tmp53_;
	DinoPeerState* _tmp54_;
	DinoPeerState* _tmp55_;
	XmppJid* _tmp56_;
	XmppJid* _tmp57_;
	DinoCallState* _tmp58_;
	XmppJid* _tmp59_;
	XmppJid* _tmp60_;
	DinoEntitiesCall* _tmp61_;
	DinoCallState* _tmp62_;
};

struct _DinoCallsCanConversationDoCallsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoCalls* self;
	DinoEntitiesConversation* conversation;
	gboolean result;
	DinoEntitiesAccount* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	DinoEntitiesConversationType _tmp2_;
	DinoEntitiesConversationType _tmp3_;
	XmppJid* _tmp4_;
	XmppJid* _tmp5_;
	DinoEntitiesAccount* _tmp6_;
	DinoEntitiesAccount* _tmp7_;
	XmppJid* _tmp8_;
	XmppJid* _tmp9_;
	XmppJid* _tmp10_;
	gboolean _tmp11_;
	gboolean is_private;
	DinoStreamInteractor* _tmp12_;
	DinoModuleIdentity* _tmp13_;
	gpointer _tmp14_;
	DinoMucManager* _tmp15_;
	DinoEntitiesAccount* _tmp16_;
	DinoEntitiesAccount* _tmp17_;
	XmppJid* _tmp18_;
	XmppJid* _tmp19_;
	gboolean _tmp20_;
	gboolean _tmp21_;
	DinoEntitiesAccount* _tmp22_;
	DinoEntitiesAccount* _tmp23_;
};

struct _DinoCallsGetCallResourcesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoCalls* self;
	DinoEntitiesAccount* account;
	XmppJid* counterpart;
	GeeList* result;
	GeeArrayList* ret;
	GeeArrayList* _tmp0_;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp1_;
	XmppXmppStream* _tmp2_;
	XmppXmppStream* _tmp3_;
	XmppPresenceFlag* presence_flag;
	XmppXmppStream* _tmp4_;
	XmppFlagIdentity* _tmp5_;
	gpointer _tmp6_;
	XmppPresenceFlag* _tmp7_;
	GeeList* full_jids;
	XmppPresenceFlag* _tmp8_;
	GeeList* _tmp9_;
	GeeList* _tmp10_;
	GeeList* _full_jid_list;
	GeeList* _tmp11_;
	gint _full_jid_size;
	GeeList* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	gint _full_jid_index;
	gint _tmp15_;
	gint _tmp16_;
	XmppJid* full_jid;
	GeeList* _tmp17_;
	gpointer _tmp18_;
	XmppXepJingleRtpModule* module;
	XmppXmppStream* _tmp19_;
	XmppModuleIdentity* _tmp20_;
	gpointer _tmp21_;
	XmppXepJingleRtpModule* _tmp22_;
	gboolean supports_rtc;
	XmppXepJingleRtpModule* _tmp23_;
	XmppXmppStream* _tmp24_;
	XmppJid* _tmp25_;
	GeeArrayList* _tmp26_;
	XmppJid* _tmp27_;
};

struct _DinoCallsContainsJmiResourcesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoCalls* self;
	DinoEntitiesAccount* account;
	GeeList* full_jids;
	gboolean result;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppXmppStream* _tmp2_;
	GeeList* _full_jid_list;
	gint _full_jid_size;
	GeeList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint _full_jid_index;
	gint _tmp6_;
	gint _tmp7_;
	XmppJid* full_jid;
	GeeList* _tmp8_;
	gpointer _tmp9_;
	gboolean does_jmi;
	DinoStreamInteractor* _tmp10_;
	DinoModuleIdentity* _tmp11_;
	gpointer _tmp12_;
	DinoEntityInfo* _tmp13_;
	XmppJid* _tmp14_;
	gboolean _tmp15_;
};

struct _Block7Data {
	int _ref_count_;
	DinoCalls* self;
	gulong terminated_handler_id;
	DinoCallState* call_state;
};

struct _Block8Data {
	int _ref_count_;
	DinoCalls* self;
	DinoEntitiesAccount* account;
};

static gint DinoCalls_private_offset;
static gpointer dino_calls_parent_class = NULL;
DinoModuleIdentity* dino_calls_IDENTITY = NULL;
static DinoStreamInteractionModuleIface * dino_calls_dino_stream_interaction_module_parent_iface = NULL;

static guint _dino_entities_call_hash_func_gee_hash_data_func (gconstpointer v,
                                                        gpointer self);
static gboolean _dino_entities_call_equals_func_gee_equal_data_func (gconstpointer a,
                                                              gconstpointer b,
                                                              gpointer self);
static DinoCalls* dino_calls_new (DinoStreamInteractor* stream_interactor,
                           DinoDatabase* db);
static DinoCalls* dino_calls_construct (GType object_type,
                                 DinoStreamInteractor* stream_interactor,
                                 DinoDatabase* db);
static void dino_calls_on_account_added (DinoCalls* self,
                                  DinoEntitiesAccount* account);
static void _dino_calls_on_account_added_dino_stream_interactor_account_added (DinoStreamInteractor* _sender,
                                                                        DinoEntitiesAccount* account,
                                                                        gpointer self);
static void dino_calls_initiate_call_data_free (gpointer _data);
static gboolean dino_calls_initiate_call_co (DinoCallsInitiateCallData* _data_);
static void dino_calls_connect_call_state_signals (DinoCalls* self,
                                            DinoCallState* call_state);
VALA_EXTERN DinoPeerState* dino_call_state_set_first_peer (DinoCallState* self,
                                               XmppJid* peer);
static void dino_calls_initiate_call_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
VALA_EXTERN void dino_call_state_initiate_groupchat_call (DinoCallState* self,
                                              XmppJid* muc,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
VALA_EXTERN void dino_call_state_initiate_groupchat_call_finish (DinoCallState* self,
                                                     GAsyncResult* _res_);
static void dino_calls_can_conversation_do_calls_data_free (gpointer _data);
static gboolean dino_calls_can_conversation_do_calls_co (DinoCallsCanConversationDoCallsData* _data_);
static void dino_calls_get_call_resources_data_free (gpointer _data);
static gboolean dino_calls_get_call_resources_co (DinoCallsGetCallResourcesData* _data_);
static void dino_calls_get_call_resources_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void dino_calls_contains_jmi_resources_data_free (gpointer _data);
static gboolean dino_calls_contains_jmi_resources_co (DinoCallsContainsJmiResourcesData* _data_);
static void dino_calls_contains_jmi_resources_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_);
static void dino_calls_on_incoming_call (DinoCalls* self,
                                  DinoEntitiesAccount* account,
                                  XmppXepJingleSession* session);
VALA_EXTERN void dino_peer_state_set_session (DinoPeerState* self,
                                  XmppXepJingleSession* session);
VALA_EXTERN void dino_call_state_add_peer (DinoCallState* self,
                               DinoPeerState* peer);
static DinoPeerState* dino_calls_get_peer_by_sid (DinoCalls* self,
                                           DinoEntitiesAccount* account,
                                           const gchar* sid,
                                           XmppJid* jid1,
                                           XmppJid* jid2);
static DinoPeerState* dino_calls_create_received_call (DinoCalls* self,
                                                DinoEntitiesAccount* account,
                                                XmppJid* from,
                                                XmppJid* to,
                                                gboolean video_requested);
static DinoCallState* dino_calls_get_call_state_by_call_id (DinoCalls* self,
                                                     DinoEntitiesAccount* account,
                                                     const gchar* call_id,
                                                     XmppJid* counterpart_jid);
static DinoCallState* dino_calls_create_recv_muji_call (DinoCalls* self,
                                                 DinoEntitiesAccount* account,
                                                 const gchar* call_id,
                                                 XmppJid* inviter_jid,
                                                 XmppJid* muc_jid,
                                                 const gchar* message_type);
static void dino_calls_remove_call_from_datastructures (DinoCalls* self,
                                                 DinoEntitiesCall* call);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static void __lambda72_ (Block7Data* _data7_,
                  XmppJid* who_terminated,
                  const gchar* reason_name,
                  const gchar* reason_text);
static void ___lambda72__dino_call_state_terminated (DinoCallState* _sender,
                                              XmppJid* who_terminated,
                                              const gchar* reason_name,
                                              const gchar* reason_text,
                                              gpointer self);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void __lambda71_ (Block8Data* _data8_,
                  XmppXmppStream* stream,
                  XmppXepJingleSession* session);
static void ___lambda71__xmpp_xep_jingle_module_session_initiate_received (XmppXepJingleModule* _sender,
                                                                    XmppXmppStream* stream,
                                                                    XmppXepJingleSession* session,
                                                                    gpointer self);
static void __lambda73_ (Block8Data* _data8_,
                  XmppJid* from,
                  XmppJid* to,
                  const gchar* sid,
                  GeeList* descriptions);
static gboolean __lambda74_ (DinoCalls* self,
                      XmppStanzaNode* description);
static gboolean ___lambda74__gee_predicate (gconstpointer g,
                                     gpointer self);
static gboolean __lambda75_ (DinoCalls* self,
                      XmppStanzaNode* description);
static gboolean ___lambda75__gee_predicate (gconstpointer g,
                                     gpointer self);
static void ___lambda73__xmpp_xep_jingle_message_initiation_module_session_proposed (XmppXepJingleMessageInitiationModule* _sender,
                                                                              XmppJid* from,
                                                                              XmppJid* to,
                                                                              const gchar* sid,
                                                                              GeeList* descriptions,
                                                                              gpointer self);
static void __lambda76_ (Block8Data* _data8_,
                  XmppJid* from,
                  XmppJid* to,
                  const gchar* sid);
VALA_EXTERN void dino_call_state_rename_peer (DinoCallState* self,
                                  XmppJid* from_jid,
                                  XmppJid* to_jid);
static void ___lambda76__xmpp_xep_jingle_message_initiation_module_session_accepted (XmppXepJingleMessageInitiationModule* _sender,
                                                                              XmppJid* from,
                                                                              XmppJid* to,
                                                                              const gchar* sid,
                                                                              gpointer self);
static void __lambda77_ (Block8Data* _data8_,
                  XmppJid* from,
                  XmppJid* to,
                  const gchar* sid);
static void ___lambda77__xmpp_xep_jingle_message_initiation_module_session_rejected (XmppXepJingleMessageInitiationModule* _sender,
                                                                              XmppJid* from,
                                                                              XmppJid* to,
                                                                              const gchar* sid,
                                                                              gpointer self);
static void __lambda78_ (Block8Data* _data8_,
                  XmppJid* from,
                  XmppJid* to,
                  const gchar* sid);
static void ___lambda78__xmpp_xep_jingle_message_initiation_module_session_retracted (XmppXepJingleMessageInitiationModule* _sender,
                                                                               XmppJid* from,
                                                                               XmppJid* to,
                                                                               const gchar* sid,
                                                                               gpointer self);
static void __lambda79_ (Block8Data* _data8_,
                  XmppJid* from_jid,
                  XmppJid* to_jid,
                  const gchar* call_id,
                  gboolean video_requested,
                  GeeList* join_methods,
                  XmppMessageStanza* message_stanza);
static void ___lambda79__xmpp_xep_call_invites_module_call_proposed (XmppXepCallInvitesModule* _sender,
                                                              XmppJid* from,
                                                              XmppJid* to,
                                                              const gchar* call_id,
                                                              gboolean video,
                                                              GeeList* join_methods,
                                                              XmppMessageStanza* message,
                                                              gpointer self);
static void __lambda80_ (Block8Data* _data8_,
                  XmppJid* from_jid,
                  XmppJid* to_jid,
                  const gchar* call_id,
                  const gchar* message_type);
static void ___lambda80__xmpp_xep_call_invites_module_call_accepted (XmppXepCallInvitesModule* _sender,
                                                              XmppJid* from,
                                                              XmppJid* to,
                                                              const gchar* call_id,
                                                              const gchar* message_type,
                                                              gpointer self);
static void __lambda81_ (Block8Data* _data8_,
                  XmppJid* from_jid,
                  XmppJid* to_jid,
                  const gchar* call_id,
                  const gchar* message_type);
static void ___lambda81__xmpp_xep_call_invites_module_call_retracted (XmppXepCallInvitesModule* _sender,
                                                               XmppJid* from,
                                                               XmppJid* to,
                                                               const gchar* call_id,
                                                               const gchar* message_type,
                                                               gpointer self);
static void __lambda82_ (Block8Data* _data8_,
                  XmppJid* from_jid,
                  XmppJid* to_jid,
                  const gchar* call_id,
                  const gchar* message_type);
static void ___lambda82__xmpp_xep_call_invites_module_call_rejected (XmppXepCallInvitesModule* _sender,
                                                              XmppJid* from,
                                                              XmppJid* to,
                                                              const gchar* call_id,
                                                              const gchar* message_type,
                                                              gpointer self);
static void __lambda83_ (DinoCalls* self,
                  XmppJid* jid,
                  XmppXepCoinConferenceInfo* info);
static void ___lambda83__xmpp_xep_coin_module_coin_info_received (XmppXepCoinModule* _sender,
                                                           XmppJid* jid,
                                                           XmppXepCoinConferenceInfo* info,
                                                           gpointer self);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT_BOOLEAN_BOOLEAN (GClosure * closure,
                                                                         GValue * return_value,
                                                                         guint n_param_values,
                                                                         const GValue * param_values,
                                                                         gpointer invocation_hint,
                                                                         gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT (GClosure * closure,
                                                         GValue * return_value,
                                                         guint n_param_values,
                                                         const GValue * param_values,
                                                         gpointer invocation_hint,
                                                         gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_STRING_STRING (GClosure * closure,
                                                         GValue * return_value,
                                                         guint n_param_values,
                                                         const GValue * param_values,
                                                         gpointer invocation_hint,
                                                         gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_XMPP_XEP_COIN_CONFERENCE_INFO (GClosure * closure,
                                                                         GValue * return_value,
                                                                         guint n_param_values,
                                                                         const GValue * param_values,
                                                                         gpointer invocation_hint,
                                                                         gpointer marshal_data);
static void dino_calls_finalize (GObject * obj);
static GType dino_calls_get_type_once (void);
static void _vala_dino_calls_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_calls_get_instance_private (DinoCalls* self)
{
	return G_STRUCT_MEMBER_P (self, DinoCalls_private_offset);
}

static guint
_dino_entities_call_hash_func_gee_hash_data_func (gconstpointer v,
                                                  gpointer self)
{
	guint result;
	result = dino_entities_call_hash_func ((DinoEntitiesCall*) v);
	return result;
}

static gboolean
_dino_entities_call_equals_func_gee_equal_data_func (gconstpointer a,
                                                     gconstpointer b,
                                                     gpointer self)
{
	gboolean result;
	result = dino_entities_call_equals_func ((DinoEntitiesCall*) a, (DinoEntitiesCall*) b);
	return result;
}

void
dino_calls_start (DinoStreamInteractor* stream_interactor,
                  DinoDatabase* db)
{
	DinoCalls* m = NULL;
	DinoCalls* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	g_return_if_fail (db != NULL);
	_tmp0_ = dino_calls_new (stream_interactor, db);
	m = _tmp0_;
	dino_stream_interactor_add_module (stream_interactor, (DinoStreamInteractionModule*) m);
	_g_object_unref0 (m);
}

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

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

static void
_dino_calls_on_account_added_dino_stream_interactor_account_added (DinoStreamInteractor* _sender,
                                                                   DinoEntitiesAccount* account,
                                                                   gpointer self)
{
	dino_calls_on_account_added ((DinoCalls*) self, account);
}

static DinoCalls*
dino_calls_construct (GType object_type,
                      DinoStreamInteractor* stream_interactor,
                      DinoDatabase* db)
{
	DinoCalls * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoDatabase* _tmp1_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoCalls*) 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_;
	g_signal_connect_object (stream_interactor, "account-added", (GCallback) _dino_calls_on_account_added_dino_stream_interactor_account_added, self, 0);
	return self;
}

static DinoCalls*
dino_calls_new (DinoStreamInteractor* stream_interactor,
                DinoDatabase* db)
{
	return dino_calls_construct (DINO_TYPE_CALLS, stream_interactor, db);
}

static void
dino_calls_initiate_call_data_free (gpointer _data)
{
	DinoCallsInitiateCallData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoCallsInitiateCallData, _data_);
}

void
dino_calls_initiate_call (DinoCalls* self,
                          DinoEntitiesConversation* conversation,
                          gboolean video,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	DinoCallsInitiateCallData* _data_;
	DinoCalls* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_data_ = g_slice_new0 (DinoCallsInitiateCallData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_calls_initiate_call_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	_data_->video = video;
	dino_calls_initiate_call_co (_data_);
}

DinoCallState*
dino_calls_initiate_call_finish (DinoCalls* self,
                                 GAsyncResult* _res_)
{
	DinoCallState* result;
	DinoCallsInitiateCallData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

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

static void
dino_calls_initiate_call_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	DinoCallsInitiateCallData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_calls_initiate_call_co (_data_);
}

static gboolean
dino_calls_initiate_call_co (DinoCallsInitiateCallData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = dino_entities_call_new ();
	_data_->call = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->call;
	dino_entities_call_set_direction (_data_->_tmp1_, DINO_ENTITIES_CALL_DIRECTION_OUTGOING);
	_data_->_tmp2_ = _data_->call;
	_data_->_tmp3_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp4_ = _data_->_tmp3_;
	dino_entities_call_set_account (_data_->_tmp2_, _data_->_tmp4_);
	_data_->_tmp5_ = _data_->call;
	_data_->_tmp6_ = dino_entities_conversation_get_counterpart (_data_->conversation);
	_data_->_tmp7_ = _data_->_tmp6_;
	dino_entities_call_set_counterpart (_data_->_tmp5_, _data_->_tmp7_);
	_data_->_tmp9_ = _data_->self->priv->stream_interactor;
	_data_->_tmp10_ = dino_muc_manager_IDENTITY;
	_data_->_tmp11_ = dino_stream_interactor_get_module (_data_->_tmp9_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp10_);
	_data_->_tmp12_ = (DinoMucManager*) _data_->_tmp11_;
	_data_->_tmp13_ = dino_entities_conversation_get_counterpart (_data_->conversation);
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->_tmp15_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = dino_muc_manager_get_own_jid (_data_->_tmp12_, _data_->_tmp14_, _data_->_tmp16_);
	_data_->_tmp18_ = _data_->_tmp17_;
	_g_object_unref0 (_data_->_tmp12_);
	_data_->_tmp8_ = _data_->_tmp18_;
	if (_data_->_tmp8_ == NULL) {
		_data_->_tmp19_ = dino_entities_conversation_get_account (_data_->conversation);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp21_ = dino_entities_account_get_full_jid (_data_->_tmp20_);
		_data_->_tmp22_ = _data_->_tmp21_;
		_data_->_tmp23_ = _xmpp_jid_ref0 (_data_->_tmp22_);
		_xmpp_jid_unref0 (_data_->_tmp8_);
		_data_->_tmp8_ = _data_->_tmp23_;
	}
	_data_->_tmp24_ = _data_->call;
	dino_entities_call_set_ourpart (_data_->_tmp24_, _data_->_tmp8_);
	_data_->_tmp25_ = _data_->call;
	_data_->_tmp26_ = _data_->call;
	_data_->_tmp27_ = _data_->call;
	_data_->_tmp28_ = g_date_time_new_now_utc ();
	_data_->_tmp29_ = _data_->_tmp28_;
	dino_entities_call_set_end_time (_data_->_tmp27_, _data_->_tmp29_);
	dino_entities_call_set_local_time (_data_->_tmp26_, _data_->_tmp29_);
	dino_entities_call_set_time (_data_->_tmp25_, _data_->_tmp29_);
	_g_date_time_unref0 (_data_->_tmp29_);
	_data_->_tmp30_ = _data_->call;
	dino_entities_call_set_encryption (_data_->_tmp30_, DINO_ENTITIES_ENCRYPTION_UNKNOWN);
	_data_->_tmp31_ = _data_->call;
	dino_entities_call_set_state (_data_->_tmp31_, DINO_ENTITIES_CALL_STATE_RINGING);
	_data_->_tmp32_ = _data_->self->priv->stream_interactor;
	_data_->_tmp33_ = dino_call_store_IDENTITY;
	_data_->_tmp34_ = dino_stream_interactor_get_module (_data_->_tmp32_, DINO_TYPE_CALL_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp33_);
	_data_->_tmp35_ = (DinoCallStore*) _data_->_tmp34_;
	_data_->_tmp36_ = _data_->call;
	dino_call_store_add_call (_data_->_tmp35_, _data_->_tmp36_, _data_->conversation);
	_g_object_unref0 (_data_->_tmp35_);
	_data_->_tmp37_ = _data_->call;
	_data_->_tmp38_ = _data_->self->priv->stream_interactor;
	_data_->_tmp39_ = dino_call_state_new (_data_->_tmp37_, _data_->_tmp38_);
	_data_->call_state = _data_->_tmp39_;
	_data_->_tmp40_ = _data_->call_state;
	dino_calls_connect_call_state_signals (_data_->self, _data_->_tmp40_);
	_data_->_tmp41_ = _data_->call_state;
	dino_call_state_set_we_should_send_video (_data_->_tmp41_, _data_->video);
	_data_->_tmp42_ = _data_->call_state;
	dino_call_state_set_we_should_send_audio (_data_->_tmp42_, TRUE);
	_data_->_tmp43_ = dino_entities_conversation_get_type_ (_data_->conversation);
	_data_->_tmp44_ = _data_->_tmp43_;
	if (_data_->_tmp44_ == DINO_ENTITIES_CONVERSATION_TYPE_CHAT) {
		_data_->_tmp45_ = _data_->call;
		_data_->_tmp46_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp47_ = _data_->_tmp46_;
		dino_entities_call_add_peer (_data_->_tmp45_, _data_->_tmp47_);
		_data_->_tmp48_ = _data_->call_state;
		_data_->_tmp49_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp50_ = _data_->_tmp49_;
		_data_->_tmp51_ = dino_call_state_set_first_peer (_data_->_tmp48_, _data_->_tmp50_);
		_data_->peer_state = _data_->_tmp51_;
		_data_->_tmp52_ = _data_->self->jmi_request_peer;
		_data_->_tmp53_ = _data_->call;
		_data_->_tmp54_ = _data_->peer_state;
		gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp52_, _data_->_tmp53_, _data_->_tmp54_);
		_data_->_tmp55_ = _data_->peer_state;
		_data_->_tmp56_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp57_ = _data_->_tmp56_;
		_data_->_state_ = 1;
		dino_peer_state_initiate_call (_data_->_tmp55_, _data_->_tmp57_, dino_calls_initiate_call_ready, _data_);
		return FALSE;
		_state_1:
		dino_peer_state_initiate_call_finish (_data_->_tmp55_, _data_->_res_);
		_g_object_unref0 (_data_->peer_state);
	} else {
		_data_->_tmp58_ = _data_->call_state;
		_data_->_tmp59_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp60_ = _data_->_tmp59_;
		dino_call_state_initiate_groupchat_call (_data_->_tmp58_, _data_->_tmp60_, NULL, NULL);
	}
	_data_->_tmp61_ = _data_->call;
	_data_->_tmp62_ = _data_->call_state;
	g_signal_emit (_data_->self, dino_calls_signals[DINO_CALLS_CALL_OUTGOING_SIGNAL], 0, _data_->_tmp61_, _data_->_tmp62_, _data_->conversation);
	_data_->result = _data_->call_state;
	_xmpp_jid_unref0 (_data_->_tmp8_);
	_g_object_unref0 (_data_->call);
	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;
}

gboolean
dino_calls_can_we_do_calls (DinoCalls* self,
                            DinoEntitiesAccount* account)
{
	DinoPluginsVideoCallPlugin* plugin = NULL;
	DinoApplication* _tmp0_;
	DinoPluginsRegistry* _tmp1_;
	DinoPluginsRegistry* _tmp2_;
	DinoPluginsVideoCallPlugin* _tmp3_;
	DinoPluginsVideoCallPlugin* _tmp4_;
	DinoPluginsVideoCallPlugin* _tmp5_;
	DinoPluginsVideoCallPlugin* _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account != NULL, FALSE);
	_tmp0_ = dino_application_get_default ();
	_tmp1_ = dino_application_get_plugin_registry (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_->video_call_plugin;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	plugin = _tmp4_;
	_tmp5_ = plugin;
	if (_tmp5_ == NULL) {
		result = FALSE;
		_g_object_unref0 (plugin);
		return result;
	}
	_tmp6_ = plugin;
	result = dino_plugins_video_call_plugin_supported (_tmp6_);
	_g_object_unref0 (plugin);
	return result;
}

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

void
dino_calls_can_conversation_do_calls (DinoCalls* self,
                                      DinoEntitiesConversation* conversation,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	DinoCallsCanConversationDoCallsData* _data_;
	DinoCalls* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_data_ = g_slice_new0 (DinoCallsCanConversationDoCallsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_calls_can_conversation_do_calls_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	dino_calls_can_conversation_do_calls_co (_data_);
}

gboolean
dino_calls_can_conversation_do_calls_finish (DinoCalls* self,
                                             GAsyncResult* _res_)
{
	gboolean result;
	DinoCallsCanConversationDoCallsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static gboolean
dino_calls_can_conversation_do_calls_co (DinoCallsCanConversationDoCallsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp1_ = _data_->_tmp0_;
	if (!dino_calls_can_we_do_calls (_data_->self, _data_->_tmp1_)) {
		_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_->_tmp2_ = dino_entities_conversation_get_type_ (_data_->conversation);
	_data_->_tmp3_ = _data_->_tmp2_;
	if (_data_->_tmp3_ == DINO_ENTITIES_CONVERSATION_TYPE_CHAT) {
		_data_->_tmp4_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp6_ = dino_entities_conversation_get_account (_data_->conversation);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = dino_entities_account_get_bare_jid (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = !xmpp_jid_equals_bare (_data_->_tmp5_, _data_->_tmp10_);
		_xmpp_jid_unref0 (_data_->_tmp10_);
		_data_->result = _data_->_tmp11_;
		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;
	} else {
		_data_->_tmp12_ = _data_->self->priv->stream_interactor;
		_data_->_tmp13_ = dino_muc_manager_IDENTITY;
		_data_->_tmp14_ = dino_stream_interactor_get_module (_data_->_tmp12_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp13_);
		_data_->_tmp15_ = (DinoMucManager*) _data_->_tmp14_;
		_data_->_tmp16_ = dino_entities_conversation_get_account (_data_->conversation);
		_data_->_tmp17_ = _data_->_tmp16_;
		_data_->_tmp18_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp19_ = _data_->_tmp18_;
		_data_->_tmp20_ = dino_muc_manager_is_private_room (_data_->_tmp15_, _data_->_tmp17_, _data_->_tmp19_);
		_g_object_unref0 (_data_->_tmp15_);
		_data_->is_private = _data_->_tmp20_;
		if (_data_->is_private) {
			_data_->_tmp22_ = dino_entities_conversation_get_account (_data_->conversation);
			_data_->_tmp23_ = _data_->_tmp22_;
			_data_->_tmp21_ = dino_calls_can_initiate_groupcall (_data_->self, _data_->_tmp23_);
		} else {
			_data_->_tmp21_ = FALSE;
		}
		_data_->result = _data_->_tmp21_;
		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;
	}
}

gboolean
dino_calls_can_initiate_groupcall (DinoCalls* self,
                                   DinoEntitiesAccount* account)
{
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoMucManager* _tmp3_;
	GeeHashMap* _tmp4_;
	gpointer _tmp5_;
	XmppJid* _tmp6_;
	gboolean _tmp7_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account != NULL, FALSE);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_muc_manager_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoMucManager*) _tmp2_;
	_tmp4_ = _tmp3_->default_muc_server;
	_tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp4_, account);
	_tmp6_ = (XmppJid*) _tmp5_;
	_tmp7_ = _tmp6_ != NULL;
	_xmpp_jid_unref0 (_tmp6_);
	_g_object_unref0 (_tmp3_);
	result = _tmp7_;
	return result;
}

static void
dino_calls_get_call_resources_data_free (gpointer _data)
{
	DinoCallsGetCallResourcesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_xmpp_jid_unref0 (_data_->counterpart);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoCallsGetCallResourcesData, _data_);
}

void
dino_calls_get_call_resources (DinoCalls* self,
                               DinoEntitiesAccount* account,
                               XmppJid* counterpart,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DinoCallsGetCallResourcesData* _data_;
	DinoCalls* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (counterpart != NULL);
	_data_ = g_slice_new0 (DinoCallsGetCallResourcesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_calls_get_call_resources_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (counterpart);
	_xmpp_jid_unref0 (_data_->counterpart);
	_data_->counterpart = _tmp2_;
	dino_calls_get_call_resources_co (_data_);
}

GeeList*
dino_calls_get_call_resources_finish (DinoCalls* self,
                                      GAsyncResult* _res_)
{
	GeeList* result;
	DinoCallsGetCallResourcesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dino_calls_get_call_resources_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DinoCallsGetCallResourcesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_calls_get_call_resources_co (_data_);
}

static gboolean
dino_calls_get_call_resources_co (DinoCallsGetCallResourcesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gee_array_list_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, NULL, NULL, NULL);
	_data_->ret = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->stream_interactor;
	_data_->_tmp2_ = dino_stream_interactor_get_stream (_data_->_tmp1_, _data_->account);
	_data_->stream = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->stream;
	if (_data_->_tmp3_ == NULL) {
		_data_->result = (GeeList*) _data_->ret;
		_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;
	}
	_data_->_tmp4_ = _data_->stream;
	_data_->_tmp5_ = xmpp_presence_flag_IDENTITY;
	_data_->_tmp6_ = xmpp_xmpp_stream_get_flag (_data_->_tmp4_, XMPP_PRESENCE_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp5_);
	_data_->presence_flag = (XmppPresenceFlag*) _data_->_tmp6_;
	_data_->_tmp7_ = _data_->presence_flag;
	if (_data_->_tmp7_ == NULL) {
		_data_->result = (GeeList*) _data_->ret;
		_g_object_unref0 (_data_->presence_flag);
		_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;
	}
	_data_->_tmp8_ = _data_->presence_flag;
	_data_->_tmp9_ = xmpp_presence_flag_get_resources (_data_->_tmp8_, _data_->counterpart);
	_data_->full_jids = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->full_jids;
	if (_data_->_tmp10_ == NULL) {
		_data_->result = (GeeList*) _data_->ret;
		_g_object_unref0 (_data_->full_jids);
		_g_object_unref0 (_data_->presence_flag);
		_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;
	}
	{
		_data_->_tmp11_ = _data_->full_jids;
		_data_->_full_jid_list = _data_->_tmp11_;
		_data_->_tmp12_ = _data_->_full_jid_list;
		_data_->_tmp13_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_full_jid_size = _data_->_tmp14_;
		_data_->_full_jid_index = -1;
		while (TRUE) {
			_data_->_full_jid_index = _data_->_full_jid_index + 1;
			_data_->_tmp15_ = _data_->_full_jid_index;
			_data_->_tmp16_ = _data_->_full_jid_size;
			if (!(_data_->_tmp15_ < _data_->_tmp16_)) {
				break;
			}
			_data_->_tmp17_ = _data_->_full_jid_list;
			_data_->_tmp18_ = gee_list_get (_data_->_tmp17_, _data_->_full_jid_index);
			_data_->full_jid = (XmppJid*) _data_->_tmp18_;
			_data_->_tmp19_ = _data_->stream;
			_data_->_tmp20_ = xmpp_xep_jingle_rtp_module_IDENTITY;
			_data_->_tmp21_ = xmpp_xmpp_stream_get_module (_data_->_tmp19_, XMPP_XEP_JINGLE_RTP_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp20_);
			_data_->module = (XmppXepJingleRtpModule*) _data_->_tmp21_;
			_data_->_tmp22_ = _data_->module;
			if (_data_->_tmp22_ == NULL) {
				_data_->result = (GeeList*) _data_->ret;
				_g_object_unref0 (_data_->module);
				_xmpp_jid_unref0 (_data_->full_jid);
				_g_object_unref0 (_data_->full_jids);
				_g_object_unref0 (_data_->presence_flag);
				_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;
			}
			_data_->_tmp23_ = _data_->module;
			_data_->_tmp24_ = _data_->stream;
			_data_->_tmp25_ = _data_->full_jid;
			_data_->_state_ = 1;
			xmpp_xep_jingle_rtp_module_is_available (_data_->_tmp23_, _data_->_tmp24_, _data_->_tmp25_, dino_calls_get_call_resources_ready, _data_);
			return FALSE;
			_state_1:
			_data_->supports_rtc = xmpp_xep_jingle_rtp_module_is_available_finish (_data_->_tmp23_, _data_->_res_);
			if (!_data_->supports_rtc) {
				_g_object_unref0 (_data_->module);
				_xmpp_jid_unref0 (_data_->full_jid);
				continue;
			}
			_data_->_tmp26_ = _data_->ret;
			_data_->_tmp27_ = _data_->full_jid;
			gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp26_, _data_->_tmp27_);
			_g_object_unref0 (_data_->module);
			_xmpp_jid_unref0 (_data_->full_jid);
		}
	}
	_data_->result = (GeeList*) _data_->ret;
	_g_object_unref0 (_data_->full_jids);
	_g_object_unref0 (_data_->presence_flag);
	_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_calls_contains_jmi_resources_data_free (gpointer _data)
{
	DinoCallsContainsJmiResourcesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->full_jids);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoCallsContainsJmiResourcesData, _data_);
}

void
dino_calls_contains_jmi_resources (DinoCalls* self,
                                   DinoEntitiesAccount* account,
                                   GeeList* full_jids,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_)
{
	DinoCallsContainsJmiResourcesData* _data_;
	DinoCalls* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	GeeList* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (full_jids != NULL);
	_data_ = g_slice_new0 (DinoCallsContainsJmiResourcesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_calls_contains_jmi_resources_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _g_object_ref0 (full_jids);
	_g_object_unref0 (_data_->full_jids);
	_data_->full_jids = _tmp2_;
	dino_calls_contains_jmi_resources_co (_data_);
}

gboolean
dino_calls_contains_jmi_resources_finish (DinoCalls* self,
                                          GAsyncResult* _res_)
{
	gboolean result;
	DinoCallsContainsJmiResourcesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
dino_calls_contains_jmi_resources_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_)
{
	DinoCallsContainsJmiResourcesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_calls_contains_jmi_resources_co (_data_);
}

static gboolean
dino_calls_contains_jmi_resources_co (DinoCallsContainsJmiResourcesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->stream_interactor;
	_data_->_tmp1_ = dino_stream_interactor_get_stream (_data_->_tmp0_, _data_->account);
	_data_->stream = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->stream;
	if (_data_->_tmp2_ == NULL) {
		_data_->result = FALSE;
		_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;
	}
	{
		_data_->_full_jid_list = _data_->full_jids;
		_data_->_tmp3_ = _data_->_full_jid_list;
		_data_->_tmp4_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_full_jid_size = _data_->_tmp5_;
		_data_->_full_jid_index = -1;
		while (TRUE) {
			_data_->_full_jid_index = _data_->_full_jid_index + 1;
			_data_->_tmp6_ = _data_->_full_jid_index;
			_data_->_tmp7_ = _data_->_full_jid_size;
			if (!(_data_->_tmp6_ < _data_->_tmp7_)) {
				break;
			}
			_data_->_tmp8_ = _data_->_full_jid_list;
			_data_->_tmp9_ = gee_list_get (_data_->_tmp8_, _data_->_full_jid_index);
			_data_->full_jid = (XmppJid*) _data_->_tmp9_;
			_data_->_tmp10_ = _data_->self->priv->stream_interactor;
			_data_->_tmp11_ = dino_entity_info_IDENTITY;
			_data_->_tmp12_ = dino_stream_interactor_get_module (_data_->_tmp10_, DINO_TYPE_ENTITY_INFO, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp11_);
			_data_->_tmp13_ = (DinoEntityInfo*) _data_->_tmp12_;
			_data_->_tmp14_ = _data_->full_jid;
			_data_->_state_ = 1;
			dino_entity_info_has_feature (_data_->_tmp13_, _data_->account, _data_->_tmp14_, XMPP_XEP_JINGLE_MESSAGE_INITIATION_NS_URI, dino_calls_contains_jmi_resources_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp15_ = dino_entity_info_has_feature_finish (_data_->_tmp13_, _data_->_res_);
			_g_object_unref0 (_data_->_tmp13_);
			_data_->does_jmi = _data_->_tmp15_;
			if (_data_->does_jmi) {
				_data_->result = TRUE;
				_xmpp_jid_unref0 (_data_->full_jid);
				_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;
			}
			_xmpp_jid_unref0 (_data_->full_jid);
		}
	}
	_data_->result = FALSE;
	_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;
}

gboolean
dino_calls_has_jmi_resources (DinoCalls* self,
                              XmppJid* counterpart)
{
	gint64 jmi_resources = 0LL;
	DinoDatabase* _tmp0_;
	DinoDatabaseEntityTable* _tmp1_;
	DinoDatabaseEntityTable* _tmp2_;
	QliteQueryBuilder* _tmp3_;
	QliteQueryBuilder* _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseEntityTable* _tmp6_;
	DinoDatabaseEntityTable* _tmp7_;
	QliteColumn* _tmp8_;
	DinoDatabase* _tmp9_;
	QliteQueryBuilder* _tmp10_;
	QliteQueryBuilder* _tmp11_;
	DinoDatabase* _tmp12_;
	DinoDatabaseEntityFeatureTable* _tmp13_;
	DinoDatabaseEntityFeatureTable* _tmp14_;
	DinoDatabase* _tmp15_;
	DinoDatabaseEntityTable* _tmp16_;
	DinoDatabaseEntityTable* _tmp17_;
	QliteColumn* _tmp18_;
	DinoDatabase* _tmp19_;
	DinoDatabaseEntityFeatureTable* _tmp20_;
	DinoDatabaseEntityFeatureTable* _tmp21_;
	QliteColumn* _tmp22_;
	QliteQueryBuilder* _tmp23_;
	QliteQueryBuilder* _tmp24_;
	DinoDatabase* _tmp25_;
	DinoDatabaseEntityFeatureTable* _tmp26_;
	DinoDatabaseEntityFeatureTable* _tmp27_;
	QliteColumn* _tmp28_;
	QliteQueryBuilder* _tmp29_;
	QliteQueryBuilder* _tmp30_;
	gint64 _tmp31_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (counterpart != NULL, FALSE);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_entity (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_select ((QliteTable*) _tmp2_, NULL, (gint) 0);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_entity (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->jid_id;
	_tmp9_ = self->priv->db;
	_tmp10_ = qlite_query_builder_with (_tmp4_, G_TYPE_INT, NULL, NULL, _tmp8_, "=", (gpointer) ((gintptr) dino_database_get_jid_id (_tmp9_, counterpart)));
	_tmp11_ = _tmp10_;
	_tmp12_ = self->priv->db;
	_tmp13_ = dino_database_get_entity_feature (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = self->priv->db;
	_tmp16_ = dino_database_get_entity (_tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = _tmp17_->caps_hash;
	_tmp19_ = self->priv->db;
	_tmp20_ = dino_database_get_entity_feature (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = _tmp21_->entity;
	_tmp23_ = qlite_query_builder_join_with (_tmp11_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, (QliteTable*) _tmp14_, _tmp18_, _tmp22_, NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = self->priv->db;
	_tmp26_ = dino_database_get_entity_feature (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = _tmp27_->feature;
	_tmp29_ = qlite_query_builder_with (_tmp24_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp28_, "=", XMPP_XEP_JINGLE_MESSAGE_INITIATION_NS_URI);
	_tmp30_ = _tmp29_;
	_tmp31_ = qlite_query_builder_count (_tmp30_);
	_qlite_statement_builder_unref0 (_tmp30_);
	_qlite_statement_builder_unref0 (_tmp24_);
	_qlite_statement_builder_unref0 (_tmp11_);
	_qlite_statement_builder_unref0 (_tmp4_);
	jmi_resources = _tmp31_;
	result = jmi_resources > ((gint64) 0);
	return result;
}

gboolean
dino_calls_is_call_in_progress (DinoCalls* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		GeeIterator* _call_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->call_states;
		_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_call_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoEntitiesCall* call = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			gboolean _tmp9_ = FALSE;
			gboolean _tmp10_ = FALSE;
			DinoEntitiesCall* _tmp11_;
			DinoEntitiesCallState _tmp12_;
			DinoEntitiesCallState _tmp13_;
			_tmp6_ = _call_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _call_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			call = (DinoEntitiesCall*) _tmp8_;
			_tmp11_ = call;
			_tmp12_ = dino_entities_call_get_state (_tmp11_);
			_tmp13_ = _tmp12_;
			if (_tmp13_ == DINO_ENTITIES_CALL_STATE_IN_PROGRESS) {
				_tmp10_ = TRUE;
			} else {
				DinoEntitiesCall* _tmp14_;
				DinoEntitiesCallState _tmp15_;
				DinoEntitiesCallState _tmp16_;
				_tmp14_ = call;
				_tmp15_ = dino_entities_call_get_state (_tmp14_);
				_tmp16_ = _tmp15_;
				_tmp10_ = _tmp16_ == DINO_ENTITIES_CALL_STATE_RINGING;
			}
			if (_tmp10_) {
				_tmp9_ = TRUE;
			} else {
				DinoEntitiesCall* _tmp17_;
				DinoEntitiesCallState _tmp18_;
				DinoEntitiesCallState _tmp19_;
				_tmp17_ = call;
				_tmp18_ = dino_entities_call_get_state (_tmp17_);
				_tmp19_ = _tmp18_;
				_tmp9_ = _tmp19_ == DINO_ENTITIES_CALL_STATE_ESTABLISHING;
			}
			if (_tmp9_) {
				result = TRUE;
				_g_object_unref0 (call);
				_g_object_unref0 (_call_it);
				return result;
			}
			_g_object_unref0 (call);
		}
		_g_object_unref0 (_call_it);
	}
	result = FALSE;
	return result;
}

static gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

static void
dino_calls_on_incoming_call (DinoCalls* self,
                             DinoEntitiesAccount* account,
                             XmppXepJingleSession* session)
{
	XmppJid* muji_room = NULL;
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gboolean counterpart_wants_video = FALSE;
	XmppJid* _tmp22_;
	XmppJid* _tmp106_;
	XmppJid* _tmp107_;
	XmppJid* _tmp108_;
	gchar* _tmp109_;
	gchar* _tmp110_;
	XmppJid* _tmp111_;
	XmppJid* _tmp112_;
	gchar* _tmp113_;
	gchar* _tmp114_;
	DinoPeerState* peer_state = NULL;
	const gchar* _tmp115_;
	const gchar* _tmp116_;
	XmppJid* _tmp117_;
	XmppJid* _tmp118_;
	DinoPeerState* _tmp119_;
	DinoPeerState* _tmp120_;
	DinoStreamInteractor* _tmp134_;
	DinoModuleIdentity* _tmp135_;
	gpointer _tmp136_;
	DinoMucManager* _tmp137_;
	XmppJid* _tmp138_;
	XmppJid* _tmp139_;
	XmppJid* _tmp140_;
	XmppJid* _tmp141_;
	XmppJid* _tmp142_;
	gboolean _tmp143_;
	XmppJid* _tmp144_;
	XmppJid* _tmp145_;
	XmppJid* _tmp146_;
	XmppJid* _tmp147_;
	DinoPeerState* _tmp148_;
	DinoPeerState* _tmp149_;
	DinoEntitiesConversation* conversation = NULL;
	DinoStreamInteractor* _tmp150_;
	DinoModuleIdentity* _tmp151_;
	gpointer _tmp152_;
	DinoConversationManager* _tmp153_;
	DinoPeerState* _tmp154_;
	DinoEntitiesCall* _tmp155_;
	XmppJid* _tmp156_;
	XmppJid* _tmp157_;
	XmppJid* _tmp158_;
	XmppJid* _tmp159_;
	XmppJid* _tmp160_;
	DinoEntitiesConversationType _tmp161_;
	DinoEntitiesConversation* _tmp162_;
	DinoEntitiesConversation* _tmp163_;
	DinoPeerState* _tmp164_;
	DinoEntitiesCall* _tmp165_;
	DinoPeerState* _tmp166_;
	DinoCallState* _tmp167_;
	DinoEntitiesConversation* _tmp168_;
	DinoStreamInteractor* _tmp169_;
	DinoModuleManager* _tmp170_;
	XmppModuleIdentity* _tmp171_;
	gpointer _tmp172_;
	XmppXepJingleRtpModule* _tmp173_;
	XmppXepJingleRtpSessionInfoType* _tmp174_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (session != NULL);
	_tmp0_ = xmpp_xep_jingle_session_get_muji_room (session);
	_tmp1_ = _tmp0_;
	_tmp2_ = _xmpp_jid_ref0 (_tmp1_);
	muji_room = _tmp2_;
	counterpart_wants_video = FALSE;
	{
		GeeList* _content_list = NULL;
		GeeList* _tmp3_;
		gint _content_size = 0;
		GeeList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _content_index = 0;
		_tmp3_ = session->contents;
		_content_list = _tmp3_;
		_tmp4_ = _content_list;
		_tmp5_ = gee_collection_get_size ((GeeCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_content_size = _tmp6_;
		_content_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			XmppXepJingleContent* content = NULL;
			GeeList* _tmp9_;
			gpointer _tmp10_;
			XmppXepJingleRtpParameters* rtp_content_parameter = NULL;
			XmppXepJingleContent* _tmp11_;
			XmppXepJingleContentParameters* _tmp12_;
			XmppXepJingleRtpParameters* _tmp13_;
			XmppXepJingleRtpParameters* _tmp14_;
			gboolean _tmp15_ = FALSE;
			XmppXepJingleRtpParameters* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			_content_index = _content_index + 1;
			_tmp7_ = _content_index;
			_tmp8_ = _content_size;
			if (!(_tmp7_ < _tmp8_)) {
				break;
			}
			_tmp9_ = _content_list;
			_tmp10_ = gee_list_get (_tmp9_, _content_index);
			content = (XmppXepJingleContent*) _tmp10_;
			_tmp11_ = content;
			_tmp12_ = _tmp11_->content_params;
			_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp12_, XMPP_XEP_JINGLE_RTP_TYPE_PARAMETERS) ? ((XmppXepJingleRtpParameters*) _tmp12_) : NULL);
			rtp_content_parameter = _tmp13_;
			_tmp14_ = rtp_content_parameter;
			if (_tmp14_ == NULL) {
				_g_object_unref0 (rtp_content_parameter);
				_g_object_unref0 (content);
				continue;
			}
			_tmp16_ = rtp_content_parameter;
			_tmp17_ = xmpp_xep_jingle_rtp_parameters_get_media (_tmp16_);
			_tmp18_ = _tmp17_;
			if (g_strcmp0 (_tmp18_, "video") == 0) {
				XmppXepJingleContent* _tmp19_;
				XmppXepJingleSenders _tmp20_;
				XmppXepJingleSenders _tmp21_;
				_tmp19_ = content;
				_tmp20_ = xmpp_xep_jingle_content_get_senders (_tmp19_);
				_tmp21_ = _tmp20_;
				_tmp15_ = xmpp_xep_jingle_session_senders_include_us (session, _tmp21_);
			} else {
				_tmp15_ = FALSE;
			}
			if (_tmp15_) {
				counterpart_wants_video = TRUE;
			}
			_g_object_unref0 (rtp_content_parameter);
			_g_object_unref0 (content);
		}
	}
	_tmp22_ = muji_room;
	if (_tmp22_ != NULL) {
		XmppJid* _tmp23_;
		XmppJid* _tmp24_;
		XmppJid* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		XmppJid* _tmp28_;
		XmppJid* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		XmppJid* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		_tmp23_ = dino_entities_account_get_bare_jid (account);
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_;
		_tmp26_ = xmpp_jid_to_string (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
		_tmp29_ = _tmp28_;
		_tmp30_ = xmpp_jid_to_string (_tmp29_);
		_tmp31_ = _tmp30_;
		_tmp32_ = muji_room;
		_tmp33_ = xmpp_jid_to_string (_tmp32_);
		_tmp34_ = _tmp33_;
		g_debug ("calls.vala:155: [%s] Incoming call from %s from MUJI muc %s", _tmp27_, _tmp31_, _tmp34_);
		_g_free0 (_tmp34_);
		_g_free0 (_tmp31_);
		_g_free0 (_tmp27_);
		_xmpp_jid_unref0 (_tmp25_);
		{
			GeeIterator* _call_state_it = NULL;
			GeeHashMap* _tmp35_;
			GeeCollection* _tmp36_;
			GeeCollection* _tmp37_;
			GeeCollection* _tmp38_;
			GeeIterator* _tmp39_;
			GeeIterator* _tmp40_;
			_tmp35_ = self->call_states;
			_tmp36_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp35_);
			_tmp37_ = _tmp36_;
			_tmp38_ = _tmp37_;
			_tmp39_ = gee_iterable_iterator ((GeeIterable*) _tmp38_);
			_tmp40_ = _tmp39_;
			_g_object_unref0 (_tmp38_);
			_call_state_it = _tmp40_;
			while (TRUE) {
				GeeIterator* _tmp41_;
				DinoCallState* call_state = NULL;
				GeeIterator* _tmp42_;
				gpointer _tmp43_;
				gboolean _tmp44_ = FALSE;
				gboolean _tmp45_ = FALSE;
				DinoCallState* _tmp46_;
				DinoEntitiesCall* _tmp47_;
				DinoEntitiesAccount* _tmp48_;
				DinoEntitiesAccount* _tmp49_;
				_tmp41_ = _call_state_it;
				if (!gee_iterator_next (_tmp41_)) {
					break;
				}
				_tmp42_ = _call_state_it;
				_tmp43_ = gee_iterator_get (_tmp42_);
				call_state = (DinoCallState*) _tmp43_;
				_tmp46_ = call_state;
				_tmp47_ = _tmp46_->call;
				_tmp48_ = dino_entities_call_get_account (_tmp47_);
				_tmp49_ = _tmp48_;
				if (dino_entities_account_equals (_tmp49_, account)) {
					DinoCallState* _tmp50_;
					XmppXepMujiGroupCall* _tmp51_;
					XmppXepMujiGroupCall* _tmp52_;
					_tmp50_ = call_state;
					_tmp51_ = dino_call_state_get_group_call (_tmp50_);
					_tmp52_ = _tmp51_;
					_tmp45_ = _tmp52_ != NULL;
				} else {
					_tmp45_ = FALSE;
				}
				if (_tmp45_) {
					DinoCallState* _tmp53_;
					XmppXepMujiGroupCall* _tmp54_;
					XmppXepMujiGroupCall* _tmp55_;
					XmppJid* _tmp56_;
					XmppJid* _tmp57_;
					_tmp53_ = call_state;
					_tmp54_ = dino_call_state_get_group_call (_tmp53_);
					_tmp55_ = _tmp54_;
					_tmp56_ = _tmp55_->muc_jid;
					_tmp57_ = muji_room;
					_tmp44_ = xmpp_jid_equals (_tmp56_, _tmp57_);
				} else {
					_tmp44_ = FALSE;
				}
				if (_tmp44_) {
					DinoCallState* _tmp58_;
					GeeHashMap* _tmp59_;
					GeeSet* _tmp60_;
					GeeSet* _tmp61_;
					GeeSet* _tmp62_;
					XmppJid* _tmp63_;
					XmppJid* _tmp64_;
					gboolean _tmp65_;
					_tmp58_ = call_state;
					_tmp59_ = _tmp58_->peers;
					_tmp60_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp59_);
					_tmp61_ = _tmp60_;
					_tmp62_ = _tmp61_;
					_tmp63_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
					_tmp64_ = _tmp63_;
					_tmp65_ = gee_collection_contains ((GeeCollection*) _tmp62_, _tmp64_);
					_g_object_unref0 (_tmp62_);
					if (_tmp65_) {
						DinoPeerState* peer_state = NULL;
						DinoCallState* _tmp66_;
						GeeHashMap* _tmp67_;
						XmppJid* _tmp68_;
						XmppJid* _tmp69_;
						gpointer _tmp70_;
						XmppJid* _tmp71_;
						XmppJid* _tmp72_;
						XmppJid* _tmp73_;
						gchar* _tmp74_;
						gchar* _tmp75_;
						DinoPeerState* _tmp76_;
						gchar* _tmp77_;
						gchar* _tmp78_;
						DinoPeerState* _tmp79_;
						DinoPeerState* _tmp80_;
						XmppJid* _tmp81_;
						XmppJid* _tmp82_;
						XmppJid* _tmp83_;
						gchar* _tmp84_;
						gchar* _tmp85_;
						XmppJid* _tmp86_;
						XmppJid* _tmp87_;
						gchar* _tmp88_;
						gchar* _tmp89_;
						DinoPeerState* _tmp90_;
						_tmp66_ = call_state;
						_tmp67_ = _tmp66_->peers;
						_tmp68_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
						_tmp69_ = _tmp68_;
						_tmp70_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp67_, _tmp69_);
						peer_state = (DinoPeerState*) _tmp70_;
						_tmp71_ = dino_entities_account_get_bare_jid (account);
						_tmp72_ = _tmp71_;
						_tmp73_ = _tmp72_;
						_tmp74_ = xmpp_jid_to_string (_tmp73_);
						_tmp75_ = _tmp74_;
						_tmp76_ = peer_state;
						_tmp77_ = bool_to_string (_tmp76_->waiting_for_inbound_muji_connection);
						_tmp78_ = _tmp77_;
						g_debug ("calls.vala:161: [%s] Incoming call, we know the peer. Expected %s", _tmp75_, _tmp78_);
						_g_free0 (_tmp78_);
						_g_free0 (_tmp75_);
						_xmpp_jid_unref0 (_tmp73_);
						_tmp79_ = peer_state;
						if (!_tmp79_->waiting_for_inbound_muji_connection) {
							_g_object_unref0 (peer_state);
							_g_object_unref0 (call_state);
							_g_object_unref0 (_call_state_it);
							_xmpp_jid_unref0 (muji_room);
							return;
						}
						_tmp80_ = peer_state;
						dino_peer_state_set_session (_tmp80_, session);
						_tmp81_ = dino_entities_account_get_bare_jid (account);
						_tmp82_ = _tmp81_;
						_tmp83_ = _tmp82_;
						_tmp84_ = xmpp_jid_to_string (_tmp83_);
						_tmp85_ = _tmp84_;
						_tmp86_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
						_tmp87_ = _tmp86_;
						_tmp88_ = xmpp_jid_to_string (_tmp87_);
						_tmp89_ = _tmp88_;
						g_debug ("calls.vala:165: [%s] Accepting incoming MUJI call from %s", _tmp85_, _tmp89_);
						_g_free0 (_tmp89_);
						_g_free0 (_tmp85_);
						_xmpp_jid_unref0 (_tmp83_);
						_tmp90_ = peer_state;
						dino_peer_state_accept (_tmp90_);
						_g_object_unref0 (peer_state);
					} else {
						XmppJid* _tmp91_;
						XmppJid* _tmp92_;
						XmppJid* _tmp93_;
						gchar* _tmp94_;
						gchar* _tmp95_;
						DinoPeerState* peer_state = NULL;
						XmppJid* _tmp96_;
						XmppJid* _tmp97_;
						DinoCallState* _tmp98_;
						DinoEntitiesCall* _tmp99_;
						DinoCallState* _tmp100_;
						DinoStreamInteractor* _tmp101_;
						DinoPeerState* _tmp102_;
						DinoPeerState* _tmp103_;
						DinoCallState* _tmp104_;
						DinoPeerState* _tmp105_;
						_tmp91_ = dino_entities_account_get_bare_jid (account);
						_tmp92_ = _tmp91_;
						_tmp93_ = _tmp92_;
						_tmp94_ = xmpp_jid_to_string (_tmp93_);
						_tmp95_ = _tmp94_;
						g_debug ("calls.vala:168: [%s] Incoming call, but didn't see peer in MUC yet", _tmp95_);
						_g_free0 (_tmp95_);
						_xmpp_jid_unref0 (_tmp93_);
						_tmp96_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
						_tmp97_ = _tmp96_;
						_tmp98_ = call_state;
						_tmp99_ = _tmp98_->call;
						_tmp100_ = call_state;
						_tmp101_ = self->priv->stream_interactor;
						_tmp102_ = dino_peer_state_new (_tmp97_, _tmp99_, _tmp100_, _tmp101_);
						peer_state = _tmp102_;
						_tmp103_ = peer_state;
						dino_peer_state_set_session (_tmp103_, session);
						_tmp104_ = call_state;
						_tmp105_ = peer_state;
						dino_call_state_add_peer (_tmp104_, _tmp105_);
						_g_object_unref0 (peer_state);
					}
					_g_object_unref0 (call_state);
					_g_object_unref0 (_call_state_it);
					_xmpp_jid_unref0 (muji_room);
					return;
				}
				_g_object_unref0 (call_state);
			}
			_g_object_unref0 (_call_state_it);
		}
		_xmpp_jid_unref0 (muji_room);
		return;
	}
	_tmp106_ = dino_entities_account_get_bare_jid (account);
	_tmp107_ = _tmp106_;
	_tmp108_ = _tmp107_;
	_tmp109_ = xmpp_jid_to_string (_tmp108_);
	_tmp110_ = _tmp109_;
	_tmp111_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
	_tmp112_ = _tmp111_;
	_tmp113_ = xmpp_jid_to_string (_tmp112_);
	_tmp114_ = _tmp113_;
	g_debug ("calls.vala:179: [%s] Incoming call from %s", _tmp110_, _tmp114_);
	_g_free0 (_tmp114_);
	_g_free0 (_tmp110_);
	_xmpp_jid_unref0 (_tmp108_);
	_tmp115_ = xmpp_xep_jingle_session_get_sid (session);
	_tmp116_ = _tmp115_;
	_tmp117_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
	_tmp118_ = _tmp117_;
	_tmp119_ = dino_calls_get_peer_by_sid (self, account, _tmp116_, _tmp118_, NULL);
	peer_state = _tmp119_;
	_tmp120_ = peer_state;
	if (_tmp120_ != NULL) {
		GeeHashMap* _tmp121_;
		DinoPeerState* _tmp122_;
		DinoEntitiesCall* _tmp123_;
		gpointer _tmp124_;
		DinoPeerState* _tmp125_;
		GeeHashMap* _tmp126_;
		DinoPeerState* _tmp127_;
		DinoEntitiesCall* _tmp128_;
		gpointer _tmp129_;
		DinoPeerState* _tmp130_;
		GeeHashMap* _tmp131_;
		DinoPeerState* _tmp132_;
		DinoEntitiesCall* _tmp133_;
		_tmp121_ = self->jmi_request_peer;
		_tmp122_ = peer_state;
		_tmp123_ = _tmp122_->call;
		_tmp124_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp121_, _tmp123_);
		_tmp125_ = (DinoPeerState*) _tmp124_;
		dino_peer_state_set_session (_tmp125_, session);
		_g_object_unref0 (_tmp125_);
		_tmp126_ = self->jmi_request_peer;
		_tmp127_ = peer_state;
		_tmp128_ = _tmp127_->call;
		_tmp129_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp126_, _tmp128_);
		_tmp130_ = (DinoPeerState*) _tmp129_;
		dino_peer_state_accept (_tmp130_);
		_g_object_unref0 (_tmp130_);
		_tmp131_ = self->jmi_request_peer;
		_tmp132_ = peer_state;
		_tmp133_ = _tmp132_->call;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp131_, _tmp133_, NULL);
		_g_object_unref0 (peer_state);
		_xmpp_jid_unref0 (muji_room);
		return;
	}
	_tmp134_ = self->priv->stream_interactor;
	_tmp135_ = dino_muc_manager_IDENTITY;
	_tmp136_ = dino_stream_interactor_get_module (_tmp134_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp135_);
	_tmp137_ = (DinoMucManager*) _tmp136_;
	_tmp138_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
	_tmp139_ = _tmp138_;
	_tmp140_ = xmpp_jid_get_bare_jid (_tmp139_);
	_tmp141_ = _tmp140_;
	_tmp142_ = _tmp141_;
	_tmp143_ = dino_muc_manager_might_be_groupchat (_tmp137_, _tmp142_, account);
	_xmpp_jid_unref0 (_tmp142_);
	_g_object_unref0 (_tmp137_);
	if (_tmp143_) {
		_g_object_unref0 (peer_state);
		_xmpp_jid_unref0 (muji_room);
		return;
	}
	_tmp144_ = xmpp_xep_jingle_session_get_peer_full_jid (session);
	_tmp145_ = _tmp144_;
	_tmp146_ = dino_entities_account_get_full_jid (account);
	_tmp147_ = _tmp146_;
	_tmp148_ = dino_calls_create_received_call (self, account, _tmp145_, _tmp147_, counterpart_wants_video);
	_g_object_unref0 (peer_state);
	peer_state = _tmp148_;
	_tmp149_ = peer_state;
	dino_peer_state_set_session (_tmp149_, session);
	_tmp150_ = self->priv->stream_interactor;
	_tmp151_ = dino_conversation_manager_IDENTITY;
	_tmp152_ = dino_stream_interactor_get_module (_tmp150_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp151_);
	_tmp153_ = (DinoConversationManager*) _tmp152_;
	_tmp154_ = peer_state;
	_tmp155_ = _tmp154_->call;
	_tmp156_ = dino_entities_call_get_counterpart (_tmp155_);
	_tmp157_ = _tmp156_;
	_tmp158_ = xmpp_jid_get_bare_jid (_tmp157_);
	_tmp159_ = _tmp158_;
	_tmp160_ = _tmp159_;
	_tmp161_ = DINO_ENTITIES_CONVERSATION_TYPE_CHAT;
	_tmp162_ = dino_conversation_manager_get_conversation (_tmp153_, _tmp160_, account, &_tmp161_);
	_tmp163_ = _tmp162_;
	_xmpp_jid_unref0 (_tmp160_);
	_g_object_unref0 (_tmp153_);
	conversation = _tmp163_;
	_tmp164_ = peer_state;
	_tmp165_ = _tmp164_->call;
	_tmp166_ = peer_state;
	_tmp167_ = _tmp166_->call_state;
	_tmp168_ = conversation;
	g_signal_emit (self, dino_calls_signals[DINO_CALLS_CALL_INCOMING_SIGNAL], 0, _tmp165_, _tmp167_, _tmp168_, counterpart_wants_video, FALSE);
	_tmp169_ = self->priv->stream_interactor;
	_tmp170_ = _tmp169_->module_manager;
	_tmp171_ = xmpp_xep_jingle_rtp_module_IDENTITY;
	_tmp172_ = dino_module_manager_get_module (_tmp170_, XMPP_XEP_JINGLE_RTP_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, account, _tmp171_);
	_tmp173_ = (XmppXepJingleRtpModule*) _tmp172_;
	_tmp174_ = _tmp173_->session_info_type;
	xmpp_xep_jingle_rtp_session_info_type_send_ringing (_tmp174_, session);
	_g_object_unref0 (_tmp173_);
	_g_object_unref0 (conversation);
	_g_object_unref0 (peer_state);
	_xmpp_jid_unref0 (muji_room);
}

static DinoPeerState*
dino_calls_create_received_call (DinoCalls* self,
                                 DinoEntitiesAccount* account,
                                 XmppJid* from,
                                 XmppJid* to,
                                 gboolean video_requested)
{
	DinoEntitiesCall* call = NULL;
	DinoEntitiesCall* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	XmppJid* _tmp3_;
	gboolean _tmp4_;
	DinoEntitiesCall* _tmp15_;
	DinoEntitiesCall* _tmp16_;
	XmppJid* _tmp17_;
	XmppJid* _tmp18_;
	DinoEntitiesCall* _tmp19_;
	DinoEntitiesCall* _tmp20_;
	DinoEntitiesCall* _tmp21_;
	DinoEntitiesCall* _tmp22_;
	GDateTime* _tmp23_;
	GDateTime* _tmp24_;
	DinoEntitiesCall* _tmp25_;
	DinoEntitiesConversation* conversation = NULL;
	DinoStreamInteractor* _tmp26_;
	DinoModuleIdentity* _tmp27_;
	gpointer _tmp28_;
	DinoConversationManager* _tmp29_;
	DinoEntitiesCall* _tmp30_;
	XmppJid* _tmp31_;
	XmppJid* _tmp32_;
	XmppJid* _tmp33_;
	XmppJid* _tmp34_;
	XmppJid* _tmp35_;
	DinoEntitiesConversationType _tmp36_;
	DinoEntitiesConversation* _tmp37_;
	DinoEntitiesConversation* _tmp38_;
	DinoStreamInteractor* _tmp39_;
	DinoModuleIdentity* _tmp40_;
	gpointer _tmp41_;
	DinoCallStore* _tmp42_;
	DinoEntitiesCall* _tmp43_;
	DinoCallState* call_state = NULL;
	DinoEntitiesCall* _tmp44_;
	DinoStreamInteractor* _tmp45_;
	DinoCallState* _tmp46_;
	DinoPeerState* peer_state = NULL;
	DinoEntitiesCall* _tmp47_;
	XmppJid* _tmp48_;
	XmppJid* _tmp49_;
	DinoPeerState* _tmp50_;
	DinoPeerState* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	g_return_val_if_fail (from != NULL, NULL);
	g_return_val_if_fail (to != NULL, NULL);
	_tmp0_ = dino_entities_call_new ();
	call = _tmp0_;
	_tmp1_ = dino_entities_account_get_bare_jid (account);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_jid_equals_bare (from, _tmp3_);
	_xmpp_jid_unref0 (_tmp3_);
	if (_tmp4_) {
		DinoEntitiesCall* _tmp5_;
		DinoEntitiesCall* _tmp6_;
		DinoEntitiesCall* _tmp7_;
		DinoEntitiesCall* _tmp8_;
		_tmp5_ = call;
		dino_entities_call_set_direction (_tmp5_, DINO_ENTITIES_CALL_DIRECTION_OUTGOING);
		_tmp6_ = call;
		dino_entities_call_set_ourpart (_tmp6_, from);
		_tmp7_ = call;
		dino_entities_call_set_state (_tmp7_, DINO_ENTITIES_CALL_STATE_OTHER_DEVICE);
		_tmp8_ = call;
		dino_entities_call_set_counterpart (_tmp8_, to);
	} else {
		DinoEntitiesCall* _tmp9_;
		DinoEntitiesCall* _tmp10_;
		XmppJid* _tmp11_;
		XmppJid* _tmp12_;
		DinoEntitiesCall* _tmp13_;
		DinoEntitiesCall* _tmp14_;
		_tmp9_ = call;
		dino_entities_call_set_direction (_tmp9_, DINO_ENTITIES_CALL_DIRECTION_INCOMING);
		_tmp10_ = call;
		_tmp11_ = dino_entities_account_get_full_jid (account);
		_tmp12_ = _tmp11_;
		dino_entities_call_set_ourpart (_tmp10_, _tmp12_);
		_tmp13_ = call;
		dino_entities_call_set_state (_tmp13_, DINO_ENTITIES_CALL_STATE_RINGING);
		_tmp14_ = call;
		dino_entities_call_set_counterpart (_tmp14_, from);
	}
	_tmp15_ = call;
	_tmp16_ = call;
	_tmp17_ = dino_entities_call_get_counterpart (_tmp16_);
	_tmp18_ = _tmp17_;
	dino_entities_call_add_peer (_tmp15_, _tmp18_);
	_tmp19_ = call;
	dino_entities_call_set_account (_tmp19_, account);
	_tmp20_ = call;
	_tmp21_ = call;
	_tmp22_ = call;
	_tmp23_ = g_date_time_new_now_utc ();
	_tmp24_ = _tmp23_;
	dino_entities_call_set_end_time (_tmp22_, _tmp24_);
	dino_entities_call_set_local_time (_tmp21_, _tmp24_);
	dino_entities_call_set_time (_tmp20_, _tmp24_);
	_g_date_time_unref0 (_tmp24_);
	_tmp25_ = call;
	dino_entities_call_set_encryption (_tmp25_, DINO_ENTITIES_ENCRYPTION_UNKNOWN);
	_tmp26_ = self->priv->stream_interactor;
	_tmp27_ = dino_conversation_manager_IDENTITY;
	_tmp28_ = dino_stream_interactor_get_module (_tmp26_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp27_);
	_tmp29_ = (DinoConversationManager*) _tmp28_;
	_tmp30_ = call;
	_tmp31_ = dino_entities_call_get_counterpart (_tmp30_);
	_tmp32_ = _tmp31_;
	_tmp33_ = xmpp_jid_get_bare_jid (_tmp32_);
	_tmp34_ = _tmp33_;
	_tmp35_ = _tmp34_;
	_tmp36_ = DINO_ENTITIES_CONVERSATION_TYPE_CHAT;
	_tmp37_ = dino_conversation_manager_create_conversation (_tmp29_, _tmp35_, account, &_tmp36_);
	_tmp38_ = _tmp37_;
	_xmpp_jid_unref0 (_tmp35_);
	_g_object_unref0 (_tmp29_);
	conversation = _tmp38_;
	_tmp39_ = self->priv->stream_interactor;
	_tmp40_ = dino_call_store_IDENTITY;
	_tmp41_ = dino_stream_interactor_get_module (_tmp39_, DINO_TYPE_CALL_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp40_);
	_tmp42_ = (DinoCallStore*) _tmp41_;
	_tmp43_ = call;
	dino_call_store_add_call (_tmp42_, _tmp43_, conversation);
	_g_object_unref0 (_tmp42_);
	_tmp44_ = call;
	_tmp45_ = self->priv->stream_interactor;
	_tmp46_ = dino_call_state_new (_tmp44_, _tmp45_);
	call_state = _tmp46_;
	dino_calls_connect_call_state_signals (self, call_state);
	_tmp47_ = call;
	_tmp48_ = dino_entities_call_get_counterpart (_tmp47_);
	_tmp49_ = _tmp48_;
	_tmp50_ = dino_call_state_set_first_peer (call_state, _tmp49_);
	peer_state = _tmp50_;
	dino_call_state_set_we_should_send_video (call_state, video_requested);
	dino_call_state_set_we_should_send_audio (call_state, TRUE);
	result = peer_state;
	_g_object_unref0 (call_state);
	_g_object_unref0 (conversation);
	_g_object_unref0 (call);
	return result;
}

static DinoCallState*
dino_calls_get_call_state_by_call_id (DinoCalls* self,
                                      DinoEntitiesAccount* account,
                                      const gchar* call_id,
                                      XmppJid* counterpart_jid)
{
	DinoCallState* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	g_return_val_if_fail (call_id != NULL, NULL);
	{
		GeeIterator* _call_state_it = NULL;
		GeeHashMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->call_states;
		_tmp1_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_call_state_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoCallState* call_state = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			DinoCallState* _tmp9_;
			DinoEntitiesCall* _tmp10_;
			DinoEntitiesAccount* _tmp11_;
			DinoEntitiesAccount* _tmp12_;
			DinoCallState* _tmp13_;
			const gchar* _tmp14_;
			_tmp6_ = _call_state_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _call_state_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			call_state = (DinoCallState*) _tmp8_;
			_tmp9_ = call_state;
			_tmp10_ = _tmp9_->call;
			_tmp11_ = dino_entities_call_get_account (_tmp10_);
			_tmp12_ = _tmp11_;
			if (!dino_entities_account_equals (_tmp12_, account)) {
				_g_object_unref0 (call_state);
				continue;
			}
			_tmp13_ = call_state;
			_tmp14_ = _tmp13_->cim_call_id;
			if (g_strcmp0 (_tmp14_, call_id) == 0) {
				if (counterpart_jid == NULL) {
					result = call_state;
					_g_object_unref0 (_call_state_it);
					return result;
				}
				{
					GeeIterator* _jid_it = NULL;
					DinoCallState* _tmp15_;
					GeeHashMap* _tmp16_;
					GeeSet* _tmp17_;
					GeeSet* _tmp18_;
					GeeSet* _tmp19_;
					GeeIterator* _tmp20_;
					GeeIterator* _tmp21_;
					_tmp15_ = call_state;
					_tmp16_ = _tmp15_->peers;
					_tmp17_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp16_);
					_tmp18_ = _tmp17_;
					_tmp19_ = _tmp18_;
					_tmp20_ = gee_iterable_iterator ((GeeIterable*) _tmp19_);
					_tmp21_ = _tmp20_;
					_g_object_unref0 (_tmp19_);
					_jid_it = _tmp21_;
					while (TRUE) {
						GeeIterator* _tmp22_;
						XmppJid* jid = NULL;
						GeeIterator* _tmp23_;
						gpointer _tmp24_;
						XmppJid* _tmp25_;
						_tmp22_ = _jid_it;
						if (!gee_iterator_next (_tmp22_)) {
							break;
						}
						_tmp23_ = _jid_it;
						_tmp24_ = gee_iterator_get (_tmp23_);
						jid = (XmppJid*) _tmp24_;
						_tmp25_ = jid;
						if (xmpp_jid_equals_bare (_tmp25_, counterpart_jid)) {
							result = call_state;
							_xmpp_jid_unref0 (jid);
							_g_object_unref0 (_jid_it);
							_g_object_unref0 (_call_state_it);
							return result;
						}
						_xmpp_jid_unref0 (jid);
					}
					_g_object_unref0 (_jid_it);
				}
			}
			_g_object_unref0 (call_state);
		}
		_g_object_unref0 (_call_state_it);
	}
	result = NULL;
	return result;
}

static DinoPeerState*
dino_calls_get_peer_by_sid (DinoCalls* self,
                            DinoEntitiesAccount* account,
                            const gchar* sid,
                            XmppJid* jid1,
                            XmppJid* jid2)
{
	XmppJid* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	XmppJid* _tmp2_;
	XmppJid* _tmp3_;
	XmppJid* _tmp4_;
	gboolean _tmp5_;
	XmppJid* relevant_jid = NULL;
	XmppJid* _tmp6_;
	DinoPeerState* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	g_return_val_if_fail (sid != NULL, NULL);
	g_return_val_if_fail (jid1 != NULL, NULL);
	_tmp2_ = dino_entities_account_get_bare_jid (account);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = xmpp_jid_equals_bare (jid1, _tmp4_);
	_xmpp_jid_unref0 (_tmp4_);
	if (_tmp5_) {
		_tmp1_ = jid2 != NULL;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = jid2;
	} else {
		_tmp0_ = jid1;
	}
	_tmp6_ = _xmpp_jid_ref0 (_tmp0_);
	relevant_jid = _tmp6_;
	{
		GeeIterator* _call_state_it = NULL;
		GeeHashMap* _tmp7_;
		GeeCollection* _tmp8_;
		GeeCollection* _tmp9_;
		GeeCollection* _tmp10_;
		GeeIterator* _tmp11_;
		GeeIterator* _tmp12_;
		_tmp7_ = self->call_states;
		_tmp8_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = _tmp9_;
		_tmp11_ = gee_iterable_iterator ((GeeIterable*) _tmp10_);
		_tmp12_ = _tmp11_;
		_g_object_unref0 (_tmp10_);
		_call_state_it = _tmp12_;
		while (TRUE) {
			GeeIterator* _tmp13_;
			DinoCallState* call_state = NULL;
			GeeIterator* _tmp14_;
			gpointer _tmp15_;
			DinoCallState* _tmp16_;
			DinoEntitiesCall* _tmp17_;
			DinoEntitiesAccount* _tmp18_;
			DinoEntitiesAccount* _tmp19_;
			_tmp13_ = _call_state_it;
			if (!gee_iterator_next (_tmp13_)) {
				break;
			}
			_tmp14_ = _call_state_it;
			_tmp15_ = gee_iterator_get (_tmp14_);
			call_state = (DinoCallState*) _tmp15_;
			_tmp16_ = call_state;
			_tmp17_ = _tmp16_->call;
			_tmp18_ = dino_entities_call_get_account (_tmp17_);
			_tmp19_ = _tmp18_;
			if (!dino_entities_account_equals (_tmp19_, account)) {
				_g_object_unref0 (call_state);
				continue;
			}
			{
				GeeIterator* _peer_state_it = NULL;
				DinoCallState* _tmp20_;
				GeeHashMap* _tmp21_;
				GeeCollection* _tmp22_;
				GeeCollection* _tmp23_;
				GeeCollection* _tmp24_;
				GeeIterator* _tmp25_;
				GeeIterator* _tmp26_;
				_tmp20_ = call_state;
				_tmp21_ = _tmp20_->peers;
				_tmp22_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp21_);
				_tmp23_ = _tmp22_;
				_tmp24_ = _tmp23_;
				_tmp25_ = gee_iterable_iterator ((GeeIterable*) _tmp24_);
				_tmp26_ = _tmp25_;
				_g_object_unref0 (_tmp24_);
				_peer_state_it = _tmp26_;
				while (TRUE) {
					GeeIterator* _tmp27_;
					DinoPeerState* peer_state = NULL;
					GeeIterator* _tmp28_;
					gpointer _tmp29_;
					DinoPeerState* _tmp30_;
					const gchar* _tmp31_;
					DinoPeerState* _tmp32_;
					XmppJid* _tmp33_;
					XmppJid* _tmp34_;
					_tmp27_ = _peer_state_it;
					if (!gee_iterator_next (_tmp27_)) {
						break;
					}
					_tmp28_ = _peer_state_it;
					_tmp29_ = gee_iterator_get (_tmp28_);
					peer_state = (DinoPeerState*) _tmp29_;
					_tmp30_ = peer_state;
					_tmp31_ = _tmp30_->sid;
					if (g_strcmp0 (_tmp31_, sid) != 0) {
						_g_object_unref0 (peer_state);
						continue;
					}
					_tmp32_ = peer_state;
					_tmp33_ = _tmp32_->jid;
					_tmp34_ = relevant_jid;
					if (xmpp_jid_equals_bare (_tmp33_, _tmp34_)) {
						result = peer_state;
						_g_object_unref0 (_peer_state_it);
						_g_object_unref0 (call_state);
						_g_object_unref0 (_call_state_it);
						_xmpp_jid_unref0 (relevant_jid);
						return result;
					}
					_g_object_unref0 (peer_state);
				}
				_g_object_unref0 (_peer_state_it);
			}
			_g_object_unref0 (call_state);
		}
		_g_object_unref0 (_call_state_it);
	}
	result = NULL;
	_xmpp_jid_unref0 (relevant_jid);
	return result;
}

static DinoCallState*
dino_calls_create_recv_muji_call (DinoCalls* self,
                                  DinoEntitiesAccount* account,
                                  const gchar* call_id,
                                  XmppJid* inviter_jid,
                                  XmppJid* muc_jid,
                                  const gchar* message_type)
{
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	DinoEntitiesCall* call = NULL;
	DinoEntitiesCall* _tmp38_;
	DinoEntitiesCall* _tmp39_;
	DinoEntitiesCall* _tmp40_;
	XmppJid* _tmp41_;
	XmppJid* _tmp42_;
	DinoEntitiesCall* _tmp43_;
	DinoEntitiesCall* _tmp44_;
	DinoEntitiesCall* _tmp45_;
	DinoEntitiesCall* _tmp46_;
	DinoEntitiesCall* _tmp47_;
	GDateTime* _tmp48_;
	GDateTime* _tmp49_;
	DinoEntitiesCall* _tmp50_;
	DinoEntitiesCall* _tmp51_;
	DinoEntitiesConversation* conversation = NULL;
	DinoStreamInteractor* _tmp52_;
	DinoModuleIdentity* _tmp53_;
	gpointer _tmp54_;
	DinoConversationManager* _tmp55_;
	XmppJid* _tmp56_;
	XmppJid* _tmp57_;
	XmppJid* _tmp58_;
	DinoEntitiesConversation* _tmp59_;
	DinoEntitiesConversation* _tmp60_;
	DinoEntitiesConversation* _tmp61_;
	DinoStreamInteractor* _tmp62_;
	DinoModuleIdentity* _tmp63_;
	gpointer _tmp64_;
	DinoCallStore* _tmp65_;
	DinoEntitiesCall* _tmp66_;
	DinoEntitiesConversation* _tmp67_;
	DinoCallState* call_state = NULL;
	DinoEntitiesCall* _tmp68_;
	DinoStreamInteractor* _tmp69_;
	DinoCallState* _tmp70_;
	DinoCallState* _tmp71_;
	DinoCallState* _tmp72_;
	XmppJid* _tmp73_;
	DinoCallState* _tmp74_;
	DinoCallState* _tmp75_;
	GeeArrayList* _tmp76_;
	XmppJid* _tmp77_;
	XmppJid* _tmp78_;
	XmppJid* _tmp79_;
	XmppJid* _tmp80_;
	XmppJid* _tmp81_;
	XmppJid* _tmp82_;
	gchar* _tmp83_;
	gchar* _tmp84_;
	DinoCallState* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	g_return_val_if_fail (call_id != NULL, NULL);
	g_return_val_if_fail (inviter_jid != NULL, NULL);
	g_return_val_if_fail (muc_jid != NULL, NULL);
	g_return_val_if_fail (message_type != NULL, NULL);
	_tmp0_ = dino_entities_account_get_bare_jid (account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_to_string (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = xmpp_jid_to_string (inviter_jid);
	_tmp6_ = _tmp5_;
	_tmp7_ = xmpp_jid_to_string (muc_jid);
	_tmp8_ = _tmp7_;
	g_debug ("calls.vala:266: [%s] Muji call received from %s for MUC %s, type %s", _tmp4_, _tmp6_, _tmp8_, message_type);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_xmpp_jid_unref0 (_tmp2_);
	{
		GeeIterator* _call_it = NULL;
		GeeHashMap* _tmp9_;
		GeeSet* _tmp10_;
		GeeSet* _tmp11_;
		GeeSet* _tmp12_;
		GeeIterator* _tmp13_;
		GeeIterator* _tmp14_;
		_tmp9_ = self->call_states;
		_tmp10_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = _tmp11_;
		_tmp13_ = gee_iterable_iterator ((GeeIterable*) _tmp12_);
		_tmp14_ = _tmp13_;
		_g_object_unref0 (_tmp12_);
		_call_it = _tmp14_;
		while (TRUE) {
			GeeIterator* _tmp15_;
			DinoEntitiesCall* call = NULL;
			GeeIterator* _tmp16_;
			gpointer _tmp17_;
			DinoEntitiesCall* _tmp18_;
			DinoEntitiesAccount* _tmp19_;
			DinoEntitiesAccount* _tmp20_;
			DinoCallState* call_state = NULL;
			GeeHashMap* _tmp21_;
			DinoEntitiesCall* _tmp22_;
			gpointer _tmp23_;
			gboolean _tmp24_ = FALSE;
			gboolean _tmp25_ = FALSE;
			DinoEntitiesCall* _tmp26_;
			GeeList* _tmp27_;
			gint _tmp28_;
			gint _tmp29_;
			_tmp15_ = _call_it;
			if (!gee_iterator_next (_tmp15_)) {
				break;
			}
			_tmp16_ = _call_it;
			_tmp17_ = gee_iterator_get (_tmp16_);
			call = (DinoEntitiesCall*) _tmp17_;
			_tmp18_ = call;
			_tmp19_ = dino_entities_call_get_account (_tmp18_);
			_tmp20_ = _tmp19_;
			if (!dino_entities_account_equals (_tmp20_, account)) {
				_g_object_unref0 (call);
				continue;
			}
			_tmp21_ = self->call_states;
			_tmp22_ = call;
			_tmp23_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp21_, _tmp22_);
			call_state = (DinoCallState*) _tmp23_;
			_tmp26_ = call;
			_tmp27_ = _tmp26_->counterparts;
			_tmp28_ = gee_collection_get_size ((GeeCollection*) _tmp27_);
			_tmp29_ = _tmp28_;
			if (_tmp29_ == 1) {
				DinoEntitiesCall* _tmp30_;
				GeeList* _tmp31_;
				_tmp30_ = call;
				_tmp31_ = _tmp30_->counterparts;
				_tmp25_ = gee_collection_contains ((GeeCollection*) _tmp31_, inviter_jid);
			} else {
				_tmp25_ = FALSE;
			}
			if (_tmp25_) {
				DinoCallState* _tmp32_;
				gboolean _tmp33_;
				gboolean _tmp34_;
				_tmp32_ = call_state;
				_tmp33_ = dino_call_state_get_accepted (_tmp32_);
				_tmp34_ = _tmp33_;
				_tmp24_ = _tmp34_;
			} else {
				_tmp24_ = FALSE;
			}
			if (_tmp24_) {
				DinoCallState* _tmp35_;
				gchar* _tmp36_;
				DinoCallState* _tmp37_;
				_tmp35_ = call_state;
				_tmp36_ = g_strdup (call_id);
				_g_free0 (_tmp35_->cim_call_id);
				_tmp35_->cim_call_id = _tmp36_;
				_tmp37_ = call_state;
				dino_call_state_join_group_call (_tmp37_, muc_jid, NULL, NULL);
				result = NULL;
				_g_object_unref0 (call_state);
				_g_object_unref0 (call);
				_g_object_unref0 (_call_it);
				return result;
			}
			_g_object_unref0 (call_state);
			_g_object_unref0 (call);
		}
		_g_object_unref0 (_call_it);
	}
	_tmp38_ = dino_entities_call_new ();
	call = _tmp38_;
	_tmp39_ = call;
	dino_entities_call_set_direction (_tmp39_, DINO_ENTITIES_CALL_DIRECTION_INCOMING);
	_tmp40_ = call;
	_tmp41_ = dino_entities_account_get_full_jid (account);
	_tmp42_ = _tmp41_;
	dino_entities_call_set_ourpart (_tmp40_, _tmp42_);
	_tmp43_ = call;
	dino_entities_call_set_counterpart (_tmp43_, inviter_jid);
	_tmp44_ = call;
	dino_entities_call_set_account (_tmp44_, account);
	_tmp45_ = call;
	_tmp46_ = call;
	_tmp47_ = call;
	_tmp48_ = g_date_time_new_now_utc ();
	_tmp49_ = _tmp48_;
	dino_entities_call_set_end_time (_tmp47_, _tmp49_);
	dino_entities_call_set_local_time (_tmp46_, _tmp49_);
	dino_entities_call_set_time (_tmp45_, _tmp49_);
	_g_date_time_unref0 (_tmp49_);
	_tmp50_ = call;
	dino_entities_call_set_encryption (_tmp50_, DINO_ENTITIES_ENCRYPTION_UNKNOWN);
	_tmp51_ = call;
	dino_entities_call_set_state (_tmp51_, DINO_ENTITIES_CALL_STATE_RINGING);
	_tmp52_ = self->priv->stream_interactor;
	_tmp53_ = dino_conversation_manager_IDENTITY;
	_tmp54_ = dino_stream_interactor_get_module (_tmp52_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp53_);
	_tmp55_ = (DinoConversationManager*) _tmp54_;
	_tmp56_ = xmpp_jid_get_bare_jid (inviter_jid);
	_tmp57_ = _tmp56_;
	_tmp58_ = _tmp57_;
	_tmp59_ = dino_conversation_manager_get_conversation (_tmp55_, _tmp58_, account, NULL);
	_tmp60_ = _tmp59_;
	_xmpp_jid_unref0 (_tmp58_);
	_g_object_unref0 (_tmp55_);
	conversation = _tmp60_;
	_tmp61_ = conversation;
	if (_tmp61_ == NULL) {
		result = NULL;
		_g_object_unref0 (conversation);
		_g_object_unref0 (call);
		return result;
	}
	_tmp62_ = self->priv->stream_interactor;
	_tmp63_ = dino_call_store_IDENTITY;
	_tmp64_ = dino_stream_interactor_get_module (_tmp62_, DINO_TYPE_CALL_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp63_);
	_tmp65_ = (DinoCallStore*) _tmp64_;
	_tmp66_ = call;
	_tmp67_ = conversation;
	dino_call_store_add_call (_tmp65_, _tmp66_, _tmp67_);
	_g_object_unref0 (_tmp65_);
	_tmp68_ = call;
	_tmp69_ = self->priv->stream_interactor;
	_tmp70_ = dino_call_state_new (_tmp68_, _tmp69_);
	call_state = _tmp70_;
	_tmp71_ = call_state;
	dino_calls_connect_call_state_signals (self, _tmp71_);
	_tmp72_ = call_state;
	_tmp73_ = _xmpp_jid_ref0 (muc_jid);
	_xmpp_jid_unref0 (_tmp72_->invited_to_group_call);
	_tmp72_->invited_to_group_call = _tmp73_;
	_tmp74_ = call_state;
	_tmp74_->use_cim = TRUE;
	_tmp75_ = call_state;
	_tmp76_ = _tmp75_->cim_jids_to_inform;
	_tmp77_ = xmpp_jid_get_bare_jid (inviter_jid);
	_tmp78_ = _tmp77_;
	_tmp79_ = _tmp78_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp76_, _tmp79_);
	_xmpp_jid_unref0 (_tmp79_);
	_tmp80_ = dino_entities_account_get_bare_jid (account);
	_tmp81_ = _tmp80_;
	_tmp82_ = _tmp81_;
	_tmp83_ = xmpp_jid_to_string (_tmp82_);
	_tmp84_ = _tmp83_;
	g_debug ("calls.vala:301: [%s] on_muji_call_received accepting", _tmp84_);
	_g_free0 (_tmp84_);
	_xmpp_jid_unref0 (_tmp82_);
	result = call_state;
	_g_object_unref0 (conversation);
	_g_object_unref0 (call);
	return result;
}

static void
dino_calls_remove_call_from_datastructures (DinoCalls* self,
                                            DinoEntitiesCall* call)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (call != NULL);
	_tmp0_ = self->jmi_request_peer;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, call, NULL);
	_tmp1_ = self->call_states;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp1_, call, NULL);
}

static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		DinoCalls* self;
		self = _data7_->self;
		_g_object_unref0 (_data7_->call_state);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

static void
__lambda72_ (Block7Data* _data7_,
             XmppJid* who_terminated,
             const gchar* reason_name,
             const gchar* reason_text)
{
	DinoCalls* self;
	DinoEntitiesCall* _tmp0_;
	DinoEntitiesCall* _tmp1_;
	self = _data7_->self;
	g_return_if_fail (who_terminated != NULL);
	_tmp0_ = _data7_->call_state->call;
	dino_calls_remove_call_from_datastructures (self, _tmp0_);
	_tmp1_ = _data7_->call_state->call;
	g_signal_emit (self, dino_calls_signals[DINO_CALLS_CALL_TERMINATED_SIGNAL], 0, _tmp1_, reason_name, reason_text);
	g_signal_handler_disconnect ((GObject*) _data7_->call_state, _data7_->terminated_handler_id);
}

static void
___lambda72__dino_call_state_terminated (DinoCallState* _sender,
                                         XmppJid* who_terminated,
                                         const gchar* reason_name,
                                         const gchar* reason_text,
                                         gpointer self)
{
	__lambda72_ (self, who_terminated, reason_name, reason_text);
}

static void
dino_calls_connect_call_state_signals (DinoCalls* self,
                                       DinoCallState* call_state)
{
	Block7Data* _data7_;
	DinoCallState* _tmp0_;
	GeeHashMap* _tmp1_;
	DinoEntitiesCall* _tmp2_;
	gulong _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (call_state != NULL);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_data7_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (call_state);
	_g_object_unref0 (_data7_->call_state);
	_data7_->call_state = _tmp0_;
	_tmp1_ = self->call_states;
	_tmp2_ = _data7_->call_state->call;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, _tmp2_, _data7_->call_state);
	_data7_->terminated_handler_id = (gulong) -1;
	_tmp3_ = g_signal_connect_data (_data7_->call_state, "terminated", (GCallback) ___lambda72__dino_call_state_terminated, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_data7_->terminated_handler_id = _tmp3_;
	block7_data_unref (_data7_);
	_data7_ = NULL;
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		DinoCalls* self;
		self = _data8_->self;
		_g_object_unref0 (_data8_->account);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

static void
__lambda71_ (Block8Data* _data8_,
             XmppXmppStream* stream,
             XmppXepJingleSession* session)
{
	DinoCalls* self;
	self = _data8_->self;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (session != NULL);
	{
		GeeList* _content_list = NULL;
		GeeList* _tmp0_;
		gint _content_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _content_index = 0;
		_tmp0_ = session->contents;
		_content_list = _tmp0_;
		_tmp1_ = _content_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_content_size = _tmp3_;
		_content_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXepJingleContent* content = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXepJingleRtpParameters* rtp_content_parameter = NULL;
			XmppXepJingleContent* _tmp8_;
			XmppXepJingleContentParameters* _tmp9_;
			XmppXepJingleRtpParameters* _tmp10_;
			XmppXepJingleRtpParameters* _tmp11_;
			_content_index = _content_index + 1;
			_tmp4_ = _content_index;
			_tmp5_ = _content_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _content_list;
			_tmp7_ = gee_list_get (_tmp6_, _content_index);
			content = (XmppXepJingleContent*) _tmp7_;
			_tmp8_ = content;
			_tmp9_ = _tmp8_->content_params;
			_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp9_, XMPP_XEP_JINGLE_RTP_TYPE_PARAMETERS) ? ((XmppXepJingleRtpParameters*) _tmp9_) : NULL);
			rtp_content_parameter = _tmp10_;
			_tmp11_ = rtp_content_parameter;
			if (_tmp11_ != NULL) {
				dino_calls_on_incoming_call (self, _data8_->account, session);
				_g_object_unref0 (rtp_content_parameter);
				_g_object_unref0 (content);
				break;
			}
			_g_object_unref0 (rtp_content_parameter);
			_g_object_unref0 (content);
		}
	}
}

static void
___lambda71__xmpp_xep_jingle_module_session_initiate_received (XmppXepJingleModule* _sender,
                                                               XmppXmppStream* stream,
                                                               XmppXepJingleSession* session,
                                                               gpointer self)
{
	__lambda71_ (self, stream, session);
}

static gboolean
__lambda74_ (DinoCalls* self,
             XmppStanzaNode* description)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gboolean result;
	g_return_val_if_fail (description != NULL, FALSE);
	_tmp1_ = ((XmppStanzaEntry*) description)->ns_uri;
	if (g_strcmp0 (_tmp1_, XMPP_XEP_JINGLE_RTP_NS_URI) == 0) {
		const gchar* _tmp2_;
		_tmp2_ = xmpp_stanza_node_get_attribute (description, "media", NULL);
		_tmp0_ = g_strcmp0 (_tmp2_, "audio") == 0;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gboolean
___lambda74__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda74_ ((DinoCalls*) self, (XmppStanzaNode*) g);
	return result;
}

static gboolean
__lambda75_ (DinoCalls* self,
             XmppStanzaNode* description)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gboolean result;
	g_return_val_if_fail (description != NULL, FALSE);
	_tmp1_ = ((XmppStanzaEntry*) description)->ns_uri;
	if (g_strcmp0 (_tmp1_, XMPP_XEP_JINGLE_RTP_NS_URI) == 0) {
		const gchar* _tmp2_;
		_tmp2_ = xmpp_stanza_node_get_attribute (description, "media", NULL);
		_tmp0_ = g_strcmp0 (_tmp2_, "video") == 0;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gboolean
___lambda75__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda75_ ((DinoCalls*) self, (XmppStanzaNode*) g);
	return result;
}

static void
__lambda73_ (Block8Data* _data8_,
             XmppJid* from,
             XmppJid* to,
             const gchar* sid,
             GeeList* descriptions)
{
	DinoCalls* self;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoMucManager* _tmp3_;
	XmppJid* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* _tmp6_;
	gboolean _tmp7_;
	gboolean audio_requested = FALSE;
	gboolean video_requested = FALSE;
	gboolean _tmp8_ = FALSE;
	DinoPeerState* peer_state = NULL;
	DinoPeerState* _tmp9_;
	DinoPeerState* _tmp10_;
	gchar* _tmp11_;
	DinoCallState* call_state = NULL;
	GeeHashMap* _tmp12_;
	DinoPeerState* _tmp13_;
	DinoEntitiesCall* _tmp14_;
	gpointer _tmp15_;
	GeeHashMap* _tmp16_;
	DinoPeerState* _tmp17_;
	DinoEntitiesCall* _tmp18_;
	DinoPeerState* _tmp19_;
	DinoEntitiesConversation* conversation = NULL;
	DinoStreamInteractor* _tmp20_;
	DinoModuleIdentity* _tmp21_;
	gpointer _tmp22_;
	DinoConversationManager* _tmp23_;
	DinoCallState* _tmp24_;
	DinoEntitiesCall* _tmp25_;
	XmppJid* _tmp26_;
	XmppJid* _tmp27_;
	XmppJid* _tmp28_;
	XmppJid* _tmp29_;
	XmppJid* _tmp30_;
	DinoEntitiesConversationType _tmp31_;
	DinoEntitiesConversation* _tmp32_;
	DinoEntitiesConversation* _tmp33_;
	DinoCallState* _tmp34_;
	DinoEntitiesCall* _tmp35_;
	gboolean _tmp36_;
	gboolean _tmp37_;
	self = _data8_->self;
	g_return_if_fail (from != NULL);
	g_return_if_fail (to != NULL);
	g_return_if_fail (sid != NULL);
	g_return_if_fail (descriptions != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_muc_manager_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoMucManager*) _tmp2_;
	_tmp4_ = xmpp_jid_get_bare_jid (from);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = dino_muc_manager_might_be_groupchat (_tmp3_, _tmp6_, _data8_->account);
	_xmpp_jid_unref0 (_tmp6_);
	_g_object_unref0 (_tmp3_);
	if (_tmp7_) {
		return;
	}
	audio_requested = gee_traversable_any_match ((GeeTraversable*) descriptions, ___lambda74__gee_predicate, g_object_ref (self), g_object_unref);
	video_requested = gee_traversable_any_match ((GeeTraversable*) descriptions, ___lambda75__gee_predicate, g_object_ref (self), g_object_unref);
	if (!audio_requested) {
		_tmp8_ = !video_requested;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		return;
	}
	_tmp9_ = dino_calls_create_received_call (self, _data8_->account, from, to, video_requested);
	peer_state = _tmp9_;
	_tmp10_ = peer_state;
	_tmp11_ = g_strdup (sid);
	_g_free0 (_tmp10_->sid);
	_tmp10_->sid = _tmp11_;
	_tmp12_ = self->call_states;
	_tmp13_ = peer_state;
	_tmp14_ = _tmp13_->call;
	_tmp15_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp12_, _tmp14_);
	call_state = (DinoCallState*) _tmp15_;
	_tmp16_ = self->jmi_request_peer;
	_tmp17_ = peer_state;
	_tmp18_ = _tmp17_->call;
	_tmp19_ = peer_state;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp16_, _tmp18_, _tmp19_);
	_tmp20_ = self->priv->stream_interactor;
	_tmp21_ = dino_conversation_manager_IDENTITY;
	_tmp22_ = dino_stream_interactor_get_module (_tmp20_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp21_);
	_tmp23_ = (DinoConversationManager*) _tmp22_;
	_tmp24_ = call_state;
	_tmp25_ = _tmp24_->call;
	_tmp26_ = dino_entities_call_get_counterpart (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = xmpp_jid_get_bare_jid (_tmp27_);
	_tmp29_ = _tmp28_;
	_tmp30_ = _tmp29_;
	_tmp31_ = DINO_ENTITIES_CONVERSATION_TYPE_CHAT;
	_tmp32_ = dino_conversation_manager_get_conversation (_tmp23_, _tmp30_, _data8_->account, &_tmp31_);
	_tmp33_ = _tmp32_;
	_xmpp_jid_unref0 (_tmp30_);
	_g_object_unref0 (_tmp23_);
	conversation = _tmp33_;
	_tmp34_ = call_state;
	_tmp35_ = _tmp34_->call;
	_tmp36_ = dino_entities_call_get_direction (_tmp35_);
	_tmp37_ = _tmp36_;
	if (_tmp37_ == DINO_ENTITIES_CALL_DIRECTION_INCOMING) {
		DinoCallState* _tmp38_;
		DinoEntitiesCall* _tmp39_;
		DinoCallState* _tmp40_;
		DinoEntitiesConversation* _tmp41_;
		_tmp38_ = call_state;
		_tmp39_ = _tmp38_->call;
		_tmp40_ = call_state;
		_tmp41_ = conversation;
		g_signal_emit (self, dino_calls_signals[DINO_CALLS_CALL_INCOMING_SIGNAL], 0, _tmp39_, _tmp40_, _tmp41_, video_requested, FALSE);
	} else {
		DinoCallState* _tmp42_;
		DinoEntitiesCall* _tmp43_;
		DinoCallState* _tmp44_;
		DinoEntitiesConversation* _tmp45_;
		_tmp42_ = call_state;
		_tmp43_ = _tmp42_->call;
		_tmp44_ = call_state;
		_tmp45_ = conversation;
		g_signal_emit (self, dino_calls_signals[DINO_CALLS_CALL_OUTGOING_SIGNAL], 0, _tmp43_, _tmp44_, _tmp45_);
	}
	_g_object_unref0 (conversation);
	_g_object_unref0 (call_state);
	_g_object_unref0 (peer_state);
}

static void
___lambda73__xmpp_xep_jingle_message_initiation_module_session_proposed (XmppXepJingleMessageInitiationModule* _sender,
                                                                         XmppJid* from,
                                                                         XmppJid* to,
                                                                         const gchar* sid,
                                                                         GeeList* descriptions,
                                                                         gpointer self)
{
	__lambda73_ (self, from, to, sid, descriptions);
}

static void
__lambda76_ (Block8Data* _data8_,
             XmppJid* from,
             XmppJid* to,
             const gchar* sid)
{
	DinoCalls* self;
	DinoPeerState* peer_state = NULL;
	DinoPeerState* _tmp0_;
	DinoPeerState* _tmp1_;
	DinoEntitiesCall* call = NULL;
	DinoPeerState* _tmp2_;
	DinoEntitiesCall* _tmp3_;
	DinoEntitiesCall* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* _tmp6_;
	XmppJid* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp14_ = FALSE;
	gboolean _tmp15_ = FALSE;
	DinoEntitiesCall* _tmp16_;
	gboolean _tmp17_;
	gboolean _tmp18_;
	self = _data8_->self;
	g_return_if_fail (from != NULL);
	g_return_if_fail (to != NULL);
	g_return_if_fail (sid != NULL);
	_tmp0_ = dino_calls_get_peer_by_sid (self, _data8_->account, sid, from, to);
	peer_state = _tmp0_;
	_tmp1_ = peer_state;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (peer_state);
		return;
	}
	_tmp2_ = peer_state;
	_tmp3_ = _tmp2_->call;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	call = _tmp4_;
	_tmp5_ = dino_entities_account_get_bare_jid (_data8_->account);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = xmpp_jid_equals_bare (from, _tmp7_);
	_xmpp_jid_unref0 (_tmp7_);
	if (_tmp8_) {
		XmppJid* _tmp9_;
		XmppJid* _tmp10_;
		DinoEntitiesCall* _tmp11_;
		DinoEntitiesCall* _tmp12_;
		DinoEntitiesCall* _tmp13_;
		_tmp9_ = dino_entities_account_get_full_jid (_data8_->account);
		_tmp10_ = _tmp9_;
		if (xmpp_jid_equals (from, _tmp10_)) {
			_g_object_unref0 (call);
			_g_object_unref0 (peer_state);
			return;
		}
		_tmp11_ = call;
		dino_entities_call_set_ourpart (_tmp11_, from);
		_tmp12_ = call;
		dino_entities_call_set_state (_tmp12_, DINO_ENTITIES_CALL_STATE_OTHER_DEVICE);
		_tmp13_ = call;
		dino_calls_remove_call_from_datastructures (self, _tmp13_);
		_g_object_unref0 (call);
		_g_object_unref0 (peer_state);
		return;
	}
	_tmp16_ = call;
	_tmp17_ = dino_entities_call_get_direction (_tmp16_);
	_tmp18_ = _tmp17_;
	if (_tmp18_ == DINO_ENTITIES_CALL_DIRECTION_OUTGOING) {
		DinoPeerState* _tmp19_;
		XmppJid* _tmp20_;
		_tmp19_ = peer_state;
		_tmp20_ = _tmp19_->jid;
		_tmp15_ = xmpp_jid_equals_bare (from, _tmp20_);
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		XmppJid* _tmp21_;
		XmppJid* _tmp22_;
		_tmp21_ = dino_entities_account_get_full_jid (_data8_->account);
		_tmp22_ = _tmp21_;
		_tmp14_ = xmpp_jid_equals (to, _tmp22_);
	} else {
		_tmp14_ = FALSE;
	}
	if (_tmp14_) {
		GeeHashMap* _tmp23_;
		DinoEntitiesCall* _tmp24_;
		gpointer _tmp25_;
		DinoCallState* _tmp26_;
		GeeHashMap* _tmp27_;
		DinoEntitiesCall* _tmp28_;
		gpointer _tmp29_;
		DinoPeerState* _tmp30_;
		XmppJid* _tmp31_;
		GeeHashMap* _tmp32_;
		DinoEntitiesCall* _tmp33_;
		gpointer _tmp34_;
		DinoPeerState* _tmp35_;
		_tmp23_ = self->call_states;
		_tmp24_ = call;
		_tmp25_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp23_, _tmp24_);
		_tmp26_ = (DinoCallState*) _tmp25_;
		_tmp27_ = self->jmi_request_peer;
		_tmp28_ = call;
		_tmp29_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp27_, _tmp28_);
		_tmp30_ = (DinoPeerState*) _tmp29_;
		_tmp31_ = _tmp30_->jid;
		dino_call_state_rename_peer (_tmp26_, _tmp31_, from);
		_g_object_unref0 (_tmp30_);
		_g_object_unref0 (_tmp26_);
		_tmp32_ = self->jmi_request_peer;
		_tmp33_ = call;
		_tmp34_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp32_, _tmp33_);
		_tmp35_ = (DinoPeerState*) _tmp34_;
		dino_peer_state_call_resource (_tmp35_, from, NULL, NULL);
		_g_object_unref0 (_tmp35_);
	}
	_g_object_unref0 (call);
	_g_object_unref0 (peer_state);
}

static void
___lambda76__xmpp_xep_jingle_message_initiation_module_session_accepted (XmppXepJingleMessageInitiationModule* _sender,
                                                                         XmppJid* from,
                                                                         XmppJid* to,
                                                                         const gchar* sid,
                                                                         gpointer self)
{
	__lambda76_ (self, from, to, sid);
}

static void
__lambda77_ (Block8Data* _data8_,
             XmppJid* from,
             XmppJid* to,
             const gchar* sid)
{
	DinoCalls* self;
	DinoPeerState* peer_state = NULL;
	DinoPeerState* _tmp0_;
	DinoPeerState* _tmp1_;
	DinoEntitiesCall* call = NULL;
	DinoPeerState* _tmp2_;
	DinoEntitiesCall* _tmp3_;
	DinoEntitiesCall* _tmp4_;
	gboolean _tmp5_ = FALSE;
	DinoEntitiesCall* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean outgoing_reject = FALSE;
	gboolean _tmp13_ = FALSE;
	DinoEntitiesCall* _tmp14_;
	gboolean _tmp15_;
	gboolean _tmp16_;
	gboolean incoming_reject = FALSE;
	gboolean _tmp20_ = FALSE;
	gboolean _tmp21_ = FALSE;
	DinoEntitiesCall* _tmp28_;
	GeeHashMap* _tmp29_;
	DinoEntitiesCall* _tmp30_;
	gpointer _tmp31_;
	DinoCallState* _tmp32_;
	DinoEntitiesCall* _tmp33_;
	self = _data8_->self;
	g_return_if_fail (from != NULL);
	g_return_if_fail (to != NULL);
	g_return_if_fail (sid != NULL);
	_tmp0_ = dino_calls_get_peer_by_sid (self, _data8_->account, sid, from, to);
	peer_state = _tmp0_;
	_tmp1_ = peer_state;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (peer_state);
		return;
	}
	_tmp2_ = peer_state;
	_tmp3_ = _tmp2_->call;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	call = _tmp4_;
	_tmp6_ = call;
	_tmp7_ = dino_entities_call_get_direction (_tmp6_);
	_tmp8_ = _tmp7_;
	if (_tmp8_ == DINO_ENTITIES_CALL_DIRECTION_OUTGOING) {
		DinoEntitiesCall* _tmp9_;
		GeeList* _tmp10_;
		gpointer _tmp11_;
		XmppJid* _tmp12_;
		_tmp9_ = call;
		_tmp10_ = _tmp9_->counterparts;
		_tmp11_ = gee_list_get (_tmp10_, 0);
		_tmp12_ = (XmppJid*) _tmp11_;
		_tmp5_ = xmpp_jid_equals_bare (from, _tmp12_);
		_xmpp_jid_unref0 (_tmp12_);
	} else {
		_tmp5_ = FALSE;
	}
	outgoing_reject = _tmp5_;
	_tmp14_ = call;
	_tmp15_ = dino_entities_call_get_direction (_tmp14_);
	_tmp16_ = _tmp15_;
	if (_tmp16_ == DINO_ENTITIES_CALL_DIRECTION_INCOMING) {
		XmppJid* _tmp17_;
		XmppJid* _tmp18_;
		XmppJid* _tmp19_;
		_tmp17_ = dino_entities_account_get_bare_jid (_data8_->account);
		_tmp18_ = _tmp17_;
		_tmp19_ = _tmp18_;
		_tmp13_ = xmpp_jid_equals_bare (from, _tmp19_);
		_xmpp_jid_unref0 (_tmp19_);
	} else {
		_tmp13_ = FALSE;
	}
	incoming_reject = _tmp13_;
	if (!outgoing_reject) {
		_tmp20_ = !incoming_reject;
	} else {
		_tmp20_ = FALSE;
	}
	if (_tmp20_) {
		_g_object_unref0 (call);
		_g_object_unref0 (peer_state);
		return;
	}
	if (incoming_reject) {
		GeeHashMap* _tmp22_;
		DinoEntitiesCall* _tmp23_;
		gpointer _tmp24_;
		DinoCallState* _tmp25_;
		XmppXepMujiGroupCall* _tmp26_;
		XmppXepMujiGroupCall* _tmp27_;
		_tmp22_ = self->call_states;
		_tmp23_ = call;
		_tmp24_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp22_, _tmp23_);
		_tmp25_ = (DinoCallState*) _tmp24_;
		_tmp26_ = dino_call_state_get_group_call (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp21_ = _tmp27_ != NULL;
		_g_object_unref0 (_tmp25_);
	} else {
		_tmp21_ = FALSE;
	}
	if (_tmp21_) {
		_g_object_unref0 (call);
		_g_object_unref0 (peer_state);
		return;
	}
	_tmp28_ = call;
	dino_entities_call_set_state (_tmp28_, DINO_ENTITIES_CALL_STATE_DECLINED);
	_tmp29_ = self->call_states;
	_tmp30_ = call;
	_tmp31_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp29_, _tmp30_);
	_tmp32_ = (DinoCallState*) _tmp31_;
	g_signal_emit_by_name (_tmp32_, "terminated", from, XMPP_XEP_JINGLE_REASON_ELEMENT_DECLINE, "JMI reject");
	_g_object_unref0 (_tmp32_);
	_tmp33_ = call;
	dino_calls_remove_call_from_datastructures (self, _tmp33_);
	_g_object_unref0 (call);
	_g_object_unref0 (peer_state);
}

static void
___lambda77__xmpp_xep_jingle_message_initiation_module_session_rejected (XmppXepJingleMessageInitiationModule* _sender,
                                                                         XmppJid* from,
                                                                         XmppJid* to,
                                                                         const gchar* sid,
                                                                         gpointer self)
{
	__lambda77_ (self, from, to, sid);
}

static void
__lambda78_ (Block8Data* _data8_,
             XmppJid* from,
             XmppJid* to,
             const gchar* sid)
{
	DinoCalls* self;
	DinoPeerState* peer_state = NULL;
	DinoPeerState* _tmp0_;
	DinoPeerState* _tmp1_;
	DinoEntitiesCall* call = NULL;
	DinoPeerState* _tmp2_;
	DinoEntitiesCall* _tmp3_;
	DinoEntitiesCall* _tmp4_;
	gboolean _tmp5_ = FALSE;
	DinoEntitiesCall* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean outgoing_retract = FALSE;
	gboolean _tmp12_ = FALSE;
	DinoEntitiesCall* _tmp13_;
	gboolean _tmp14_;
	gboolean _tmp15_;
	gboolean incoming_retract = FALSE;
	gboolean _tmp19_ = FALSE;
	DinoEntitiesCall* _tmp20_;
	GeeHashMap* _tmp21_;
	DinoEntitiesCall* _tmp22_;
	gpointer _tmp23_;
	DinoCallState* _tmp24_;
	DinoEntitiesCall* _tmp25_;
	self = _data8_->self;
	g_return_if_fail (from != NULL);
	g_return_if_fail (to != NULL);
	g_return_if_fail (sid != NULL);
	_tmp0_ = dino_calls_get_peer_by_sid (self, _data8_->account, sid, from, to);
	peer_state = _tmp0_;
	_tmp1_ = peer_state;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (peer_state);
		return;
	}
	_tmp2_ = peer_state;
	_tmp3_ = _tmp2_->call;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	call = _tmp4_;
	_tmp6_ = call;
	_tmp7_ = dino_entities_call_get_direction (_tmp6_);
	_tmp8_ = _tmp7_;
	if (_tmp8_ == DINO_ENTITIES_CALL_DIRECTION_OUTGOING) {
		XmppJid* _tmp9_;
		XmppJid* _tmp10_;
		XmppJid* _tmp11_;
		_tmp9_ = dino_entities_account_get_bare_jid (_data8_->account);
		_tmp10_ = _tmp9_;
		_tmp11_ = _tmp10_;
		_tmp5_ = xmpp_jid_equals_bare (from, _tmp11_);
		_xmpp_jid_unref0 (_tmp11_);
	} else {
		_tmp5_ = FALSE;
	}
	outgoing_retract = _tmp5_;
	_tmp13_ = call;
	_tmp14_ = dino_entities_call_get_direction (_tmp13_);
	_tmp15_ = _tmp14_;
	if (_tmp15_ == DINO_ENTITIES_CALL_DIRECTION_INCOMING) {
		DinoEntitiesCall* _tmp16_;
		XmppJid* _tmp17_;
		XmppJid* _tmp18_;
		_tmp16_ = call;
		_tmp17_ = dino_entities_call_get_counterpart (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp12_ = xmpp_jid_equals_bare (from, _tmp18_);
	} else {
		_tmp12_ = FALSE;
	}
	incoming_retract = _tmp12_;
	if (outgoing_retract) {
		_tmp19_ = TRUE;
	} else {
		_tmp19_ = incoming_retract;
	}
	if (!_tmp19_) {
		_g_object_unref0 (call);
		_g_object_unref0 (peer_state);
		return;
	}
	_tmp20_ = call;
	dino_entities_call_set_state (_tmp20_, DINO_ENTITIES_CALL_STATE_MISSED);
	_tmp21_ = self->call_states;
	_tmp22_ = call;
	_tmp23_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp21_, _tmp22_);
	_tmp24_ = (DinoCallState*) _tmp23_;
	g_signal_emit_by_name (_tmp24_, "terminated", from, XMPP_XEP_JINGLE_REASON_ELEMENT_CANCEL, "JMI retract");
	_g_object_unref0 (_tmp24_);
	_tmp25_ = call;
	dino_calls_remove_call_from_datastructures (self, _tmp25_);
	_g_object_unref0 (call);
	_g_object_unref0 (peer_state);
}

static void
___lambda78__xmpp_xep_jingle_message_initiation_module_session_retracted (XmppXepJingleMessageInitiationModule* _sender,
                                                                          XmppJid* from,
                                                                          XmppJid* to,
                                                                          const gchar* sid,
                                                                          gpointer self)
{
	__lambda78_ (self, from, to, sid);
}

static void
__lambda79_ (Block8Data* _data8_,
             XmppJid* from_jid,
             XmppJid* to_jid,
             const gchar* call_id,
             gboolean video_requested,
             GeeList* join_methods,
             XmppMessageStanza* message_stanza)
{
	DinoCalls* self;
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gboolean _tmp3_;
	DinoStreamInteractor* _tmp4_;
	DinoModuleIdentity* _tmp5_;
	gpointer _tmp6_;
	DinoMucManager* _tmp7_;
	gboolean _tmp8_;
	gboolean multiparty = FALSE;
	DinoCallState* call_state = NULL;
	DinoCallState* _tmp66_;
	DinoCallState* _tmp67_;
	DinoCallState* _tmp68_;
	DinoCallState* _tmp69_;
	DinoCallState* _tmp70_;
	gchar* _tmp71_;
	XmppJid* _tmp72_ = NULL;
	const gchar* _tmp73_;
	const gchar* _tmp74_;
	DinoCallState* _tmp78_;
	GeeArrayList* _tmp79_;
	DinoCallState* _tmp80_;
	const gchar* _tmp81_;
	const gchar* _tmp82_;
	DinoEntitiesConversation* conversation = NULL;
	DinoStreamInteractor* _tmp83_;
	DinoModuleIdentity* _tmp84_;
	gpointer _tmp85_;
	DinoConversationManager* _tmp86_;
	const gchar* _tmp87_;
	const gchar* _tmp88_;
	DinoEntitiesConversation* _tmp89_;
	DinoEntitiesConversation* _tmp90_;
	DinoEntitiesConversation* _tmp91_;
	DinoCallState* _tmp92_;
	DinoEntitiesCall* _tmp93_;
	gboolean _tmp94_;
	gboolean _tmp95_;
	GError* _inner_error0_ = NULL;
	self = _data8_->self;
	g_return_if_fail (from_jid != NULL);
	g_return_if_fail (to_jid != NULL);
	g_return_if_fail (call_id != NULL);
	g_return_if_fail (join_methods != NULL);
	g_return_if_fail (message_stanza != NULL);
	_tmp0_ = dino_entities_account_get_bare_jid (_data8_->account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_equals_bare (from_jid, _tmp2_);
	_xmpp_jid_unref0 (_tmp2_);
	if (_tmp3_) {
		return;
	}
	_tmp4_ = self->priv->stream_interactor;
	_tmp5_ = dino_muc_manager_IDENTITY;
	_tmp6_ = dino_stream_interactor_get_module (_tmp4_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp5_);
	_tmp7_ = (DinoMucManager*) _tmp6_;
	_tmp8_ = dino_muc_manager_is_own_muc_jid (_tmp7_, from_jid, _data8_->account);
	_g_object_unref0 (_tmp7_);
	if (_tmp8_) {
		return;
	}
	multiparty = FALSE;
	call_state = NULL;
	{
		GeeList* _join_method_node_list = NULL;
		gint _join_method_node_size = 0;
		GeeList* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		gint _join_method_node_index = 0;
		_join_method_node_list = join_methods;
		_tmp9_ = _join_method_node_list;
		_tmp10_ = gee_collection_get_size ((GeeCollection*) _tmp9_);
		_tmp11_ = _tmp10_;
		_join_method_node_size = _tmp11_;
		_join_method_node_index = -1;
		while (TRUE) {
			gint _tmp12_;
			gint _tmp13_;
			XmppStanzaNode* join_method_node = NULL;
			GeeList* _tmp14_;
			gpointer _tmp15_;
			gboolean _tmp16_ = FALSE;
			XmppStanzaNode* _tmp17_;
			const gchar* _tmp18_;
			_join_method_node_index = _join_method_node_index + 1;
			_tmp12_ = _join_method_node_index;
			_tmp13_ = _join_method_node_size;
			if (!(_tmp12_ < _tmp13_)) {
				break;
			}
			_tmp14_ = _join_method_node_list;
			_tmp15_ = gee_list_get (_tmp14_, _join_method_node_index);
			join_method_node = (XmppStanzaNode*) _tmp15_;
			_tmp17_ = join_method_node;
			_tmp18_ = ((XmppStanzaEntry*) _tmp17_)->name;
			if (g_strcmp0 (_tmp18_, "muji") == 0) {
				XmppStanzaNode* _tmp19_;
				const gchar* _tmp20_;
				_tmp19_ = join_method_node;
				_tmp20_ = ((XmppStanzaEntry*) _tmp19_)->ns_uri;
				_tmp16_ = g_strcmp0 (_tmp20_, XMPP_XEP_MUJI_NS_URI) == 0;
			} else {
				_tmp16_ = FALSE;
			}
			if (_tmp16_) {
				GDateTime* delay = NULL;
				XmppJid* _tmp21_;
				XmppJid* _tmp22_;
				XmppJid* _tmp23_;
				GDateTime* _tmp24_;
				GDateTime* _tmp25_;
				GDateTime* _tmp26_;
				gchar* room_jid_str = NULL;
				XmppStanzaNode* _tmp27_;
				const gchar* _tmp28_;
				gchar* _tmp29_;
				const gchar* _tmp30_;
				XmppJid* room_jid = NULL;
				const gchar* _tmp31_;
				XmppJid* _tmp32_;
				XmppJid* _tmp33_;
				const gchar* _tmp34_;
				const gchar* _tmp35_;
				DinoCallState* _tmp36_;
				_tmp21_ = xmpp_jid_get_bare_jid (from_jid);
				_tmp22_ = _tmp21_;
				_tmp23_ = _tmp22_;
				_tmp24_ = xmpp_xep_delayed_delivery_get_time_for_message (message_stanza, _tmp23_);
				_tmp25_ = _tmp24_;
				_xmpp_jid_unref0 (_tmp23_);
				delay = _tmp25_;
				_tmp26_ = delay;
				if (_tmp26_ != NULL) {
					_g_date_time_unref0 (delay);
					_xmpp_stanza_entry_unref0 (join_method_node);
					_g_object_unref0 (call_state);
					return;
				}
				_tmp27_ = join_method_node;
				_tmp28_ = xmpp_stanza_node_get_attribute (_tmp27_, "room", NULL);
				_tmp29_ = g_strdup (_tmp28_);
				room_jid_str = _tmp29_;
				_tmp30_ = room_jid_str;
				if (_tmp30_ == NULL) {
					_g_free0 (room_jid_str);
					_g_date_time_unref0 (delay);
					_xmpp_stanza_entry_unref0 (join_method_node);
					_g_object_unref0 (call_state);
					return;
				}
				_tmp31_ = room_jid_str;
				_tmp32_ = xmpp_jid_new (_tmp31_, &_inner_error0_);
				room_jid = _tmp32_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_free0 (room_jid_str);
					_g_date_time_unref0 (delay);
					_xmpp_stanza_entry_unref0 (join_method_node);
					_g_object_unref0 (call_state);
					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;
				}
				_tmp33_ = room_jid;
				_tmp34_ = xmpp_stanza_get_type_ ((XmppStanza*) message_stanza);
				_tmp35_ = _tmp34_;
				_tmp36_ = dino_calls_create_recv_muji_call (self, _data8_->account, call_id, from_jid, _tmp33_, _tmp35_);
				_g_object_unref0 (call_state);
				call_state = _tmp36_;
				multiparty = TRUE;
				_xmpp_jid_unref0 (room_jid);
				_g_free0 (room_jid_str);
				_g_date_time_unref0 (delay);
				_xmpp_stanza_entry_unref0 (join_method_node);
				break;
			} else {
				gboolean _tmp37_ = FALSE;
				XmppStanzaNode* _tmp38_;
				const gchar* _tmp39_;
				_tmp38_ = join_method_node;
				_tmp39_ = ((XmppStanzaEntry*) _tmp38_)->name;
				if (g_strcmp0 (_tmp39_, "jingle") == 0) {
					XmppStanzaNode* _tmp40_;
					const gchar* _tmp41_;
					_tmp40_ = join_method_node;
					_tmp41_ = ((XmppStanzaEntry*) _tmp40_)->ns_uri;
					_tmp37_ = g_strcmp0 (_tmp41_, XMPP_XEP_CALL_INVITES_NS_URI) == 0;
				} else {
					_tmp37_ = FALSE;
				}
				if (_tmp37_) {
					DinoStreamInteractor* _tmp42_;
					DinoModuleIdentity* _tmp43_;
					gpointer _tmp44_;
					DinoMucManager* _tmp45_;
					XmppJid* _tmp46_;
					XmppJid* _tmp47_;
					XmppJid* _tmp48_;
					gboolean _tmp49_;
					gchar* sid = NULL;
					XmppStanzaNode* _tmp50_;
					const gchar* _tmp51_;
					gchar* _tmp52_;
					const gchar* _tmp53_;
					DinoPeerState* peer_state = NULL;
					DinoPeerState* _tmp54_;
					DinoPeerState* _tmp55_;
					const gchar* _tmp56_;
					gchar* _tmp57_;
					GeeHashMap* _tmp58_;
					DinoPeerState* _tmp59_;
					DinoEntitiesCall* _tmp60_;
					gpointer _tmp61_;
					GeeHashMap* _tmp62_;
					DinoCallState* _tmp63_;
					DinoEntitiesCall* _tmp64_;
					DinoPeerState* _tmp65_;
					_tmp42_ = self->priv->stream_interactor;
					_tmp43_ = dino_muc_manager_IDENTITY;
					_tmp44_ = dino_stream_interactor_get_module (_tmp42_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp43_);
					_tmp45_ = (DinoMucManager*) _tmp44_;
					_tmp46_ = xmpp_jid_get_bare_jid (from_jid);
					_tmp47_ = _tmp46_;
					_tmp48_ = _tmp47_;
					_tmp49_ = dino_muc_manager_might_be_groupchat (_tmp45_, _tmp48_, _data8_->account);
					_xmpp_jid_unref0 (_tmp48_);
					_g_object_unref0 (_tmp45_);
					if (_tmp49_) {
						_xmpp_stanza_entry_unref0 (join_method_node);
						_g_object_unref0 (call_state);
						return;
					}
					_tmp50_ = join_method_node;
					_tmp51_ = xmpp_stanza_node_get_attribute (_tmp50_, "sid", NULL);
					_tmp52_ = g_strdup (_tmp51_);
					sid = _tmp52_;
					_tmp53_ = sid;
					if (_tmp53_ == NULL) {
						_g_free0 (sid);
						_xmpp_stanza_entry_unref0 (join_method_node);
						_g_object_unref0 (call_state);
						return;
					}
					_tmp54_ = dino_calls_create_received_call (self, _data8_->account, from_jid, to_jid, video_requested);
					peer_state = _tmp54_;
					_tmp55_ = peer_state;
					_tmp56_ = sid;
					_tmp57_ = g_strdup (_tmp56_);
					_g_free0 (_tmp55_->sid);
					_tmp55_->sid = _tmp57_;
					_tmp58_ = self->call_states;
					_tmp59_ = peer_state;
					_tmp60_ = _tmp59_->call;
					_tmp61_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp58_, _tmp60_);
					_g_object_unref0 (call_state);
					call_state = (DinoCallState*) _tmp61_;
					_tmp62_ = self->jmi_request_peer;
					_tmp63_ = call_state;
					_tmp64_ = _tmp63_->call;
					_tmp65_ = peer_state;
					gee_abstract_map_set ((GeeAbstractMap*) _tmp62_, _tmp64_, _tmp65_);
					_g_object_unref0 (peer_state);
					_g_free0 (sid);
					_xmpp_stanza_entry_unref0 (join_method_node);
					break;
				}
			}
			_xmpp_stanza_entry_unref0 (join_method_node);
		}
	}
	_tmp66_ = call_state;
	if (_tmp66_ == NULL) {
		_g_object_unref0 (call_state);
		return;
	}
	_tmp67_ = call_state;
	dino_call_state_set_we_should_send_audio (_tmp67_, TRUE);
	_tmp68_ = call_state;
	dino_call_state_set_we_should_send_video (_tmp68_, video_requested);
	_tmp69_ = call_state;
	_tmp69_->use_cim = TRUE;
	_tmp70_ = call_state;
	_tmp71_ = g_strdup (call_id);
	_g_free0 (_tmp70_->cim_call_id);
	_tmp70_->cim_call_id = _tmp71_;
	_tmp73_ = xmpp_stanza_get_type_ ((XmppStanza*) message_stanza);
	_tmp74_ = _tmp73_;
	if (g_strcmp0 (_tmp74_, XMPP_MESSAGE_STANZA_TYPE_GROUPCHAT) == 0) {
		XmppJid* _tmp75_;
		XmppJid* _tmp76_;
		_tmp75_ = xmpp_jid_get_bare_jid (from_jid);
		_tmp76_ = _tmp75_;
		_xmpp_jid_unref0 (_tmp72_);
		_tmp72_ = _tmp76_;
	} else {
		XmppJid* _tmp77_;
		_tmp77_ = _xmpp_jid_ref0 (from_jid);
		_xmpp_jid_unref0 (_tmp72_);
		_tmp72_ = _tmp77_;
	}
	_tmp78_ = call_state;
	_tmp79_ = _tmp78_->cim_jids_to_inform;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp79_, _tmp72_);
	_tmp80_ = call_state;
	_tmp81_ = xmpp_stanza_get_type_ ((XmppStanza*) message_stanza);
	_tmp82_ = _tmp81_;
	dino_call_state_set_cim_message_type (_tmp80_, _tmp82_);
	_tmp83_ = self->priv->stream_interactor;
	_tmp84_ = dino_conversation_manager_IDENTITY;
	_tmp85_ = dino_stream_interactor_get_module (_tmp83_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp84_);
	_tmp86_ = (DinoConversationManager*) _tmp85_;
	_tmp87_ = xmpp_stanza_get_type_ ((XmppStanza*) message_stanza);
	_tmp88_ = _tmp87_;
	_tmp89_ = dino_conversation_manager_approx_conversation_for_stanza (_tmp86_, from_jid, to_jid, _data8_->account, _tmp88_);
	_tmp90_ = _tmp89_;
	_g_object_unref0 (_tmp86_);
	conversation = _tmp90_;
	_tmp91_ = conversation;
	if (_tmp91_ == NULL) {
		_g_object_unref0 (conversation);
		_xmpp_jid_unref0 (_tmp72_);
		_g_object_unref0 (call_state);
		return;
	}
	_tmp92_ = call_state;
	_tmp93_ = _tmp92_->call;
	_tmp94_ = dino_entities_call_get_direction (_tmp93_);
	_tmp95_ = _tmp94_;
	if (_tmp95_ == DINO_ENTITIES_CALL_DIRECTION_INCOMING) {
		DinoCallState* _tmp96_;
		DinoEntitiesCall* _tmp97_;
		DinoCallState* _tmp98_;
		DinoEntitiesConversation* _tmp99_;
		_tmp96_ = call_state;
		_tmp97_ = _tmp96_->call;
		_tmp98_ = call_state;
		_tmp99_ = conversation;
		g_signal_emit (self, dino_calls_signals[DINO_CALLS_CALL_INCOMING_SIGNAL], 0, _tmp97_, _tmp98_, _tmp99_, video_requested, multiparty);
	} else {
		DinoCallState* _tmp100_;
		DinoEntitiesCall* _tmp101_;
		DinoCallState* _tmp102_;
		DinoEntitiesConversation* _tmp103_;
		_tmp100_ = call_state;
		_tmp101_ = _tmp100_->call;
		_tmp102_ = call_state;
		_tmp103_ = conversation;
		g_signal_emit (self, dino_calls_signals[DINO_CALLS_CALL_OUTGOING_SIGNAL], 0, _tmp101_, _tmp102_, _tmp103_);
	}
	_g_object_unref0 (conversation);
	_xmpp_jid_unref0 (_tmp72_);
	_g_object_unref0 (call_state);
}

static void
___lambda79__xmpp_xep_call_invites_module_call_proposed (XmppXepCallInvitesModule* _sender,
                                                         XmppJid* from,
                                                         XmppJid* to,
                                                         const gchar* call_id,
                                                         gboolean video,
                                                         GeeList* join_methods,
                                                         XmppMessageStanza* message,
                                                         gpointer self)
{
	__lambda79_ (self, from, to, call_id, video, join_methods, message);
}

static void
__lambda80_ (Block8Data* _data8_,
             XmppJid* from_jid,
             XmppJid* to_jid,
             const gchar* call_id,
             const gchar* message_type)
{
	DinoCalls* self;
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gboolean _tmp3_;
	DinoCallState* call_state = NULL;
	DinoCallState* _tmp14_;
	DinoCallState* _tmp15_;
	DinoEntitiesCall* call = NULL;
	DinoCallState* _tmp16_;
	DinoEntitiesCall* _tmp17_;
	DinoEntitiesCall* _tmp18_;
	gboolean _tmp19_ = FALSE;
	DinoEntitiesCall* _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	self = _data8_->self;
	g_return_if_fail (from_jid != NULL);
	g_return_if_fail (to_jid != NULL);
	g_return_if_fail (call_id != NULL);
	g_return_if_fail (message_type != NULL);
	_tmp0_ = dino_entities_account_get_bare_jid (_data8_->account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_equals_bare (from_jid, _tmp2_);
	_xmpp_jid_unref0 (_tmp2_);
	if (_tmp3_) {
		DinoCallState* call_state = NULL;
		DinoCallState* _tmp4_;
		DinoCallState* _tmp5_;
		DinoEntitiesCall* call = NULL;
		DinoCallState* _tmp6_;
		DinoEntitiesCall* _tmp7_;
		DinoEntitiesCall* _tmp8_;
		XmppJid* _tmp9_;
		XmppJid* _tmp10_;
		DinoEntitiesCall* _tmp11_;
		DinoEntitiesCall* _tmp12_;
		DinoEntitiesCall* _tmp13_;
		_tmp4_ = dino_calls_get_call_state_by_call_id (self, _data8_->account, call_id, NULL);
		call_state = _tmp4_;
		_tmp5_ = call_state;
		if (_tmp5_ == NULL) {
			_g_object_unref0 (call_state);
			return;
		}
		_tmp6_ = call_state;
		_tmp7_ = _tmp6_->call;
		_tmp8_ = _g_object_ref0 (_tmp7_);
		call = _tmp8_;
		_tmp9_ = dino_entities_account_get_full_jid (_data8_->account);
		_tmp10_ = _tmp9_;
		if (xmpp_jid_equals (from_jid, _tmp10_)) {
			_g_object_unref0 (call);
			_g_object_unref0 (call_state);
			return;
		}
		_tmp11_ = call;
		dino_entities_call_set_ourpart (_tmp11_, from_jid);
		_tmp12_ = call;
		dino_entities_call_set_state (_tmp12_, DINO_ENTITIES_CALL_STATE_OTHER_DEVICE);
		_tmp13_ = call;
		dino_calls_remove_call_from_datastructures (self, _tmp13_);
		_g_object_unref0 (call);
		_g_object_unref0 (call_state);
		return;
	}
	_tmp14_ = dino_calls_get_call_state_by_call_id (self, _data8_->account, call_id, from_jid);
	call_state = _tmp14_;
	_tmp15_ = call_state;
	if (_tmp15_ == NULL) {
		_g_object_unref0 (call_state);
		return;
	}
	_tmp16_ = call_state;
	_tmp17_ = _tmp16_->call;
	_tmp18_ = _g_object_ref0 (_tmp17_);
	call = _tmp18_;
	_tmp20_ = call;
	_tmp21_ = dino_entities_call_get_direction (_tmp20_);
	_tmp22_ = _tmp21_;
	if (_tmp22_ == DINO_ENTITIES_CALL_DIRECTION_OUTGOING) {
		XmppJid* _tmp23_;
		XmppJid* _tmp24_;
		_tmp23_ = dino_entities_account_get_full_jid (_data8_->account);
		_tmp24_ = _tmp23_;
		_tmp19_ = xmpp_jid_equals (to_jid, _tmp24_);
	} else {
		_tmp19_ = FALSE;
	}
	if (_tmp19_) {
		DinoCallState* _tmp25_;
		GeeHashMap* _tmp26_;
		DinoEntitiesCall* _tmp27_;
		gpointer _tmp28_;
		DinoPeerState* _tmp29_;
		XmppJid* _tmp30_;
		GeeHashMap* _tmp31_;
		DinoEntitiesCall* _tmp32_;
		gpointer _tmp33_;
		DinoPeerState* _tmp34_;
		_tmp25_ = call_state;
		_tmp26_ = self->jmi_request_peer;
		_tmp27_ = call;
		_tmp28_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp26_, _tmp27_);
		_tmp29_ = (DinoPeerState*) _tmp28_;
		_tmp30_ = _tmp29_->jid;
		dino_call_state_rename_peer (_tmp25_, _tmp30_, from_jid);
		_g_object_unref0 (_tmp29_);
		_tmp31_ = self->jmi_request_peer;
		_tmp32_ = call;
		_tmp33_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp31_, _tmp32_);
		_tmp34_ = (DinoPeerState*) _tmp33_;
		dino_peer_state_call_resource (_tmp34_, from_jid, NULL, NULL);
		_g_object_unref0 (_tmp34_);
	}
	_g_object_unref0 (call);
	_g_object_unref0 (call_state);
}

static void
___lambda80__xmpp_xep_call_invites_module_call_accepted (XmppXepCallInvitesModule* _sender,
                                                         XmppJid* from,
                                                         XmppJid* to,
                                                         const gchar* call_id,
                                                         const gchar* message_type,
                                                         gpointer self)
{
	__lambda80_ (self, from, to, call_id, message_type);
}

static void
__lambda81_ (Block8Data* _data8_,
             XmppJid* from_jid,
             XmppJid* to_jid,
             const gchar* call_id,
             const gchar* message_type)
{
	DinoCalls* self;
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gboolean _tmp3_;
	DinoCallState* call_state = NULL;
	DinoCallState* _tmp4_;
	DinoCallState* _tmp5_;
	DinoCallState* _tmp6_;
	DinoEntitiesCall* _tmp7_;
	DinoEntitiesCallState _tmp8_;
	DinoEntitiesCallState _tmp9_;
	DinoCallState* _tmp17_;
	DinoEntitiesCall* _tmp18_;
	DinoCallState* _tmp19_;
	DinoEntitiesCall* _tmp20_;
	self = _data8_->self;
	g_return_if_fail (from_jid != NULL);
	g_return_if_fail (to_jid != NULL);
	g_return_if_fail (call_id != NULL);
	g_return_if_fail (message_type != NULL);
	_tmp0_ = dino_entities_account_get_bare_jid (_data8_->account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_equals_bare (from_jid, _tmp2_);
	_xmpp_jid_unref0 (_tmp2_);
	if (_tmp3_) {
		return;
	}
	_tmp4_ = dino_calls_get_call_state_by_call_id (self, _data8_->account, call_id, from_jid);
	call_state = _tmp4_;
	_tmp5_ = call_state;
	if (_tmp5_ == NULL) {
		_g_object_unref0 (call_state);
		return;
	}
	_tmp6_ = call_state;
	_tmp7_ = _tmp6_->call;
	_tmp8_ = dino_entities_call_get_state (_tmp7_);
	_tmp9_ = _tmp8_;
	if (_tmp9_ != DINO_ENTITIES_CALL_STATE_RINGING) {
		gchar* _tmp10_;
		gchar* _tmp11_;
		DinoCallState* _tmp12_;
		DinoEntitiesCall* _tmp13_;
		DinoEntitiesCallState _tmp14_;
		DinoEntitiesCallState _tmp15_;
		GEnumValue* _tmp16_;
		_tmp10_ = xmpp_jid_to_string (from_jid);
		_tmp11_ = _tmp10_;
		_tmp12_ = call_state;
		_tmp13_ = _tmp12_->call;
		_tmp14_ = dino_entities_call_get_state (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_enum_get_value (g_type_class_ref (DINO_ENTITIES_CALL_TYPE_STATE), _tmp15_);
		g_debug ("calls.vala:510: %s tried to retract a call that's in state %s. Ignorin" \
"g.", _tmp11_, (_tmp16_ != NULL) ? _tmp16_->value_name : NULL);
		_g_free0 (_tmp11_);
		_g_object_unref0 (call_state);
		return;
	}
	_tmp17_ = call_state;
	_tmp18_ = _tmp17_->call;
	dino_entities_call_set_state (_tmp18_, DINO_ENTITIES_CALL_STATE_MISSED);
	_tmp19_ = call_state;
	_tmp20_ = _tmp19_->call;
	dino_calls_remove_call_from_datastructures (self, _tmp20_);
	_g_object_unref0 (call_state);
}

static void
___lambda81__xmpp_xep_call_invites_module_call_retracted (XmppXepCallInvitesModule* _sender,
                                                          XmppJid* from,
                                                          XmppJid* to,
                                                          const gchar* call_id,
                                                          const gchar* message_type,
                                                          gpointer self)
{
	__lambda81_ (self, from, to, call_id, message_type);
}

static void
__lambda82_ (Block8Data* _data8_,
             XmppJid* from_jid,
             XmppJid* to_jid,
             const gchar* call_id,
             const gchar* message_type)
{
	DinoCalls* self;
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gboolean _tmp3_;
	XmppJid* _tmp10_;
	XmppJid* _tmp11_;
	XmppJid* _tmp12_;
	gboolean _tmp13_;
	XmppJid* _tmp14_;
	XmppJid* _tmp15_;
	XmppJid* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	self = _data8_->self;
	g_return_if_fail (from_jid != NULL);
	g_return_if_fail (to_jid != NULL);
	g_return_if_fail (call_id != NULL);
	g_return_if_fail (message_type != NULL);
	_tmp0_ = dino_entities_account_get_bare_jid (_data8_->account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_equals_bare (from_jid, _tmp2_);
	_xmpp_jid_unref0 (_tmp2_);
	if (_tmp3_) {
		DinoCallState* call_state = NULL;
		DinoCallState* _tmp4_;
		DinoCallState* _tmp5_;
		DinoEntitiesCall* call = NULL;
		DinoCallState* _tmp6_;
		DinoEntitiesCall* _tmp7_;
		DinoEntitiesCall* _tmp8_;
		DinoEntitiesCall* _tmp9_;
		_tmp4_ = dino_calls_get_call_state_by_call_id (self, _data8_->account, call_id, NULL);
		call_state = _tmp4_;
		_tmp5_ = call_state;
		if (_tmp5_ == NULL) {
			_g_object_unref0 (call_state);
			return;
		}
		_tmp6_ = call_state;
		_tmp7_ = _tmp6_->call;
		_tmp8_ = _g_object_ref0 (_tmp7_);
		call = _tmp8_;
		_tmp9_ = call;
		dino_entities_call_set_state (_tmp9_, DINO_ENTITIES_CALL_STATE_DECLINED);
		_g_object_unref0 (call);
		_g_object_unref0 (call_state);
	}
	_tmp10_ = dino_entities_account_get_bare_jid (_data8_->account);
	_tmp11_ = _tmp10_;
	_tmp12_ = _tmp11_;
	_tmp13_ = xmpp_jid_equals_bare (from_jid, _tmp12_);
	_xmpp_jid_unref0 (_tmp12_);
	if (_tmp13_) {
		return;
	}
	_tmp14_ = dino_entities_account_get_bare_jid (_data8_->account);
	_tmp15_ = _tmp14_;
	_tmp16_ = _tmp15_;
	_tmp17_ = xmpp_jid_to_string (_tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = xmpp_jid_to_string (from_jid);
	_tmp20_ = _tmp19_;
	g_debug ("calls.vala:529: [%s] %s rejected our MUJI invite", _tmp18_, _tmp20_);
	_g_free0 (_tmp20_);
	_g_free0 (_tmp18_);
	_xmpp_jid_unref0 (_tmp16_);
}

static void
___lambda82__xmpp_xep_call_invites_module_call_rejected (XmppXepCallInvitesModule* _sender,
                                                         XmppJid* from,
                                                         XmppJid* to,
                                                         const gchar* call_id,
                                                         const gchar* message_type,
                                                         gpointer self)
{
	__lambda82_ (self, from, to, call_id, message_type);
}

static void
__lambda83_ (DinoCalls* self,
             XmppJid* jid,
             XmppXepCoinConferenceInfo* info)
{
	g_return_if_fail (jid != NULL);
	g_return_if_fail (info != NULL);
	{
		GeeIterator* _call_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->call_states;
		_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_call_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoEntitiesCall* call = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			DinoEntitiesCall* _tmp9_;
			GeeList* _tmp10_;
			gpointer _tmp11_;
			XmppJid* _tmp12_;
			gboolean _tmp13_;
			_tmp6_ = _call_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _call_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			call = (DinoEntitiesCall*) _tmp8_;
			_tmp9_ = call;
			_tmp10_ = _tmp9_->counterparts;
			_tmp11_ = gee_list_get (_tmp10_, 0);
			_tmp12_ = (XmppJid*) _tmp11_;
			_tmp13_ = xmpp_jid_equals_bare (_tmp12_, jid);
			_xmpp_jid_unref0 (_tmp12_);
			if (_tmp13_) {
				DinoEntitiesCall* _tmp14_;
				_tmp14_ = call;
				g_signal_emit (self, dino_calls_signals[DINO_CALLS_CONFERENCE_INFO_RECEIVED_SIGNAL], 0, _tmp14_, info);
				_g_object_unref0 (call);
				_g_object_unref0 (_call_it);
				return;
			}
			_g_object_unref0 (call);
		}
		_g_object_unref0 (_call_it);
	}
}

static void
___lambda83__xmpp_xep_coin_module_coin_info_received (XmppXepCoinModule* _sender,
                                                      XmppJid* jid,
                                                      XmppXepCoinConferenceInfo* info,
                                                      gpointer self)
{
	__lambda83_ ((DinoCalls*) self, jid, info);
}

static void
dino_calls_on_account_added (DinoCalls* self,
                             DinoEntitiesAccount* account)
{
	Block8Data* _data8_;
	DinoEntitiesAccount* _tmp0_;
	XmppXepJingleModule* jingle_module = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoModuleManager* _tmp2_;
	XmppModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	XmppXepJingleMessageInitiationModule* mi_module = NULL;
	DinoStreamInteractor* _tmp5_;
	DinoModuleManager* _tmp6_;
	XmppModuleIdentity* _tmp7_;
	gpointer _tmp8_;
	XmppXepCallInvitesModule* call_invites_module = NULL;
	DinoStreamInteractor* _tmp9_;
	DinoModuleManager* _tmp10_;
	XmppModuleIdentity* _tmp11_;
	gpointer _tmp12_;
	DinoStreamInteractor* _tmp13_;
	DinoModuleManager* _tmp14_;
	XmppModuleIdentity* _tmp15_;
	gpointer _tmp16_;
	XmppXepCoinModule* _tmp17_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_data8_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (_data8_->account);
	_data8_->account = _tmp0_;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = _tmp1_->module_manager;
	_tmp3_ = xmpp_xep_jingle_module_IDENTITY;
	_tmp4_ = dino_module_manager_get_module (_tmp2_, XMPP_XEP_JINGLE_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data8_->account, _tmp3_);
	jingle_module = (XmppXepJingleModule*) _tmp4_;
	g_signal_connect_data (jingle_module, "session-initiate-received", (GCallback) ___lambda71__xmpp_xep_jingle_module_session_initiate_received, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	_tmp5_ = self->priv->stream_interactor;
	_tmp6_ = _tmp5_->module_manager;
	_tmp7_ = xmpp_xep_jingle_message_initiation_module_IDENTITY;
	_tmp8_ = dino_module_manager_get_module (_tmp6_, XMPP_XEP_JINGLE_MESSAGE_INITIATION_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data8_->account, _tmp7_);
	mi_module = (XmppXepJingleMessageInitiationModule*) _tmp8_;
	g_signal_connect_data (mi_module, "session-proposed", (GCallback) ___lambda73__xmpp_xep_jingle_message_initiation_module_session_proposed, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	g_signal_connect_data (mi_module, "session-accepted", (GCallback) ___lambda76__xmpp_xep_jingle_message_initiation_module_session_accepted, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	g_signal_connect_data (mi_module, "session-rejected", (GCallback) ___lambda77__xmpp_xep_jingle_message_initiation_module_session_rejected, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	g_signal_connect_data (mi_module, "session-retracted", (GCallback) ___lambda78__xmpp_xep_jingle_message_initiation_module_session_retracted, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	_tmp9_ = self->priv->stream_interactor;
	_tmp10_ = _tmp9_->module_manager;
	_tmp11_ = xmpp_xep_call_invites_module_IDENTITY;
	_tmp12_ = dino_module_manager_get_module (_tmp10_, XMPP_XEP_CALL_INVITES_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data8_->account, _tmp11_);
	call_invites_module = (XmppXepCallInvitesModule*) _tmp12_;
	g_signal_connect_data (call_invites_module, "call-proposed", (GCallback) ___lambda79__xmpp_xep_call_invites_module_call_proposed, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	g_signal_connect_data (call_invites_module, "call-accepted", (GCallback) ___lambda80__xmpp_xep_call_invites_module_call_accepted, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	g_signal_connect_data (call_invites_module, "call-retracted", (GCallback) ___lambda81__xmpp_xep_call_invites_module_call_retracted, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	g_signal_connect_data (call_invites_module, "call-rejected", (GCallback) ___lambda82__xmpp_xep_call_invites_module_call_rejected, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	_tmp13_ = self->priv->stream_interactor;
	_tmp14_ = _tmp13_->module_manager;
	_tmp15_ = xmpp_xep_coin_module_IDENTITY;
	_tmp16_ = dino_module_manager_get_module (_tmp14_, XMPP_XEP_COIN_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data8_->account, _tmp15_);
	_tmp17_ = (XmppXepCoinModule*) _tmp16_;
	g_signal_connect_object (_tmp17_, "coin-info-received", (GCallback) ___lambda83__xmpp_xep_coin_module_coin_info_received, self, 0);
	_g_object_unref0 (_tmp17_);
	_g_object_unref0 (call_invites_module);
	_g_object_unref0 (mi_module);
	_g_object_unref0 (jingle_module);
	block8_data_unref (_data8_);
	_data8_ = NULL;
}

static const gchar*
dino_calls_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoCalls* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoCalls*) base;
	_tmp0_ = dino_calls_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

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

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

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

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

static void
dino_calls_class_init (DinoCallsClass * klass,
                       gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_calls_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoCalls_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_calls_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_calls_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_CALLS_ID_PROPERTY, dino_calls_properties[DINO_CALLS_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	dino_calls_signals[DINO_CALLS_CALL_INCOMING_SIGNAL] = g_signal_new ("call-incoming", DINO_TYPE_CALLS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT_BOOLEAN_BOOLEAN, G_TYPE_NONE, 5, DINO_ENTITIES_TYPE_CALL, DINO_TYPE_CALL_STATE, DINO_ENTITIES_TYPE_CONVERSATION, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
	dino_calls_signals[DINO_CALLS_CALL_OUTGOING_SIGNAL] = g_signal_new ("call-outgoing", DINO_TYPE_CALLS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT, G_TYPE_NONE, 3, DINO_ENTITIES_TYPE_CALL, DINO_TYPE_CALL_STATE, DINO_ENTITIES_TYPE_CONVERSATION);
	dino_calls_signals[DINO_CALLS_CALL_TERMINATED_SIGNAL] = g_signal_new ("call-terminated", DINO_TYPE_CALLS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_STRING_STRING, G_TYPE_NONE, 3, DINO_ENTITIES_TYPE_CALL, G_TYPE_STRING, G_TYPE_STRING);
	dino_calls_signals[DINO_CALLS_CONFERENCE_INFO_RECEIVED_SIGNAL] = g_signal_new ("conference-info-received", DINO_TYPE_CALLS, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_XEP_COIN_CONFERENCE_INFO, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_CALL, XMPP_XEP_COIN_TYPE_CONFERENCE_INFO);
	_tmp0_ = dino_module_identity_new (DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "calls");
	dino_calls_IDENTITY = _tmp0_;
}

static void
dino_calls_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                          gpointer iface_data)
{
	dino_calls_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_calls_real_get_id;
}

static void
dino_calls_instance_init (DinoCalls * self,
                          gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	self->priv = dino_calls_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (DINO_ENTITIES_TYPE_CALL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_TYPE_PEER_STATE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _dino_entities_call_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_call_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->jmi_request_peer = _tmp0_;
	_tmp1_ = gee_hash_map_new (DINO_ENTITIES_TYPE_CALL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_TYPE_CALL_STATE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _dino_entities_call_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_call_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->call_states = _tmp1_;
}

static void
dino_calls_finalize (GObject * obj)
{
	DinoCalls * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_CALLS, DinoCalls);
	_g_object_unref0 (self->priv->stream_interactor);
	_qlite_database_unref0 (self->priv->db);
	_g_object_unref0 (self->jmi_request_peer);
	_g_object_unref0 (self->call_states);
	G_OBJECT_CLASS (dino_calls_parent_class)->finalize (obj);
}

static GType
dino_calls_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoCallsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_calls_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoCalls), 0, (GInstanceInitFunc) dino_calls_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_calls_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_calls_type_id;
	dino_calls_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoCalls", &g_define_type_info, 0);
	g_type_add_interface_static (dino_calls_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	DinoCalls_private_offset = g_type_add_instance_private (dino_calls_type_id, sizeof (DinoCallsPrivate));
	return dino_calls_type_id;
}

GType
dino_calls_get_type (void)
{
	static volatile gsize dino_calls_type_id__once = 0;
	if (g_once_init_enter (&dino_calls_type_id__once)) {
		GType dino_calls_type_id;
		dino_calls_type_id = dino_calls_get_type_once ();
		g_once_init_leave (&dino_calls_type_id__once, dino_calls_type_id);
	}
	return dino_calls_type_id__once;
}

static void
_vala_dino_calls_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec)
{
	DinoCalls * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_CALLS, DinoCalls);
	switch (property_id) {
		case DINO_CALLS_ID_PROPERTY:
		g_value_set_string (value, dino_stream_interaction_module_get_id ((DinoStreamInteractionModule*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

