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

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

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

#define _g_free0(var) (var = (g_free (var), NULL))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _xmpp_roster_item_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_roster_item_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

gchar*
dino_get_conversation_display_name (DinoStreamInteractor* stream_interactor,
                                    DinoEntitiesConversation* conversation,
                                    const gchar* muc_pm_format)
{
	DinoEntitiesConversationType _tmp0_;
	DinoEntitiesConversationType _tmp1_;
	DinoEntitiesConversationType _tmp11_;
	DinoEntitiesConversationType _tmp12_;
	DinoEntitiesConversationType _tmp18_;
	DinoEntitiesConversationType _tmp19_;
	XmppJid* _tmp36_;
	XmppJid* _tmp37_;
	gchar* _tmp38_;
	gchar* result;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (conversation != NULL, NULL);
	_tmp0_ = dino_entities_conversation_get_type_ (conversation);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == DINO_ENTITIES_CONVERSATION_TYPE_CHAT) {
		gchar* display_name = NULL;
		DinoEntitiesAccount* _tmp2_;
		DinoEntitiesAccount* _tmp3_;
		XmppJid* _tmp4_;
		XmppJid* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		XmppJid* _tmp8_;
		XmppJid* _tmp9_;
		gchar* _tmp10_;
		_tmp2_ = dino_entities_conversation_get_account (conversation);
		_tmp3_ = _tmp2_;
		_tmp4_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp5_ = _tmp4_;
		_tmp6_ = dino_get_real_display_name (stream_interactor, _tmp3_, _tmp5_, NULL);
		display_name = _tmp6_;
		_tmp7_ = display_name;
		if (_tmp7_ != NULL) {
			result = display_name;
			return result;
		}
		_tmp8_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp9_ = _tmp8_;
		_tmp10_ = xmpp_jid_to_string (_tmp9_);
		result = _tmp10_;
		_g_free0 (display_name);
		return result;
	}
	_tmp11_ = dino_entities_conversation_get_type_ (conversation);
	_tmp12_ = _tmp11_;
	if (_tmp12_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT) {
		DinoEntitiesAccount* _tmp13_;
		DinoEntitiesAccount* _tmp14_;
		XmppJid* _tmp15_;
		XmppJid* _tmp16_;
		gchar* _tmp17_;
		_tmp13_ = dino_entities_conversation_get_account (conversation);
		_tmp14_ = _tmp13_;
		_tmp15_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp16_ = _tmp15_;
		_tmp17_ = dino_get_groupchat_display_name (stream_interactor, _tmp14_, _tmp16_);
		result = _tmp17_;
		return result;
	}
	_tmp18_ = dino_entities_conversation_get_type_ (conversation);
	_tmp19_ = _tmp18_;
	if (_tmp19_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT_PM) {
		const gchar* _tmp20_ = NULL;
		XmppJid* _tmp21_;
		XmppJid* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		DinoEntitiesAccount* _tmp25_;
		DinoEntitiesAccount* _tmp26_;
		XmppJid* _tmp27_;
		XmppJid* _tmp28_;
		XmppJid* _tmp29_;
		XmppJid* _tmp30_;
		XmppJid* _tmp31_;
		gchar* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		gchar* _tmp35_;
		_tmp20_ = muc_pm_format;
		if (_tmp20_ == NULL) {
			_tmp20_ = "%s / %s";
		}
		_tmp21_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp22_ = _tmp21_;
		_tmp23_ = dino_get_occupant_display_name (stream_interactor, conversation, _tmp22_, NULL, FALSE);
		_tmp24_ = _tmp23_;
		_tmp25_ = dino_entities_conversation_get_account (conversation);
		_tmp26_ = _tmp25_;
		_tmp27_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp28_ = _tmp27_;
		_tmp29_ = xmpp_jid_get_bare_jid (_tmp28_);
		_tmp30_ = _tmp29_;
		_tmp31_ = _tmp30_;
		_tmp32_ = dino_get_groupchat_display_name (stream_interactor, _tmp26_, _tmp31_);
		_tmp33_ = _tmp32_;
		_tmp34_ = g_strdup_printf (_tmp20_, _tmp24_, _tmp33_);
		_tmp35_ = _tmp34_;
		_g_free0 (_tmp33_);
		_xmpp_jid_unref0 (_tmp31_);
		_g_free0 (_tmp24_);
		result = _tmp35_;
		return result;
	}
	_tmp36_ = dino_entities_conversation_get_counterpart (conversation);
	_tmp37_ = _tmp36_;
	_tmp38_ = xmpp_jid_to_string (_tmp37_);
	result = _tmp38_;
	return result;
}

gchar*
dino_get_participant_display_name (DinoStreamInteractor* stream_interactor,
                                   DinoEntitiesConversation* conversation,
                                   XmppJid* participant,
                                   const gchar* self_word)
{
	DinoEntitiesConversationType _tmp0_;
	DinoEntitiesConversationType _tmp1_;
	gboolean _tmp11_ = FALSE;
	DinoEntitiesConversationType _tmp12_;
	DinoEntitiesConversationType _tmp13_;
	XmppJid* _tmp17_;
	XmppJid* _tmp18_;
	XmppJid* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* result;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (participant != NULL, NULL);
	_tmp0_ = dino_entities_conversation_get_type_ (conversation);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == DINO_ENTITIES_CONVERSATION_TYPE_CHAT) {
		gchar* _tmp2_ = NULL;
		DinoEntitiesAccount* _tmp3_;
		DinoEntitiesAccount* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp10_;
		_tmp3_ = dino_entities_conversation_get_account (conversation);
		_tmp4_ = _tmp3_;
		_tmp5_ = dino_get_real_display_name (stream_interactor, _tmp4_, participant, self_word);
		_tmp2_ = _tmp5_;
		if (_tmp2_ == NULL) {
			XmppJid* _tmp6_;
			XmppJid* _tmp7_;
			XmppJid* _tmp8_;
			gchar* _tmp9_;
			_tmp6_ = xmpp_jid_get_bare_jid (participant);
			_tmp7_ = _tmp6_;
			_tmp8_ = _tmp7_;
			_tmp9_ = xmpp_jid_to_string (_tmp8_);
			_g_free0 (_tmp2_);
			_tmp2_ = _tmp9_;
			_xmpp_jid_unref0 (_tmp8_);
		}
		_tmp10_ = _tmp2_;
		_tmp2_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp2_);
		return result;
	}
	_tmp12_ = dino_entities_conversation_get_type_ (conversation);
	_tmp13_ = _tmp12_;
	if (_tmp13_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT) {
		_tmp11_ = TRUE;
	} else {
		DinoEntitiesConversationType _tmp14_;
		DinoEntitiesConversationType _tmp15_;
		_tmp14_ = dino_entities_conversation_get_type_ (conversation);
		_tmp15_ = _tmp14_;
		_tmp11_ = _tmp15_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT_PM;
	}
	if (_tmp11_) {
		gchar* _tmp16_;
		_tmp16_ = dino_get_occupant_display_name (stream_interactor, conversation, participant, NULL, FALSE);
		result = _tmp16_;
		return result;
	}
	_tmp17_ = xmpp_jid_get_bare_jid (participant);
	_tmp18_ = _tmp17_;
	_tmp19_ = _tmp18_;
	_tmp20_ = xmpp_jid_to_string (_tmp19_);
	_tmp21_ = _tmp20_;
	_xmpp_jid_unref0 (_tmp19_);
	result = _tmp21_;
	return result;
}

gchar*
dino_get_real_display_name (DinoStreamInteractor* stream_interactor,
                            DinoEntitiesAccount* account,
                            XmppJid* jid,
                            const gchar* self_word)
{
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gboolean _tmp3_;
	XmppRosterItem* roster_item = NULL;
	DinoModuleIdentity* _tmp23_;
	gpointer _tmp24_;
	DinoRosterManager* _tmp25_;
	XmppRosterItem* _tmp26_;
	XmppRosterItem* _tmp27_;
	gboolean _tmp28_ = FALSE;
	gboolean _tmp29_ = FALSE;
	XmppRosterItem* _tmp30_;
	gchar* result;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	g_return_val_if_fail (jid != NULL, NULL);
	_tmp0_ = dino_entities_account_get_bare_jid (account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_equals_bare (jid, _tmp2_);
	_xmpp_jid_unref0 (_tmp2_);
	if (_tmp3_) {
		gboolean _tmp4_ = FALSE;
		gboolean _tmp13_ = FALSE;
		const gchar* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp20_;
		const gchar* _tmp21_;
		gchar* _tmp22_;
		if (self_word != NULL) {
			gboolean _tmp5_ = FALSE;
			const gchar* _tmp6_;
			const gchar* _tmp7_;
			_tmp6_ = dino_entities_account_get_alias (account);
			_tmp7_ = _tmp6_;
			if (_tmp7_ == NULL) {
				_tmp5_ = TRUE;
			} else {
				const gchar* _tmp8_;
				const gchar* _tmp9_;
				gint _tmp10_;
				gint _tmp11_;
				_tmp8_ = dino_entities_account_get_alias (account);
				_tmp9_ = _tmp8_;
				_tmp10_ = strlen (_tmp9_);
				_tmp11_ = _tmp10_;
				_tmp5_ = _tmp11_ == 0;
			}
			_tmp4_ = _tmp5_;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			gchar* _tmp12_;
			_tmp12_ = g_strdup (self_word);
			result = _tmp12_;
			return result;
		}
		_tmp14_ = dino_entities_account_get_alias (account);
		_tmp15_ = _tmp14_;
		if (_tmp15_ != NULL) {
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			gint _tmp18_;
			gint _tmp19_;
			_tmp16_ = dino_entities_account_get_alias (account);
			_tmp17_ = _tmp16_;
			_tmp18_ = strlen (_tmp17_);
			_tmp19_ = _tmp18_;
			_tmp13_ = _tmp19_ == 0;
		} else {
			_tmp13_ = FALSE;
		}
		if (_tmp13_) {
			result = NULL;
			return result;
		}
		_tmp20_ = dino_entities_account_get_alias (account);
		_tmp21_ = _tmp20_;
		_tmp22_ = g_strdup (_tmp21_);
		result = _tmp22_;
		return result;
	}
	_tmp23_ = dino_roster_manager_IDENTITY;
	_tmp24_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_ROSTER_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp23_);
	_tmp25_ = (DinoRosterManager*) _tmp24_;
	_tmp26_ = dino_roster_manager_get_roster_item (_tmp25_, account, jid);
	_tmp27_ = _tmp26_;
	_g_object_unref0 (_tmp25_);
	roster_item = _tmp27_;
	_tmp30_ = roster_item;
	if (_tmp30_ != NULL) {
		XmppRosterItem* _tmp31_;
		const gchar* _tmp32_;
		const gchar* _tmp33_;
		_tmp31_ = roster_item;
		_tmp32_ = xmpp_roster_item_get_name (_tmp31_);
		_tmp33_ = _tmp32_;
		_tmp29_ = _tmp33_ != NULL;
	} else {
		_tmp29_ = FALSE;
	}
	if (_tmp29_) {
		XmppRosterItem* _tmp34_;
		const gchar* _tmp35_;
		const gchar* _tmp36_;
		_tmp34_ = roster_item;
		_tmp35_ = xmpp_roster_item_get_name (_tmp34_);
		_tmp36_ = _tmp35_;
		_tmp28_ = g_strcmp0 (_tmp36_, "") != 0;
	} else {
		_tmp28_ = FALSE;
	}
	if (_tmp28_) {
		XmppRosterItem* _tmp37_;
		const gchar* _tmp38_;
		const gchar* _tmp39_;
		gchar* _tmp40_;
		_tmp37_ = roster_item;
		_tmp38_ = xmpp_roster_item_get_name (_tmp37_);
		_tmp39_ = _tmp38_;
		_tmp40_ = g_strdup (_tmp39_);
		result = _tmp40_;
		_xmpp_roster_item_unref0 (roster_item);
		return result;
	}
	result = NULL;
	_xmpp_roster_item_unref0 (roster_item);
	return result;
}

gchar*
dino_get_groupchat_display_name (DinoStreamInteractor* stream_interactor,
                                 DinoEntitiesAccount* account,
                                 XmppJid* jid)
{
	DinoMucManager* muc_manager = NULL;
	DinoModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	gchar* room_name = NULL;
	DinoMucManager* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_ = FALSE;
	const gchar* _tmp5_;
	DinoMucManager* _tmp8_;
	gchar* _tmp44_;
	gchar* result;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	g_return_val_if_fail (jid != NULL, NULL);
	_tmp0_ = dino_muc_manager_IDENTITY;
	_tmp1_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	muc_manager = (DinoMucManager*) _tmp1_;
	_tmp2_ = muc_manager;
	_tmp3_ = dino_muc_manager_get_room_name (_tmp2_, account, jid);
	room_name = _tmp3_;
	_tmp5_ = room_name;
	if (_tmp5_ != NULL) {
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp6_ = room_name;
		_tmp7_ = jid->localpart;
		_tmp4_ = g_strcmp0 (_tmp6_, _tmp7_) != 0;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		result = room_name;
		_g_object_unref0 (muc_manager);
		return result;
	}
	_tmp8_ = muc_manager;
	if (dino_muc_manager_is_private_room (_tmp8_, account, jid)) {
		GeeList* other_occupants = NULL;
		DinoMucManager* _tmp9_;
		GeeList* _tmp10_;
		gboolean _tmp11_ = FALSE;
		GeeList* _tmp12_;
		_tmp9_ = muc_manager;
		_tmp10_ = dino_muc_manager_get_other_offline_members (_tmp9_, jid, account);
		other_occupants = _tmp10_;
		_tmp12_ = other_occupants;
		if (_tmp12_ != NULL) {
			GeeList* _tmp13_;
			gint _tmp14_;
			gint _tmp15_;
			_tmp13_ = other_occupants;
			_tmp14_ = gee_collection_get_size ((GeeCollection*) _tmp13_);
			_tmp15_ = _tmp14_;
			_tmp11_ = _tmp15_ > 0;
		} else {
			_tmp11_ = FALSE;
		}
		if (_tmp11_) {
			GString* builder = NULL;
			GString* _tmp16_;
			GString* _tmp41_;
			const gchar* _tmp42_;
			gchar* _tmp43_;
			_tmp16_ = g_string_new ("");
			builder = _tmp16_;
			{
				GeeList* _occupant_list = NULL;
				GeeList* _tmp17_;
				gint _occupant_size = 0;
				GeeList* _tmp18_;
				gint _tmp19_;
				gint _tmp20_;
				gint _occupant_index = 0;
				_tmp17_ = other_occupants;
				_occupant_list = _tmp17_;
				_tmp18_ = _occupant_list;
				_tmp19_ = gee_collection_get_size ((GeeCollection*) _tmp18_);
				_tmp20_ = _tmp19_;
				_occupant_size = _tmp20_;
				_occupant_index = -1;
				while (TRUE) {
					gint _tmp21_;
					gint _tmp22_;
					XmppJid* occupant = NULL;
					GeeList* _tmp23_;
					gpointer _tmp24_;
					GString* _tmp25_;
					gchar* _tmp27_ = NULL;
					XmppJid* _tmp28_;
					gchar* _tmp29_;
					GString* _tmp36_;
					gchar** _tmp37_;
					gchar** _tmp38_;
					gchar** _tmp39_;
					gint _tmp39__length1;
					const gchar* _tmp40_;
					_occupant_index = _occupant_index + 1;
					_tmp21_ = _occupant_index;
					_tmp22_ = _occupant_size;
					if (!(_tmp21_ < _tmp22_)) {
						break;
					}
					_tmp23_ = _occupant_list;
					_tmp24_ = gee_list_get (_tmp23_, _occupant_index);
					occupant = (XmppJid*) _tmp24_;
					_tmp25_ = builder;
					if (_tmp25_->len != ((gssize) 0)) {
						GString* _tmp26_;
						_tmp26_ = builder;
						g_string_append (_tmp26_, ", ");
					}
					_tmp28_ = occupant;
					_tmp29_ = dino_get_real_display_name (stream_interactor, account, _tmp28_, NULL);
					_tmp27_ = _tmp29_;
					if (_tmp27_ == NULL) {
						const gchar* _tmp30_ = NULL;
						XmppJid* _tmp31_;
						const gchar* _tmp32_;
						gchar* _tmp35_;
						_tmp31_ = occupant;
						_tmp32_ = _tmp31_->localpart;
						_tmp30_ = _tmp32_;
						if (_tmp30_ == NULL) {
							XmppJid* _tmp33_;
							const gchar* _tmp34_;
							_tmp33_ = occupant;
							_tmp34_ = _tmp33_->domainpart;
							_tmp30_ = _tmp34_;
						}
						_tmp35_ = g_strdup (_tmp30_);
						_g_free0 (_tmp27_);
						_tmp27_ = _tmp35_;
					}
					_tmp36_ = builder;
					_tmp38_ = _tmp37_ = g_strsplit (_tmp27_, " ", 0);
					_tmp39_ = _tmp38_;
					_tmp39__length1 = _vala_array_length (_tmp37_);
					_tmp40_ = _tmp39_[0];
					g_string_append (_tmp36_, _tmp40_);
					_tmp39_ = (_vala_array_free (_tmp39_, _tmp39__length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (_tmp27_);
					_xmpp_jid_unref0 (occupant);
				}
			}
			_tmp41_ = builder;
			_tmp42_ = _tmp41_->str;
			_tmp43_ = g_strdup (_tmp42_);
			result = _tmp43_;
			_g_string_free0 (builder);
			_g_object_unref0 (other_occupants);
			_g_free0 (room_name);
			_g_object_unref0 (muc_manager);
			return result;
		}
		_g_object_unref0 (other_occupants);
	}
	_tmp44_ = xmpp_jid_to_string (jid);
	result = _tmp44_;
	_g_free0 (room_name);
	_g_object_unref0 (muc_manager);
	return result;
}

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

gchar*
dino_get_occupant_display_name (DinoStreamInteractor* stream_interactor,
                                DinoEntitiesConversation* conversation,
                                XmppJid* jid,
                                const gchar* self_word,
                                gboolean muc_real_name)
{
	gboolean _tmp21_ = FALSE;
	DinoEntitiesConversationType _tmp22_;
	DinoEntitiesConversationType _tmp23_;
	XmppJid* _tmp51_;
	XmppJid* _tmp52_;
	gchar* _tmp72_ = NULL;
	const gchar* _tmp73_;
	gchar* _tmp74_;
	gchar* _tmp76_;
	gchar* result;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (jid != NULL, NULL);
	if (muc_real_name) {
		DinoMucManager* muc_manager = NULL;
		DinoModuleIdentity* _tmp0_;
		gpointer _tmp1_;
		DinoMucManager* _tmp2_;
		DinoEntitiesAccount* _tmp3_;
		DinoEntitiesAccount* _tmp4_;
		XmppJid* _tmp5_;
		XmppJid* _tmp6_;
		_tmp0_ = dino_muc_manager_IDENTITY;
		_tmp1_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
		muc_manager = (DinoMucManager*) _tmp1_;
		_tmp2_ = muc_manager;
		_tmp3_ = dino_entities_conversation_get_account (conversation);
		_tmp4_ = _tmp3_;
		_tmp5_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp6_ = _tmp5_;
		if (dino_muc_manager_is_private_room (_tmp2_, _tmp4_, _tmp6_)) {
			XmppJid* real_jid = NULL;
			XmppJid* _tmp7_;
			XmppJid* _tmp8_;
			XmppJid* _tmp15_;
			real_jid = NULL;
			_tmp7_ = dino_entities_conversation_get_counterpart (conversation);
			_tmp8_ = _tmp7_;
			if (xmpp_jid_equals_bare (jid, _tmp8_)) {
				DinoMucManager* _tmp9_;
				DinoEntitiesAccount* _tmp10_;
				DinoEntitiesAccount* _tmp11_;
				XmppJid* _tmp12_;
				XmppJid* _tmp13_;
				_tmp9_ = muc_manager;
				_tmp10_ = dino_entities_conversation_get_account (conversation);
				_tmp11_ = _tmp10_;
				_tmp12_ = dino_muc_manager_get_real_jid (_tmp9_, jid, _tmp11_);
				_tmp13_ = _tmp12_;
				_xmpp_jid_unref0 (_tmp13_);
			} else {
				XmppJid* _tmp14_;
				_tmp14_ = _xmpp_jid_ref0 (jid);
				_xmpp_jid_unref0 (real_jid);
				real_jid = _tmp14_;
			}
			_tmp15_ = real_jid;
			if (_tmp15_ != NULL) {
				gchar* display_name = NULL;
				DinoEntitiesAccount* _tmp16_;
				DinoEntitiesAccount* _tmp17_;
				XmppJid* _tmp18_;
				gchar* _tmp19_;
				const gchar* _tmp20_;
				_tmp16_ = dino_entities_conversation_get_account (conversation);
				_tmp17_ = _tmp16_;
				_tmp18_ = real_jid;
				_tmp19_ = dino_get_real_display_name (stream_interactor, _tmp17_, _tmp18_, self_word);
				display_name = _tmp19_;
				_tmp20_ = display_name;
				if (_tmp20_ != NULL) {
					result = display_name;
					_xmpp_jid_unref0 (real_jid);
					_g_object_unref0 (muc_manager);
					return result;
				}
				_g_free0 (display_name);
			}
			_xmpp_jid_unref0 (real_jid);
		}
		_g_object_unref0 (muc_manager);
	}
	_tmp22_ = dino_entities_conversation_get_type_ (conversation);
	_tmp23_ = _tmp22_;
	if (_tmp23_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT_PM) {
		DinoEntitiesAccount* _tmp24_;
		DinoEntitiesAccount* _tmp25_;
		XmppJid* _tmp26_;
		XmppJid* _tmp27_;
		XmppJid* _tmp28_;
		_tmp24_ = dino_entities_conversation_get_account (conversation);
		_tmp25_ = _tmp24_;
		_tmp26_ = dino_entities_account_get_bare_jid (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = _tmp27_;
		_tmp21_ = xmpp_jid_equals_bare (_tmp28_, jid);
		_xmpp_jid_unref0 (_tmp28_);
	} else {
		_tmp21_ = FALSE;
	}
	if (_tmp21_) {
		DinoEntitiesConversation* muc_conv = NULL;
		DinoModuleIdentity* _tmp29_;
		gpointer _tmp30_;
		DinoConversationManager* _tmp31_;
		XmppJid* _tmp32_;
		XmppJid* _tmp33_;
		XmppJid* _tmp34_;
		XmppJid* _tmp35_;
		XmppJid* _tmp36_;
		DinoEntitiesAccount* _tmp37_;
		DinoEntitiesAccount* _tmp38_;
		DinoEntitiesConversationType _tmp39_;
		DinoEntitiesConversation* _tmp40_;
		DinoEntitiesConversation* _tmp41_;
		gboolean _tmp42_ = FALSE;
		DinoEntitiesConversation* _tmp43_;
		_tmp29_ = dino_conversation_manager_IDENTITY;
		_tmp30_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp29_);
		_tmp31_ = (DinoConversationManager*) _tmp30_;
		_tmp32_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp33_ = _tmp32_;
		_tmp34_ = xmpp_jid_get_bare_jid (_tmp33_);
		_tmp35_ = _tmp34_;
		_tmp36_ = _tmp35_;
		_tmp37_ = dino_entities_conversation_get_account (conversation);
		_tmp38_ = _tmp37_;
		_tmp39_ = DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT;
		_tmp40_ = dino_conversation_manager_get_conversation (_tmp31_, _tmp36_, _tmp38_, &_tmp39_);
		_tmp41_ = _tmp40_;
		_xmpp_jid_unref0 (_tmp36_);
		_g_object_unref0 (_tmp31_);
		muc_conv = _tmp41_;
		_tmp43_ = muc_conv;
		if (_tmp43_ != NULL) {
			DinoEntitiesConversation* _tmp44_;
			const gchar* _tmp45_;
			const gchar* _tmp46_;
			_tmp44_ = muc_conv;
			_tmp45_ = dino_entities_conversation_get_nickname (_tmp44_);
			_tmp46_ = _tmp45_;
			_tmp42_ = _tmp46_ != NULL;
		} else {
			_tmp42_ = FALSE;
		}
		if (_tmp42_) {
			DinoEntitiesConversation* _tmp47_;
			const gchar* _tmp48_;
			const gchar* _tmp49_;
			gchar* _tmp50_;
			_tmp47_ = muc_conv;
			_tmp48_ = dino_entities_conversation_get_nickname (_tmp47_);
			_tmp49_ = _tmp48_;
			_tmp50_ = g_strdup (_tmp49_);
			result = _tmp50_;
			_g_object_unref0 (muc_conv);
			return result;
		}
		_g_object_unref0 (muc_conv);
	}
	_tmp51_ = dino_entities_conversation_get_counterpart (conversation);
	_tmp52_ = _tmp51_;
	if (!xmpp_jid_equals_bare (jid, _tmp52_)) {
		DinoMucManager* muc_manager = NULL;
		DinoModuleIdentity* _tmp53_;
		gpointer _tmp54_;
		XmppJid* occupant_jid = NULL;
		DinoMucManager* _tmp55_;
		DinoEntitiesAccount* _tmp56_;
		DinoEntitiesAccount* _tmp57_;
		XmppJid* _tmp58_;
		XmppJid* _tmp59_;
		XmppJid* _tmp60_;
		XmppJid* _tmp61_;
		XmppJid* _tmp62_;
		XmppJid* _tmp63_;
		XmppJid* _tmp64_;
		gboolean _tmp65_ = FALSE;
		XmppJid* _tmp66_;
		_tmp53_ = dino_muc_manager_IDENTITY;
		_tmp54_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp53_);
		muc_manager = (DinoMucManager*) _tmp54_;
		_tmp55_ = muc_manager;
		_tmp56_ = dino_entities_conversation_get_account (conversation);
		_tmp57_ = _tmp56_;
		_tmp58_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp59_ = _tmp58_;
		_tmp60_ = xmpp_jid_get_bare_jid (_tmp59_);
		_tmp61_ = _tmp60_;
		_tmp62_ = _tmp61_;
		_tmp63_ = dino_muc_manager_get_occupant_jid (_tmp55_, _tmp57_, _tmp62_, jid);
		_tmp64_ = _tmp63_;
		_xmpp_jid_unref0 (_tmp62_);
		occupant_jid = _tmp64_;
		_tmp66_ = occupant_jid;
		if (_tmp66_ != NULL) {
			XmppJid* _tmp67_;
			const gchar* _tmp68_;
			_tmp67_ = occupant_jid;
			_tmp68_ = _tmp67_->resourcepart;
			_tmp65_ = _tmp68_ != NULL;
		} else {
			_tmp65_ = FALSE;
		}
		if (_tmp65_) {
			XmppJid* _tmp69_;
			const gchar* _tmp70_;
			gchar* _tmp71_;
			_tmp69_ = occupant_jid;
			_tmp70_ = _tmp69_->resourcepart;
			_tmp71_ = g_strdup (_tmp70_);
			result = _tmp71_;
			_xmpp_jid_unref0 (occupant_jid);
			_g_object_unref0 (muc_manager);
			return result;
		}
		_xmpp_jid_unref0 (occupant_jid);
		_g_object_unref0 (muc_manager);
	}
	_tmp73_ = jid->resourcepart;
	_tmp74_ = g_strdup (_tmp73_);
	_tmp72_ = _tmp74_;
	if (_tmp72_ == NULL) {
		gchar* _tmp75_;
		_tmp75_ = xmpp_jid_to_string (jid);
		_g_free0 (_tmp72_);
		_tmp72_ = _tmp75_;
	}
	_tmp76_ = _tmp72_;
	_tmp72_ = NULL;
	result = _tmp76_;
	_g_free0 (_tmp72_);
	return result;
}

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

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

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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;
}

