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

#include <glib-object.h>
#include "libdino.h"
#include <gtk/gtk.h>
#include "dino_i18n.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include "xmpp-vala.h"
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define DINO_UI_TYPE_CALL_TITLEBAR_ENTRY (dino_ui_call_titlebar_entry_get_type ())
#define DINO_UI_CALL_TITLEBAR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_CALL_TITLEBAR_ENTRY, DinoUiCallTitlebarEntry))
#define DINO_UI_CALL_TITLEBAR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_CALL_TITLEBAR_ENTRY, DinoUiCallTitlebarEntryClass))
#define DINO_UI_IS_CALL_TITLEBAR_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_CALL_TITLEBAR_ENTRY))
#define DINO_UI_IS_CALL_TITLEBAR_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_CALL_TITLEBAR_ENTRY))
#define DINO_UI_CALL_TITLEBAR_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_CALL_TITLEBAR_ENTRY, DinoUiCallTitlebarEntryClass))

typedef struct _DinoUiCallTitlebarEntry DinoUiCallTitlebarEntry;
typedef struct _DinoUiCallTitlebarEntryClass DinoUiCallTitlebarEntryClass;
typedef struct _DinoUiCallTitlebarEntryPrivate DinoUiCallTitlebarEntryPrivate;
enum  {
	DINO_UI_CALL_TITLEBAR_ENTRY_0_PROPERTY,
	DINO_UI_CALL_TITLEBAR_ENTRY_ID_PROPERTY,
	DINO_UI_CALL_TITLEBAR_ENTRY_ORDER_PROPERTY,
	DINO_UI_CALL_TITLEBAR_ENTRY_NUM_PROPERTIES
};
static GParamSpec* dino_ui_call_titlebar_entry_properties[DINO_UI_CALL_TITLEBAR_ENTRY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block55Data Block55Data;

#define DINO_UI_TYPE_CALL_WINDOW (dino_ui_call_window_get_type ())
#define DINO_UI_CALL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_CALL_WINDOW, DinoUiCallWindow))
#define DINO_UI_CALL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_CALL_WINDOW, DinoUiCallWindowClass))
#define DINO_UI_IS_CALL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_CALL_WINDOW))
#define DINO_UI_IS_CALL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_CALL_WINDOW))
#define DINO_UI_CALL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_CALL_WINDOW, DinoUiCallWindowClass))

typedef struct _DinoUiCallWindow DinoUiCallWindow;
typedef struct _DinoUiCallWindowClass DinoUiCallWindowClass;

#define DINO_UI_TYPE_CALL_WINDOW_CONTROLLER (dino_ui_call_window_controller_get_type ())
#define DINO_UI_CALL_WINDOW_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_CALL_WINDOW_CONTROLLER, DinoUiCallWindowController))
#define DINO_UI_CALL_WINDOW_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_CALL_WINDOW_CONTROLLER, DinoUiCallWindowControllerClass))
#define DINO_UI_IS_CALL_WINDOW_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_CALL_WINDOW_CONTROLLER))
#define DINO_UI_IS_CALL_WINDOW_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_CALL_WINDOW_CONTROLLER))
#define DINO_UI_CALL_WINDOW_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_CALL_WINDOW_CONTROLLER, DinoUiCallWindowControllerClass))

typedef struct _DinoUiCallWindowController DinoUiCallWindowController;
typedef struct _DinoUiCallWindowControllerClass DinoUiCallWindowControllerClass;
typedef struct _DinoUiCallWindowPrivate DinoUiCallWindowPrivate;

#define DINO_UI_TYPE_CALL_BOTTOM_BAR (dino_ui_call_bottom_bar_get_type ())
#define DINO_UI_CALL_BOTTOM_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_CALL_BOTTOM_BAR, DinoUiCallBottomBar))
#define DINO_UI_CALL_BOTTOM_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_CALL_BOTTOM_BAR, DinoUiCallBottomBarClass))
#define DINO_UI_IS_CALL_BOTTOM_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_CALL_BOTTOM_BAR))
#define DINO_UI_IS_CALL_BOTTOM_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_CALL_BOTTOM_BAR))
#define DINO_UI_CALL_BOTTOM_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_CALL_BOTTOM_BAR, DinoUiCallBottomBarClass))

typedef struct _DinoUiCallBottomBar DinoUiCallBottomBar;
typedef struct _DinoUiCallBottomBarClass DinoUiCallBottomBarClass;
typedef struct _DinoUiCallTitlebarEntryUpdateVisibilityData DinoUiCallTitlebarEntryUpdateVisibilityData;

struct _DinoUiCallTitlebarEntry {
	GObject parent_instance;
	DinoUiCallTitlebarEntryPrivate * priv;
};

struct _DinoUiCallTitlebarEntryClass {
	GObjectClass parent_class;
};

struct _DinoUiCallTitlebarEntryPrivate {
	GtkMenuButton* button;
	DinoStreamInteractor* stream_interactor;
	DinoEntitiesConversation* conversation;
};

struct _Block55Data {
	int _ref_count_;
	DinoUiCallTitlebarEntry* self;
	DinoStreamInteractor* stream_interactor;
};

struct _DinoUiCallWindow {
	GtkWindow parent_instance;
	DinoUiCallWindowPrivate * priv;
	DinoUiCallWindowController* controller;
	GtkOverlay* overlay;
	GtkGrid* grid;
	DinoUiCallBottomBar* bottom_bar;
	GtkRevealer* bottom_bar_revealer;
	GtkHeaderBar* header_bar;
	GtkRevealer* header_bar_revealer;
	GtkBox* own_video_box;
};

struct _DinoUiCallWindowClass {
	GtkWindowClass parent_class;
};

struct _DinoUiCallTitlebarEntryUpdateVisibilityData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoUiCallTitlebarEntry* self;
	DinoEntitiesConversation* _tmp0_;
	GtkMenuButton* _tmp1_;
	DinoEntitiesConversation* conv_bak;
	DinoEntitiesConversation* _tmp2_;
	DinoEntitiesConversation* _tmp3_;
	gboolean can_do_calls;
	DinoStreamInteractor* _tmp4_;
	DinoModuleIdentity* _tmp5_;
	gpointer _tmp6_;
	DinoCalls* _tmp7_;
	DinoEntitiesConversation* _tmp8_;
	gboolean _tmp9_;
	DinoEntitiesConversation* _tmp10_;
	DinoEntitiesConversation* _tmp11_;
	GtkMenuButton* _tmp12_;
};

static gint DinoUiCallTitlebarEntry_private_offset;
static gpointer dino_ui_call_titlebar_entry_parent_class = NULL;
static DinoPluginsConversationTitlebarEntryIface * dino_ui_call_titlebar_entry_dino_plugins_conversation_titlebar_entry_parent_iface = NULL;

VALA_EXTERN GType dino_ui_call_titlebar_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiCallTitlebarEntry, g_object_unref)
VALA_EXTERN DinoUiCallTitlebarEntry* dino_ui_call_titlebar_entry_new (DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiCallTitlebarEntry* dino_ui_call_titlebar_entry_construct (GType object_type,
                                                                DinoStreamInteractor* stream_interactor);
static Block55Data* block55_data_ref (Block55Data* _data55_);
static void block55_data_unref (void * _userdata_);
static void __lambda219_ (Block55Data* _data55_,
                   GVariant* parameter);
static void __lambda220_ (Block55Data* _data55_,
                   GObject* _,
                   GAsyncResult* res);
static void dino_ui_call_titlebar_entry_open_call_window (DinoUiCallTitlebarEntry* self,
                                                   DinoCallState* call_state);
static void ___lambda220__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void ___lambda219__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda221_ (Block55Data* _data55_,
                   GVariant* parameter);
static void __lambda222_ (Block55Data* _data55_,
                   GObject* _,
                   GAsyncResult* res);
static void ___lambda222__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void ___lambda221__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda223_ (DinoUiCallTitlebarEntry* self,
                   DinoEntitiesCall* call,
                   DinoCallState* state,
                   DinoEntitiesConversation* conversation);
static void dino_ui_call_titlebar_entry_update_button_state (DinoUiCallTitlebarEntry* self);
static void ___lambda223__dino_calls_call_incoming (DinoCalls* _sender,
                                             DinoEntitiesCall* call,
                                             DinoCallState* state,
                                             DinoEntitiesConversation* conversation,
                                             gboolean video,
                                             gboolean multiparty,
                                             gpointer self);
static void __lambda224_ (DinoUiCallTitlebarEntry* self,
                   DinoEntitiesCall* call);
static void ___lambda224__dino_calls_call_terminated (DinoCalls* _sender,
                                               DinoEntitiesCall* call,
                                               const gchar* reason_name,
                                               const gchar* reason_text,
                                               gpointer self);
static void __lambda225_ (DinoUiCallTitlebarEntry* self,
                   XmppJid* jid,
                   DinoEntitiesAccount* account);
static void dino_ui_call_titlebar_entry_update_visibility (DinoUiCallTitlebarEntry* self,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
static void dino_ui_call_titlebar_entry_update_visibility_finish (DinoUiCallTitlebarEntry* self,
                                                           GAsyncResult* _res_);
static void ___lambda225__dino_presence_manager_show_received (DinoPresenceManager* _sender,
                                                        XmppJid* jid,
                                                        DinoEntitiesAccount* account,
                                                        gpointer self);
static void __lambda226_ (DinoUiCallTitlebarEntry* self,
                   DinoEntitiesAccount* account,
                   DinoConnectionManagerConnectionState state);
static void ___lambda226__dino_connection_manager_connection_state_changed (DinoConnectionManager* _sender,
                                                                     DinoEntitiesAccount* account,
                                                                     DinoConnectionManagerConnectionState state,
                                                                     gpointer self);
VALA_EXTERN GType dino_ui_call_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiCallWindow, g_object_unref)
VALA_EXTERN DinoUiCallWindow* dino_ui_call_window_new (void);
VALA_EXTERN DinoUiCallWindow* dino_ui_call_window_construct (GType object_type);
VALA_EXTERN GType dino_ui_call_window_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiCallWindowController, g_object_unref)
VALA_EXTERN DinoUiCallWindowController* dino_ui_call_window_controller_new (DinoUiCallWindow* call_window,
                                                                DinoCallState* call_state,
                                                                DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiCallWindowController* dino_ui_call_window_controller_construct (GType object_type,
                                                                      DinoUiCallWindow* call_window,
                                                                      DinoCallState* call_state,
                                                                      DinoStreamInteractor* stream_interactor);
VALA_EXTERN GType dino_ui_call_bottom_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiCallBottomBar, g_object_unref)
static void dino_ui_call_titlebar_entry_real_set_conversation (DinoPluginsConversationTitlebarEntry* base,
                                                        DinoEntitiesConversation* conversation);
static void dino_ui_call_titlebar_entry_update_visibility_data_free (gpointer _data);
static gboolean dino_ui_call_titlebar_entry_update_visibility_co (DinoUiCallTitlebarEntryUpdateVisibilityData* _data_);
static void dino_ui_call_titlebar_entry_update_visibility_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_);
static void dino_ui_call_titlebar_entry_real_unset_conversation (DinoPluginsConversationTitlebarEntry* base);
static GObject* dino_ui_call_titlebar_entry_real_get_widget (DinoPluginsConversationTitlebarEntry* base,
                                                      DinoPluginsWidgetType type);
static void dino_ui_call_titlebar_entry_finalize (GObject * obj);
static GType dino_ui_call_titlebar_entry_get_type_once (void);
static void _vala_dino_ui_call_titlebar_entry_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_ui_call_titlebar_entry_get_instance_private (DinoUiCallTitlebarEntry* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiCallTitlebarEntry_private_offset);
}

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

static Block55Data*
block55_data_ref (Block55Data* _data55_)
{
	g_atomic_int_inc (&_data55_->_ref_count_);
	return _data55_;
}

static void
block55_data_unref (void * _userdata_)
{
	Block55Data* _data55_;
	_data55_ = (Block55Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data55_->_ref_count_)) {
		DinoUiCallTitlebarEntry* self;
		self = _data55_->self;
		_g_object_unref0 (_data55_->stream_interactor);
		_g_object_unref0 (self);
		g_slice_free (Block55Data, _data55_);
	}
}

static void
__lambda220_ (Block55Data* _data55_,
              GObject* _,
              GAsyncResult* res)
{
	DinoUiCallTitlebarEntry* self;
	DinoCallState* call_state = NULL;
	DinoModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	DinoCalls* _tmp2_;
	DinoCallState* _tmp3_;
	DinoCallState* _tmp4_;
	self = _data55_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = dino_calls_IDENTITY;
	_tmp1_ = dino_stream_interactor_get_module (_data55_->stream_interactor, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (DinoCalls*) _tmp1_;
	_tmp3_ = dino_calls_initiate_call_finish (_tmp2_, res);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp2_);
	call_state = _tmp4_;
	dino_ui_call_titlebar_entry_open_call_window (self, call_state);
	_g_object_unref0 (call_state);
}

static void
___lambda220__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda220_ (self, source_object, res);
	block55_data_unref (self);
}

static void
__lambda219_ (Block55Data* _data55_,
              GVariant* parameter)
{
	DinoUiCallTitlebarEntry* self;
	DinoModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	DinoCalls* _tmp2_;
	DinoEntitiesConversation* _tmp3_;
	self = _data55_->self;
	_tmp0_ = dino_calls_IDENTITY;
	_tmp1_ = dino_stream_interactor_get_module (_data55_->stream_interactor, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (DinoCalls*) _tmp1_;
	_tmp3_ = self->priv->conversation;
	dino_calls_initiate_call (_tmp2_, _tmp3_, FALSE, ___lambda220__gasync_ready_callback, block55_data_ref (_data55_));
	_g_object_unref0 (_tmp2_);
}

static void
___lambda219__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda219_ (self, parameter);
}

static void
__lambda222_ (Block55Data* _data55_,
              GObject* _,
              GAsyncResult* res)
{
	DinoUiCallTitlebarEntry* self;
	DinoCallState* call_state = NULL;
	DinoModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	DinoCalls* _tmp2_;
	DinoCallState* _tmp3_;
	DinoCallState* _tmp4_;
	self = _data55_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = dino_calls_IDENTITY;
	_tmp1_ = dino_stream_interactor_get_module (_data55_->stream_interactor, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (DinoCalls*) _tmp1_;
	_tmp3_ = dino_calls_initiate_call_finish (_tmp2_, res);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp2_);
	call_state = _tmp4_;
	dino_ui_call_titlebar_entry_open_call_window (self, call_state);
	_g_object_unref0 (call_state);
}

static void
___lambda222__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda222_ (self, source_object, res);
	block55_data_unref (self);
}

static void
__lambda221_ (Block55Data* _data55_,
              GVariant* parameter)
{
	DinoUiCallTitlebarEntry* self;
	DinoModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	DinoCalls* _tmp2_;
	DinoEntitiesConversation* _tmp3_;
	self = _data55_->self;
	_tmp0_ = dino_calls_IDENTITY;
	_tmp1_ = dino_stream_interactor_get_module (_data55_->stream_interactor, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (DinoCalls*) _tmp1_;
	_tmp3_ = self->priv->conversation;
	dino_calls_initiate_call (_tmp2_, _tmp3_, TRUE, ___lambda222__gasync_ready_callback, block55_data_ref (_data55_));
	_g_object_unref0 (_tmp2_);
}

static void
___lambda221__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda221_ (self, parameter);
}

static void
__lambda223_ (DinoUiCallTitlebarEntry* self,
              DinoEntitiesCall* call,
              DinoCallState* state,
              DinoEntitiesConversation* conversation)
{
	g_return_if_fail (call != NULL);
	g_return_if_fail (state != NULL);
	g_return_if_fail (conversation != NULL);
	dino_ui_call_titlebar_entry_update_button_state (self);
}

static void
___lambda223__dino_calls_call_incoming (DinoCalls* _sender,
                                        DinoEntitiesCall* call,
                                        DinoCallState* state,
                                        DinoEntitiesConversation* conversation,
                                        gboolean video,
                                        gboolean multiparty,
                                        gpointer self)
{
	__lambda223_ ((DinoUiCallTitlebarEntry*) self, call, state, conversation);
}

static void
__lambda224_ (DinoUiCallTitlebarEntry* self,
              DinoEntitiesCall* call)
{
	g_return_if_fail (call != NULL);
	dino_ui_call_titlebar_entry_update_button_state (self);
}

static void
___lambda224__dino_calls_call_terminated (DinoCalls* _sender,
                                          DinoEntitiesCall* call,
                                          const gchar* reason_name,
                                          const gchar* reason_text,
                                          gpointer self)
{
	__lambda224_ ((DinoUiCallTitlebarEntry*) self, call);
}

static void
__lambda225_ (DinoUiCallTitlebarEntry* self,
              XmppJid* jid,
              DinoEntitiesAccount* account)
{
	DinoEntitiesConversation* _tmp0_;
	gboolean _tmp1_ = FALSE;
	DinoEntitiesConversation* _tmp2_;
	XmppJid* _tmp3_;
	XmppJid* _tmp4_;
	g_return_if_fail (jid != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = self->priv->conversation;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp2_ = self->priv->conversation;
	_tmp3_ = dino_entities_conversation_get_counterpart (_tmp2_);
	_tmp4_ = _tmp3_;
	if (xmpp_jid_equals_bare (_tmp4_, jid)) {
		DinoEntitiesConversation* _tmp5_;
		DinoEntitiesAccount* _tmp6_;
		DinoEntitiesAccount* _tmp7_;
		_tmp5_ = self->priv->conversation;
		_tmp6_ = dino_entities_conversation_get_account (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp1_ = dino_entities_account_equals (_tmp7_, account);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		dino_ui_call_titlebar_entry_update_visibility (self, NULL, NULL);
	}
}

static void
___lambda225__dino_presence_manager_show_received (DinoPresenceManager* _sender,
                                                   XmppJid* jid,
                                                   DinoEntitiesAccount* account,
                                                   gpointer self)
{
	__lambda225_ ((DinoUiCallTitlebarEntry*) self, jid, account);
}

static void
__lambda226_ (DinoUiCallTitlebarEntry* self,
              DinoEntitiesAccount* account,
              DinoConnectionManagerConnectionState state)
{
	g_return_if_fail (account != NULL);
	dino_ui_call_titlebar_entry_update_visibility (self, NULL, NULL);
}

static void
___lambda226__dino_connection_manager_connection_state_changed (DinoConnectionManager* _sender,
                                                                DinoEntitiesAccount* account,
                                                                DinoConnectionManagerConnectionState state,
                                                                gpointer self)
{
	__lambda226_ ((DinoUiCallTitlebarEntry*) self, account, state);
}

DinoUiCallTitlebarEntry*
dino_ui_call_titlebar_entry_construct (GType object_type,
                                       DinoStreamInteractor* stream_interactor)
{
	DinoUiCallTitlebarEntry * self = NULL;
	Block55Data* _data55_;
	DinoStreamInteractor* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	GtkMenuButton* _tmp2_;
	GMenu* menu_model = NULL;
	GMenu* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	GtkPopoverMenu* popover_menu = NULL;
	GtkPopoverMenu* _tmp6_;
	GtkMenuButton* _tmp7_;
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp8_;
	GSimpleAction* audio_call_action = NULL;
	GSimpleAction* _tmp9_;
	GSimpleAction* video_call_action = NULL;
	GSimpleAction* _tmp10_;
	GtkMenuButton* _tmp11_;
	DinoModuleIdentity* _tmp12_;
	gpointer _tmp13_;
	DinoCalls* _tmp14_;
	DinoModuleIdentity* _tmp15_;
	gpointer _tmp16_;
	DinoCalls* _tmp17_;
	DinoModuleIdentity* _tmp18_;
	gpointer _tmp19_;
	DinoPresenceManager* _tmp20_;
	DinoConnectionManager* _tmp21_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	_data55_ = g_slice_new0 (Block55Data);
	_data55_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (_data55_->stream_interactor);
	_data55_->stream_interactor = _tmp0_;
	self = (DinoUiCallTitlebarEntry*) g_object_new (object_type, NULL);
	_data55_->self = g_object_ref (self);
	_tmp1_ = _g_object_ref0 (_data55_->stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp1_;
	_tmp2_ = self->priv->button;
	gtk_menu_button_set_icon_name (_tmp2_, "dino-phone-symbolic");
	_tmp3_ = g_menu_new ();
	menu_model = _tmp3_;
	_tmp4_ = dino_gettext ("Audio call");
	g_menu_append (menu_model, _tmp4_, "call.audio");
	_tmp5_ = dino_gettext ("Video call");
	g_menu_append (menu_model, _tmp5_, "call.video");
	_tmp6_ = (GtkPopoverMenu*) gtk_popover_menu_new_from_model ((GMenuModel*) menu_model);
	g_object_ref_sink (_tmp6_);
	popover_menu = _tmp6_;
	_tmp7_ = self->priv->button;
	gtk_menu_button_set_popover (_tmp7_, (GtkPopover*) popover_menu);
	_tmp8_ = g_simple_action_group_new ();
	action_group = _tmp8_;
	_tmp9_ = g_simple_action_new ("audio", NULL);
	audio_call_action = _tmp9_;
	g_signal_connect_data (audio_call_action, "activate", (GCallback) ___lambda219__g_simple_action_activate, block55_data_ref (_data55_), (GClosureNotify) block55_data_unref, 0);
	g_simple_action_group_insert (action_group, (GAction*) audio_call_action);
	_tmp10_ = g_simple_action_new ("video", NULL);
	video_call_action = _tmp10_;
	g_signal_connect_data (video_call_action, "activate", (GCallback) ___lambda221__g_simple_action_activate, block55_data_ref (_data55_), (GClosureNotify) block55_data_unref, 0);
	g_simple_action_group_insert (action_group, (GAction*) video_call_action);
	_tmp11_ = self->priv->button;
	gtk_widget_insert_action_group ((GtkWidget*) _tmp11_, "call", (GActionGroup*) action_group);
	_tmp12_ = dino_calls_IDENTITY;
	_tmp13_ = dino_stream_interactor_get_module (_data55_->stream_interactor, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp12_);
	_tmp14_ = (DinoCalls*) _tmp13_;
	g_signal_connect_object (_tmp14_, "call-incoming", (GCallback) ___lambda223__dino_calls_call_incoming, self, 0);
	_g_object_unref0 (_tmp14_);
	_tmp15_ = dino_calls_IDENTITY;
	_tmp16_ = dino_stream_interactor_get_module (_data55_->stream_interactor, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp15_);
	_tmp17_ = (DinoCalls*) _tmp16_;
	g_signal_connect_object (_tmp17_, "call-terminated", (GCallback) ___lambda224__dino_calls_call_terminated, self, 0);
	_g_object_unref0 (_tmp17_);
	_tmp18_ = dino_presence_manager_IDENTITY;
	_tmp19_ = dino_stream_interactor_get_module (_data55_->stream_interactor, DINO_TYPE_PRESENCE_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp18_);
	_tmp20_ = (DinoPresenceManager*) _tmp19_;
	g_signal_connect_object (_tmp20_, "show-received", (GCallback) ___lambda225__dino_presence_manager_show_received, self, 0);
	_g_object_unref0 (_tmp20_);
	_tmp21_ = _data55_->stream_interactor->connection_manager;
	g_signal_connect_object (_tmp21_, "connection-state-changed", (GCallback) ___lambda226__dino_connection_manager_connection_state_changed, self, 0);
	_g_object_unref0 (video_call_action);
	_g_object_unref0 (audio_call_action);
	_g_object_unref0 (action_group);
	_g_object_unref0 (popover_menu);
	_g_object_unref0 (menu_model);
	block55_data_unref (_data55_);
	_data55_ = NULL;
	return self;
}

DinoUiCallTitlebarEntry*
dino_ui_call_titlebar_entry_new (DinoStreamInteractor* stream_interactor)
{
	return dino_ui_call_titlebar_entry_construct (DINO_UI_TYPE_CALL_TITLEBAR_ENTRY, stream_interactor);
}

static void
dino_ui_call_titlebar_entry_open_call_window (DinoUiCallTitlebarEntry* self,
                                              DinoCallState* call_state)
{
	DinoUiCallWindow* call_window = NULL;
	DinoUiCallWindow* _tmp0_;
	DinoUiCallWindowController* call_controller = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoUiCallWindowController* _tmp2_;
	DinoUiCallWindowController* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (call_state != NULL);
	_tmp0_ = dino_ui_call_window_new ();
	g_object_ref_sink (_tmp0_);
	call_window = _tmp0_;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_ui_call_window_controller_new (call_window, call_state, _tmp1_);
	call_controller = _tmp2_;
	_tmp3_ = _g_object_ref0 (call_controller);
	_g_object_unref0 (call_window->controller);
	call_window->controller = _tmp3_;
	gtk_window_present ((GtkWindow*) call_window);
	dino_ui_call_titlebar_entry_update_button_state (self);
	_g_object_unref0 (call_controller);
	_g_object_unref0 (call_window);
}

static void
dino_ui_call_titlebar_entry_real_set_conversation (DinoPluginsConversationTitlebarEntry* base,
                                                   DinoEntitiesConversation* conversation)
{
	DinoUiCallTitlebarEntry * self;
	DinoEntitiesConversation* _tmp0_;
	self = (DinoUiCallTitlebarEntry*) base;
	g_return_if_fail (conversation != NULL);
	_tmp0_ = _g_object_ref0 (conversation);
	_g_object_unref0 (self->priv->conversation);
	self->priv->conversation = _tmp0_;
	dino_ui_call_titlebar_entry_update_visibility (self, NULL, NULL);
	dino_ui_call_titlebar_entry_update_button_state (self);
}

static void
dino_ui_call_titlebar_entry_update_button_state (DinoUiCallTitlebarEntry* self)
{
	GtkMenuButton* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	DinoModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	DinoCalls* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->button;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_calls_IDENTITY;
	_tmp3_ = dino_stream_interactor_get_module (_tmp1_, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (DinoCalls*) _tmp3_;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, !dino_calls_is_call_in_progress (_tmp4_));
	_g_object_unref0 (_tmp4_);
}

static void
dino_ui_call_titlebar_entry_update_visibility_data_free (gpointer _data)
{
	DinoUiCallTitlebarEntryUpdateVisibilityData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoUiCallTitlebarEntryUpdateVisibilityData, _data_);
}

static void
dino_ui_call_titlebar_entry_update_visibility (DinoUiCallTitlebarEntry* self,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	DinoUiCallTitlebarEntryUpdateVisibilityData* _data_;
	DinoUiCallTitlebarEntry* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DinoUiCallTitlebarEntryUpdateVisibilityData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_ui_call_titlebar_entry_update_visibility_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dino_ui_call_titlebar_entry_update_visibility_co (_data_);
}

static void
dino_ui_call_titlebar_entry_update_visibility_finish (DinoUiCallTitlebarEntry* self,
                                                      GAsyncResult* _res_)
{
	DinoUiCallTitlebarEntryUpdateVisibilityData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dino_ui_call_titlebar_entry_update_visibility_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_)
{
	DinoUiCallTitlebarEntryUpdateVisibilityData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_ui_call_titlebar_entry_update_visibility_co (_data_);
}

static gboolean
dino_ui_call_titlebar_entry_update_visibility_co (DinoUiCallTitlebarEntryUpdateVisibilityData* _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->conversation;
	if (_data_->_tmp0_ == NULL) {
		_data_->_tmp1_ = _data_->self->priv->button;
		gtk_widget_set_visible ((GtkWidget*) _data_->_tmp1_, 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_ = _data_->self->priv->conversation;
	_data_->_tmp3_ = _g_object_ref0 (_data_->_tmp2_);
	_data_->conv_bak = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->self->priv->stream_interactor;
	_data_->_tmp5_ = dino_calls_IDENTITY;
	_data_->_tmp6_ = dino_stream_interactor_get_module (_data_->_tmp4_, DINO_TYPE_CALLS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp5_);
	_data_->_tmp7_ = (DinoCalls*) _data_->_tmp6_;
	_data_->_tmp8_ = _data_->self->priv->conversation;
	_data_->_state_ = 1;
	dino_calls_can_conversation_do_calls (_data_->_tmp7_, _data_->_tmp8_, dino_ui_call_titlebar_entry_update_visibility_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp9_ = dino_calls_can_conversation_do_calls_finish (_data_->_tmp7_, _data_->_res_);
	_g_object_unref0 (_data_->_tmp7_);
	_data_->can_do_calls = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->conv_bak;
	_data_->_tmp11_ = _data_->self->priv->conversation;
	if (_data_->_tmp10_ != _data_->_tmp11_) {
		_g_object_unref0 (_data_->conv_bak);
		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_->_tmp12_ = _data_->self->priv->button;
	gtk_widget_set_visible ((GtkWidget*) _data_->_tmp12_, _data_->can_do_calls);
	_g_object_unref0 (_data_->conv_bak);
	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_ui_call_titlebar_entry_real_unset_conversation (DinoPluginsConversationTitlebarEntry* base)
{
	DinoUiCallTitlebarEntry * self;
	self = (DinoUiCallTitlebarEntry*) base;
}

static GObject*
dino_ui_call_titlebar_entry_real_get_widget (DinoPluginsConversationTitlebarEntry* base,
                                             DinoPluginsWidgetType type)
{
	DinoUiCallTitlebarEntry * self;
	GtkMenuButton* _tmp0_;
	GObject* _tmp1_;
	GObject* result;
	self = (DinoUiCallTitlebarEntry*) base;
	if (type != DINO_PLUGINS_WIDGET_TYPE_GTK4) {
		result = NULL;
		return result;
	}
	_tmp0_ = self->priv->button;
	_tmp1_ = _g_object_ref0 ((GObject*) _tmp0_);
	result = _tmp1_;
	return result;
}

static const gchar*
dino_ui_call_titlebar_entry_real_get_id (DinoPluginsConversationTitlebarEntry* base)
{
	const gchar* result;
	DinoUiCallTitlebarEntry* self;
	self = (DinoUiCallTitlebarEntry*) base;
	result = "call";
	return result;
}

static gdouble
dino_ui_call_titlebar_entry_real_get_order (DinoPluginsConversationTitlebarEntry* base)
{
	gdouble result;
	DinoUiCallTitlebarEntry* self;
	self = (DinoUiCallTitlebarEntry*) base;
	result = (gdouble) 4;
	return result;
}

static void
dino_ui_call_titlebar_entry_class_init (DinoUiCallTitlebarEntryClass * klass,
                                        gpointer klass_data)
{
	dino_ui_call_titlebar_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiCallTitlebarEntry_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_ui_call_titlebar_entry_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_ui_call_titlebar_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_CALL_TITLEBAR_ENTRY_ID_PROPERTY, dino_ui_call_titlebar_entry_properties[DINO_UI_CALL_TITLEBAR_ENTRY_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_CALL_TITLEBAR_ENTRY_ORDER_PROPERTY, dino_ui_call_titlebar_entry_properties[DINO_UI_CALL_TITLEBAR_ENTRY_ORDER_PROPERTY] = g_param_spec_double ("order", "order", "order", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dino_ui_call_titlebar_entry_dino_plugins_conversation_titlebar_entry_interface_init (DinoPluginsConversationTitlebarEntryIface * iface,
                                                                                     gpointer iface_data)
{
	dino_ui_call_titlebar_entry_dino_plugins_conversation_titlebar_entry_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_conversation = (void (*) (DinoPluginsConversationTitlebarEntry*, DinoEntitiesConversation*)) dino_ui_call_titlebar_entry_real_set_conversation;
	iface->unset_conversation = (void (*) (DinoPluginsConversationTitlebarEntry*)) dino_ui_call_titlebar_entry_real_unset_conversation;
	iface->get_widget = (GObject* (*) (DinoPluginsConversationTitlebarEntry*, DinoPluginsWidgetType)) dino_ui_call_titlebar_entry_real_get_widget;
	iface->get_id = dino_ui_call_titlebar_entry_real_get_id;
	iface->get_order = dino_ui_call_titlebar_entry_real_get_order;
}

static void
dino_ui_call_titlebar_entry_instance_init (DinoUiCallTitlebarEntry * self,
                                           gpointer klass)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GtkMenuButton* _tmp2_ = NULL;
	self->priv = dino_ui_call_titlebar_entry_get_instance_private (self);
	_tmp0_ = dino_gettext ("Start call");
	_tmp1_ = g_strdup (_tmp0_);
	_tmp2_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, _tmp1_);
	_g_free0 (_tmp1_);
	g_object_ref_sink (_tmp2_);
	self->priv->button = _tmp2_;
}

static void
dino_ui_call_titlebar_entry_finalize (GObject * obj)
{
	DinoUiCallTitlebarEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_CALL_TITLEBAR_ENTRY, DinoUiCallTitlebarEntry);
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->conversation);
	G_OBJECT_CLASS (dino_ui_call_titlebar_entry_parent_class)->finalize (obj);
}

static GType
dino_ui_call_titlebar_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiCallTitlebarEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_call_titlebar_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiCallTitlebarEntry), 0, (GInstanceInitFunc) dino_ui_call_titlebar_entry_instance_init, NULL };
	static const GInterfaceInfo dino_plugins_conversation_titlebar_entry_info = { (GInterfaceInitFunc) dino_ui_call_titlebar_entry_dino_plugins_conversation_titlebar_entry_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_ui_call_titlebar_entry_type_id;
	dino_ui_call_titlebar_entry_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoUiCallTitlebarEntry", &g_define_type_info, 0);
	g_type_add_interface_static (dino_ui_call_titlebar_entry_type_id, DINO_PLUGINS_TYPE_CONVERSATION_TITLEBAR_ENTRY, &dino_plugins_conversation_titlebar_entry_info);
	DinoUiCallTitlebarEntry_private_offset = g_type_add_instance_private (dino_ui_call_titlebar_entry_type_id, sizeof (DinoUiCallTitlebarEntryPrivate));
	return dino_ui_call_titlebar_entry_type_id;
}

GType
dino_ui_call_titlebar_entry_get_type (void)
{
	static volatile gsize dino_ui_call_titlebar_entry_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_call_titlebar_entry_type_id__once)) {
		GType dino_ui_call_titlebar_entry_type_id;
		dino_ui_call_titlebar_entry_type_id = dino_ui_call_titlebar_entry_get_type_once ();
		g_once_init_leave (&dino_ui_call_titlebar_entry_type_id__once, dino_ui_call_titlebar_entry_type_id);
	}
	return dino_ui_call_titlebar_entry_type_id__once;
}

static void
_vala_dino_ui_call_titlebar_entry_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	DinoUiCallTitlebarEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_UI_TYPE_CALL_TITLEBAR_ENTRY, DinoUiCallTitlebarEntry);
	switch (property_id) {
		case DINO_UI_CALL_TITLEBAR_ENTRY_ID_PROPERTY:
		g_value_set_string (value, dino_plugins_conversation_titlebar_entry_get_id ((DinoPluginsConversationTitlebarEntry*) self));
		break;
		case DINO_UI_CALL_TITLEBAR_ENTRY_ORDER_PROPERTY:
		g_value_set_double (value, dino_plugins_conversation_titlebar_entry_get_order ((DinoPluginsConversationTitlebarEntry*) 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;
}

