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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <adwaita.h>
#include <gio/gio.h>
#include <json-glib/json-glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <glib/gstdio.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 DC_TYPE_CONVERSATION_VIEW (dc_conversation_view_get_type ())
#define DC_CONVERSATION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CONVERSATION_VIEW, DcConversationView))
#define DC_CONVERSATION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CONVERSATION_VIEW, DcConversationViewClass))
#define DC_IS_CONVERSATION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CONVERSATION_VIEW))
#define DC_IS_CONVERSATION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CONVERSATION_VIEW))
#define DC_CONVERSATION_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CONVERSATION_VIEW, DcConversationViewClass))

typedef struct _DcConversationView DcConversationView;
typedef struct _DcConversationViewClass DcConversationViewClass;
typedef struct _DcConversationViewPrivate DcConversationViewPrivate;

#define DC_TYPE_WINDOW (dc_window_get_type ())
#define DC_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_WINDOW, DcWindow))
#define DC_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_WINDOW, DcWindowClass))
#define DC_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_WINDOW))
#define DC_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_WINDOW))
#define DC_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_WINDOW, DcWindowClass))

typedef struct _DcWindow DcWindow;
typedef struct _DcWindowClass DcWindowClass;

#define DC_TYPE_RPC_CLIENT (dc_rpc_client_get_type ())
#define DC_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RPC_CLIENT, DcRpcClient))
#define DC_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RPC_CLIENT, DcRpcClientClass))
#define DC_IS_RPC_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RPC_CLIENT))
#define DC_IS_RPC_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RPC_CLIENT))
#define DC_RPC_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RPC_CLIENT, DcRpcClientClass))

typedef struct _DcRpcClient DcRpcClient;
typedef struct _DcRpcClientClass DcRpcClientClass;

#define DC_TYPE_SETTINGS_MANAGER (dc_settings_manager_get_type ())
#define DC_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SETTINGS_MANAGER, DcSettingsManager))
#define DC_SETTINGS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SETTINGS_MANAGER, DcSettingsManagerClass))
#define DC_IS_SETTINGS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SETTINGS_MANAGER))
#define DC_IS_SETTINGS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SETTINGS_MANAGER))
#define DC_SETTINGS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SETTINGS_MANAGER, DcSettingsManagerClass))

typedef struct _DcSettingsManager DcSettingsManager;
typedef struct _DcSettingsManagerClass DcSettingsManagerClass;

#define DC_TYPE_COMPOSE_BAR (dc_compose_bar_get_type ())
#define DC_COMPOSE_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_COMPOSE_BAR, DcComposeBar))
#define DC_COMPOSE_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_COMPOSE_BAR, DcComposeBarClass))
#define DC_IS_COMPOSE_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_COMPOSE_BAR))
#define DC_IS_COMPOSE_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_COMPOSE_BAR))
#define DC_COMPOSE_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_COMPOSE_BAR, DcComposeBarClass))

typedef struct _DcComposeBar DcComposeBar;
typedef struct _DcComposeBarClass DcComposeBarClass;

#define DC_TYPE_FILE_DROP_TARGET (dc_file_drop_target_get_type ())
#define DC_FILE_DROP_TARGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_FILE_DROP_TARGET, DcFileDropTarget))
#define DC_FILE_DROP_TARGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_FILE_DROP_TARGET, DcFileDropTargetClass))
#define DC_IS_FILE_DROP_TARGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_FILE_DROP_TARGET))
#define DC_IS_FILE_DROP_TARGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_FILE_DROP_TARGET))
#define DC_FILE_DROP_TARGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_FILE_DROP_TARGET, DcFileDropTargetClass))

typedef struct _DcFileDropTarget DcFileDropTarget;
typedef struct _DcFileDropTargetClass DcFileDropTargetClass;

#define DC_TYPE_PINNED_MESSAGES_MANAGER (dc_pinned_messages_manager_get_type ())
#define DC_PINNED_MESSAGES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManager))
#define DC_PINNED_MESSAGES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManagerClass))
#define DC_IS_PINNED_MESSAGES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_PINNED_MESSAGES_MANAGER))
#define DC_IS_PINNED_MESSAGES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_PINNED_MESSAGES_MANAGER))
#define DC_PINNED_MESSAGES_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_PINNED_MESSAGES_MANAGER, DcPinnedMessagesManagerClass))

typedef struct _DcPinnedMessagesManager DcPinnedMessagesManager;
typedef struct _DcPinnedMessagesManagerClass DcPinnedMessagesManagerClass;

#define DC_TYPE_MESSAGE_ACTIONS (dc_message_actions_get_type ())
#define DC_MESSAGE_ACTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MESSAGE_ACTIONS, DcMessageActions))
#define DC_MESSAGE_ACTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MESSAGE_ACTIONS, DcMessageActionsClass))
#define DC_IS_MESSAGE_ACTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MESSAGE_ACTIONS))
#define DC_IS_MESSAGE_ACTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MESSAGE_ACTIONS))
#define DC_MESSAGE_ACTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MESSAGE_ACTIONS, DcMessageActionsClass))

typedef struct _DcMessageActions DcMessageActions;
typedef struct _DcMessageActionsClass DcMessageActionsClass;
enum  {
	DC_CONVERSATION_VIEW_0_PROPERTY,
	DC_CONVERSATION_VIEW_CHAT_ID_PROPERTY,
	DC_CONVERSATION_VIEW_PINNED_PROPERTY,
	DC_CONVERSATION_VIEW_MSG_ACTIONS_PROPERTY,
	DC_CONVERSATION_VIEW_NUM_PROPERTIES
};
static GParamSpec* dc_conversation_view_properties[DC_CONVERSATION_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))

#define DC_TYPE_MESSAGE (dc_message_get_type ())
#define DC_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MESSAGE, DcMessage))
#define DC_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MESSAGE, DcMessageClass))
#define DC_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MESSAGE))
#define DC_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MESSAGE))
#define DC_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MESSAGE, DcMessageClass))

typedef struct _DcMessage DcMessage;
typedef struct _DcMessageClass DcMessageClass;
typedef struct _Block22Data Block22Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef enum  {
	DC_MESSAGE_STYLE_BUBBLES = 0,
	DC_MESSAGE_STYLE_IRC = 1
} DcMessageStyle;

#define DC_TYPE_MESSAGE_STYLE (dc_message_style_get_type ())
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))

#define DC_TYPE_MESSAGE_ROW (dc_message_row_get_type ())
#define DC_MESSAGE_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MESSAGE_ROW, DcMessageRow))
#define DC_MESSAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MESSAGE_ROW, DcMessageRowClass))
#define DC_IS_MESSAGE_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MESSAGE_ROW))
#define DC_IS_MESSAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MESSAGE_ROW))
#define DC_MESSAGE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MESSAGE_ROW, DcMessageRowClass))

typedef struct _DcMessageRow DcMessageRow;
typedef struct _DcMessageRowClass DcMessageRowClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcConversationViewAcceptRequestData DcConversationViewAcceptRequestData;
typedef struct _DcConversationViewBlockRequestData DcConversationViewBlockRequestData;
typedef struct _DcConversationViewReloadMessagesData DcConversationViewReloadMessagesData;
typedef struct _DcConversationViewHandleIncomingMsgData DcConversationViewHandleIncomingMsgData;
typedef struct _Block23Data Block23Data;
typedef struct _Block24Data Block24Data;
typedef struct _Block25Data Block25Data;
typedef struct _DcConversationViewLoadMessagesData DcConversationViewLoadMessagesData;
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
typedef struct _DcConversationViewFetchMessagesBatchData DcConversationViewFetchMessagesBatchData;
typedef struct _Block26Data Block26Data;
typedef struct _DcConversationViewLoadEarlierMessagesData DcConversationViewLoadEarlierMessagesData;
typedef struct _DcConversationViewDoSendData DcConversationViewDoSendData;

#define DC_TYPE_AUDIO_PLAYER (dc_audio_player_get_type ())
#define DC_AUDIO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_AUDIO_PLAYER, DcAudioPlayer))
#define DC_AUDIO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_AUDIO_PLAYER, DcAudioPlayerClass))
#define DC_IS_AUDIO_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_AUDIO_PLAYER))
#define DC_IS_AUDIO_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_AUDIO_PLAYER))
#define DC_AUDIO_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_AUDIO_PLAYER, DcAudioPlayerClass))

typedef struct _DcAudioPlayer DcAudioPlayer;
typedef struct _DcAudioPlayerClass DcAudioPlayerClass;

struct _DcConversationView {
	GtkBox parent_instance;
	DcConversationViewPrivate * priv;
};

struct _DcConversationViewClass {
	GtkBoxClass parent_class;
};

struct _DcConversationViewPrivate {
	gint _chat_id;
	DcWindow* window;
	DcRpcClient* rpc;
	DcSettingsManager* settings;
	GtkListView* message_listview;
	GtkScrolledWindow* message_scroll;
	GListStore* message_store;
	GtkFilterListModel* filtered_message_store;
	GtkCustomFilter* message_filter;
	DcComposeBar* compose_bar;
	GtkBox* request_bar;
	gboolean is_contact_request;
	GtkButton* scroll_down_btn;
	GtkRevealer* loading_more_revealer;
	GtkSpinner* loading_more_spinner;
	GtkRevealer* message_search_revealer;
	GtkSearchEntry* message_search_entry;
	gboolean search_toggling;
	DcFileDropTarget* file_drop_target;
	gboolean stick_to_bottom;
	gint* pending_seen_ids;
	gint pending_seen_ids_length1;
	gint _pending_seen_ids_size_;
	JsonArray* all_msg_ids;
	guint loaded_start_index;
	gboolean loading_more;
	gboolean loading_chat;
	gboolean messages_loaded;
	gint64 scroll_freeze_until_us;
	DcPinnedMessagesManager* _pinned;
	DcMessageActions* _msg_actions;
};

struct _Block22Data {
	int _ref_count_;
	DcConversationView* self;
	gint dc_last_id;
	gint64 dc_last_time;
};

struct _DcConversationViewAcceptRequestData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	DcComposeBar* _tmp2_;
	DcWindow* _tmp3_;
	GError* e;
	DcWindow* _tmp4_;
	GError* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GError* _inner_error0_;
};

struct _DcConversationViewBlockRequestData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	DcWindow* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	DcWindow* _tmp6_;
	DcWindow* _tmp7_;
	GError* e;
	DcWindow* _tmp8_;
	GError* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	GError* _inner_error0_;
};

struct _DcConversationViewReloadMessagesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
};

struct _DcConversationViewHandleIncomingMsgData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
	gint msg_id;
	DcMessage* msg;
	DcRpcClient* _tmp0_;
	DcMessage* _tmp1_;
	DcMessage* _tmp2_;
	gboolean is_current;
	DcWindow* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	DcMessage* _tmp7_;
	DcMessage* _tmp8_;
	DcPinnedMessagesManager* _tmp9_;
	DcMessage* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	DcMessage* _tmp13_;
	gboolean _tmp14_;
	DcWindow* _tmp15_;
	gboolean _tmp16_;
	gboolean _tmp17_;
	DcRpcClient* _tmp18_;
	gint* _tmp19_;
	gint* _tmp20_;
	gint _tmp20__length1;
	GError* e;
	GError* _tmp21_;
	const gchar* _tmp22_;
	GError* _inner_error0_;
};

struct _Block23Data {
	int _ref_count_;
	DcConversationView* self;
	gdouble saved_value;
	gboolean was_at_bottom;
	gboolean was_loading;
};

struct _Block24Data {
	int _ref_count_;
	DcConversationView* self;
	gdouble v;
};

struct _Block25Data {
	int _ref_count_;
	DcConversationView* self;
	gdouble previous_scroll_value;
};

struct _DcConversationViewLoadMessagesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
	gboolean preserve_scroll;
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	Block25Data* _data25_;
	gboolean was_near_bottom;
	GtkScrolledWindow* _tmp3_;
	GtkAdjustment* _tmp4_;
	GtkAdjustment* _tmp5_;
	gdouble _tmp6_;
	gdouble _tmp7_;
	JsonArray* _tmp8_;
	DcRpcClient* _tmp9_;
	gint _tmp10_;
	JsonArray* _tmp11_;
	JsonArray* _tmp12_;
	JsonArray* _tmp13_;
	guint _tmp14_;
	JsonArray* _tmp15_;
	JsonArray* _tmp16_;
	GPtrArray* messages;
	JsonArray* _tmp17_;
	GPtrArray* _tmp18_;
	DcPinnedMessagesManager* _tmp19_;
	gint _tmp20_;
	gboolean _tmp21_;
	GObject** batch;
	GPtrArray* _tmp22_;
	gint _tmp23_;
	gint _tmp24_;
	GObject** _tmp25_;
	gint batch_length1;
	gint _batch_size_;
	guint i;
	gboolean _tmp26_;
	guint _tmp27_;
	GPtrArray* _tmp28_;
	gint _tmp29_;
	gint _tmp30_;
	GPtrArray* _tmp31_;
	gconstpointer _tmp32_;
	DcPinnedMessagesManager* _tmp33_;
	GPtrArray* _tmp34_;
	gconstpointer _tmp35_;
	gint _tmp36_;
	gint _tmp37_;
	GObject** _tmp38_;
	gint _tmp38__length1;
	GPtrArray* _tmp39_;
	gconstpointer _tmp40_;
	GObject* _tmp41_;
	GListStore* _tmp42_;
	GListStore* _tmp43_;
	GObject** _tmp44_;
	gint _tmp44__length1;
	GPtrArray* _tmp45_;
	gint _tmp46_;
	gint _tmp47_;
	gboolean _tmp48_;
	DcPinnedMessagesManager* _tmp49_;
	GError* e;
	DcWindow* _tmp50_;
	GError* _tmp51_;
	const gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	GError* _inner_error0_;
};

struct _DcConversationViewFetchMessagesBatchData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
	guint start;
	guint end;
	GPtrArray* result;
	guint count;
	gint* ids;
	gint* _tmp0_;
	gint ids_length1;
	gint _ids_size_;
	guint i;
	gboolean _tmp1_;
	guint _tmp2_;
	gint* _tmp3_;
	gint _tmp3__length1;
	JsonArray* _tmp4_;
	JsonObject* map;
	DcRpcClient* _tmp5_;
	gint* _tmp6_;
	gint _tmp6__length1;
	JsonObject* _tmp7_;
	GPtrArray* _result_;
	GPtrArray* _tmp8_;
	gint* _tmp9_;
	gint _tmp9__length1;
	gint* mid_collection;
	gint mid_collection_length1;
	gint _mid_collection_size_;
	gint mid_it;
	gint mid;
	gchar* k;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	GPtrArray* _tmp12_;
	const gchar* _tmp13_;
	JsonObject* _tmp14_;
	DcRpcClient* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	DcMessage* _tmp18_;
	GError* _inner_error0_;
};

struct _Block26Data {
	int _ref_count_;
	DcConversationView* self;
	gdouble old_upper;
	gdouble old_value;
};

struct _DcConversationViewLoadEarlierMessagesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	JsonArray* _tmp2_;
	guint _tmp3_;
	guint new_start;
	Block26Data* _data26_;
	GPtrArray* messages;
	GPtrArray* _tmp4_;
	GtkAdjustment* adj;
	GtkScrolledWindow* _tmp5_;
	GtkAdjustment* _tmp6_;
	GtkAdjustment* _tmp7_;
	GtkAdjustment* _tmp8_;
	GtkAdjustment* _tmp9_;
	gdouble _tmp10_;
	gdouble _tmp11_;
	GtkAdjustment* _tmp12_;
	gdouble _tmp13_;
	gdouble _tmp14_;
	GObject** batch;
	GPtrArray* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	GObject** _tmp18_;
	gint batch_length1;
	gint _batch_size_;
	guint i;
	gboolean _tmp19_;
	guint _tmp20_;
	GPtrArray* _tmp21_;
	gint _tmp22_;
	gint _tmp23_;
	GPtrArray* _tmp24_;
	gconstpointer _tmp25_;
	DcPinnedMessagesManager* _tmp26_;
	GPtrArray* _tmp27_;
	gconstpointer _tmp28_;
	gint _tmp29_;
	gint _tmp30_;
	GObject** _tmp31_;
	gint _tmp31__length1;
	GPtrArray* _tmp32_;
	gconstpointer _tmp33_;
	GObject* _tmp34_;
	GListStore* _tmp35_;
	GObject** _tmp36_;
	gint _tmp36__length1;
	GError* e;
	DcWindow* _tmp37_;
	GError* _tmp38_;
	const gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	GError* _inner_error0_;
};

struct _DcConversationViewDoSendData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcConversationView* self;
	gchar* text;
	gchar* file_path;
	gchar* file_name;
	gint quote_msg_id;
	const gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gchar* send_text;
	gchar* _tmp3_;
	gint msg_id;
	DcRpcClient* _tmp4_;
	gint _tmp5_;
	const gchar* _tmp6_;
	DcMessage* msg;
	DcRpcClient* _tmp7_;
	DcMessage* _tmp8_;
	DcMessage* _tmp9_;
	DcMessage* _tmp10_;
	GError* e;
	DcWindow* _tmp11_;
	GError* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	GError* _inner_error0_;
};

static gint DcConversationView_private_offset;
static gpointer dc_conversation_view_parent_class = NULL;

VALA_EXTERN GType dc_conversation_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcConversationView, g_object_unref)
VALA_EXTERN GType dc_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcWindow, g_object_unref)
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
VALA_EXTERN GType dc_settings_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSettingsManager, g_object_unref)
VALA_EXTERN GType dc_compose_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcComposeBar, g_object_unref)
VALA_EXTERN GType dc_file_drop_target_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcFileDropTarget, g_object_unref)
VALA_EXTERN GType dc_pinned_messages_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcPinnedMessagesManager, g_object_unref)
VALA_EXTERN GType dc_message_actions_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessageActions, g_object_unref)
VALA_EXTERN DcConversationView* dc_conversation_view_new (gint chat_id,
                                              DcWindow* window,
                                              DcRpcClient* rpc,
                                              DcSettingsManager* settings);
VALA_EXTERN DcConversationView* dc_conversation_view_construct (GType object_type,
                                                    gint chat_id,
                                                    DcWindow* window,
                                                    DcRpcClient* rpc,
                                                    DcSettingsManager* settings);
VALA_EXTERN GType dc_message_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessage, g_object_unref)
VALA_EXTERN DcPinnedMessagesManager* dc_pinned_messages_manager_new (GListStore* message_store,
                                                         DcSettingsManager* settings);
VALA_EXTERN DcPinnedMessagesManager* dc_pinned_messages_manager_construct (GType object_type,
                                                               GListStore* message_store,
                                                               DcSettingsManager* settings);
static void dc_conversation_view_set_pinned (DcConversationView* self,
                                      DcPinnedMessagesManager* value);
VALA_EXTERN DcPinnedMessagesManager* dc_conversation_view_get_pinned (DcConversationView* self);
VALA_EXTERN void dc_pinned_messages_manager_set_rpc (DcPinnedMessagesManager* self,
                                         DcRpcClient* r);
static void __lambda63_ (DcConversationView* self,
                  gint mid);
VALA_EXTERN void dc_conversation_view_scroll_to_message (DcConversationView* self,
                                             gint msg_id);
static void ___lambda63__dc_pinned_messages_manager_scroll_requested (DcPinnedMessagesManager* _sender,
                                                               gint msg_id,
                                                               gpointer self);
static void dc_conversation_view_build_ui (DcConversationView* self);
VALA_EXTERN DcMessageActions* dc_message_actions_new (DcWindow* window,
                                          DcRpcClient* rpc,
                                          GListStore* message_store,
                                          DcPinnedMessagesManager* pinned,
                                          DcComposeBar* compose_bar,
                                          DcSettingsManager* settings);
VALA_EXTERN DcMessageActions* dc_message_actions_construct (GType object_type,
                                                DcWindow* window,
                                                DcRpcClient* rpc,
                                                GListStore* message_store,
                                                DcPinnedMessagesManager* pinned,
                                                DcComposeBar* compose_bar,
                                                DcSettingsManager* settings);
static void dc_conversation_view_set_msg_actions (DcConversationView* self,
                                           DcMessageActions* value);
static Block22Data* block22_data_ref (Block22Data* _data22_);
static void block22_data_unref (void * _userdata_);
static void __lambda64_ (DcConversationView* self);
static void dc_conversation_view_maybe_autoscroll (DcConversationView* self);
static gboolean dc_conversation_view_is_near_bottom (DcConversationView* self);
static void ___lambda64__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda65_ (DcConversationView* self);
static void ___lambda65__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda66_ (DcConversationView* self);
static gboolean dc_conversation_view_is_near_top (DcConversationView* self);
static void dc_conversation_view_load_earlier_messages (DcConversationView* self,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static void dc_conversation_view_load_earlier_messages_finish (DcConversationView* self,
                                                        GAsyncResult* _res_);
static void ___lambda66__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static gboolean __lambda68_ (DcConversationView* self,
                      GObject* item);
VALA_EXTERN const gchar* dc_message_get_text (DcMessage* self);
static gboolean ___lambda68__gtk_custom_filter_func (GObject* item,
                                              gpointer self);
static void __lambda69_ (DcConversationView* self,
                  GObject* obj);
VALA_EXTERN GType dc_message_style_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DcMessageStyle dc_settings_manager_get_message_style (DcSettingsManager* self);
VALA_EXTERN gboolean dc_message_row_is_image_only_message (DcMessage* m);
VALA_EXTERN gboolean dc_message_row_same_irc_sender (DcMessage* a,
                                         DcMessage* b);
static void _g_object_unref0_ (gpointer var);
VALA_EXTERN GType dc_message_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessageRow, g_object_unref)
VALA_EXTERN DcMessageRow* dc_message_row_new (DcMessage* msg,
                                  DcMessage* prev,
                                  GPtrArray* trailing_images,
                                  gboolean is_image_continuation);
VALA_EXTERN DcMessageRow* dc_message_row_construct (GType object_type,
                                        DcMessage* msg,
                                        DcMessage* prev,
                                        GPtrArray* trailing_images,
                                        gboolean is_image_continuation);
static void __lambda79_ (DcConversationView* self,
                  gint qid);
static void ___lambda79__dc_message_row_quote_clicked (DcMessageRow* _sender,
                                                gint quoted_msg_id,
                                                gpointer self);
VALA_EXTERN gboolean dc_message_get_highlighted (DcMessage* self);
VALA_EXTERN void dc_message_set_highlighted (DcMessage* self,
                                 gboolean value);
VALA_EXTERN void dc_message_row_highlight (DcMessageRow* self);
static void ___lambda69__gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                     GObject* object,
                                                     gpointer self);
static void __lambda80_ (DcConversationView* self,
                  gint n,
                  gdouble x,
                  gdouble y);
static DcMessageRow* dc_conversation_view_pick_message_row (DcConversationView* self,
                                                     gdouble x,
                                                     gdouble y);
VALA_EXTERN DcMessageActions* dc_conversation_view_get_msg_actions (DcConversationView* self);
VALA_EXTERN void dc_message_actions_show_context_menu (DcMessageActions* self,
                                           gint msg_id,
                                           gboolean is_outgoing,
                                           gdouble x,
                                           gdouble y,
                                           GtkWidget* parent);
VALA_EXTERN gint dc_message_row_get_message_id (DcMessageRow* self);
VALA_EXTERN gboolean dc_message_row_get_is_outgoing (DcMessageRow* self);
static void ___lambda80__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                             gint n_press,
                                             gdouble x,
                                             gdouble y,
                                             gpointer self);
static void __lambda81_ (Block22Data* _data22_,
                  gint n,
                  gdouble x,
                  gdouble y);
static gboolean dc_conversation_view_pointer_on_selectable_text (DcConversationView* self,
                                                          gdouble x,
                                                          gdouble y);
static gboolean dc_conversation_view_pointer_on_media (DcConversationView* self,
                                                gdouble x,
                                                gdouble y);
static void dc_conversation_view_hold_scroll_on_focus_shift (DcConversationView* self);
VALA_EXTERN void dc_message_actions_handle_double_click (DcMessageActions* self,
                                             gint msg_id);
VALA_EXTERN DcMessage* dc_find_message (GListStore* store,
                            gint msg_id);
static void dc_conversation_view_on_message_activated (DcConversationView* self,
                                                DcMessage* msg);
static void ___lambda81__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                             gint n_press,
                                             gdouble x,
                                             gdouble y,
                                             gpointer self);
static void __lambda90_ (DcConversationView* self);
static void ___lambda90__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                   gpointer self);
VALA_EXTERN GtkRevealer* dc_pinned_messages_manager_get_revealer (DcPinnedMessagesManager* self);
static void __lambda91_ (DcConversationView* self);
VALA_EXTERN void dc_conversation_view_scroll_to_bottom (DcConversationView* self);
static void ___lambda91__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
VALA_EXTERN DcComposeBar* dc_compose_bar_new (void);
VALA_EXTERN DcComposeBar* dc_compose_bar_construct (GType object_type);
static void dc_conversation_view_on_send_message (DcConversationView* self,
                                           const gchar* text,
                                           const gchar* file_path,
                                           const gchar* file_name,
                                           gint quote_msg_id);
static void _dc_conversation_view_on_send_message_dc_compose_bar_send_message (DcComposeBar* _sender,
                                                                        const gchar* text,
                                                                        const gchar* file_path,
                                                                        const gchar* file_name,
                                                                        gint quote_msg_id,
                                                                        gpointer self);
static void __lambda92_ (DcConversationView* self,
                  gint msg_id,
                  const gchar* new_text);
VALA_EXTERN void dc_message_actions_edit_message (DcMessageActions* self,
                                      gint msg_id,
                                      const gchar* new_text,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
VALA_EXTERN void dc_message_actions_edit_message_finish (DcMessageActions* self,
                                             GAsyncResult* _res_);
static void ___lambda92__dc_compose_bar_edit_message (DcComposeBar* _sender,
                                               gint msg_id,
                                               const gchar* new_text,
                                               gpointer self);
static void __lambda93_ (DcConversationView* self);
VALA_EXTERN void dc_message_actions_start_editing_last (DcMessageActions* self);
static void ___lambda93__dc_compose_bar_edit_last_requested (DcComposeBar* _sender,
                                                      gpointer self);
static GtkBox* dc_conversation_view_build_request_bar (DcConversationView* self);
static void dc_conversation_view_install_file_drop_target (DcConversationView* self);
static void __lambda94_ (DcConversationView* self);
static void dc_conversation_view_block_request (DcConversationView* self,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
static void dc_conversation_view_block_request_finish (DcConversationView* self,
                                                GAsyncResult* _res_);
static void ___lambda94__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda95_ (DcConversationView* self);
static void dc_conversation_view_accept_request (DcConversationView* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void dc_conversation_view_accept_request_finish (DcConversationView* self,
                                                 GAsyncResult* _res_);
static void ___lambda95__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
VALA_EXTERN void dc_conversation_view_set_contact_request (DcConversationView* self,
                                               gboolean is_request);
static void dc_conversation_view_accept_request_data_free (gpointer _data);
static gboolean dc_conversation_view_accept_request_co (DcConversationViewAcceptRequestData* _data_);
VALA_EXTERN void dc_rpc_client_accept_chat (DcRpcClient* self,
                                gint chat_id,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_accept_chat_finish (DcRpcClient* self,
                                       GAsyncResult* _res_,
                                       GError** error);
VALA_EXTERN gint dc_conversation_view_get_chat_id (DcConversationView* self);
static void dc_conversation_view_accept_request_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
VALA_EXTERN void dc_compose_bar_grab_entry_focus (DcComposeBar* self);
VALA_EXTERN void dc_window_request_reload_chats (DcWindow* self);
VALA_EXTERN void dc_window_show_toast (DcWindow* self,
                           const gchar* message);
static void dc_conversation_view_block_request_data_free (gpointer _data);
static gboolean dc_conversation_view_block_request_co (DcConversationViewBlockRequestData* _data_);
VALA_EXTERN void dc_rpc_client_block_chat (DcRpcClient* self,
                               gint chat_id,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_block_chat_finish (DcRpcClient* self,
                                      GAsyncResult* _res_,
                                      GError** error);
static void dc_conversation_view_block_request_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
VALA_EXTERN gint dc_window_get_current_chat_id (DcWindow* self);
VALA_EXTERN void dc_window_clear_chat_view (DcWindow* self);
VALA_EXTERN void dc_conversation_view_on_activated (DcConversationView* self);
static void dc_conversation_view_load_messages (DcConversationView* self,
                                         gboolean preserve_scroll,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
static void dc_conversation_view_load_messages_finish (DcConversationView* self,
                                                GAsyncResult* _res_);
VALA_EXTERN void dc_conversation_view_on_reselected (DcConversationView* self);
VALA_EXTERN void dc_conversation_view_attach_dropped_file_path (DcConversationView* self,
                                                    const gchar* path);
static void dc_conversation_view_attach_local_file (DcConversationView* self,
                                             const gchar* path,
                                             const gchar* name);
VALA_EXTERN void dc_conversation_view_focus_entry (DcConversationView* self);
VALA_EXTERN gboolean dc_conversation_view_has_active_compose_mode (DcConversationView* self);
VALA_EXTERN gboolean dc_compose_bar_has_active_mode (DcComposeBar* self);
VALA_EXTERN gboolean dc_conversation_view_compose_entry_has_focus (DcConversationView* self);
VALA_EXTERN gboolean dc_compose_bar_entry_has_focus (DcComposeBar* self);
VALA_EXTERN void dc_conversation_view_cancel_active_compose_mode (DcConversationView* self);
VALA_EXTERN void dc_compose_bar_cancel_active_mode (DcComposeBar* self);
VALA_EXTERN void dc_conversation_view_type_into_entry (DcConversationView* self,
                                           const gchar* text);
VALA_EXTERN void dc_compose_bar_type_text (DcComposeBar* self,
                               const gchar* text);
static void dc_conversation_view_reload_messages_data_free (gpointer _data);
VALA_EXTERN void dc_conversation_view_reload_messages (DcConversationView* self,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
VALA_EXTERN void dc_conversation_view_reload_messages_finish (DcConversationView* self,
                                                  GAsyncResult* _res_);
static gboolean dc_conversation_view_reload_messages_co (DcConversationViewReloadMessagesData* _data_);
static void dc_conversation_view_reload_messages_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
static void dc_conversation_view_handle_incoming_msg_data_free (gpointer _data);
VALA_EXTERN void dc_conversation_view_handle_incoming_msg (DcConversationView* self,
                                               gint msg_id,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
VALA_EXTERN void dc_conversation_view_handle_incoming_msg_finish (DcConversationView* self,
                                                      GAsyncResult* _res_);
static gboolean dc_conversation_view_handle_incoming_msg_co (DcConversationViewHandleIncomingMsgData* _data_);
VALA_EXTERN void dc_rpc_client_fetch_message (DcRpcClient* self,
                                  gint msg_id,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN DcMessage* dc_rpc_client_fetch_message_finish (DcRpcClient* self,
                                               GAsyncResult* _res_,
                                               GError** error);
static void dc_conversation_view_handle_incoming_msg_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
VALA_EXTERN gboolean dc_pinned_messages_manager_is_pinned (DcPinnedMessagesManager* self,
                                               gint msg_id);
VALA_EXTERN gint dc_message_get_id (DcMessage* self);
VALA_EXTERN void dc_message_set_is_pinned (DcMessage* self,
                               gboolean value);
static void dc_conversation_view_insert_message_sorted (DcConversationView* self,
                                                 DcMessage* msg);
VALA_EXTERN void dc_rpc_client_mark_seen_msgs (DcRpcClient* self,
                                   gint* msg_ids,
                                   gint msg_ids_length1,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_mark_seen_msgs_finish (DcRpcClient* self,
                                          GAsyncResult* _res_,
                                          GError** error);
static void _vala_array_add5 (gint* * array,
                       gint* length,
                       gint* size,
                       gint value);
VALA_EXTERN void dc_conversation_view_flush_pending_seen (DcConversationView* self);
static gint* _vala_array_dup2 (gint* self,
                        gssize length);
static void __lambda61_ (DcConversationView* self,
                  GObject* o,
                  GAsyncResult* res);
static void ___lambda61__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
VALA_EXTERN void dc_conversation_view_toggle_search (DcConversationView* self);
static gboolean ___lambda97_ (DcConversationView* self);
static gboolean ____lambda97__gsource_func (gpointer self);
static gboolean ___lambda98_ (DcConversationView* self);
static gboolean ____lambda98__gsource_func (gpointer self);
VALA_EXTERN void dc_conversation_view_replace_message (DcConversationView* self,
                                           gint msg_id,
                                           DcMessage* new_msg);
static Block23Data* block23_data_ref (Block23Data* _data23_);
static void block23_data_unref (void * _userdata_);
VALA_EXTERN gint dc_find_message_index (GListStore* store,
                            gint msg_id);
VALA_EXTERN void dc_conversation_view_freeze_scroll_handler (DcConversationView* self,
                                                 guint ms);
static gboolean __lambda42_ (Block23Data* _data23_,
                      GtkWidget* w,
                      GdkFrameClock* clock);
static gboolean ___lambda42__gtk_tick_callback (GtkWidget* widget,
                                         GdkFrameClock* frame_clock,
                                         gpointer self);
VALA_EXTERN gdouble dc_conversation_view_get_scroll_value (DcConversationView* self);
VALA_EXTERN void dc_conversation_view_restore_scroll_value (DcConversationView* self,
                                                gdouble v);
VALA_EXTERN void dc_conversation_view_restore_scroll_value_deferred (DcConversationView* self,
                                                         gdouble v);
static Block24Data* block24_data_ref (Block24Data* _data24_);
static void block24_data_unref (void * _userdata_);
static gboolean __lambda44_ (Block24Data* _data24_,
                      GtkWidget* w,
                      GdkFrameClock* clock);
static gboolean ___lambda44__gtk_tick_callback (GtkWidget* widget,
                                         GdkFrameClock* frame_clock,
                                         gpointer self);
VALA_EXTERN gboolean dc_conversation_view_close_search_if_active (DcConversationView* self);
static void dc_conversation_view_load_messages_data_free (gpointer _data);
static gboolean dc_conversation_view_load_messages_co (DcConversationViewLoadMessagesData* _data_);
VALA_EXTERN gint dc_rpc_client_get_account_id (DcRpcClient* self);
static Block25Data* block25_data_ref (Block25Data* _data25_);
static void block25_data_unref (void * _userdata_);
VALA_EXTERN void dc_rpc_client_get_message_ids (DcRpcClient* self,
                                    gint chat_id,
                                    gboolean info_only,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
VALA_EXTERN JsonArray* dc_rpc_client_get_message_ids_finish (DcRpcClient* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
static void dc_conversation_view_load_messages_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static void dc_conversation_view_fetch_messages_batch (DcConversationView* self,
                                                guint start,
                                                guint end,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
static GPtrArray* dc_conversation_view_fetch_messages_batch_finish (DcConversationView* self,
                                                             GAsyncResult* _res_,
                                                             GError** error);
VALA_EXTERN void dc_pinned_messages_manager_load_for_chat (DcPinnedMessagesManager* self,
                                               gint chat_id);
static gboolean _____lambda62_ (Block25Data* _data25_);
static gboolean ______lambda62__gsource_func (gpointer self);
VALA_EXTERN void dc_pinned_messages_manager_update_bar (DcPinnedMessagesManager* self,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void dc_pinned_messages_manager_update_bar_finish (DcPinnedMessagesManager* self,
                                                   GAsyncResult* _res_);
static void dc_conversation_view_fetch_messages_batch_data_free (gpointer _data);
static gboolean dc_conversation_view_fetch_messages_batch_co (DcConversationViewFetchMessagesBatchData* _data_);
VALA_EXTERN void dc_rpc_client_get_messages (DcRpcClient* self,
                                 gint* msg_ids,
                                 gint msg_ids_length1,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN JsonObject* dc_rpc_client_get_messages_finish (DcRpcClient* self,
                                               GAsyncResult* _res_,
                                               GError** error);
static void dc_conversation_view_fetch_messages_batch_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
VALA_EXTERN DcMessage* dc_rpc_parsers_parse_message (JsonObject* obj,
                                         const gchar* self_email);
VALA_EXTERN const gchar* dc_rpc_client_get_self_email (DcRpcClient* self);
static void dc_conversation_view_load_earlier_messages_data_free (gpointer _data);
static gboolean dc_conversation_view_load_earlier_messages_co (DcConversationViewLoadEarlierMessagesData* _data_);
static void dc_conversation_view_set_loading_more_visible (DcConversationView* self,
                                                    gboolean visible);
static Block26Data* block26_data_ref (Block26Data* _data26_);
static void block26_data_unref (void * _userdata_);
static void dc_conversation_view_load_earlier_messages_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_);
static gboolean ___lambda67_ (Block26Data* _data26_);
static gboolean ____lambda67__gsource_func (gpointer self);
VALA_EXTERN gint64 dc_message_get_timestamp (DcMessage* self);
static void dc_conversation_view_do_send (DcConversationView* self,
                                   const gchar* text,
                                   const gchar* file_path,
                                   const gchar* file_name,
                                   gint quote_msg_id,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
static void dc_conversation_view_do_send_finish (DcConversationView* self,
                                          GAsyncResult* _res_);
static void dc_conversation_view_do_send_data_free (gpointer _data);
static gboolean dc_conversation_view_do_send_co (DcConversationViewDoSendData* _data_);
VALA_EXTERN void dc_rpc_client_send_msg (DcRpcClient* self,
                             gint chat_id,
                             const gchar* text,
                             const gchar* file_path,
                             const gchar* file_name,
                             gint quoted_msg_id,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_send_msg_finish (DcRpcClient* self,
                                    GAsyncResult* _res_,
                                    GError** error);
static void dc_conversation_view_do_send_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
static gboolean dc_conversation_view_can_accept_file_attachment (DcConversationView* self);
VALA_EXTERN gboolean dc_compose_bar_can_accept_attachment (DcComposeBar* self);
VALA_EXTERN void dc_compose_bar_set_pending_attachment (DcComposeBar* self,
                                            const gchar* file_path,
                                            const gchar* file_name);
VALA_EXTERN DcFileDropTarget* dc_file_drop_target_new (GtkWidget* widget,
                                           const gchar* active_css_class);
VALA_EXTERN DcFileDropTarget* dc_file_drop_target_construct (GType object_type,
                                                 GtkWidget* widget,
                                                 const gchar* active_css_class);
static gboolean _dc_conversation_view_can_accept_file_attachment_dc_file_drop_target_accept (DcFileDropTarget* _sender,
                                                                                      gpointer self);
static void _dc_conversation_view_attach_local_file_dc_file_drop_target_dropped (DcFileDropTarget* _sender,
                                                                          const gchar* path,
                                                                          const gchar* name,
                                                                          gpointer self);
static void __lambda96_ (DcConversationView* self,
                  const gchar* message);
static void ___lambda96__dc_file_drop_target_failed (DcFileDropTarget* _sender,
                                              const gchar* message,
                                              gpointer self);
VALA_EXTERN GType dc_audio_player_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcAudioPlayer, g_object_unref)
VALA_EXTERN const gchar* dc_message_get_file_path (DcMessage* self);
VALA_EXTERN gboolean dc_message_row_is_image_file (DcMessage* msg);
static void dc_conversation_view_collect_image_paths (DcConversationView* self,
                                               const gchar* current_path,
                                               gchar*** paths,
                                               gint* paths_length1,
                                               gint* start_index);
VALA_EXTERN void dc_window_show_image_list (DcWindow* self,
                                gchar** paths,
                                gint paths_length1,
                                gint start_index);
VALA_EXTERN gboolean dc_message_row_is_video_file (DcMessage* msg);
VALA_EXTERN void dc_window_show_video (DcWindow* self,
                           const gchar* path,
                           const gchar* name);
VALA_EXTERN const gchar* dc_message_get_file_name (DcMessage* self);
VALA_EXTERN gboolean dc_message_row_is_audio_file (DcMessage* msg);
VALA_EXTERN void dc_window_save_attachment (DcWindow* self,
                                const gchar* src_path,
                                const gchar* name,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN void dc_window_save_attachment_finish (DcWindow* self,
                                       GAsyncResult* _res_);
static void _g_free0_ (gpointer var);
static void dc_conversation_view_set_chat_id (DcConversationView* self,
                                       gint value);
static void dc_conversation_view_finalize (GObject * obj);
static GType dc_conversation_view_get_type_once (void);
static void _vala_dc_conversation_view_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_dc_conversation_view_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dc_conversation_view_get_instance_private (DcConversationView* self)
{
	return G_STRUCT_MEMBER_P (self, DcConversationView_private_offset);
}

static void
__lambda63_ (DcConversationView* self,
             gint mid)
{
	dc_conversation_view_scroll_to_message (self, mid);
}

static void
___lambda63__dc_pinned_messages_manager_scroll_requested (DcPinnedMessagesManager* _sender,
                                                          gint msg_id,
                                                          gpointer self)
{
	__lambda63_ ((DcConversationView*) self, msg_id);
}

DcConversationView*
dc_conversation_view_construct (GType object_type,
                                gint chat_id,
                                DcWindow* window,
                                DcRpcClient* rpc,
                                DcSettingsManager* settings)
{
	DcConversationView * self = NULL;
	GListStore* _tmp0_;
	GListStore* _tmp1_;
	DcPinnedMessagesManager* _tmp2_;
	DcPinnedMessagesManager* _tmp3_;
	DcPinnedMessagesManager* _tmp4_;
	DcPinnedMessagesManager* _tmp5_;
	GListStore* _tmp6_;
	DcPinnedMessagesManager* _tmp7_;
	DcComposeBar* _tmp8_;
	DcMessageActions* _tmp9_;
	DcMessageActions* _tmp10_;
	g_return_val_if_fail (window != NULL, NULL);
	g_return_val_if_fail (rpc != NULL, NULL);
	g_return_val_if_fail (settings != NULL, NULL);
	self = (DcConversationView*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, "chat-id", chat_id, NULL);
	self->priv->window = window;
	self->priv->rpc = rpc;
	self->priv->settings = settings;
	gtk_widget_add_css_class ((GtkWidget*) self, "conversation-view");
	_tmp0_ = g_list_store_new (DC_TYPE_MESSAGE);
	_g_object_unref0 (self->priv->message_store);
	self->priv->message_store = _tmp0_;
	_tmp1_ = self->priv->message_store;
	_tmp2_ = dc_pinned_messages_manager_new (_tmp1_, settings);
	_tmp3_ = _tmp2_;
	dc_conversation_view_set_pinned (self, _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->_pinned;
	dc_pinned_messages_manager_set_rpc (_tmp4_, rpc);
	_tmp5_ = self->priv->_pinned;
	g_signal_connect_object (_tmp5_, "scroll-requested", (GCallback) ___lambda63__dc_pinned_messages_manager_scroll_requested, self, 0);
	dc_conversation_view_build_ui (self);
	_tmp6_ = self->priv->message_store;
	_tmp7_ = self->priv->_pinned;
	_tmp8_ = self->priv->compose_bar;
	_tmp9_ = dc_message_actions_new (window, rpc, _tmp6_, _tmp7_, _tmp8_, settings);
	_tmp10_ = _tmp9_;
	dc_conversation_view_set_msg_actions (self, _tmp10_);
	_g_object_unref0 (_tmp10_);
	return self;
}

DcConversationView*
dc_conversation_view_new (gint chat_id,
                          DcWindow* window,
                          DcRpcClient* rpc,
                          DcSettingsManager* settings)
{
	return dc_conversation_view_construct (DC_TYPE_CONVERSATION_VIEW, chat_id, window, rpc, settings);
}

static Block22Data*
block22_data_ref (Block22Data* _data22_)
{
	g_atomic_int_inc (&_data22_->_ref_count_);
	return _data22_;
}

static void
block22_data_unref (void * _userdata_)
{
	Block22Data* _data22_;
	_data22_ = (Block22Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data22_->_ref_count_)) {
		DcConversationView* self;
		self = _data22_->self;
		_g_object_unref0 (self);
		g_slice_free (Block22Data, _data22_);
	}
}

static void
__lambda64_ (DcConversationView* self)
{
	GtkButton* _tmp0_;
	if (self->priv->loading_chat) {
		return;
	}
	dc_conversation_view_maybe_autoscroll (self);
	_tmp0_ = self->priv->scroll_down_btn;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, !dc_conversation_view_is_near_bottom (self));
}

static void
___lambda64__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda64_ ((DcConversationView*) self);
}

static void
__lambda65_ (DcConversationView* self)
{
	GtkButton* _tmp0_;
	if (self->priv->loading_chat) {
		return;
	}
	dc_conversation_view_maybe_autoscroll (self);
	_tmp0_ = self->priv->scroll_down_btn;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, !dc_conversation_view_is_near_bottom (self));
}

static void
___lambda65__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda65_ ((DcConversationView*) self);
}

static void
__lambda66_ (DcConversationView* self)
{
	GtkButton* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	if (self->priv->loading_chat) {
		return;
	}
	if (g_get_monotonic_time () < self->priv->scroll_freeze_until_us) {
		return;
	}
	self->priv->stick_to_bottom = dc_conversation_view_is_near_bottom (self);
	_tmp0_ = self->priv->scroll_down_btn;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, !self->priv->stick_to_bottom);
	if (dc_conversation_view_is_near_top (self)) {
		_tmp2_ = !self->priv->loading_more;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = self->priv->loaded_start_index > ((guint) 0);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		dc_conversation_view_load_earlier_messages (self, NULL, NULL);
	}
}

static void
___lambda66__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda66_ ((DcConversationView*) self);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

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

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
__lambda68_ (DcConversationView* self,
             GObject* item)
{
	GtkRevealer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gchar* query = NULL;
	GtkSearchEntry* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	DcMessage* msg = NULL;
	DcMessage* _tmp13_;
	gboolean _tmp14_ = FALSE;
	DcMessage* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	gboolean result;
	g_return_val_if_fail (item != NULL, FALSE);
	_tmp0_ = self->priv->message_search_revealer;
	_tmp1_ = gtk_revealer_get_reveal_child (_tmp0_);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		result = TRUE;
		return result;
	}
	_tmp3_ = self->priv->message_search_entry;
	_tmp4_ = gtk_editable_get_text ((GtkEditable*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = string_strip (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_utf8_strdown (_tmp7_, (gssize) -1);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	query = _tmp9_;
	_tmp10_ = query;
	_tmp11_ = strlen (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ == 0) {
		result = TRUE;
		_g_free0 (query);
		return result;
	}
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (item, DC_TYPE_MESSAGE, DcMessage));
	msg = _tmp13_;
	_tmp15_ = msg;
	_tmp16_ = dc_message_get_text (_tmp15_);
	_tmp17_ = _tmp16_;
	if (_tmp17_ != NULL) {
		DcMessage* _tmp18_;
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		const gchar* _tmp23_;
		_tmp18_ = msg;
		_tmp19_ = dc_message_get_text (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = g_utf8_strdown (_tmp20_, (gssize) -1);
		_tmp22_ = _tmp21_;
		_tmp23_ = query;
		_tmp14_ = string_contains (_tmp22_, _tmp23_);
		_g_free0 (_tmp22_);
	} else {
		_tmp14_ = FALSE;
	}
	result = _tmp14_;
	_g_object_unref0 (msg);
	_g_free0 (query);
	return result;
}

static gboolean
___lambda68__gtk_custom_filter_func (GObject* item,
                                     gpointer self)
{
	gboolean result;
	result = __lambda68_ ((DcConversationView*) self, item);
	return result;
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static gint
vala_g_ptr_array_get_length (GPtrArray* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = (gint) self->len;
	return result;
}

static void
__lambda79_ (DcConversationView* self,
             gint qid)
{
	dc_conversation_view_scroll_to_message (self, qid);
}

static void
___lambda79__dc_message_row_quote_clicked (DcMessageRow* _sender,
                                           gint quoted_msg_id,
                                           gpointer self)
{
	__lambda79_ ((DcConversationView*) self, quoted_msg_id);
}

static void
__lambda69_ (DcConversationView* self,
             GObject* obj)
{
	GtkListItem* li = NULL;
	GtkListItem* _tmp0_;
	DcMessage* msg = NULL;
	GtkListItem* _tmp1_;
	GObject* _tmp2_;
	GObject* _tmp3_;
	DcMessage* _tmp4_;
	DcMessage* prev = NULL;
	guint pos = 0U;
	GtkListItem* _tmp5_;
	guint _tmp6_;
	guint _tmp7_;
	GPtrArray* trailing = NULL;
	gboolean is_img_continuation = FALSE;
	gboolean _tmp10_ = FALSE;
	DcSettingsManager* _tmp11_;
	DcMessageStyle _tmp12_;
	DcMessageStyle _tmp13_;
	DcMessageRow* row = NULL;
	DcMessage* _tmp36_;
	DcMessage* _tmp37_;
	GPtrArray* _tmp38_;
	DcMessageRow* _tmp39_;
	DcMessageRow* _tmp40_;
	DcMessage* _tmp41_;
	gboolean _tmp42_;
	gboolean _tmp43_;
	GtkListItem* _tmp46_;
	DcMessageRow* _tmp47_;
	GtkListItem* _tmp48_;
	GtkListItem* _tmp49_;
	g_return_if_fail (obj != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_list_item_get_type (), GtkListItem));
	li = _tmp0_;
	_tmp1_ = li;
	_tmp2_ = gtk_list_item_get_item (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, DC_TYPE_MESSAGE, DcMessage));
	msg = _tmp4_;
	prev = NULL;
	_tmp5_ = li;
	_tmp6_ = gtk_list_item_get_position (_tmp5_);
	_tmp7_ = _tmp6_;
	pos = _tmp7_;
	if (pos > ((guint) 0)) {
		GtkFilterListModel* _tmp8_;
		GObject* _tmp9_;
		_tmp8_ = self->priv->filtered_message_store;
		_tmp9_ = g_list_model_get_item ((GListModel*) _tmp8_, pos - 1);
		_g_object_unref0 (prev);
		prev = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, DC_TYPE_MESSAGE, DcMessage);
	}
	trailing = NULL;
	is_img_continuation = FALSE;
	_tmp11_ = self->priv->settings;
	_tmp12_ = dc_settings_manager_get_message_style (_tmp11_);
	_tmp13_ = _tmp12_;
	if (_tmp13_ == DC_MESSAGE_STYLE_IRC) {
		DcMessage* _tmp14_;
		_tmp14_ = msg;
		_tmp10_ = dc_message_row_is_image_only_message (_tmp14_);
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		gboolean _tmp15_ = FALSE;
		gboolean _tmp16_ = FALSE;
		DcMessage* _tmp17_;
		_tmp17_ = prev;
		if (_tmp17_ != NULL) {
			DcMessage* _tmp18_;
			_tmp18_ = prev;
			_tmp16_ = dc_message_row_is_image_only_message (_tmp18_);
		} else {
			_tmp16_ = FALSE;
		}
		if (_tmp16_) {
			DcMessage* _tmp19_;
			DcMessage* _tmp20_;
			_tmp19_ = prev;
			_tmp20_ = msg;
			_tmp15_ = dc_message_row_same_irc_sender (_tmp19_, _tmp20_);
		} else {
			_tmp15_ = FALSE;
		}
		if (_tmp15_) {
			is_img_continuation = TRUE;
		} else {
			GPtrArray* _tmp21_;
			guint i = 0U;
			guint n = 0U;
			GtkFilterListModel* _tmp22_;
			_tmp21_ = g_ptr_array_new_full ((guint) 0, _g_object_unref0_);
			_g_ptr_array_unref0 (trailing);
			trailing = _tmp21_;
			i = pos + 1;
			_tmp22_ = self->priv->filtered_message_store;
			n = g_list_model_get_n_items ((GListModel*) _tmp22_);
			while (TRUE) {
				gboolean _tmp23_ = FALSE;
				DcMessage* next = NULL;
				GtkFilterListModel* _tmp27_;
				GObject* _tmp28_;
				DcMessage* _tmp29_;
				DcMessage* _tmp30_;
				DcMessage* _tmp31_;
				GPtrArray* _tmp32_;
				DcMessage* _tmp33_;
				DcMessage* _tmp34_;
				guint _tmp35_;
				if (i < n) {
					GPtrArray* _tmp24_;
					gint _tmp25_;
					gint _tmp26_;
					_tmp24_ = trailing;
					_tmp25_ = vala_g_ptr_array_get_length (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp23_ = _tmp26_ < 5;
				} else {
					_tmp23_ = FALSE;
				}
				if (!_tmp23_) {
					break;
				}
				_tmp27_ = self->priv->filtered_message_store;
				_tmp28_ = g_list_model_get_item ((GListModel*) _tmp27_, i);
				next = G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, DC_TYPE_MESSAGE, DcMessage);
				_tmp29_ = next;
				if (!dc_message_row_is_image_only_message (_tmp29_)) {
					_g_object_unref0 (next);
					break;
				}
				_tmp30_ = msg;
				_tmp31_ = next;
				if (!dc_message_row_same_irc_sender (_tmp30_, _tmp31_)) {
					_g_object_unref0 (next);
					break;
				}
				_tmp32_ = trailing;
				_tmp33_ = next;
				_tmp34_ = _g_object_ref0 (_tmp33_);
				g_ptr_array_add (_tmp32_, _tmp34_);
				_tmp35_ = i;
				i = _tmp35_ + 1;
				_g_object_unref0 (next);
			}
		}
	}
	_tmp36_ = msg;
	_tmp37_ = prev;
	_tmp38_ = trailing;
	_tmp39_ = dc_message_row_new (_tmp36_, _tmp37_, _tmp38_, is_img_continuation);
	g_object_ref_sink (_tmp39_);
	row = _tmp39_;
	_tmp40_ = row;
	g_signal_connect_object (_tmp40_, "quote-clicked", (GCallback) ___lambda79__dc_message_row_quote_clicked, self, 0);
	_tmp41_ = msg;
	_tmp42_ = dc_message_get_highlighted (_tmp41_);
	_tmp43_ = _tmp42_;
	if (_tmp43_) {
		DcMessage* _tmp44_;
		DcMessageRow* _tmp45_;
		_tmp44_ = msg;
		dc_message_set_highlighted (_tmp44_, FALSE);
		_tmp45_ = row;
		dc_message_row_highlight (_tmp45_);
	}
	_tmp46_ = li;
	_tmp47_ = row;
	gtk_list_item_set_child (_tmp46_, (GtkWidget*) _tmp47_);
	_tmp48_ = li;
	gtk_list_item_set_selectable (_tmp48_, FALSE);
	_tmp49_ = li;
	gtk_list_item_set_activatable (_tmp49_, FALSE);
	_g_object_unref0 (row);
	_g_ptr_array_unref0 (trailing);
	_g_object_unref0 (prev);
	_g_object_unref0 (msg);
	_g_object_unref0 (li);
}

static void
___lambda69__gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                GObject* object,
                                                gpointer self)
{
	__lambda69_ ((DcConversationView*) self, object);
}

static void
__lambda80_ (DcConversationView* self,
             gint n,
             gdouble x,
             gdouble y)
{
	DcMessageRow* row = NULL;
	DcMessageRow* _tmp0_;
	DcMessageRow* _tmp1_;
	_tmp0_ = dc_conversation_view_pick_message_row (self, x, y);
	row = _tmp0_;
	_tmp1_ = row;
	if (_tmp1_ != NULL) {
		DcMessageActions* _tmp2_;
		DcMessageRow* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		DcMessageRow* _tmp6_;
		gboolean _tmp7_;
		gboolean _tmp8_;
		GtkListView* _tmp9_;
		_tmp2_ = self->priv->_msg_actions;
		_tmp3_ = row;
		_tmp4_ = dc_message_row_get_message_id (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = row;
		_tmp7_ = dc_message_row_get_is_outgoing (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = self->priv->message_listview;
		dc_message_actions_show_context_menu (_tmp2_, _tmp5_, _tmp8_, x, y, (GtkWidget*) _tmp9_);
	}
	_g_object_unref0 (row);
}

static void
___lambda80__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                        gint n_press,
                                        gdouble x,
                                        gdouble y,
                                        gpointer self)
{
	__lambda80_ ((DcConversationView*) self, n_press, x, y);
}

static void
__lambda81_ (Block22Data* _data22_,
             gint n,
             gdouble x,
             gdouble y)
{
	DcConversationView* self;
	DcMessageRow* row = NULL;
	DcMessageRow* _tmp0_;
	DcMessageRow* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gint64 now = 0LL;
	gint dct = 0;
	GtkSettings* gs = NULL;
	GtkSettings* _tmp3_;
	GtkSettings* _tmp4_;
	GtkSettings* _tmp5_;
	gboolean _tmp9_ = FALSE;
	DcMessageRow* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	self = _data22_->self;
	_tmp0_ = dc_conversation_view_pick_message_row (self, x, y);
	row = _tmp0_;
	_tmp1_ = row;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (row);
		return;
	}
	if (dc_conversation_view_pointer_on_selectable_text (self, x, y)) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = dc_conversation_view_pointer_on_media (self, x, y);
	}
	if (_tmp2_) {
		_data22_->dc_last_id = -1;
		_data22_->dc_last_time = (gint64) 0;
		_g_object_unref0 (row);
		return;
	}
	dc_conversation_view_hold_scroll_on_focus_shift (self);
	now = g_get_monotonic_time () / 1000;
	dct = 400;
	_tmp3_ = gtk_settings_get_default ();
	_tmp4_ = _g_object_ref0 (_tmp3_);
	gs = _tmp4_;
	_tmp5_ = gs;
	if (_tmp5_ != NULL) {
		GtkSettings* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp6_ = gs;
		g_object_get (_tmp6_, "gtk-double-click-time", &_tmp7_, NULL);
		_tmp8_ = _tmp7_;
		dct = _tmp8_;
	}
	_tmp10_ = row;
	_tmp11_ = dc_message_row_get_message_id (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ == _data22_->dc_last_id) {
		_tmp9_ = (now - _data22_->dc_last_time) <= ((gint64) dct);
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		DcMessageActions* _tmp13_;
		DcMessageRow* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		_data22_->dc_last_id = -1;
		_data22_->dc_last_time = (gint64) 0;
		_tmp13_ = self->priv->_msg_actions;
		_tmp14_ = row;
		_tmp15_ = dc_message_row_get_message_id (_tmp14_);
		_tmp16_ = _tmp15_;
		dc_message_actions_handle_double_click (_tmp13_, _tmp16_);
	} else {
		DcMessageRow* _tmp17_;
		gint _tmp18_;
		gint _tmp19_;
		DcMessage* msg = NULL;
		GListStore* _tmp20_;
		DcMessageRow* _tmp21_;
		gint _tmp22_;
		gint _tmp23_;
		DcMessage* _tmp24_;
		DcMessage* _tmp25_;
		_tmp17_ = row;
		_tmp18_ = dc_message_row_get_message_id (_tmp17_);
		_tmp19_ = _tmp18_;
		_data22_->dc_last_id = _tmp19_;
		_data22_->dc_last_time = now;
		_tmp20_ = self->priv->message_store;
		_tmp21_ = row;
		_tmp22_ = dc_message_row_get_message_id (_tmp21_);
		_tmp23_ = _tmp22_;
		_tmp24_ = dc_find_message (_tmp20_, _tmp23_);
		msg = _tmp24_;
		_tmp25_ = msg;
		if (_tmp25_ != NULL) {
			DcMessage* _tmp26_;
			_tmp26_ = msg;
			dc_conversation_view_on_message_activated (self, _tmp26_);
		}
		_g_object_unref0 (msg);
	}
	_g_object_unref0 (gs);
	_g_object_unref0 (row);
}

static void
___lambda81__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                        gint n_press,
                                        gdouble x,
                                        gdouble y,
                                        gpointer self)
{
	__lambda81_ (self, n_press, x, y);
}

static void
__lambda90_ (DcConversationView* self)
{
	GtkCustomFilter* _tmp0_;
	_tmp0_ = self->priv->message_filter;
	gtk_filter_changed ((GtkFilter*) _tmp0_, GTK_FILTER_CHANGE_DIFFERENT);
}

static void
___lambda90__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                              gpointer self)
{
	__lambda90_ ((DcConversationView*) self);
}

static void
__lambda91_ (DcConversationView* self)
{
	dc_conversation_view_scroll_to_bottom (self);
}

static void
___lambda91__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda91_ ((DcConversationView*) self);
}

static void
_dc_conversation_view_on_send_message_dc_compose_bar_send_message (DcComposeBar* _sender,
                                                                   const gchar* text,
                                                                   const gchar* file_path,
                                                                   const gchar* file_name,
                                                                   gint quote_msg_id,
                                                                   gpointer self)
{
	dc_conversation_view_on_send_message ((DcConversationView*) self, text, file_path, file_name, quote_msg_id);
}

static void
__lambda92_ (DcConversationView* self,
             gint msg_id,
             const gchar* new_text)
{
	DcMessageActions* _tmp0_;
	g_return_if_fail (new_text != NULL);
	_tmp0_ = self->priv->_msg_actions;
	dc_message_actions_edit_message (_tmp0_, msg_id, new_text, NULL, NULL);
}

static void
___lambda92__dc_compose_bar_edit_message (DcComposeBar* _sender,
                                          gint msg_id,
                                          const gchar* new_text,
                                          gpointer self)
{
	__lambda92_ ((DcConversationView*) self, msg_id, new_text);
}

static void
__lambda93_ (DcConversationView* self)
{
	DcMessageActions* _tmp0_;
	_tmp0_ = self->priv->_msg_actions;
	dc_message_actions_start_editing_last (_tmp0_);
}

static void
___lambda93__dc_compose_bar_edit_last_requested (DcComposeBar* _sender,
                                                 gpointer self)
{
	__lambda93_ ((DcConversationView*) self);
}

static void
dc_conversation_view_build_ui (DcConversationView* self)
{
	Block22Data* _data22_;
	GtkScrolledWindow* _tmp0_;
	GtkScrolledWindow* _tmp1_;
	GtkScrolledWindow* _tmp2_;
	GtkScrolledWindow* _tmp3_;
	GtkAdjustment* _tmp4_;
	GtkAdjustment* _tmp5_;
	GtkScrolledWindow* _tmp6_;
	GtkAdjustment* _tmp7_;
	GtkAdjustment* _tmp8_;
	GtkScrolledWindow* _tmp9_;
	GtkAdjustment* _tmp10_;
	GtkAdjustment* _tmp11_;
	GtkCustomFilter* _tmp12_;
	GListStore* _tmp13_;
	GListModel* _tmp14_;
	GtkCustomFilter* _tmp15_;
	GtkFilter* _tmp16_;
	GtkFilterListModel* _tmp17_;
	GtkSignalListItemFactory* factory = NULL;
	GtkSignalListItemFactory* _tmp18_;
	GtkNoSelection* selection = NULL;
	GtkFilterListModel* _tmp19_;
	GListModel* _tmp20_;
	GtkNoSelection* _tmp21_;
	GtkSelectionModel* _tmp22_;
	GtkListItemFactory* _tmp23_;
	GtkListView* _tmp24_;
	GtkListView* _tmp25_;
	GtkGestureClick* rc = NULL;
	GtkGestureClick* _tmp26_;
	GtkListView* _tmp27_;
	GtkEventController* _tmp28_;
	GtkGestureClick* dc = NULL;
	GtkGestureClick* _tmp29_;
	GtkListView* _tmp30_;
	GtkEventController* _tmp31_;
	GtkScrolledWindow* _tmp32_;
	GtkListView* _tmp33_;
	GtkSearchEntry* _tmp34_;
	GtkSearchEntry* _tmp35_;
	GtkSearchEntry* _tmp36_;
	GtkSearchEntry* _tmp37_;
	GtkSearchEntry* _tmp38_;
	GtkSearchEntry* _tmp39_;
	GtkSearchEntry* _tmp40_;
	GtkSearchEntry* _tmp41_;
	GtkRevealer* _tmp42_;
	GtkRevealer* _tmp43_;
	GtkSearchEntry* _tmp44_;
	GtkRevealer* _tmp45_;
	GtkRevealer* _tmp46_;
	GtkRevealer* _tmp47_;
	DcPinnedMessagesManager* _tmp48_;
	GtkRevealer* _tmp49_;
	GtkRevealer* _tmp50_;
	GtkButton* _tmp51_;
	GtkButton* _tmp52_;
	GtkButton* _tmp53_;
	GtkButton* _tmp54_;
	GtkButton* _tmp55_;
	GtkButton* _tmp56_;
	GtkButton* _tmp57_;
	GtkButton* _tmp58_;
	GtkButton* _tmp59_;
	GtkButton* _tmp60_;
	GtkBox* loading_pill = NULL;
	GtkBox* _tmp61_;
	GtkSpinner* _tmp62_;
	GtkSpinner* _tmp63_;
	GtkLabel* _tmp64_;
	GtkLabel* _tmp65_;
	GtkRevealer* _tmp66_;
	GtkRevealer* _tmp67_;
	GtkRevealer* _tmp68_;
	GtkRevealer* _tmp69_;
	GtkRevealer* _tmp70_;
	GtkRevealer* _tmp71_;
	GtkRevealer* _tmp72_;
	GtkRevealer* _tmp73_;
	GtkOverlay* scroll_overlay = NULL;
	GtkOverlay* _tmp74_;
	GtkScrolledWindow* _tmp75_;
	GtkButton* _tmp76_;
	GtkRevealer* _tmp77_;
	DcComposeBar* _tmp78_;
	DcSettingsManager* _tmp79_;
	DcComposeBar* _tmp80_;
	DcComposeBar* _tmp81_;
	DcComposeBar* _tmp82_;
	DcComposeBar* _tmp83_;
	DcComposeBar* _tmp84_;
	GtkBox* _tmp85_;
	GtkBox* _tmp86_;
	g_return_if_fail (self != NULL);
	_data22_ = g_slice_new0 (Block22Data);
	_data22_->_ref_count_ = 1;
	_data22_->self = g_object_ref (self);
	_tmp0_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->message_scroll);
	self->priv->message_scroll = _tmp0_;
	_tmp1_ = self->priv->message_scroll;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp1_, TRUE);
	_tmp2_ = self->priv->message_scroll;
	g_object_set (_tmp2_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp3_ = self->priv->message_scroll;
	_tmp4_ = gtk_scrolled_window_get_vadjustment (_tmp3_);
	_tmp5_ = _tmp4_;
	g_signal_connect_object ((GObject*) _tmp5_, "notify::upper", (GCallback) ___lambda64__g_object_notify, self, 0);
	_tmp6_ = self->priv->message_scroll;
	_tmp7_ = gtk_scrolled_window_get_vadjustment (_tmp6_);
	_tmp8_ = _tmp7_;
	g_signal_connect_object ((GObject*) _tmp8_, "notify::page-size", (GCallback) ___lambda65__g_object_notify, self, 0);
	_tmp9_ = self->priv->message_scroll;
	_tmp10_ = gtk_scrolled_window_get_vadjustment (_tmp9_);
	_tmp11_ = _tmp10_;
	g_signal_connect_object ((GObject*) _tmp11_, "notify::value", (GCallback) ___lambda66__g_object_notify, self, 0);
	_tmp12_ = gtk_custom_filter_new (___lambda68__gtk_custom_filter_func, g_object_ref (self), g_object_unref);
	_g_object_unref0 (self->priv->message_filter);
	self->priv->message_filter = _tmp12_;
	_tmp13_ = self->priv->message_store;
	_tmp14_ = _g_object_ref0 ((GListModel*) _tmp13_);
	_tmp15_ = self->priv->message_filter;
	_tmp16_ = _g_object_ref0 ((GtkFilter*) _tmp15_);
	_tmp17_ = gtk_filter_list_model_new (_tmp14_, _tmp16_);
	_g_object_unref0 (self->priv->filtered_message_store);
	self->priv->filtered_message_store = _tmp17_;
	_tmp18_ = (GtkSignalListItemFactory*) gtk_signal_list_item_factory_new ();
	factory = _tmp18_;
	g_signal_connect_object (factory, "bind", (GCallback) ___lambda69__gtk_signal_list_item_factory_bind, self, 0);
	_tmp19_ = self->priv->filtered_message_store;
	_tmp20_ = _g_object_ref0 ((GListModel*) _tmp19_);
	_tmp21_ = gtk_no_selection_new (_tmp20_);
	selection = _tmp21_;
	_tmp22_ = _g_object_ref0 ((GtkSelectionModel*) selection);
	_tmp23_ = _g_object_ref0 ((GtkListItemFactory*) factory);
	_tmp24_ = (GtkListView*) gtk_list_view_new (_tmp22_, _tmp23_);
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->message_listview);
	self->priv->message_listview = _tmp24_;
	_tmp25_ = self->priv->message_listview;
	gtk_widget_add_css_class ((GtkWidget*) _tmp25_, "boxed-list-separate");
	_tmp26_ = (GtkGestureClick*) gtk_gesture_click_new ();
	rc = _tmp26_;
	gtk_gesture_single_set_button ((GtkGestureSingle*) rc, (guint) 3);
	g_signal_connect_object (rc, "pressed", (GCallback) ___lambda80__gtk_gesture_click_pressed, self, 0);
	_tmp27_ = self->priv->message_listview;
	_tmp28_ = _g_object_ref0 ((GtkEventController*) rc);
	gtk_widget_add_controller ((GtkWidget*) _tmp27_, _tmp28_);
	_tmp29_ = (GtkGestureClick*) gtk_gesture_click_new ();
	dc = _tmp29_;
	gtk_gesture_single_set_button ((GtkGestureSingle*) dc, (guint) 1);
	gtk_event_controller_set_propagation_phase ((GtkEventController*) dc, GTK_PHASE_CAPTURE);
	_data22_->dc_last_id = -1;
	_data22_->dc_last_time = (gint64) 0;
	g_signal_connect_data (dc, "pressed", (GCallback) ___lambda81__gtk_gesture_click_pressed, block22_data_ref (_data22_), (GClosureNotify) block22_data_unref, 0);
	_tmp30_ = self->priv->message_listview;
	_tmp31_ = _g_object_ref0 ((GtkEventController*) dc);
	gtk_widget_add_controller ((GtkWidget*) _tmp30_, _tmp31_);
	_tmp32_ = self->priv->message_scroll;
	_tmp33_ = self->priv->message_listview;
	gtk_scrolled_window_set_child (_tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = (GtkSearchEntry*) gtk_search_entry_new ();
	g_object_ref_sink (_tmp34_);
	_g_object_unref0 (self->priv->message_search_entry);
	self->priv->message_search_entry = _tmp34_;
	_tmp35_ = self->priv->message_search_entry;
	g_object_set (_tmp35_, "placeholder-text", "Search in conversation\u2026", NULL);
	_tmp36_ = self->priv->message_search_entry;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp36_, TRUE);
	_tmp37_ = self->priv->message_search_entry;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp37_, 8);
	_tmp38_ = self->priv->message_search_entry;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp38_, 8);
	_tmp39_ = self->priv->message_search_entry;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp39_, 4);
	_tmp40_ = self->priv->message_search_entry;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp40_, 4);
	_tmp41_ = self->priv->message_search_entry;
	g_signal_connect_object (_tmp41_, "search-changed", (GCallback) ___lambda90__gtk_search_entry_search_changed, self, 0);
	_tmp42_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp42_);
	_g_object_unref0 (self->priv->message_search_revealer);
	self->priv->message_search_revealer = _tmp42_;
	_tmp43_ = self->priv->message_search_revealer;
	_tmp44_ = self->priv->message_search_entry;
	gtk_revealer_set_child (_tmp43_, (GtkWidget*) _tmp44_);
	_tmp45_ = self->priv->message_search_revealer;
	gtk_revealer_set_reveal_child (_tmp45_, FALSE);
	_tmp46_ = self->priv->message_search_revealer;
	gtk_revealer_set_transition_type (_tmp46_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
	_tmp47_ = self->priv->message_search_revealer;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp47_);
	_tmp48_ = self->priv->_pinned;
	_tmp49_ = dc_pinned_messages_manager_get_revealer (_tmp48_);
	_tmp50_ = _tmp49_;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp50_);
	_tmp51_ = (GtkButton*) gtk_button_new ();
	g_object_ref_sink (_tmp51_);
	_g_object_unref0 (self->priv->scroll_down_btn);
	self->priv->scroll_down_btn = _tmp51_;
	_tmp52_ = self->priv->scroll_down_btn;
	gtk_button_set_icon_name (_tmp52_, "go-down-symbolic");
	_tmp53_ = self->priv->scroll_down_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp53_, "circular");
	_tmp54_ = self->priv->scroll_down_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp54_, "osd");
	_tmp55_ = self->priv->scroll_down_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp55_, "scroll-down-btn");
	_tmp56_ = self->priv->scroll_down_btn;
	gtk_widget_set_halign ((GtkWidget*) _tmp56_, GTK_ALIGN_CENTER);
	_tmp57_ = self->priv->scroll_down_btn;
	gtk_widget_set_valign ((GtkWidget*) _tmp57_, GTK_ALIGN_END);
	_tmp58_ = self->priv->scroll_down_btn;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp58_, 12);
	_tmp59_ = self->priv->scroll_down_btn;
	gtk_widget_set_visible ((GtkWidget*) _tmp59_, FALSE);
	_tmp60_ = self->priv->scroll_down_btn;
	g_signal_connect_object (_tmp60_, "clicked", (GCallback) ___lambda91__gtk_button_clicked, self, 0);
	_tmp61_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp61_);
	loading_pill = _tmp61_;
	gtk_widget_add_css_class ((GtkWidget*) loading_pill, "osd");
	gtk_widget_add_css_class ((GtkWidget*) loading_pill, "loading-pill");
	_tmp62_ = (GtkSpinner*) gtk_spinner_new ();
	g_object_ref_sink (_tmp62_);
	_g_object_unref0 (self->priv->loading_more_spinner);
	self->priv->loading_more_spinner = _tmp62_;
	_tmp63_ = self->priv->loading_more_spinner;
	gtk_box_append (loading_pill, (GtkWidget*) _tmp63_);
	_tmp64_ = (GtkLabel*) gtk_label_new ("Loading…");
	g_object_ref_sink (_tmp64_);
	_tmp65_ = _tmp64_;
	gtk_box_append (loading_pill, (GtkWidget*) _tmp65_);
	_g_object_unref0 (_tmp65_);
	_tmp66_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp66_);
	_g_object_unref0 (self->priv->loading_more_revealer);
	self->priv->loading_more_revealer = _tmp66_;
	_tmp67_ = self->priv->loading_more_revealer;
	gtk_revealer_set_child (_tmp67_, (GtkWidget*) loading_pill);
	_tmp68_ = self->priv->loading_more_revealer;
	gtk_revealer_set_reveal_child (_tmp68_, FALSE);
	_tmp69_ = self->priv->loading_more_revealer;
	gtk_revealer_set_transition_type (_tmp69_, GTK_REVEALER_TRANSITION_TYPE_CROSSFADE);
	_tmp70_ = self->priv->loading_more_revealer;
	gtk_widget_set_halign ((GtkWidget*) _tmp70_, GTK_ALIGN_CENTER);
	_tmp71_ = self->priv->loading_more_revealer;
	gtk_widget_set_valign ((GtkWidget*) _tmp71_, GTK_ALIGN_START);
	_tmp72_ = self->priv->loading_more_revealer;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp72_, 12);
	_tmp73_ = self->priv->loading_more_revealer;
	gtk_widget_set_can_target ((GtkWidget*) _tmp73_, FALSE);
	_tmp74_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp74_);
	scroll_overlay = _tmp74_;
	_tmp75_ = self->priv->message_scroll;
	gtk_overlay_set_child (scroll_overlay, (GtkWidget*) _tmp75_);
	gtk_widget_set_vexpand ((GtkWidget*) scroll_overlay, TRUE);
	_tmp76_ = self->priv->scroll_down_btn;
	gtk_overlay_add_overlay (scroll_overlay, (GtkWidget*) _tmp76_);
	_tmp77_ = self->priv->loading_more_revealer;
	gtk_overlay_add_overlay (scroll_overlay, (GtkWidget*) _tmp77_);
	gtk_box_append ((GtkBox*) self, (GtkWidget*) scroll_overlay);
	_tmp78_ = dc_compose_bar_new ();
	g_object_ref_sink (_tmp78_);
	_g_object_unref0 (self->priv->compose_bar);
	self->priv->compose_bar = _tmp78_;
	_tmp79_ = self->priv->settings;
	_tmp80_ = self->priv->compose_bar;
	g_object_bind_property_with_closures ((GObject*) _tmp79_, "shift-enter-sends", (GObject*) _tmp80_, "shift-enter-sends", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp81_ = self->priv->compose_bar;
	g_signal_connect_object (_tmp81_, "send-message", (GCallback) _dc_conversation_view_on_send_message_dc_compose_bar_send_message, self, 0);
	_tmp82_ = self->priv->compose_bar;
	g_signal_connect_object (_tmp82_, "edit-message", (GCallback) ___lambda92__dc_compose_bar_edit_message, self, 0);
	_tmp83_ = self->priv->compose_bar;
	g_signal_connect_object (_tmp83_, "edit-last-requested", (GCallback) ___lambda93__dc_compose_bar_edit_last_requested, self, 0);
	_tmp84_ = self->priv->compose_bar;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp84_);
	_tmp85_ = dc_conversation_view_build_request_bar (self);
	_g_object_unref0 (self->priv->request_bar);
	self->priv->request_bar = _tmp85_;
	_tmp86_ = self->priv->request_bar;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp86_);
	dc_conversation_view_install_file_drop_target (self);
	_g_object_unref0 (scroll_overlay);
	_g_object_unref0 (loading_pill);
	_g_object_unref0 (dc);
	_g_object_unref0 (rc);
	_g_object_unref0 (selection);
	_g_object_unref0 (factory);
	block22_data_unref (_data22_);
	_data22_ = NULL;
}

static void
__lambda94_ (DcConversationView* self)
{
	dc_conversation_view_block_request (self, NULL, NULL);
}

static void
___lambda94__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda94_ ((DcConversationView*) self);
}

static void
__lambda95_ (DcConversationView* self)
{
	dc_conversation_view_accept_request (self, NULL, NULL);
}

static void
___lambda95__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda95_ ((DcConversationView*) self);
}

static GtkBox*
dc_conversation_view_build_request_bar (DcConversationView* self)
{
	GtkBox* bar = NULL;
	GtkBox* _tmp0_;
	GtkLabel* notice = NULL;
	GtkLabel* _tmp1_;
	GtkBox* buttons = NULL;
	GtkBox* _tmp2_;
	GtkButton* block_btn = NULL;
	GtkButton* _tmp3_;
	GtkButton* accept_btn = NULL;
	GtkButton* _tmp4_;
	GtkBox* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_tmp0_);
	bar = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) bar, "contact-request-bar");
	gtk_widget_set_margin_start ((GtkWidget*) bar, 8);
	gtk_widget_set_margin_end ((GtkWidget*) bar, 8);
	gtk_widget_set_margin_top ((GtkWidget*) bar, 8);
	gtk_widget_set_margin_bottom ((GtkWidget*) bar, 8);
	gtk_widget_set_visible ((GtkWidget*) bar, FALSE);
	_tmp1_ = (GtkLabel*) gtk_label_new ("This chat is a contact request. " "Accept it to reply, or block the sender.");
	g_object_ref_sink (_tmp1_);
	notice = _tmp1_;
	gtk_widget_add_css_class ((GtkWidget*) notice, "dim-label");
	gtk_label_set_wrap (notice, TRUE);
	gtk_label_set_justify (notice, GTK_JUSTIFY_CENTER);
	gtk_widget_set_halign ((GtkWidget*) notice, GTK_ALIGN_CENTER);
	gtk_box_append (bar, (GtkWidget*) notice);
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	g_object_ref_sink (_tmp2_);
	buttons = _tmp2_;
	gtk_widget_set_halign ((GtkWidget*) buttons, GTK_ALIGN_CENTER);
	_tmp3_ = (GtkButton*) gtk_button_new_with_label ("Block");
	g_object_ref_sink (_tmp3_);
	block_btn = _tmp3_;
	gtk_widget_add_css_class ((GtkWidget*) block_btn, "destructive-action");
	gtk_widget_add_css_class ((GtkWidget*) block_btn, "pill");
	g_signal_connect_object (block_btn, "clicked", (GCallback) ___lambda94__gtk_button_clicked, self, 0);
	gtk_box_append (buttons, (GtkWidget*) block_btn);
	_tmp4_ = (GtkButton*) gtk_button_new_with_label ("Accept");
	g_object_ref_sink (_tmp4_);
	accept_btn = _tmp4_;
	gtk_widget_add_css_class ((GtkWidget*) accept_btn, "suggested-action");
	gtk_widget_add_css_class ((GtkWidget*) accept_btn, "pill");
	g_signal_connect_object (accept_btn, "clicked", (GCallback) ___lambda95__gtk_button_clicked, self, 0);
	gtk_box_append (buttons, (GtkWidget*) accept_btn);
	gtk_box_append (bar, (GtkWidget*) buttons);
	result = bar;
	_g_object_unref0 (accept_btn);
	_g_object_unref0 (block_btn);
	_g_object_unref0 (buttons);
	_g_object_unref0 (notice);
	return result;
}

void
dc_conversation_view_set_contact_request (DcConversationView* self,
                                          gboolean is_request)
{
	GtkBox* _tmp0_;
	DcComposeBar* _tmp1_;
	g_return_if_fail (self != NULL);
	self->priv->is_contact_request = is_request;
	_tmp0_ = self->priv->request_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, is_request);
	_tmp1_ = self->priv->compose_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp1_, !is_request);
}

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

static void
dc_conversation_view_accept_request (DcConversationView* self,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	DcConversationViewAcceptRequestData* _data_;
	DcConversationView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcConversationViewAcceptRequestData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_accept_request_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_conversation_view_accept_request_co (_data_);
}

static void
dc_conversation_view_accept_request_finish (DcConversationView* self,
                                            GAsyncResult* _res_)
{
	DcConversationViewAcceptRequestData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_conversation_view_accept_request_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	DcConversationViewAcceptRequestData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_accept_request_co (_data_);
}

static gboolean
dc_conversation_view_accept_request_co (DcConversationViewAcceptRequestData* _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->rpc;
		_data_->_tmp1_ = _data_->self->priv->_chat_id;
		_data_->_state_ = 1;
		dc_rpc_client_accept_chat (_data_->_tmp0_, _data_->_tmp1_, dc_conversation_view_accept_request_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_accept_chat_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		dc_conversation_view_set_contact_request (_data_->self, FALSE);
		_data_->_tmp2_ = _data_->self->priv->compose_bar;
		dc_compose_bar_grab_entry_focus (_data_->_tmp2_);
		_data_->_tmp3_ = _data_->self->priv->window;
		dc_window_request_reload_chats (_data_->_tmp3_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp4_ = _data_->self->priv->window;
		_data_->_tmp5_ = _data_->e;
		_data_->_tmp6_ = _data_->_tmp5_->message;
		_data_->_tmp7_ = g_strconcat ("Failed to accept request: ", _data_->_tmp6_, NULL);
		_data_->_tmp8_ = _data_->_tmp7_;
		dc_window_show_toast (_data_->_tmp4_, _data_->_tmp8_);
		_g_free0 (_data_->_tmp8_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_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
dc_conversation_view_block_request_data_free (gpointer _data)
{
	DcConversationViewBlockRequestData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcConversationViewBlockRequestData, _data_);
}

static void
dc_conversation_view_block_request (DcConversationView* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	DcConversationViewBlockRequestData* _data_;
	DcConversationView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcConversationViewBlockRequestData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_block_request_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_conversation_view_block_request_co (_data_);
}

static void
dc_conversation_view_block_request_finish (DcConversationView* self,
                                           GAsyncResult* _res_)
{
	DcConversationViewBlockRequestData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_conversation_view_block_request_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	DcConversationViewBlockRequestData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_block_request_co (_data_);
}

static gboolean
dc_conversation_view_block_request_co (DcConversationViewBlockRequestData* _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->rpc;
		_data_->_tmp1_ = _data_->self->priv->_chat_id;
		_data_->_state_ = 1;
		dc_rpc_client_block_chat (_data_->_tmp0_, _data_->_tmp1_, dc_conversation_view_block_request_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_block_chat_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->self->priv->window;
		_data_->_tmp3_ = dc_window_get_current_chat_id (_data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = _data_->self->priv->_chat_id;
		if (_data_->_tmp4_ == _data_->_tmp5_) {
			_data_->_tmp6_ = _data_->self->priv->window;
			dc_window_clear_chat_view (_data_->_tmp6_);
		}
		_data_->_tmp7_ = _data_->self->priv->window;
		dc_window_request_reload_chats (_data_->_tmp7_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp8_ = _data_->self->priv->window;
		_data_->_tmp9_ = _data_->e;
		_data_->_tmp10_ = _data_->_tmp9_->message;
		_data_->_tmp11_ = g_strconcat ("Failed to block request: ", _data_->_tmp10_, NULL);
		_data_->_tmp12_ = _data_->_tmp11_;
		dc_window_show_toast (_data_->_tmp8_, _data_->_tmp12_);
		_g_free0 (_data_->_tmp12_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
dc_conversation_view_on_activated (DcConversationView* self)
{
	g_return_if_fail (self != NULL);
	if (!self->priv->messages_loaded) {
		self->priv->messages_loaded = TRUE;
		dc_conversation_view_load_messages (self, FALSE, NULL, NULL);
	}
	if (!self->priv->is_contact_request) {
		DcComposeBar* _tmp0_;
		_tmp0_ = self->priv->compose_bar;
		dc_compose_bar_grab_entry_focus (_tmp0_);
	}
}

void
dc_conversation_view_on_reselected (DcConversationView* self)
{
	DcComposeBar* _tmp0_;
	g_return_if_fail (self != NULL);
	dc_conversation_view_scroll_to_bottom (self);
	_tmp0_ = self->priv->compose_bar;
	dc_compose_bar_grab_entry_focus (_tmp0_);
}

void
dc_conversation_view_attach_dropped_file_path (DcConversationView* self,
                                               const gchar* path)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = g_path_get_basename (path);
	_tmp1_ = _tmp0_;
	dc_conversation_view_attach_local_file (self, path, _tmp1_);
	_g_free0 (_tmp1_);
}

void
dc_conversation_view_focus_entry (DcConversationView* self)
{
	DcComposeBar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->compose_bar;
	dc_compose_bar_grab_entry_focus (_tmp0_);
}

gboolean
dc_conversation_view_has_active_compose_mode (DcConversationView* self)
{
	DcComposeBar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->compose_bar;
	result = dc_compose_bar_has_active_mode (_tmp0_);
	return result;
}

gboolean
dc_conversation_view_compose_entry_has_focus (DcConversationView* self)
{
	DcComposeBar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->compose_bar;
	result = dc_compose_bar_entry_has_focus (_tmp0_);
	return result;
}

void
dc_conversation_view_cancel_active_compose_mode (DcConversationView* self)
{
	DcComposeBar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->compose_bar;
	dc_compose_bar_cancel_active_mode (_tmp0_);
}

void
dc_conversation_view_type_into_entry (DcConversationView* self,
                                      const gchar* text)
{
	DcComposeBar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->compose_bar;
	dc_compose_bar_type_text (_tmp0_, text);
}

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

void
dc_conversation_view_reload_messages (DcConversationView* self,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	DcConversationViewReloadMessagesData* _data_;
	DcConversationView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcConversationViewReloadMessagesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_reload_messages_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_conversation_view_reload_messages_co (_data_);
}

void
dc_conversation_view_reload_messages_finish (DcConversationView* self,
                                             GAsyncResult* _res_)
{
	DcConversationViewReloadMessagesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_conversation_view_reload_messages_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	DcConversationViewReloadMessagesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_reload_messages_co (_data_);
}

static gboolean
dc_conversation_view_reload_messages_co (DcConversationViewReloadMessagesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	dc_conversation_view_load_messages (_data_->self, TRUE, dc_conversation_view_reload_messages_ready, _data_);
	return FALSE;
	_state_1:
	dc_conversation_view_load_messages_finish (_data_->self, _data_->_res_);
	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
dc_conversation_view_handle_incoming_msg_data_free (gpointer _data)
{
	DcConversationViewHandleIncomingMsgData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcConversationViewHandleIncomingMsgData, _data_);
}

void
dc_conversation_view_handle_incoming_msg (DcConversationView* self,
                                          gint msg_id,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	DcConversationViewHandleIncomingMsgData* _data_;
	DcConversationView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcConversationViewHandleIncomingMsgData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_handle_incoming_msg_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->msg_id = msg_id;
	dc_conversation_view_handle_incoming_msg_co (_data_);
}

void
dc_conversation_view_handle_incoming_msg_finish (DcConversationView* self,
                                                 GAsyncResult* _res_)
{
	DcConversationViewHandleIncomingMsgData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_conversation_view_handle_incoming_msg_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	DcConversationViewHandleIncomingMsgData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_handle_incoming_msg_co (_data_);
}

static void
_vala_array_add5 (gint* * array,
                  gint* length,
                  gint* size,
                  gint value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gint, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static gboolean
dc_conversation_view_handle_incoming_msg_co (DcConversationViewHandleIncomingMsgData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_fetch_message (_data_->_tmp0_, _data_->msg_id, dc_conversation_view_handle_incoming_msg_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = dc_rpc_client_fetch_message_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		_data_->msg = _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->msg;
		if (_data_->_tmp2_ == NULL) {
			_g_object_unref0 (_data_->msg);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp3_ = _data_->self->priv->window;
		_data_->_tmp4_ = dc_window_get_current_chat_id (_data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp6_ = _data_->self->priv->_chat_id;
		_data_->is_current = _data_->_tmp5_ == _data_->_tmp6_;
		if (_data_->is_current) {
			_data_->_tmp7_ = _data_->msg;
			dc_message_set_highlighted (_data_->_tmp7_, TRUE);
		}
		_data_->_tmp8_ = _data_->msg;
		_data_->_tmp9_ = _data_->self->priv->_pinned;
		_data_->_tmp10_ = _data_->msg;
		_data_->_tmp11_ = dc_message_get_id (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		dc_message_set_is_pinned (_data_->_tmp8_, dc_pinned_messages_manager_is_pinned (_data_->_tmp9_, _data_->_tmp12_));
		_data_->_tmp13_ = _data_->msg;
		dc_conversation_view_insert_message_sorted (_data_->self, _data_->_tmp13_);
		if (_data_->is_current) {
			_data_->_tmp15_ = _data_->self->priv->window;
			g_object_get ((GtkWindow*) _data_->_tmp15_, "is-active", &_data_->_tmp16_, NULL);
			_data_->_tmp17_ = _data_->_tmp16_;
			_data_->_tmp14_ = _data_->_tmp17_;
		} else {
			_data_->_tmp14_ = FALSE;
		}
		if (_data_->_tmp14_) {
			_data_->_tmp18_ = _data_->self->priv->rpc;
			_data_->_tmp19_ = g_new0 (gint, 1);
			_data_->_tmp19_[0] = _data_->msg_id;
			_data_->_tmp20_ = _data_->_tmp19_;
			_data_->_tmp20__length1 = 1;
			_data_->_state_ = 2;
			dc_rpc_client_mark_seen_msgs (_data_->_tmp18_, _data_->_tmp20_, (gint) 1, dc_conversation_view_handle_incoming_msg_ready, _data_);
			return FALSE;
			_state_2:
			dc_rpc_client_mark_seen_msgs_finish (_data_->_tmp18_, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp20_ = (g_free (_data_->_tmp20_), NULL);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->msg);
				goto __catch0_g_error;
			}
		} else {
			if (_data_->is_current) {
				_vala_array_add5 (&_data_->self->priv->pending_seen_ids, &_data_->self->priv->pending_seen_ids_length1, &_data_->self->priv->_pending_seen_ids_size_, _data_->msg_id);
			}
		}
		_g_object_unref0 (_data_->msg);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp21_ = _data_->e;
		_data_->_tmp22_ = _data_->_tmp21_->message;
		g_warning ("conversation_view.vala:425: handle_incoming_msg: %s", _data_->_tmp22_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_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 gint*
_vala_array_dup2 (gint* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gint));
	}
	return NULL;
}

static void
__lambda61_ (DcConversationView* self,
             GObject* o,
             GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		DcRpcClient* _tmp0_;
		_tmp0_ = self->priv->rpc;
		dc_rpc_client_mark_seen_msgs_finish (_tmp0_, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda61__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda61_ ((DcConversationView*) self, source_object, res);
	g_object_unref (self);
}

void
dc_conversation_view_flush_pending_seen (DcConversationView* self)
{
	gint* _tmp0_;
	gint _tmp0__length1;
	gint* ids = NULL;
	gint* _tmp1_;
	gint _tmp1__length1;
	gint* _tmp2_;
	gint _tmp2__length1;
	gint ids_length1;
	gint _ids_size_;
	gint* _tmp3_;
	DcRpcClient* _tmp4_;
	gint* _tmp5_;
	gint _tmp5__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->pending_seen_ids;
	_tmp0__length1 = self->priv->pending_seen_ids_length1;
	if (_tmp0__length1 == 0) {
		return;
	}
	_tmp1_ = self->priv->pending_seen_ids;
	_tmp1__length1 = self->priv->pending_seen_ids_length1;
	_tmp2_ = (_tmp1_ != NULL) ? _vala_array_dup2 (_tmp1_, _tmp1__length1) : _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	ids = _tmp2_;
	ids_length1 = _tmp2__length1;
	_ids_size_ = ids_length1;
	_tmp3_ = g_new0 (gint, 0);
	self->priv->pending_seen_ids = (g_free (self->priv->pending_seen_ids), NULL);
	self->priv->pending_seen_ids = _tmp3_;
	self->priv->pending_seen_ids_length1 = 0;
	self->priv->_pending_seen_ids_size_ = self->priv->pending_seen_ids_length1;
	_tmp4_ = self->priv->rpc;
	_tmp5_ = ids;
	_tmp5__length1 = ids_length1;
	dc_rpc_client_mark_seen_msgs (_tmp4_, _tmp5_, (gint) _tmp5__length1, ___lambda61__gasync_ready_callback, g_object_ref (self));
	ids = (g_free (ids), NULL);
}

static gboolean
___lambda97_ (DcConversationView* self)
{
	GtkSearchEntry* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->message_search_entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	self->priv->search_toggling = FALSE;
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda97__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda97_ ((DcConversationView*) self);
	return result;
}

static gboolean
___lambda98_ (DcConversationView* self)
{
	gboolean result;
	self->priv->search_toggling = FALSE;
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda98__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda98_ ((DcConversationView*) self);
	return result;
}

void
dc_conversation_view_toggle_search (DcConversationView* self)
{
	gboolean was_active = FALSE;
	GtkRevealer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	GtkRevealer* _tmp3_;
	g_return_if_fail (self != NULL);
	if (self->priv->search_toggling) {
		return;
	}
	self->priv->search_toggling = TRUE;
	_tmp0_ = self->priv->message_search_revealer;
	_tmp1_ = gtk_revealer_get_reveal_child (_tmp0_);
	_tmp2_ = _tmp1_;
	was_active = _tmp2_;
	_tmp3_ = self->priv->message_search_revealer;
	gtk_revealer_set_reveal_child (_tmp3_, !was_active);
	if (!was_active) {
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda97__gsource_func, g_object_ref (self), g_object_unref);
	} else {
		GtkSearchEntry* _tmp4_;
		_tmp4_ = self->priv->message_search_entry;
		gtk_editable_set_text ((GtkEditable*) _tmp4_, "");
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda98__gsource_func, g_object_ref (self), g_object_unref);
	}
}

/**
         * Replace a single message in the store while keeping the visible
         * scroll position unchanged. Used by reaction/edit updates that
         * resize a row but should not jump the viewport.
         */
static Block23Data*
block23_data_ref (Block23Data* _data23_)
{
	g_atomic_int_inc (&_data23_->_ref_count_);
	return _data23_;
}

static void
block23_data_unref (void * _userdata_)
{
	Block23Data* _data23_;
	_data23_ = (Block23Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data23_->_ref_count_)) {
		DcConversationView* self;
		self = _data23_->self;
		_g_object_unref0 (self);
		g_slice_free (Block23Data, _data23_);
	}
}

static gboolean
__lambda42_ (Block23Data* _data23_,
             GtkWidget* w,
             GdkFrameClock* clock)
{
	DcConversationView* self;
	GtkAdjustment* a = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	gdouble max_value = 0.0;
	GtkAdjustment* _tmp4_;
	gdouble _tmp5_;
	gdouble _tmp6_;
	GtkAdjustment* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	gdouble _tmp10_ = 0.0;
	gdouble target = 0.0;
	gdouble _tmp11_ = 0.0;
	GtkAdjustment* _tmp12_;
	GtkButton* _tmp13_;
	gboolean result;
	self = _data23_->self;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (clock != NULL, FALSE);
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	a = _tmp3_;
	_tmp4_ = a;
	_tmp5_ = gtk_adjustment_get_upper (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = a;
	_tmp8_ = gtk_adjustment_get_page_size (_tmp7_);
	_tmp9_ = _tmp8_;
	max_value = _tmp6_ - _tmp9_;
	if (max_value < ((gdouble) 0)) {
		max_value = (gdouble) 0;
	}
	if (_data23_->was_at_bottom) {
		_tmp10_ = max_value;
	} else {
		_tmp10_ = _data23_->saved_value;
	}
	target = _tmp10_;
	if (target > max_value) {
		_tmp11_ = max_value;
	} else {
		_tmp11_ = target;
	}
	_tmp12_ = a;
	gtk_adjustment_set_value (_tmp12_, _tmp11_);
	self->priv->loading_chat = _data23_->was_loading;
	self->priv->stick_to_bottom = _data23_->was_at_bottom;
	_tmp13_ = self->priv->scroll_down_btn;
	gtk_widget_set_visible ((GtkWidget*) _tmp13_, !dc_conversation_view_is_near_bottom (self));
	result = G_SOURCE_REMOVE;
	_g_object_unref0 (a);
	return result;
}

static gboolean
___lambda42__gtk_tick_callback (GtkWidget* widget,
                                GdkFrameClock* frame_clock,
                                gpointer self)
{
	gboolean result;
	result = __lambda42_ (self, widget, frame_clock);
	return result;
}

void
dc_conversation_view_replace_message (DcConversationView* self,
                                      gint msg_id,
                                      DcMessage* new_msg)
{
	Block23Data* _data23_;
	gint idx = 0;
	GListStore* _tmp0_;
	GtkAdjustment* adj = NULL;
	GtkScrolledWindow* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	GtkAdjustment* _tmp4_;
	GtkAdjustment* _tmp5_;
	gdouble _tmp6_;
	gdouble _tmp7_;
	GObject** replacements = NULL;
	GObject* _tmp8_;
	GObject** _tmp9_;
	gint replacements_length1;
	gint _replacements_size_;
	GListStore* _tmp10_;
	GObject** _tmp11_;
	gint _tmp11__length1;
	GtkListView* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (new_msg != NULL);
	_data23_ = g_slice_new0 (Block23Data);
	_data23_->_ref_count_ = 1;
	_data23_->self = g_object_ref (self);
	_tmp0_ = self->priv->message_store;
	idx = dc_find_message_index (_tmp0_, msg_id);
	if (idx < 0) {
		block23_data_unref (_data23_);
		_data23_ = NULL;
		return;
	}
	_tmp1_ = self->priv->message_scroll;
	_tmp2_ = gtk_scrolled_window_get_vadjustment (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	adj = _tmp4_;
	_tmp5_ = adj;
	_tmp6_ = gtk_adjustment_get_value (_tmp5_);
	_tmp7_ = _tmp6_;
	_data23_->saved_value = _tmp7_;
	_data23_->was_at_bottom = dc_conversation_view_is_near_bottom (self);
	_data23_->was_loading = self->priv->loading_chat;
	self->priv->loading_chat = TRUE;
	dc_conversation_view_freeze_scroll_handler (self, (guint) 700);
	_tmp8_ = _g_object_ref0 ((GObject*) new_msg);
	_tmp9_ = g_new0 (GObject*, 1 + 1);
	_tmp9_[0] = _tmp8_;
	replacements = _tmp9_;
	replacements_length1 = 1;
	_replacements_size_ = replacements_length1;
	_tmp10_ = self->priv->message_store;
	_tmp11_ = replacements;
	_tmp11__length1 = replacements_length1;
	g_list_store_splice (_tmp10_, (guint) idx, (guint) 1, _tmp11_, (guint) _tmp11__length1);
	_tmp12_ = self->priv->message_listview;
	gtk_widget_add_tick_callback ((GtkWidget*) _tmp12_, ___lambda42__gtk_tick_callback, block23_data_ref (_data23_), block23_data_unref);
	replacements = (_vala_array_free (replacements, replacements_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (adj);
	block23_data_unref (_data23_);
	_data23_ = NULL;
}

/**
         * Suppress the value-notify handler's "near top / near bottom"
         * recalculation for `ms` milliseconds. Used to silence spurious
         * scroll movements triggered by popovers, focus shifts, or row
         * resizes after a reaction / edit.
         */
void
dc_conversation_view_freeze_scroll_handler (DcConversationView* self,
                                            guint ms)
{
	gint64 until = 0LL;
	g_return_if_fail (self != NULL);
	until = g_get_monotonic_time () + (((gint64) ms) * 1000);
	if (until > self->priv->scroll_freeze_until_us) {
		self->priv->scroll_freeze_until_us = until;
	}
}

gdouble
dc_conversation_view_get_scroll_value (DcConversationView* self)
{
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	gdouble _tmp3_;
	gdouble _tmp4_;
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_adjustment_get_value (_tmp2_);
	_tmp4_ = _tmp3_;
	result = _tmp4_;
	return result;
}

void
dc_conversation_view_restore_scroll_value (DcConversationView* self,
                                           gdouble v)
{
	GtkAdjustment* a = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	gdouble max_value = 0.0;
	GtkAdjustment* _tmp4_;
	gdouble _tmp5_;
	gdouble _tmp6_;
	GtkAdjustment* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	GtkAdjustment* _tmp10_;
	gdouble _tmp11_;
	gdouble _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	a = _tmp3_;
	_tmp4_ = a;
	_tmp5_ = gtk_adjustment_get_upper (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = a;
	_tmp8_ = gtk_adjustment_get_page_size (_tmp7_);
	_tmp9_ = _tmp8_;
	max_value = _tmp6_ - _tmp9_;
	if (max_value < ((gdouble) 0)) {
		max_value = (gdouble) 0;
	}
	if (v > max_value) {
		v = max_value;
	}
	_tmp10_ = a;
	_tmp11_ = gtk_adjustment_get_value (_tmp10_);
	_tmp12_ = _tmp11_;
	if (fabs (_tmp12_ - v) > 0.5) {
		GtkAdjustment* _tmp13_;
		_tmp13_ = a;
		gtk_adjustment_set_value (_tmp13_, v);
	}
	_g_object_unref0 (a);
}

/**
         * Re-assert a scroll position on the next frame, after any
         * focus-driven scroll-to-item has been applied. GtkListView scrolls a
         * newly focused row into view immediately (a synchronous re-anchor),
         * so a synchronous restore loses the race; a tick callback runs in the
         * frame-clock update phase — after the focus scroll, before paint —
         * and re-pins the viewport with no visible flicker. The freeze keeps
         * the value-notify handler from mistaking these moves for the user
         * scrolling away from the bottom.
         */
static Block24Data*
block24_data_ref (Block24Data* _data24_)
{
	g_atomic_int_inc (&_data24_->_ref_count_);
	return _data24_;
}

static void
block24_data_unref (void * _userdata_)
{
	Block24Data* _data24_;
	_data24_ = (Block24Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data24_->_ref_count_)) {
		DcConversationView* self;
		self = _data24_->self;
		_g_object_unref0 (self);
		g_slice_free (Block24Data, _data24_);
	}
}

static gboolean
__lambda44_ (Block24Data* _data24_,
             GtkWidget* w,
             GdkFrameClock* clock)
{
	DcConversationView* self;
	gboolean result;
	self = _data24_->self;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (clock != NULL, FALSE);
	dc_conversation_view_restore_scroll_value (self, _data24_->v);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda44__gtk_tick_callback (GtkWidget* widget,
                                GdkFrameClock* frame_clock,
                                gpointer self)
{
	gboolean result;
	result = __lambda44_ (self, widget, frame_clock);
	return result;
}

void
dc_conversation_view_restore_scroll_value_deferred (DcConversationView* self,
                                                    gdouble v)
{
	Block24Data* _data24_;
	GtkListView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data24_ = g_slice_new0 (Block24Data);
	_data24_->_ref_count_ = 1;
	_data24_->self = g_object_ref (self);
	_data24_->v = v;
	dc_conversation_view_freeze_scroll_handler (self, (guint) 250);
	_tmp0_ = self->priv->message_listview;
	gtk_widget_add_tick_callback ((GtkWidget*) _tmp0_, ___lambda44__gtk_tick_callback, block24_data_ref (_data24_), block24_data_unref);
	block24_data_unref (_data24_);
	_data24_ = NULL;
}

static void
dc_conversation_view_hold_scroll_on_focus_shift (DcConversationView* self)
{
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	gdouble _tmp3_;
	gdouble _tmp4_;
	g_return_if_fail (self != NULL);
	if (self->priv->stick_to_bottom) {
		return;
	}
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_adjustment_get_value (_tmp2_);
	_tmp4_ = _tmp3_;
	dc_conversation_view_restore_scroll_value_deferred (self, _tmp4_);
}

gboolean
dc_conversation_view_close_search_if_active (DcConversationView* self)
{
	GtkRevealer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	GtkRevealer* _tmp3_;
	GtkSearchEntry* _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->message_search_revealer;
	_tmp1_ = gtk_revealer_get_reveal_child (_tmp0_);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		result = FALSE;
		return result;
	}
	_tmp3_ = self->priv->message_search_revealer;
	gtk_revealer_set_reveal_child (_tmp3_, FALSE);
	_tmp4_ = self->priv->message_search_entry;
	gtk_editable_set_text ((GtkEditable*) _tmp4_, "");
	result = TRUE;
	return result;
}

void
dc_conversation_view_scroll_to_message (DcConversationView* self,
                                        gint msg_id)
{
	gint pos = 0;
	DcMessage* msg = NULL;
	GtkFilterListModel* _tmp8_;
	GObject* _tmp9_;
	DcMessage* _tmp10_;
	GtkListView* _tmp11_;
	g_return_if_fail (self != NULL);
	pos = -1;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GtkFilterListModel* _tmp2_;
				DcMessage* m = NULL;
				GtkFilterListModel* _tmp3_;
				GObject* _tmp4_;
				DcMessage* _tmp5_;
				gint _tmp6_;
				gint _tmp7_;
				if (!_tmp0_) {
					guint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->filtered_message_store;
				if (!(i < g_list_model_get_n_items ((GListModel*) _tmp2_))) {
					break;
				}
				_tmp3_ = self->priv->filtered_message_store;
				_tmp4_ = g_list_model_get_item ((GListModel*) _tmp3_, i);
				m = G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, DC_TYPE_MESSAGE, DcMessage);
				_tmp5_ = m;
				_tmp6_ = dc_message_get_id (_tmp5_);
				_tmp7_ = _tmp6_;
				if (_tmp7_ == msg_id) {
					pos = (gint) i;
					_g_object_unref0 (m);
					break;
				}
				_g_object_unref0 (m);
			}
		}
	}
	if (pos < 0) {
		return;
	}
	_tmp8_ = self->priv->filtered_message_store;
	_tmp9_ = g_list_model_get_item ((GListModel*) _tmp8_, (guint) pos);
	msg = G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, DC_TYPE_MESSAGE, DcMessage);
	_tmp10_ = msg;
	dc_message_set_highlighted (_tmp10_, TRUE);
	_tmp11_ = self->priv->message_listview;
	gtk_list_view_scroll_to (_tmp11_, (guint) pos, GTK_LIST_SCROLL_FOCUS, NULL);
	self->priv->stick_to_bottom = dc_conversation_view_is_near_bottom (self);
	_g_object_unref0 (msg);
}

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

static void
dc_conversation_view_load_messages (DcConversationView* self,
                                    gboolean preserve_scroll,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	DcConversationViewLoadMessagesData* _data_;
	DcConversationView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcConversationViewLoadMessagesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_load_messages_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->preserve_scroll = preserve_scroll;
	dc_conversation_view_load_messages_co (_data_);
}

static void
dc_conversation_view_load_messages_finish (DcConversationView* self,
                                           GAsyncResult* _res_)
{
	DcConversationViewLoadMessagesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block25Data*
block25_data_ref (Block25Data* _data25_)
{
	g_atomic_int_inc (&_data25_->_ref_count_);
	return _data25_;
}

static void
block25_data_unref (void * _userdata_)
{
	Block25Data* _data25_;
	_data25_ = (Block25Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data25_->_ref_count_)) {
		DcConversationView* self;
		self = _data25_->self;
		_g_object_unref0 (self);
		g_slice_free (Block25Data, _data25_);
	}
}

static void
dc_conversation_view_load_messages_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	DcConversationViewLoadMessagesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_load_messages_co (_data_);
}

static gboolean
_____lambda62_ (Block25Data* _data25_)
{
	DcConversationView* self;
	GtkAdjustment* adj = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	gdouble max_value = 0.0;
	GtkAdjustment* _tmp4_;
	gdouble _tmp5_;
	gdouble _tmp6_;
	GtkAdjustment* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	gdouble _tmp10_ = 0.0;
	GtkAdjustment* _tmp11_;
	GtkButton* _tmp12_;
	gboolean result;
	self = _data25_->self;
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	adj = _tmp3_;
	_tmp4_ = adj;
	_tmp5_ = gtk_adjustment_get_upper (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = adj;
	_tmp8_ = gtk_adjustment_get_page_size (_tmp7_);
	_tmp9_ = _tmp8_;
	max_value = _tmp6_ - _tmp9_;
	if (max_value < ((gdouble) 0)) {
		max_value = (gdouble) 0;
	}
	if (_data25_->previous_scroll_value > max_value) {
		_tmp10_ = max_value;
	} else {
		_tmp10_ = _data25_->previous_scroll_value;
	}
	_tmp11_ = adj;
	gtk_adjustment_set_value (_tmp11_, _tmp10_);
	self->priv->stick_to_bottom = FALSE;
	_tmp12_ = self->priv->scroll_down_btn;
	gtk_widget_set_visible ((GtkWidget*) _tmp12_, !dc_conversation_view_is_near_bottom (self));
	result = G_SOURCE_REMOVE;
	_g_object_unref0 (adj);
	return result;
}

static gboolean
______lambda62__gsource_func (gpointer self)
{
	gboolean result;
	result = _____lambda62_ (self);
	return result;
}

static gboolean
dc_conversation_view_load_messages_co (DcConversationViewLoadMessagesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->rpc;
	_data_->_tmp1_ = dc_rpc_client_get_account_id (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	if (_data_->_tmp2_ <= 0) {
		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_->_data25_ = g_slice_new0 (Block25Data);
		_data_->_data25_->_ref_count_ = 1;
		_data_->_data25_->self = g_object_ref (_data_->self);
		_data_->was_near_bottom = _data_->self->priv->stick_to_bottom;
		_data_->_data25_->previous_scroll_value = (gdouble) 0;
		if (_data_->preserve_scroll) {
			_data_->was_near_bottom = dc_conversation_view_is_near_bottom (_data_->self);
			_data_->_tmp3_ = _data_->self->priv->message_scroll;
			_data_->_tmp4_ = gtk_scrolled_window_get_vadjustment (_data_->_tmp3_);
			_data_->_tmp5_ = _data_->_tmp4_;
			_data_->_tmp6_ = gtk_adjustment_get_value (_data_->_tmp5_);
			_data_->_tmp7_ = _data_->_tmp6_;
			_data_->_data25_->previous_scroll_value = _data_->_tmp7_;
		}
		_data_->_tmp9_ = _data_->self->priv->rpc;
		_data_->_tmp10_ = _data_->self->priv->_chat_id;
		_data_->_state_ = 1;
		dc_rpc_client_get_message_ids (_data_->_tmp9_, _data_->_tmp10_, FALSE, dc_conversation_view_load_messages_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp11_ = dc_rpc_client_get_message_ids_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp8_ = _data_->_tmp11_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			block25_data_unref (_data_->_data25_);
			_data_->_data25_ = NULL;
			goto __catch0_g_error;
		}
		_data_->_tmp12_ = _data_->_tmp8_;
		_data_->_tmp8_ = NULL;
		_json_array_unref0 (_data_->self->priv->all_msg_ids);
		_data_->self->priv->all_msg_ids = _data_->_tmp12_;
		_data_->_tmp13_ = _data_->self->priv->all_msg_ids;
		if (_data_->_tmp13_ == NULL) {
			_json_array_unref0 (_data_->_tmp8_);
			block25_data_unref (_data_->_data25_);
			_data_->_data25_ = NULL;
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp15_ = _data_->self->priv->all_msg_ids;
		if (json_array_get_length (_data_->_tmp15_) > ((guint) 30)) {
			_data_->_tmp16_ = _data_->self->priv->all_msg_ids;
			_data_->_tmp14_ = json_array_get_length (_data_->_tmp16_) - 30;
		} else {
			_data_->_tmp14_ = (guint) 0;
		}
		_data_->self->priv->loaded_start_index = _data_->_tmp14_;
		_data_->_tmp17_ = _data_->self->priv->all_msg_ids;
		_data_->_state_ = 2;
		dc_conversation_view_fetch_messages_batch (_data_->self, _data_->self->priv->loaded_start_index, json_array_get_length (_data_->_tmp17_), dc_conversation_view_load_messages_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp18_ = dc_conversation_view_fetch_messages_batch_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		_data_->messages = _data_->_tmp18_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_json_array_unref0 (_data_->_tmp8_);
			block25_data_unref (_data_->_data25_);
			_data_->_data25_ = NULL;
			goto __catch0_g_error;
		}
		_data_->_tmp19_ = _data_->self->priv->_pinned;
		_data_->_tmp20_ = _data_->self->priv->_chat_id;
		dc_pinned_messages_manager_load_for_chat (_data_->_tmp19_, _data_->_tmp20_);
		_data_->self->priv->loading_chat = TRUE;
		if (_data_->preserve_scroll) {
			_data_->_tmp21_ = _data_->was_near_bottom;
		} else {
			_data_->_tmp21_ = TRUE;
		}
		_data_->self->priv->stick_to_bottom = _data_->_tmp21_;
		_data_->_tmp22_ = _data_->messages;
		_data_->_tmp23_ = vala_g_ptr_array_get_length (_data_->_tmp22_);
		_data_->_tmp24_ = _data_->_tmp23_;
		_data_->_tmp25_ = g_new0 (GObject*, _data_->_tmp24_ + 1);
		_data_->batch = _data_->_tmp25_;
		_data_->batch_length1 = _data_->_tmp24_;
		_data_->_batch_size_ = _data_->batch_length1;
		{
			_data_->i = (guint) 0;
			{
				_data_->_tmp26_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp26_) {
						_data_->_tmp27_ = _data_->i;
						_data_->i = _data_->_tmp27_ + 1;
					}
					_data_->_tmp26_ = FALSE;
					_data_->_tmp28_ = _data_->messages;
					_data_->_tmp29_ = vala_g_ptr_array_get_length (_data_->_tmp28_);
					_data_->_tmp30_ = _data_->_tmp29_;
					if (!(_data_->i < ((guint) _data_->_tmp30_))) {
						break;
					}
					_data_->_tmp31_ = _data_->messages;
					_data_->_tmp32_ = g_ptr_array_index (_data_->_tmp31_, _data_->i);
					_data_->_tmp33_ = _data_->self->priv->_pinned;
					_data_->_tmp34_ = _data_->messages;
					_data_->_tmp35_ = g_ptr_array_index (_data_->_tmp34_, _data_->i);
					_data_->_tmp36_ = dc_message_get_id ((DcMessage*) _data_->_tmp35_);
					_data_->_tmp37_ = _data_->_tmp36_;
					dc_message_set_is_pinned ((DcMessage*) _data_->_tmp32_, dc_pinned_messages_manager_is_pinned (_data_->_tmp33_, _data_->_tmp37_));
					_data_->_tmp38_ = _data_->batch;
					_data_->_tmp38__length1 = _data_->batch_length1;
					_data_->_tmp39_ = _data_->messages;
					_data_->_tmp40_ = g_ptr_array_index (_data_->_tmp39_, _data_->i);
					_data_->_tmp41_ = _g_object_ref0 ((GObject*) ((DcMessage*) _data_->_tmp40_));
					_g_object_unref0 (_data_->_tmp38_[_data_->i]);
					_data_->_tmp38_[_data_->i] = _data_->_tmp41_;
				}
			}
		}
		_data_->_tmp42_ = _data_->self->priv->message_store;
		_data_->_tmp43_ = _data_->self->priv->message_store;
		_data_->_tmp44_ = _data_->batch;
		_data_->_tmp44__length1 = _data_->batch_length1;
		g_list_store_splice (_data_->_tmp42_, (guint) 0, g_list_model_get_n_items ((GListModel*) _data_->_tmp43_), _data_->_tmp44_, (guint) _data_->_tmp44__length1);
		_data_->self->priv->loading_chat = FALSE;
		_data_->_tmp45_ = _data_->messages;
		_data_->_tmp46_ = vala_g_ptr_array_get_length (_data_->_tmp45_);
		_data_->_tmp47_ = _data_->_tmp46_;
		if (_data_->_tmp47_ > 0) {
			if (!_data_->preserve_scroll) {
				_data_->_tmp48_ = TRUE;
			} else {
				_data_->_tmp48_ = _data_->was_near_bottom;
			}
			if (_data_->_tmp48_) {
				dc_conversation_view_scroll_to_bottom (_data_->self);
			} else {
				g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ______lambda62__gsource_func, block25_data_ref (_data_->_data25_), block25_data_unref);
			}
		}
		_data_->_tmp49_ = _data_->self->priv->_pinned;
		dc_pinned_messages_manager_update_bar (_data_->_tmp49_, NULL, NULL);
		_data_->batch = (_vala_array_free (_data_->batch, _data_->batch_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_ptr_array_unref0 (_data_->messages);
		_json_array_unref0 (_data_->_tmp8_);
		block25_data_unref (_data_->_data25_);
		_data_->_data25_ = NULL;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp50_ = _data_->self->priv->window;
		_data_->_tmp51_ = _data_->e;
		_data_->_tmp52_ = _data_->_tmp51_->message;
		_data_->_tmp53_ = g_strconcat ("Failed to load messages: ", _data_->_tmp52_, NULL);
		_data_->_tmp54_ = _data_->_tmp53_;
		dc_window_show_toast (_data_->_tmp50_, _data_->_tmp54_);
		_g_free0 (_data_->_tmp54_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_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
dc_conversation_view_fetch_messages_batch_data_free (gpointer _data)
{
	DcConversationViewFetchMessagesBatchData* _data_;
	_data_ = _data;
	_g_ptr_array_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcConversationViewFetchMessagesBatchData, _data_);
}

static void
dc_conversation_view_fetch_messages_batch (DcConversationView* self,
                                           guint start,
                                           guint end,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	DcConversationViewFetchMessagesBatchData* _data_;
	DcConversationView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcConversationViewFetchMessagesBatchData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_fetch_messages_batch_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->start = start;
	_data_->end = end;
	dc_conversation_view_fetch_messages_batch_co (_data_);
}

static GPtrArray*
dc_conversation_view_fetch_messages_batch_finish (DcConversationView* self,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	GPtrArray* result;
	DcConversationViewFetchMessagesBatchData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dc_conversation_view_fetch_messages_batch_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	DcConversationViewFetchMessagesBatchData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_fetch_messages_batch_co (_data_);
}

static gboolean
dc_conversation_view_fetch_messages_batch_co (DcConversationViewFetchMessagesBatchData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->count = _data_->end - _data_->start;
	_data_->_tmp0_ = g_new0 (gint, _data_->count);
	_data_->ids = _data_->_tmp0_;
	_data_->ids_length1 = _data_->count;
	_data_->_ids_size_ = _data_->ids_length1;
	{
		_data_->i = (guint) 0;
		{
			_data_->_tmp1_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp1_) {
					_data_->_tmp2_ = _data_->i;
					_data_->i = _data_->_tmp2_ + 1;
				}
				_data_->_tmp1_ = FALSE;
				if (!(_data_->i < _data_->count)) {
					break;
				}
				_data_->_tmp3_ = _data_->ids;
				_data_->_tmp3__length1 = _data_->ids_length1;
				_data_->_tmp4_ = _data_->self->priv->all_msg_ids;
				_data_->_tmp3_[_data_->i] = (gint) json_array_get_int_element (_data_->_tmp4_, _data_->start + _data_->i);
			}
		}
	}
	_data_->_tmp5_ = _data_->self->priv->rpc;
	_data_->_tmp6_ = _data_->ids;
	_data_->_tmp6__length1 = _data_->ids_length1;
	_data_->_state_ = 1;
	dc_rpc_client_get_messages (_data_->_tmp5_, _data_->_tmp6_, (gint) _data_->_tmp6__length1, dc_conversation_view_fetch_messages_batch_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp7_ = dc_rpc_client_get_messages_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
	_data_->map = _data_->_tmp7_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_data_->ids = (g_free (_data_->ids), NULL);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp8_ = g_ptr_array_new_full ((guint) 0, _g_object_unref0_);
	_data_->_result_ = _data_->_tmp8_;
	if (_data_->map != NULL) {
		_data_->_tmp9_ = _data_->ids;
		_data_->_tmp9__length1 = _data_->ids_length1;
		{
			_data_->mid_collection_length1 = 0;
			_data_->_mid_collection_size_ = 0;
			_data_->mid_collection = _data_->_tmp9_;
			_data_->mid_collection_length1 = _data_->_tmp9__length1;
			for (_data_->mid_it = 0; _data_->mid_it < _data_->mid_collection_length1; _data_->mid_it = _data_->mid_it + 1) {
				_data_->mid = _data_->mid_collection[_data_->mid_it];
				{
					_data_->_tmp10_ = g_strdup_printf ("%i", _data_->mid);
					_data_->k = _data_->_tmp10_;
					_data_->_tmp11_ = _data_->k;
					if (json_object_has_member (_data_->map, _data_->_tmp11_)) {
						_data_->_tmp12_ = _data_->_result_;
						_data_->_tmp13_ = _data_->k;
						_data_->_tmp14_ = json_object_get_object_member (_data_->map, _data_->_tmp13_);
						_data_->_tmp15_ = _data_->self->priv->rpc;
						_data_->_tmp16_ = dc_rpc_client_get_self_email (_data_->_tmp15_);
						_data_->_tmp17_ = _data_->_tmp16_;
						_data_->_tmp18_ = dc_rpc_parsers_parse_message (_data_->_tmp14_, _data_->_tmp17_);
						g_ptr_array_add (_data_->_tmp12_, _data_->_tmp18_);
					}
					_g_free0 (_data_->k);
				}
			}
		}
	}
	_data_->result = _data_->_result_;
	_json_object_unref0 (_data_->map);
	_data_->ids = (g_free (_data_->ids), NULL);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_conversation_view_load_earlier_messages (DcConversationView* self,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	DcConversationViewLoadEarlierMessagesData* _data_;
	DcConversationView* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcConversationViewLoadEarlierMessagesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_load_earlier_messages_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_conversation_view_load_earlier_messages_co (_data_);
}

static void
dc_conversation_view_load_earlier_messages_finish (DcConversationView* self,
                                                   GAsyncResult* _res_)
{
	DcConversationViewLoadEarlierMessagesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block26Data*
block26_data_ref (Block26Data* _data26_)
{
	g_atomic_int_inc (&_data26_->_ref_count_);
	return _data26_;
}

static void
block26_data_unref (void * _userdata_)
{
	Block26Data* _data26_;
	_data26_ = (Block26Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data26_->_ref_count_)) {
		DcConversationView* self;
		self = _data26_->self;
		_g_object_unref0 (self);
		g_slice_free (Block26Data, _data26_);
	}
}

static void
dc_conversation_view_load_earlier_messages_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_)
{
	DcConversationViewLoadEarlierMessagesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_load_earlier_messages_co (_data_);
}

static gboolean
___lambda67_ (Block26Data* _data26_)
{
	DcConversationView* self;
	GtkAdjustment* a = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	gdouble _tmp4_;
	gdouble _tmp5_;
	gboolean result;
	self = _data26_->self;
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	a = _tmp3_;
	_tmp4_ = gtk_adjustment_get_upper (a);
	_tmp5_ = _tmp4_;
	gtk_adjustment_set_value (a, _data26_->old_value + (_tmp5_ - _data26_->old_upper));
	self->priv->loading_more = FALSE;
	dc_conversation_view_set_loading_more_visible (self, FALSE);
	result = G_SOURCE_REMOVE;
	_g_object_unref0 (a);
	return result;
}

static gboolean
____lambda67__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda67_ (self);
	return result;
}

static gboolean
dc_conversation_view_load_earlier_messages_co (DcConversationViewLoadEarlierMessagesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->loading_more) {
		_data_->_tmp1_ = TRUE;
	} else {
		_data_->_tmp2_ = _data_->self->priv->all_msg_ids;
		_data_->_tmp1_ = _data_->_tmp2_ == NULL;
	}
	if (_data_->_tmp1_) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp0_ = _data_->self->priv->loaded_start_index == ((guint) 0);
	}
	if (_data_->_tmp0_) {
		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_->self->priv->loading_more = TRUE;
	dc_conversation_view_set_loading_more_visible (_data_->self, TRUE);
	if (_data_->self->priv->loaded_start_index > ((guint) 100)) {
		_data_->_tmp3_ = _data_->self->priv->loaded_start_index - 100;
	} else {
		_data_->_tmp3_ = (guint) 0;
	}
	_data_->new_start = _data_->_tmp3_;
	{
		_data_->_data26_ = g_slice_new0 (Block26Data);
		_data_->_data26_->_ref_count_ = 1;
		_data_->_data26_->self = g_object_ref (_data_->self);
		_data_->_state_ = 1;
		dc_conversation_view_fetch_messages_batch (_data_->self, _data_->new_start, _data_->self->priv->loaded_start_index, dc_conversation_view_load_earlier_messages_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp4_ = dc_conversation_view_fetch_messages_batch_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		_data_->messages = _data_->_tmp4_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			block26_data_unref (_data_->_data26_);
			_data_->_data26_ = NULL;
			goto __catch0_g_error;
		}
		_data_->_tmp5_ = _data_->self->priv->message_scroll;
		_data_->_tmp6_ = gtk_scrolled_window_get_vadjustment (_data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = _g_object_ref0 (_data_->_tmp7_);
		_data_->adj = _data_->_tmp8_;
		_data_->_tmp9_ = _data_->adj;
		_data_->_tmp10_ = gtk_adjustment_get_upper (_data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_data26_->old_upper = _data_->_tmp11_;
		_data_->_tmp12_ = _data_->adj;
		_data_->_tmp13_ = gtk_adjustment_get_value (_data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_data26_->old_value = _data_->_tmp14_;
		_data_->_tmp15_ = _data_->messages;
		_data_->_tmp16_ = vala_g_ptr_array_get_length (_data_->_tmp15_);
		_data_->_tmp17_ = _data_->_tmp16_;
		_data_->_tmp18_ = g_new0 (GObject*, _data_->_tmp17_ + 1);
		_data_->batch = _data_->_tmp18_;
		_data_->batch_length1 = _data_->_tmp17_;
		_data_->_batch_size_ = _data_->batch_length1;
		{
			_data_->i = (guint) 0;
			{
				_data_->_tmp19_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp19_) {
						_data_->_tmp20_ = _data_->i;
						_data_->i = _data_->_tmp20_ + 1;
					}
					_data_->_tmp19_ = FALSE;
					_data_->_tmp21_ = _data_->messages;
					_data_->_tmp22_ = vala_g_ptr_array_get_length (_data_->_tmp21_);
					_data_->_tmp23_ = _data_->_tmp22_;
					if (!(_data_->i < ((guint) _data_->_tmp23_))) {
						break;
					}
					_data_->_tmp24_ = _data_->messages;
					_data_->_tmp25_ = g_ptr_array_index (_data_->_tmp24_, _data_->i);
					_data_->_tmp26_ = _data_->self->priv->_pinned;
					_data_->_tmp27_ = _data_->messages;
					_data_->_tmp28_ = g_ptr_array_index (_data_->_tmp27_, _data_->i);
					_data_->_tmp29_ = dc_message_get_id ((DcMessage*) _data_->_tmp28_);
					_data_->_tmp30_ = _data_->_tmp29_;
					dc_message_set_is_pinned ((DcMessage*) _data_->_tmp25_, dc_pinned_messages_manager_is_pinned (_data_->_tmp26_, _data_->_tmp30_));
					_data_->_tmp31_ = _data_->batch;
					_data_->_tmp31__length1 = _data_->batch_length1;
					_data_->_tmp32_ = _data_->messages;
					_data_->_tmp33_ = g_ptr_array_index (_data_->_tmp32_, _data_->i);
					_data_->_tmp34_ = _g_object_ref0 ((GObject*) ((DcMessage*) _data_->_tmp33_));
					_g_object_unref0 (_data_->_tmp31_[_data_->i]);
					_data_->_tmp31_[_data_->i] = _data_->_tmp34_;
				}
			}
		}
		_data_->_tmp35_ = _data_->self->priv->message_store;
		_data_->_tmp36_ = _data_->batch;
		_data_->_tmp36__length1 = _data_->batch_length1;
		g_list_store_splice (_data_->_tmp35_, (guint) 0, (guint) 0, _data_->_tmp36_, (guint) _data_->_tmp36__length1);
		_data_->self->priv->loaded_start_index = _data_->new_start;
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda67__gsource_func, block26_data_ref (_data_->_data26_), block26_data_unref);
		_data_->batch = (_vala_array_free (_data_->batch, _data_->batch_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_object_unref0 (_data_->adj);
		_g_ptr_array_unref0 (_data_->messages);
		block26_data_unref (_data_->_data26_);
		_data_->_data26_ = NULL;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->self->priv->loading_more = FALSE;
		dc_conversation_view_set_loading_more_visible (_data_->self, FALSE);
		_data_->_tmp37_ = _data_->self->priv->window;
		_data_->_tmp38_ = _data_->e;
		_data_->_tmp39_ = _data_->_tmp38_->message;
		_data_->_tmp40_ = g_strconcat ("Failed to load earlier messages: ", _data_->_tmp39_, NULL);
		_data_->_tmp41_ = _data_->_tmp40_;
		dc_window_show_toast (_data_->_tmp37_, _data_->_tmp41_);
		_g_free0 (_data_->_tmp41_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_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
dc_conversation_view_set_loading_more_visible (DcConversationView* self,
                                               gboolean visible)
{
	GtkSpinner* _tmp0_;
	GtkRevealer* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->loading_more_spinner;
	gtk_spinner_set_spinning (_tmp0_, visible);
	_tmp1_ = self->priv->loading_more_revealer;
	gtk_revealer_set_reveal_child (_tmp1_, visible);
}

static gboolean
dc_conversation_view_is_near_bottom (DcConversationView* self)
{
	GtkAdjustment* adj = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	GtkAdjustment* _tmp4_;
	gdouble _tmp5_;
	gdouble _tmp6_;
	GtkAdjustment* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	GtkAdjustment* _tmp10_;
	gdouble _tmp11_;
	gdouble _tmp12_;
	GtkAdjustment* _tmp13_;
	gdouble _tmp14_;
	gdouble _tmp15_;
	GtkAdjustment* _tmp16_;
	gdouble _tmp17_;
	gdouble _tmp18_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	adj = _tmp3_;
	_tmp4_ = adj;
	_tmp5_ = gtk_adjustment_get_upper (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = adj;
	_tmp8_ = gtk_adjustment_get_page_size (_tmp7_);
	_tmp9_ = _tmp8_;
	if (_tmp6_ <= _tmp9_) {
		result = TRUE;
		_g_object_unref0 (adj);
		return result;
	}
	_tmp10_ = adj;
	_tmp11_ = gtk_adjustment_get_upper (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = adj;
	_tmp14_ = gtk_adjustment_get_value (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = adj;
	_tmp17_ = gtk_adjustment_get_page_size (_tmp16_);
	_tmp18_ = _tmp17_;
	result = ((_tmp12_ - _tmp15_) - _tmp18_) < ((gdouble) 80);
	_g_object_unref0 (adj);
	return result;
}

static gboolean
dc_conversation_view_is_near_top (DcConversationView* self)
{
	GtkAdjustment* adj = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	gdouble _tmp4_;
	gdouble _tmp5_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	adj = _tmp3_;
	_tmp4_ = gtk_adjustment_get_value (adj);
	_tmp5_ = _tmp4_;
	result = _tmp5_ < ((gdouble) 80);
	_g_object_unref0 (adj);
	return result;
}

static void
dc_conversation_view_maybe_autoscroll (DcConversationView* self)
{
	GtkAdjustment* adj = NULL;
	GtkScrolledWindow* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	GtkAdjustment* _tmp4_;
	gdouble _tmp5_;
	gdouble _tmp6_;
	GtkAdjustment* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	g_return_if_fail (self != NULL);
	if (!self->priv->stick_to_bottom) {
		return;
	}
	_tmp0_ = self->priv->message_scroll;
	_tmp1_ = gtk_scrolled_window_get_vadjustment (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	adj = _tmp3_;
	_tmp4_ = adj;
	_tmp5_ = gtk_adjustment_get_upper (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = adj;
	_tmp8_ = gtk_adjustment_get_page_size (_tmp7_);
	_tmp9_ = _tmp8_;
	if (_tmp6_ > _tmp9_) {
		GtkAdjustment* _tmp10_;
		GtkAdjustment* _tmp11_;
		gdouble _tmp12_;
		gdouble _tmp13_;
		GtkAdjustment* _tmp14_;
		gdouble _tmp15_;
		gdouble _tmp16_;
		_tmp10_ = adj;
		_tmp11_ = adj;
		_tmp12_ = gtk_adjustment_get_upper (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = adj;
		_tmp15_ = gtk_adjustment_get_page_size (_tmp14_);
		_tmp16_ = _tmp15_;
		gtk_adjustment_set_value (_tmp10_, _tmp13_ - _tmp16_);
	}
	_g_object_unref0 (adj);
}

void
dc_conversation_view_scroll_to_bottom (DcConversationView* self)
{
	guint n = 0U;
	GtkFilterListModel* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->stick_to_bottom = TRUE;
	dc_conversation_view_maybe_autoscroll (self);
	_tmp0_ = self->priv->filtered_message_store;
	n = g_list_model_get_n_items ((GListModel*) _tmp0_);
	if (n > ((guint) 0)) {
		GtkListView* _tmp1_;
		_tmp1_ = self->priv->message_listview;
		gtk_list_view_scroll_to (_tmp1_, n - 1, GTK_LIST_SCROLL_NONE, NULL);
	}
}

static void
dc_conversation_view_insert_message_sorted (DcConversationView* self,
                                            DcMessage* msg)
{
	gint count = 0;
	GListStore* _tmp0_;
	GListStore* _tmp44_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	_tmp0_ = self->priv->message_store;
	count = (gint) g_list_model_get_n_items ((GListModel*) _tmp0_);
	if (count > 0) {
		DcMessage* last = NULL;
		GListStore* _tmp1_;
		GObject* _tmp2_;
		gboolean _tmp3_ = FALSE;
		gint64 _tmp4_;
		gint64 _tmp5_;
		DcMessage* _tmp6_;
		gint64 _tmp7_;
		gint64 _tmp8_;
		_tmp1_ = self->priv->message_store;
		_tmp2_ = g_list_model_get_item ((GListModel*) _tmp1_, (guint) (count - 1));
		last = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, DC_TYPE_MESSAGE, DcMessage);
		_tmp4_ = dc_message_get_timestamp (msg);
		_tmp5_ = _tmp4_;
		_tmp6_ = last;
		_tmp7_ = dc_message_get_timestamp (_tmp6_);
		_tmp8_ = _tmp7_;
		if (_tmp5_ > _tmp8_) {
			_tmp3_ = TRUE;
		} else {
			gboolean _tmp9_ = FALSE;
			gint64 _tmp10_;
			gint64 _tmp11_;
			DcMessage* _tmp12_;
			gint64 _tmp13_;
			gint64 _tmp14_;
			_tmp10_ = dc_message_get_timestamp (msg);
			_tmp11_ = _tmp10_;
			_tmp12_ = last;
			_tmp13_ = dc_message_get_timestamp (_tmp12_);
			_tmp14_ = _tmp13_;
			if (_tmp11_ == _tmp14_) {
				gint _tmp15_;
				gint _tmp16_;
				DcMessage* _tmp17_;
				gint _tmp18_;
				gint _tmp19_;
				_tmp15_ = dc_message_get_id (msg);
				_tmp16_ = _tmp15_;
				_tmp17_ = last;
				_tmp18_ = dc_message_get_id (_tmp17_);
				_tmp19_ = _tmp18_;
				_tmp9_ = _tmp16_ >= _tmp19_;
			} else {
				_tmp9_ = FALSE;
			}
			_tmp3_ = _tmp9_;
		}
		if (_tmp3_) {
			GListStore* _tmp20_;
			_tmp20_ = self->priv->message_store;
			g_list_store_append (_tmp20_, (GObject*) msg);
			_g_object_unref0 (last);
			return;
		}
		_g_object_unref0 (last);
	}
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp21_ = FALSE;
			_tmp21_ = TRUE;
			while (TRUE) {
				GListStore* _tmp23_;
				DcMessage* m = NULL;
				GListStore* _tmp24_;
				GObject* _tmp25_;
				gboolean _tmp26_ = FALSE;
				DcMessage* _tmp27_;
				gint64 _tmp28_;
				gint64 _tmp29_;
				gint64 _tmp30_;
				gint64 _tmp31_;
				if (!_tmp21_) {
					guint _tmp22_;
					_tmp22_ = i;
					i = _tmp22_ + 1;
				}
				_tmp21_ = FALSE;
				_tmp23_ = self->priv->message_store;
				if (!(i < g_list_model_get_n_items ((GListModel*) _tmp23_))) {
					break;
				}
				_tmp24_ = self->priv->message_store;
				_tmp25_ = g_list_model_get_item ((GListModel*) _tmp24_, i);
				m = G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, DC_TYPE_MESSAGE, DcMessage);
				_tmp27_ = m;
				_tmp28_ = dc_message_get_timestamp (_tmp27_);
				_tmp29_ = _tmp28_;
				_tmp30_ = dc_message_get_timestamp (msg);
				_tmp31_ = _tmp30_;
				if (_tmp29_ > _tmp31_) {
					_tmp26_ = TRUE;
				} else {
					gboolean _tmp32_ = FALSE;
					DcMessage* _tmp33_;
					gint64 _tmp34_;
					gint64 _tmp35_;
					gint64 _tmp36_;
					gint64 _tmp37_;
					_tmp33_ = m;
					_tmp34_ = dc_message_get_timestamp (_tmp33_);
					_tmp35_ = _tmp34_;
					_tmp36_ = dc_message_get_timestamp (msg);
					_tmp37_ = _tmp36_;
					if (_tmp35_ == _tmp37_) {
						DcMessage* _tmp38_;
						gint _tmp39_;
						gint _tmp40_;
						gint _tmp41_;
						gint _tmp42_;
						_tmp38_ = m;
						_tmp39_ = dc_message_get_id (_tmp38_);
						_tmp40_ = _tmp39_;
						_tmp41_ = dc_message_get_id (msg);
						_tmp42_ = _tmp41_;
						_tmp32_ = _tmp40_ > _tmp42_;
					} else {
						_tmp32_ = FALSE;
					}
					_tmp26_ = _tmp32_;
				}
				if (_tmp26_) {
					GListStore* _tmp43_;
					_tmp43_ = self->priv->message_store;
					g_list_store_insert (_tmp43_, (guint) ((gint) i), (GObject*) msg);
					_g_object_unref0 (m);
					return;
				}
				_g_object_unref0 (m);
			}
		}
	}
	_tmp44_ = self->priv->message_store;
	g_list_store_append (_tmp44_, (GObject*) msg);
}

static void
dc_conversation_view_on_send_message (DcConversationView* self,
                                      const gchar* text,
                                      const gchar* file_path,
                                      const gchar* file_name,
                                      gint quote_msg_id)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	dc_conversation_view_do_send (self, text, file_path, file_name, quote_msg_id, NULL, NULL);
}

static void
dc_conversation_view_do_send_data_free (gpointer _data)
{
	DcConversationViewDoSendData* _data_;
	_data_ = _data;
	_g_free0 (_data_->text);
	_g_free0 (_data_->file_path);
	_g_free0 (_data_->file_name);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcConversationViewDoSendData, _data_);
}

static void
dc_conversation_view_do_send (DcConversationView* self,
                              const gchar* text,
                              const gchar* file_path,
                              const gchar* file_name,
                              gint quote_msg_id,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	DcConversationViewDoSendData* _data_;
	DcConversationView* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_data_ = g_slice_new0 (DcConversationViewDoSendData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_conversation_view_do_send_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (text);
	_g_free0 (_data_->text);
	_data_->text = _tmp1_;
	_tmp2_ = g_strdup (file_path);
	_g_free0 (_data_->file_path);
	_data_->file_path = _tmp2_;
	_tmp3_ = g_strdup (file_name);
	_g_free0 (_data_->file_name);
	_data_->file_name = _tmp3_;
	_data_->quote_msg_id = quote_msg_id;
	dc_conversation_view_do_send_co (_data_);
}

static void
dc_conversation_view_do_send_finish (DcConversationView* self,
                                     GAsyncResult* _res_)
{
	DcConversationViewDoSendData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_conversation_view_do_send_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	DcConversationViewDoSendData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_conversation_view_do_send_co (_data_);
}

static gboolean
dc_conversation_view_do_send_co (DcConversationViewDoSendData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp1_ = strlen (_data_->text);
		_data_->_tmp2_ = _data_->_tmp1_;
		if (_data_->_tmp2_ > 0) {
			_data_->_tmp0_ = _data_->text;
		} else {
			_data_->_tmp0_ = NULL;
		}
		_data_->_tmp3_ = g_strdup (_data_->_tmp0_);
		_data_->send_text = _data_->_tmp3_;
		_data_->_tmp4_ = _data_->self->priv->rpc;
		_data_->_tmp5_ = _data_->self->priv->_chat_id;
		_data_->_tmp6_ = _data_->send_text;
		_data_->_state_ = 1;
		dc_rpc_client_send_msg (_data_->_tmp4_, _data_->_tmp5_, _data_->_tmp6_, _data_->file_path, _data_->file_name, _data_->quote_msg_id, dc_conversation_view_do_send_ready, _data_);
		return FALSE;
		_state_1:
		_data_->msg_id = dc_rpc_client_send_msg_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->send_text);
			goto __catch0_g_error;
		}
		if (_data_->msg_id > 0) {
			_data_->_tmp7_ = _data_->self->priv->rpc;
			_data_->_state_ = 2;
			dc_rpc_client_fetch_message (_data_->_tmp7_, _data_->msg_id, dc_conversation_view_do_send_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp8_ = dc_rpc_client_fetch_message_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error0_);
			_data_->msg = _data_->_tmp8_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_free0 (_data_->send_text);
				goto __catch0_g_error;
			}
			_data_->_tmp9_ = _data_->msg;
			if (_data_->_tmp9_ != NULL) {
				_data_->_tmp10_ = _data_->msg;
				dc_conversation_view_insert_message_sorted (_data_->self, _data_->_tmp10_);
				dc_conversation_view_scroll_to_bottom (_data_->self);
			}
			_g_object_unref0 (_data_->msg);
		}
		_g_free0 (_data_->send_text);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp11_ = _data_->self->priv->window;
		_data_->_tmp12_ = _data_->e;
		_data_->_tmp13_ = _data_->_tmp12_->message;
		_data_->_tmp14_ = g_strconcat ("Send failed: ", _data_->_tmp13_, NULL);
		_data_->_tmp15_ = _data_->_tmp14_;
		dc_window_show_toast (_data_->_tmp11_, _data_->_tmp15_);
		_g_free0 (_data_->_tmp15_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_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 gboolean
dc_conversation_view_can_accept_file_attachment (DcConversationView* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (!self->priv->is_contact_request) {
		DcComposeBar* _tmp1_;
		_tmp1_ = self->priv->compose_bar;
		_tmp0_ = dc_compose_bar_can_accept_attachment (_tmp1_);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
dc_conversation_view_attach_local_file (DcConversationView* self,
                                        const gchar* path,
                                        const gchar* name)
{
	gboolean _tmp1_ = FALSE;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gboolean _tmp6_;
	DcComposeBar* _tmp8_;
	DcComposeBar* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	g_return_if_fail (name != NULL);
	if (!dc_conversation_view_can_accept_file_attachment (self)) {
		DcWindow* _tmp0_;
		_tmp0_ = self->priv->window;
		dc_window_show_toast (_tmp0_, "Attach failed: cannot attach here");
		return;
	}
	_tmp2_ = string_strip (path);
	_tmp3_ = _tmp2_;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_ == 0;
	_g_free0 (_tmp3_);
	if (_tmp6_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = !g_file_test (path, G_FILE_TEST_EXISTS);
	}
	if (_tmp1_) {
		DcWindow* _tmp7_;
		_tmp7_ = self->priv->window;
		dc_window_show_toast (_tmp7_, "Attach failed: file not found");
		return;
	}
	_tmp8_ = self->priv->compose_bar;
	dc_compose_bar_set_pending_attachment (_tmp8_, path, name);
	_tmp9_ = self->priv->compose_bar;
	dc_compose_bar_grab_entry_focus (_tmp9_);
}

static gboolean
_dc_conversation_view_can_accept_file_attachment_dc_file_drop_target_accept (DcFileDropTarget* _sender,
                                                                             gpointer self)
{
	gboolean result;
	result = dc_conversation_view_can_accept_file_attachment ((DcConversationView*) self);
	return result;
}

static void
_dc_conversation_view_attach_local_file_dc_file_drop_target_dropped (DcFileDropTarget* _sender,
                                                                     const gchar* path,
                                                                     const gchar* name,
                                                                     gpointer self)
{
	dc_conversation_view_attach_local_file ((DcConversationView*) self, path, name);
}

static void
__lambda96_ (DcConversationView* self,
             const gchar* message)
{
	DcWindow* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->window;
	_tmp1_ = g_strconcat ("Attach failed: ", message, NULL);
	_tmp2_ = _tmp1_;
	dc_window_show_toast (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
}

static void
___lambda96__dc_file_drop_target_failed (DcFileDropTarget* _sender,
                                         const gchar* message,
                                         gpointer self)
{
	__lambda96_ ((DcConversationView*) self, message);
}

static void
dc_conversation_view_install_file_drop_target (DcConversationView* self)
{
	DcFileDropTarget* _tmp0_;
	DcFileDropTarget* _tmp1_;
	DcFileDropTarget* _tmp2_;
	DcFileDropTarget* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = dc_file_drop_target_new ((GtkWidget*) self, "chat-drop-active");
	_g_object_unref0 (self->priv->file_drop_target);
	self->priv->file_drop_target = _tmp0_;
	_tmp1_ = self->priv->file_drop_target;
	g_signal_connect_object (_tmp1_, "accept", (GCallback) _dc_conversation_view_can_accept_file_attachment_dc_file_drop_target_accept, self, 0);
	_tmp2_ = self->priv->file_drop_target;
	g_signal_connect_object (_tmp2_, "dropped", (GCallback) _dc_conversation_view_attach_local_file_dc_file_drop_target_dropped, self, 0);
	_tmp3_ = self->priv->file_drop_target;
	g_signal_connect_object (_tmp3_, "failed", (GCallback) ___lambda96__dc_file_drop_target_failed, self, 0);
}

static DcMessageRow*
dc_conversation_view_pick_message_row (DcConversationView* self,
                                       gdouble x,
                                       gdouble y)
{
	GtkWidget* w = NULL;
	GtkListView* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp9_;
	DcMessageRow* _tmp10_;
	DcMessageRow* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->message_listview;
	_tmp1_ = gtk_widget_pick ((GtkWidget*) _tmp0_, x, y, GTK_PICK_DEFAULT);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	w = _tmp2_;
	while (TRUE) {
		gboolean _tmp3_ = FALSE;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		_tmp4_ = w;
		if (_tmp4_ != NULL) {
			GtkWidget* _tmp5_;
			_tmp5_ = w;
			_tmp3_ = !DC_IS_MESSAGE_ROW (_tmp5_);
		} else {
			_tmp3_ = FALSE;
		}
		if (!_tmp3_) {
			break;
		}
		_tmp6_ = w;
		_tmp7_ = gtk_widget_get_parent (_tmp6_);
		_tmp8_ = _g_object_ref0 (_tmp7_);
		_g_object_unref0 (w);
		w = _tmp8_;
	}
	_tmp9_ = w;
	_tmp10_ = _g_object_ref0 (DC_IS_MESSAGE_ROW (_tmp9_) ? ((DcMessageRow*) _tmp9_) : NULL);
	result = _tmp10_;
	_g_object_unref0 (w);
	return result;
}

static gboolean
dc_conversation_view_pointer_on_selectable_text (DcConversationView* self,
                                                 gdouble x,
                                                 gdouble y)
{
	GtkWidget* w = NULL;
	GtkListView* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->message_listview;
	_tmp1_ = gtk_widget_pick ((GtkWidget*) _tmp0_, x, y, GTK_PICK_DEFAULT);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	w = _tmp2_;
	while (TRUE) {
		gboolean _tmp3_ = FALSE;
		GtkWidget* _tmp4_;
		GtkLabel* lbl = NULL;
		GtkWidget* _tmp6_;
		GtkLabel* _tmp7_;
		gboolean _tmp8_ = FALSE;
		GtkLabel* _tmp9_;
		GtkWidget* _tmp13_;
		GtkWidget* _tmp14_;
		GtkWidget* _tmp15_;
		_tmp4_ = w;
		if (_tmp4_ != NULL) {
			GtkWidget* _tmp5_;
			_tmp5_ = w;
			_tmp3_ = !DC_IS_MESSAGE_ROW (_tmp5_);
		} else {
			_tmp3_ = FALSE;
		}
		if (!_tmp3_) {
			break;
		}
		_tmp6_ = w;
		_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, gtk_label_get_type ()) ? ((GtkLabel*) _tmp6_) : NULL);
		lbl = _tmp7_;
		_tmp9_ = lbl;
		if (_tmp9_ != NULL) {
			GtkLabel* _tmp10_;
			gboolean _tmp11_;
			gboolean _tmp12_;
			_tmp10_ = lbl;
			_tmp11_ = gtk_label_get_selectable (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp8_ = _tmp12_;
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			result = TRUE;
			_g_object_unref0 (lbl);
			_g_object_unref0 (w);
			return result;
		}
		_tmp13_ = w;
		_tmp14_ = gtk_widget_get_parent (_tmp13_);
		_tmp15_ = _g_object_ref0 (_tmp14_);
		_g_object_unref0 (w);
		w = _tmp15_;
		_g_object_unref0 (lbl);
	}
	result = FALSE;
	_g_object_unref0 (w);
	return result;
}

static gboolean
dc_conversation_view_pointer_on_media (DcConversationView* self,
                                       gdouble x,
                                       gdouble y)
{
	GtkWidget* w = NULL;
	GtkListView* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->message_listview;
	_tmp1_ = gtk_widget_pick ((GtkWidget*) _tmp0_, x, y, GTK_PICK_DEFAULT);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	w = _tmp2_;
	while (TRUE) {
		gboolean _tmp3_ = FALSE;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		GtkWidget* _tmp9_;
		_tmp4_ = w;
		if (_tmp4_ != NULL) {
			GtkWidget* _tmp5_;
			_tmp5_ = w;
			_tmp3_ = !DC_IS_MESSAGE_ROW (_tmp5_);
		} else {
			_tmp3_ = FALSE;
		}
		if (!_tmp3_) {
			break;
		}
		_tmp6_ = w;
		if (DC_IS_AUDIO_PLAYER (_tmp6_)) {
			result = TRUE;
			_g_object_unref0 (w);
			return result;
		}
		_tmp7_ = w;
		_tmp8_ = gtk_widget_get_parent (_tmp7_);
		_tmp9_ = _g_object_ref0 (_tmp8_);
		_g_object_unref0 (w);
		w = _tmp9_;
	}
	result = FALSE;
	_g_object_unref0 (w);
	return result;
}

static void
dc_conversation_view_on_message_activated (DcConversationView* self,
                                           DcMessage* msg)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	_tmp1_ = dc_message_get_file_path (msg);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		_tmp3_ = dc_message_get_file_path (msg);
		_tmp4_ = _tmp3_;
		_tmp5_ = strlen (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_ == 0;
	}
	if (_tmp0_) {
		return;
	}
	_tmp7_ = dc_message_get_file_path (msg);
	_tmp8_ = _tmp7_;
	if (!g_file_test (_tmp8_, G_FILE_TEST_EXISTS)) {
		DcWindow* _tmp9_;
		_tmp9_ = self->priv->window;
		dc_window_show_toast (_tmp9_, "File not available");
		return;
	}
	if (dc_message_row_is_image_file (msg)) {
		gchar** paths = NULL;
		gint paths_length1 = 0;
		gint _paths_size_ = 0;
		gint start = 0;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gchar** _tmp12_ = NULL;
		gint _tmp13_ = 0;
		gint _tmp14_ = 0;
		DcWindow* _tmp15_;
		gchar** _tmp16_;
		gint _tmp16__length1;
		_tmp10_ = dc_message_get_file_path (msg);
		_tmp11_ = _tmp10_;
		dc_conversation_view_collect_image_paths (self, _tmp11_, &_tmp12_, &_tmp13_, &_tmp14_);
		paths = (_vala_array_free (paths, paths_length1, (GDestroyNotify) g_free), NULL);
		paths = _tmp12_;
		paths_length1 = _tmp13_;
		_paths_size_ = paths_length1;
		start = _tmp14_;
		_tmp15_ = self->priv->window;
		_tmp16_ = paths;
		_tmp16__length1 = paths_length1;
		dc_window_show_image_list (_tmp15_, _tmp16_, (gint) _tmp16__length1, start);
		paths = (_vala_array_free (paths, paths_length1, (GDestroyNotify) g_free), NULL);
	} else {
		if (dc_message_row_is_video_file (msg)) {
			DcWindow* _tmp17_;
			const gchar* _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			const gchar* _tmp21_;
			_tmp17_ = self->priv->window;
			_tmp18_ = dc_message_get_file_path (msg);
			_tmp19_ = _tmp18_;
			_tmp20_ = dc_message_get_file_name (msg);
			_tmp21_ = _tmp20_;
			dc_window_show_video (_tmp17_, _tmp19_, _tmp21_);
		} else {
			if (dc_message_row_is_audio_file (msg)) {
			} else {
				DcWindow* _tmp22_;
				const gchar* _tmp23_;
				const gchar* _tmp24_;
				const gchar* _tmp25_;
				const gchar* _tmp26_;
				_tmp22_ = self->priv->window;
				_tmp23_ = dc_message_get_file_path (msg);
				_tmp24_ = _tmp23_;
				_tmp25_ = dc_message_get_file_name (msg);
				_tmp26_ = _tmp25_;
				dc_window_save_attachment (_tmp22_, _tmp24_, _tmp26_, NULL, NULL);
			}
		}
	}
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
dc_conversation_view_collect_image_paths (DcConversationView* self,
                                          const gchar* current_path,
                                          gchar*** paths,
                                          gint* paths_length1,
                                          gint* start_index)
{
	gchar** _vala_paths = NULL;
	gint _vala_paths_length1 = 0;
	gint _vala_start_index = 0;
	GPtrArray* list = NULL;
	GPtrArray* _tmp0_;
	gint found = 0;
	guint n = 0U;
	GListStore* _tmp1_;
	GPtrArray* _tmp31_;
	gsize _tmp32_ = 0;
	gpointer* _tmp33_;
	gint _tmp34_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_path != NULL);
	_tmp0_ = g_ptr_array_new_full ((guint) 0, _g_free0_);
	list = _tmp0_;
	found = -1;
	_tmp1_ = self->priv->message_store;
	n = g_list_model_get_n_items ((GListModel*) _tmp1_);
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				DcMessage* m = NULL;
				GListStore* _tmp4_;
				GObject* _tmp5_;
				DcMessage* _tmp6_;
				gboolean _tmp7_ = FALSE;
				DcMessage* _tmp8_;
				const gchar* _tmp9_;
				const gchar* _tmp10_;
				DcMessage* _tmp16_;
				DcMessage* _tmp17_;
				const gchar* _tmp18_;
				const gchar* _tmp19_;
				DcMessage* _tmp20_;
				const gchar* _tmp21_;
				const gchar* _tmp22_;
				GPtrArray* _tmp26_;
				DcMessage* _tmp27_;
				const gchar* _tmp28_;
				const gchar* _tmp29_;
				gchar* _tmp30_;
				if (!_tmp2_) {
					guint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				if (!(i < n)) {
					break;
				}
				_tmp4_ = self->priv->message_store;
				_tmp5_ = g_list_model_get_item ((GListModel*) _tmp4_, i);
				m = G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, DC_TYPE_MESSAGE, DcMessage);
				_tmp6_ = m;
				if (_tmp6_ == NULL) {
					_g_object_unref0 (m);
					continue;
				}
				_tmp8_ = m;
				_tmp9_ = dc_message_get_file_path (_tmp8_);
				_tmp10_ = _tmp9_;
				if (_tmp10_ == NULL) {
					_tmp7_ = TRUE;
				} else {
					DcMessage* _tmp11_;
					const gchar* _tmp12_;
					const gchar* _tmp13_;
					gint _tmp14_;
					gint _tmp15_;
					_tmp11_ = m;
					_tmp12_ = dc_message_get_file_path (_tmp11_);
					_tmp13_ = _tmp12_;
					_tmp14_ = strlen (_tmp13_);
					_tmp15_ = _tmp14_;
					_tmp7_ = _tmp15_ == 0;
				}
				if (_tmp7_) {
					_g_object_unref0 (m);
					continue;
				}
				_tmp16_ = m;
				if (!dc_message_row_is_image_file (_tmp16_)) {
					_g_object_unref0 (m);
					continue;
				}
				_tmp17_ = m;
				_tmp18_ = dc_message_get_file_path (_tmp17_);
				_tmp19_ = _tmp18_;
				if (!g_file_test (_tmp19_, G_FILE_TEST_EXISTS)) {
					_g_object_unref0 (m);
					continue;
				}
				_tmp20_ = m;
				_tmp21_ = dc_message_get_file_path (_tmp20_);
				_tmp22_ = _tmp21_;
				if (g_strcmp0 (_tmp22_, current_path) == 0) {
					GPtrArray* _tmp23_;
					gint _tmp24_;
					gint _tmp25_;
					_tmp23_ = list;
					_tmp24_ = vala_g_ptr_array_get_length (_tmp23_);
					_tmp25_ = _tmp24_;
					found = (gint) _tmp25_;
				}
				_tmp26_ = list;
				_tmp27_ = m;
				_tmp28_ = dc_message_get_file_path (_tmp27_);
				_tmp29_ = _tmp28_;
				_tmp30_ = g_strdup (_tmp29_);
				g_ptr_array_add (_tmp26_, _tmp30_);
				_g_object_unref0 (m);
			}
		}
	}
	_tmp31_ = list;
	_tmp33_ = g_ptr_array_steal (_tmp31_, &_tmp32_);
	_vala_paths = (_vala_array_free (_vala_paths, _vala_paths_length1, (GDestroyNotify) g_free), NULL);
	_vala_paths = _tmp33_;
	_vala_paths_length1 = _tmp32_;
	if (found >= 0) {
		_tmp34_ = found;
	} else {
		_tmp34_ = 0;
	}
	_vala_start_index = _tmp34_;
	_g_ptr_array_unref0 (list);
	if (paths) {
		*paths = _vala_paths;
	} else {
		_vala_paths = (_vala_array_free (_vala_paths, _vala_paths_length1, (GDestroyNotify) g_free), NULL);
	}
	if (paths_length1) {
		*paths_length1 = _vala_paths_length1;
	}
	if (start_index) {
		*start_index = _vala_start_index;
	}
}

gint
dc_conversation_view_get_chat_id (DcConversationView* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_chat_id;
	return result;
}

static void
dc_conversation_view_set_chat_id (DcConversationView* self,
                                  gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_conversation_view_get_chat_id (self);
	if (old_value != value) {
		self->priv->_chat_id = value;
		g_object_notify_by_pspec ((GObject *) self, dc_conversation_view_properties[DC_CONVERSATION_VIEW_CHAT_ID_PROPERTY]);
	}
}

DcPinnedMessagesManager*
dc_conversation_view_get_pinned (DcConversationView* self)
{
	DcPinnedMessagesManager* result;
	DcPinnedMessagesManager* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_pinned;
	result = _tmp0_;
	return result;
}

static void
dc_conversation_view_set_pinned (DcConversationView* self,
                                 DcPinnedMessagesManager* value)
{
	DcPinnedMessagesManager* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_conversation_view_get_pinned (self);
	if (old_value != value) {
		DcPinnedMessagesManager* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_pinned);
		self->priv->_pinned = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_conversation_view_properties[DC_CONVERSATION_VIEW_PINNED_PROPERTY]);
	}
}

DcMessageActions*
dc_conversation_view_get_msg_actions (DcConversationView* self)
{
	DcMessageActions* result;
	DcMessageActions* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_msg_actions;
	result = _tmp0_;
	return result;
}

static void
dc_conversation_view_set_msg_actions (DcConversationView* self,
                                      DcMessageActions* value)
{
	DcMessageActions* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_conversation_view_get_msg_actions (self);
	if (old_value != value) {
		DcMessageActions* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_msg_actions);
		self->priv->_msg_actions = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_conversation_view_properties[DC_CONVERSATION_VIEW_MSG_ACTIONS_PROPERTY]);
	}
}

static void
dc_conversation_view_class_init (DcConversationViewClass * klass,
                                 gpointer klass_data)
{
	dc_conversation_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcConversationView_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_conversation_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_conversation_view_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_conversation_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_CONVERSATION_VIEW_CHAT_ID_PROPERTY, dc_conversation_view_properties[DC_CONVERSATION_VIEW_CHAT_ID_PROPERTY] = g_param_spec_int ("chat-id", "chat-id", "chat-id", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_CONVERSATION_VIEW_PINNED_PROPERTY, dc_conversation_view_properties[DC_CONVERSATION_VIEW_PINNED_PROPERTY] = g_param_spec_object ("pinned", "pinned", "pinned", DC_TYPE_PINNED_MESSAGES_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_CONVERSATION_VIEW_MSG_ACTIONS_PROPERTY, dc_conversation_view_properties[DC_CONVERSATION_VIEW_MSG_ACTIONS_PROPERTY] = g_param_spec_object ("msg-actions", "msg-actions", "msg-actions", DC_TYPE_MESSAGE_ACTIONS, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dc_conversation_view_instance_init (DcConversationView * self,
                                    gpointer klass)
{
	gint* _tmp0_;
	self->priv = dc_conversation_view_get_instance_private (self);
	self->priv->is_contact_request = FALSE;
	self->priv->stick_to_bottom = TRUE;
	_tmp0_ = g_new0 (gint, 0);
	self->priv->pending_seen_ids = _tmp0_;
	self->priv->pending_seen_ids_length1 = 0;
	self->priv->_pending_seen_ids_size_ = self->priv->pending_seen_ids_length1;
	self->priv->all_msg_ids = NULL;
	self->priv->loaded_start_index = (guint) 0;
	self->priv->loading_more = FALSE;
	self->priv->loading_chat = FALSE;
	self->priv->messages_loaded = FALSE;
	self->priv->scroll_freeze_until_us = (gint64) 0;
}

static void
dc_conversation_view_finalize (GObject * obj)
{
	DcConversationView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_CONVERSATION_VIEW, DcConversationView);
	_g_object_unref0 (self->priv->message_listview);
	_g_object_unref0 (self->priv->message_scroll);
	_g_object_unref0 (self->priv->message_store);
	_g_object_unref0 (self->priv->filtered_message_store);
	_g_object_unref0 (self->priv->message_filter);
	_g_object_unref0 (self->priv->compose_bar);
	_g_object_unref0 (self->priv->request_bar);
	_g_object_unref0 (self->priv->scroll_down_btn);
	_g_object_unref0 (self->priv->loading_more_revealer);
	_g_object_unref0 (self->priv->loading_more_spinner);
	_g_object_unref0 (self->priv->message_search_revealer);
	_g_object_unref0 (self->priv->message_search_entry);
	_g_object_unref0 (self->priv->file_drop_target);
	self->priv->pending_seen_ids = (g_free (self->priv->pending_seen_ids), NULL);
	_json_array_unref0 (self->priv->all_msg_ids);
	_g_object_unref0 (self->priv->_pinned);
	_g_object_unref0 (self->priv->_msg_actions);
	G_OBJECT_CLASS (dc_conversation_view_parent_class)->finalize (obj);
}

/**
     * Per-chat conversation view. One instance per chat, cached by the
     * window so each conversation keeps its own draft, scroll position,
     * message store, search state, and pinned bar across chat switches.
     */
static GType
dc_conversation_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcConversationViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_conversation_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcConversationView), 0, (GInstanceInitFunc) dc_conversation_view_instance_init, NULL };
	GType dc_conversation_view_type_id;
	dc_conversation_view_type_id = g_type_register_static (gtk_box_get_type (), "DcConversationView", &g_define_type_info, 0);
	DcConversationView_private_offset = g_type_add_instance_private (dc_conversation_view_type_id, sizeof (DcConversationViewPrivate));
	return dc_conversation_view_type_id;
}

GType
dc_conversation_view_get_type (void)
{
	static volatile gsize dc_conversation_view_type_id__once = 0;
	if (g_once_init_enter (&dc_conversation_view_type_id__once)) {
		GType dc_conversation_view_type_id;
		dc_conversation_view_type_id = dc_conversation_view_get_type_once ();
		g_once_init_leave (&dc_conversation_view_type_id__once, dc_conversation_view_type_id);
	}
	return dc_conversation_view_type_id__once;
}

static void
_vala_dc_conversation_view_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	DcConversationView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_CONVERSATION_VIEW, DcConversationView);
	switch (property_id) {
		case DC_CONVERSATION_VIEW_CHAT_ID_PROPERTY:
		g_value_set_int (value, dc_conversation_view_get_chat_id (self));
		break;
		case DC_CONVERSATION_VIEW_PINNED_PROPERTY:
		g_value_set_object (value, dc_conversation_view_get_pinned (self));
		break;
		case DC_CONVERSATION_VIEW_MSG_ACTIONS_PROPERTY:
		g_value_set_object (value, dc_conversation_view_get_msg_actions (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_conversation_view_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	DcConversationView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_CONVERSATION_VIEW, DcConversationView);
	switch (property_id) {
		case DC_CONVERSATION_VIEW_CHAT_ID_PROPERTY:
		dc_conversation_view_set_chat_id (self, g_value_get_int (value));
		break;
		case DC_CONVERSATION_VIEW_PINNED_PROPERTY:
		dc_conversation_view_set_pinned (self, g_value_get_object (value));
		break;
		case DC_CONVERSATION_VIEW_MSG_ACTIONS_PROPERTY:
		dc_conversation_view_set_msg_actions (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

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

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

