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

#include <adwaita.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <json-glib/json-glib.h>

#define PARLA_VERSION "0.2.6"
#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_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;
typedef struct _DcWindowPrivate DcWindowPrivate;

#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_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;

#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_IMAGE_VIEWER (dc_image_viewer_get_type ())
#define DC_IMAGE_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_IMAGE_VIEWER, DcImageViewer))
#define DC_IMAGE_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_IMAGE_VIEWER, DcImageViewerClass))
#define DC_IS_IMAGE_VIEWER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_IMAGE_VIEWER))
#define DC_IS_IMAGE_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_IMAGE_VIEWER))
#define DC_IMAGE_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_IMAGE_VIEWER, DcImageViewerClass))

typedef struct _DcImageViewer DcImageViewer;
typedef struct _DcImageViewerClass DcImageViewerClass;

#define DC_TYPE_EVENT_HANDLER (dc_event_handler_get_type ())
#define DC_EVENT_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_EVENT_HANDLER, DcEventHandler))
#define DC_EVENT_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_EVENT_HANDLER, DcEventHandlerClass))
#define DC_IS_EVENT_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_EVENT_HANDLER))
#define DC_IS_EVENT_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_EVENT_HANDLER))
#define DC_EVENT_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_EVENT_HANDLER, DcEventHandlerClass))

typedef struct _DcEventHandler DcEventHandler;
typedef struct _DcEventHandlerClass DcEventHandlerClass;

#define DC_TYPE_CHAT_CONTEXT_MENU (dc_chat_context_menu_get_type ())
#define DC_CHAT_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_CONTEXT_MENU, DcChatContextMenu))
#define DC_CHAT_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_CONTEXT_MENU, DcChatContextMenuClass))
#define DC_IS_CHAT_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_CONTEXT_MENU))
#define DC_IS_CHAT_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_CONTEXT_MENU))
#define DC_CHAT_CONTEXT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_CONTEXT_MENU, DcChatContextMenuClass))

typedef struct _DcChatContextMenu DcChatContextMenu;
typedef struct _DcChatContextMenuClass DcChatContextMenuClass;
enum  {
	DC_WINDOW_0_PROPERTY,
	DC_WINDOW_CHAT_STORE_PROPERTY,
	DC_WINDOW_CURRENT_CHAT_ID_PROPERTY,
	DC_WINDOW_NUM_PROPERTIES
};
static GParamSpec* dc_window_properties[DC_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

#define DC_TYPE_APPLICATION (dc_application_get_type ())
#define DC_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_APPLICATION, DcApplication))
#define DC_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_APPLICATION, DcApplicationClass))
#define DC_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_APPLICATION))
#define DC_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_APPLICATION))
#define DC_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_APPLICATION, DcApplicationClass))

typedef struct _DcApplication DcApplication;
typedef struct _DcApplicationClass DcApplicationClass;
typedef struct _Block1Data Block1Data;

#define DC_TYPE_CHAT_ROW (dc_chat_row_get_type ())
#define DC_CHAT_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_ROW, DcChatRow))
#define DC_CHAT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_ROW, DcChatRowClass))
#define DC_IS_CHAT_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_ROW))
#define DC_IS_CHAT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_ROW))
#define DC_CHAT_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_ROW, DcChatRowClass))

typedef struct _DcChatRow DcChatRow;
typedef struct _DcChatRowClass DcChatRowClass;
typedef enum  {
	DC_RPC_SERVER_SOURCE_AUTO = 0,
	DC_RPC_SERVER_SOURCE_CUSTOM = 1,
	DC_RPC_SERVER_SOURCE_DESKTOP = 2
} DcRpcServerSource;

#define DC_TYPE_RPC_SERVER_SOURCE (dc_rpc_server_source_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcWindowTryConnectData DcWindowTryConnectData;
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))

#define DC_TYPE_CHAT_ENTRY (dc_chat_entry_get_type ())
#define DC_CHAT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_ENTRY, DcChatEntry))
#define DC_CHAT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_ENTRY, DcChatEntryClass))
#define DC_IS_CHAT_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_ENTRY))
#define DC_IS_CHAT_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_ENTRY))
#define DC_CHAT_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_ENTRY, DcChatEntryClass))

typedef struct _DcChatEntry DcChatEntry;
typedef struct _DcChatEntryClass DcChatEntryClass;
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
typedef struct _DcWindowLoadChatsData DcWindowLoadChatsData;
typedef struct _DcWindowNoticeChatData DcWindowNoticeChatData;
typedef struct _DcWindowSaveAttachmentData DcWindowSaveAttachmentData;
typedef struct _DcWindowOnIncomingMsgData DcWindowOnIncomingMsgData;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
typedef struct _DcWindowLoadAccountMenuData DcWindowLoadAccountMenuData;
typedef struct _DcWindowBuildAccountMenuRowForIdData DcWindowBuildAccountMenuRowForIdData;
typedef struct _Block2Data Block2Data;
typedef struct _Block3Data Block3Data;

#define DC_TYPE_CREATE_PROFILE_DIALOG (dc_create_profile_dialog_get_type ())
#define DC_CREATE_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CREATE_PROFILE_DIALOG, DcCreateProfileDialog))
#define DC_CREATE_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CREATE_PROFILE_DIALOG, DcCreateProfileDialogClass))
#define DC_IS_CREATE_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CREATE_PROFILE_DIALOG))
#define DC_IS_CREATE_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CREATE_PROFILE_DIALOG))
#define DC_CREATE_PROFILE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CREATE_PROFILE_DIALOG, DcCreateProfileDialogClass))

typedef struct _DcCreateProfileDialog DcCreateProfileDialog;
typedef struct _DcCreateProfileDialogClass DcCreateProfileDialogClass;
typedef struct _DcWindowAfterProfileCreatedData DcWindowAfterProfileCreatedData;

#define DC_TYPE_INVITATION_CODE_PROFILE_DIALOG (dc_invitation_code_profile_dialog_get_type ())
#define DC_INVITATION_CODE_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_INVITATION_CODE_PROFILE_DIALOG, DcInvitationCodeProfileDialog))
#define DC_INVITATION_CODE_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_INVITATION_CODE_PROFILE_DIALOG, DcInvitationCodeProfileDialogClass))
#define DC_IS_INVITATION_CODE_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_INVITATION_CODE_PROFILE_DIALOG))
#define DC_IS_INVITATION_CODE_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_INVITATION_CODE_PROFILE_DIALOG))
#define DC_INVITATION_CODE_PROFILE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_INVITATION_CODE_PROFILE_DIALOG, DcInvitationCodeProfileDialogClass))

typedef struct _DcInvitationCodeProfileDialog DcInvitationCodeProfileDialog;
typedef struct _DcInvitationCodeProfileDialogClass DcInvitationCodeProfileDialogClass;
typedef struct _DcWindowAfterInvitationProfileCreatedData DcWindowAfterInvitationProfileCreatedData;

#define DC_TYPE_RECEIVE_BACKUP_DIALOG (dc_receive_backup_dialog_get_type ())
#define DC_RECEIVE_BACKUP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RECEIVE_BACKUP_DIALOG, DcReceiveBackupDialog))
#define DC_RECEIVE_BACKUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RECEIVE_BACKUP_DIALOG, DcReceiveBackupDialogClass))
#define DC_IS_RECEIVE_BACKUP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RECEIVE_BACKUP_DIALOG))
#define DC_IS_RECEIVE_BACKUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RECEIVE_BACKUP_DIALOG))
#define DC_RECEIVE_BACKUP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RECEIVE_BACKUP_DIALOG, DcReceiveBackupDialogClass))

typedef struct _DcReceiveBackupDialog DcReceiveBackupDialog;
typedef struct _DcReceiveBackupDialogClass DcReceiveBackupDialogClass;
typedef struct _DcWindowAfterSecondaryDeviceImportedData DcWindowAfterSecondaryDeviceImportedData;
typedef struct _Block4Data Block4Data;
typedef struct _DcWindowDoAddAccountData DcWindowDoAddAccountData;
typedef struct _DcWindowSwitchAccountFromMenuData DcWindowSwitchAccountFromMenuData;
typedef struct _DcWindowSwitchAccountData DcWindowSwitchAccountData;
typedef struct _Block5Data Block5Data;

#define DC_TYPE_PROFILE_DIALOG (dc_profile_dialog_get_type ())
#define DC_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_PROFILE_DIALOG, DcProfileDialog))
#define DC_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_PROFILE_DIALOG, DcProfileDialogClass))
#define DC_IS_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_PROFILE_DIALOG))
#define DC_IS_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_PROFILE_DIALOG))
#define DC_PROFILE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_PROFILE_DIALOG, DcProfileDialogClass))

typedef struct _DcProfileDialog DcProfileDialog;
typedef struct _DcProfileDialogClass DcProfileDialogClass;
typedef struct _DcWindowAfterProfileDeletedData DcWindowAfterProfileDeletedData;
typedef struct _DcWindowSwitchToFirstConfiguredAccountData DcWindowSwitchToFirstConfiguredAccountData;
typedef struct _DcWindowLoadProfileAvatarData DcWindowLoadProfileAvatarData;

#define DC_TYPE_CONTACT_PICKER_DIALOG (dc_contact_picker_dialog_get_type ())
#define DC_CONTACT_PICKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialog))
#define DC_CONTACT_PICKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialogClass))
#define DC_IS_CONTACT_PICKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CONTACT_PICKER_DIALOG))
#define DC_IS_CONTACT_PICKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CONTACT_PICKER_DIALOG))
#define DC_CONTACT_PICKER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CONTACT_PICKER_DIALOG, DcContactPickerDialogClass))

typedef struct _DcContactPickerDialog DcContactPickerDialog;
typedef struct _DcContactPickerDialogClass DcContactPickerDialogClass;
typedef struct _DcWindowCreateChatByEmailData DcWindowCreateChatByEmailData;

#define DC_TYPE_NEW_GROUP_DIALOG (dc_new_group_dialog_get_type ())
#define DC_NEW_GROUP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_NEW_GROUP_DIALOG, DcNewGroupDialog))
#define DC_NEW_GROUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_NEW_GROUP_DIALOG, DcNewGroupDialogClass))
#define DC_IS_NEW_GROUP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_NEW_GROUP_DIALOG))
#define DC_IS_NEW_GROUP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_NEW_GROUP_DIALOG))
#define DC_NEW_GROUP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_NEW_GROUP_DIALOG, DcNewGroupDialogClass))

typedef struct _DcNewGroupDialog DcNewGroupDialog;
typedef struct _DcNewGroupDialogClass DcNewGroupDialogClass;
typedef struct _DcWindowAfterGroupCreatedData DcWindowAfterGroupCreatedData;
typedef struct _Block6Data Block6Data;
typedef struct _DcWindowUseInviteLinkData DcWindowUseInviteLinkData;

#define DC_TYPE_SETTINGS_DIALOG (dc_settings_dialog_get_type ())
#define DC_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SETTINGS_DIALOG, DcSettingsDialog))
#define DC_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SETTINGS_DIALOG, DcSettingsDialogClass))
#define DC_IS_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SETTINGS_DIALOG))
#define DC_IS_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SETTINGS_DIALOG))
#define DC_SETTINGS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SETTINGS_DIALOG, DcSettingsDialogClass))

typedef struct _DcSettingsDialog DcSettingsDialog;
typedef struct _DcSettingsDialogClass DcSettingsDialogClass;
typedef struct _DcWindowReloadActiveAccountData DcWindowReloadActiveAccountData;

#define DC_TYPE_QUICK_SWITCH_DIALOG (dc_quick_switch_dialog_get_type ())
#define DC_QUICK_SWITCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_QUICK_SWITCH_DIALOG, DcQuickSwitchDialog))
#define DC_QUICK_SWITCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_QUICK_SWITCH_DIALOG, DcQuickSwitchDialogClass))
#define DC_IS_QUICK_SWITCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_QUICK_SWITCH_DIALOG))
#define DC_IS_QUICK_SWITCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_QUICK_SWITCH_DIALOG))
#define DC_QUICK_SWITCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_QUICK_SWITCH_DIALOG, DcQuickSwitchDialogClass))

typedef struct _DcQuickSwitchDialog DcQuickSwitchDialog;
typedef struct _DcQuickSwitchDialogClass DcQuickSwitchDialogClass;

struct _DcWindow {
	AdwApplicationWindow parent_instance;
	DcWindowPrivate * priv;
	DcSettingsManager* settings;
};

struct _DcWindowClass {
	AdwApplicationWindowClass parent_class;
};

struct _DcWindowPrivate {
	AdwToastOverlay* toast_overlay;
	AdwNavigationSplitView* split_view;
	AdwHeaderBar* sidebar_header;
	AdwHeaderBar* content_header;
	GtkLabel* content_title_label;
	GtkSearchEntry* search_entry;
	GtkListBox* chat_listbox;
	GListStore* _chat_store;
	GHashTable* views;
	AdwStatusPage* empty_status;
	GtkStack* content_stack;
	GtkRevealer* connection_banner;
	GtkLabel* connection_banner_label;
	AdwAvatar* profile_avatar;
	GtkPopover* account_popover;
	GtkListBox* account_menu_list;
	DcRpcClient* rpc;
	gint _current_chat_id;
	gboolean suppress_reselect_scroll;
	DcImageViewer* image_viewer;
	DcEventHandler* events;
	DcChatContextMenu* chat_menu;
	AdwDialog* active_modal;
};

struct _Block1Data {
	int _ref_count_;
	DcWindow* self;
	GtkGestureClick* right_click;
};

struct _DcWindowTryConnectData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	GtkApplication* _tmp0_;
	GtkApplication* _tmp1_;
	DcRpcClient* _tmp2_;
	DcRpcClient* _tmp3_;
	AdwStatusPage* _tmp4_;
	AdwStatusPage* _tmp5_;
	AdwStatusPage* _tmp6_;
	AdwStatusPage* _tmp7_;
	gchar* rpc_path;
	DcSettingsManager* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	DcSettingsManager* _tmp11_;
	DcRpcServerSource _tmp12_;
	DcRpcServerSource _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* data_dir;
	DcSettingsManager* _tmp16_;
	DcRpcServerSource _tmp17_;
	DcRpcServerSource _tmp18_;
	gchar* _tmp19_;
	const gchar* _tmp20_;
	AdwStatusPage* _tmp21_;
	AdwStatusPage* _tmp22_;
	AdwStatusPage* _tmp23_;
	GtkStack* _tmp24_;
	gchar* accounts_path;
	const gchar* _tmp25_;
	gchar* _tmp26_;
	DcRpcClient* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	gchar** _tmp30_;
	gchar** _tmp31_;
	gint _tmp31__length1;
	const gchar* _tmp32_;
	const gchar* _tmp33_;
	GError* e;
	gchar* msg;
	GError* _tmp34_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	gboolean _tmp37_;
	const gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gboolean _tmp41_;
	const gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	AdwStatusPage* _tmp45_;
	const gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	AdwStatusPage* _tmp49_;
	const gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	DcRpcClient* _tmp55_;
	gchar* acct_desc;
	gchar* acct_toast;
	DcRpcClient* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_;
	const gchar* _tmp59_;
	const gchar* _tmp60_;
	const gchar* _tmp61_;
	AdwStatusPage* _tmp62_;
	const gchar* _tmp63_;
	DcRpcClient* _tmp64_;
	DcEventHandler* _tmp65_;
	DcEventHandler* _tmp66_;
	GtkApplication* _tmp67_;
	GtkApplication* _tmp68_;
	DcEventHandler* _tmp69_;
	DcEventHandler* _tmp70_;
	DcEventHandler* _tmp71_;
	DcRpcClient* _tmp72_;
	GListStore* _tmp73_;
	DcChatContextMenu* _tmp74_;
	DcRpcClient* _tmp75_;
	gint _tmp76_;
	gint _tmp77_;
	gchar* _tmp78_;
	DcRpcClient* _tmp79_;
	gchar* _tmp80_;
	DcRpcClient* _tmp81_;
	DcRpcClient* _tmp82_;
	DcEventHandler* _tmp83_;
	GError* _inner_error0_;
};

struct _DcWindowLoadChatsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	JsonArray* entries;
	DcRpcClient* _tmp3_;
	JsonArray* _tmp4_;
	JsonArray* _tmp5_;
	JsonObject* items;
	DcRpcClient* _tmp6_;
	JsonArray* _tmp7_;
	JsonObject* _tmp8_;
	GListStore* _tmp9_;
	GtkListBox* _tmp10_;
	GtkListBoxRow* reselect_row;
	guint i;
	gboolean _tmp11_;
	guint _tmp12_;
	JsonArray* _tmp13_;
	gint chat_id;
	JsonArray* _tmp14_;
	gchar* id_str;
	gchar* _tmp15_;
	gboolean _tmp16_;
	JsonObject* _tmp17_;
	JsonObject* _tmp18_;
	const gchar* _tmp19_;
	JsonObject* item;
	JsonObject* _tmp20_;
	const gchar* _tmp21_;
	JsonObject* _tmp22_;
	JsonObject* _tmp23_;
	DcChatEntry* entry;
	JsonObject* _tmp24_;
	DcChatEntry* _tmp25_;
	GListStore* _tmp26_;
	DcChatEntry* _tmp27_;
	DcChatRow* chat_row;
	DcChatEntry* _tmp28_;
	DcChatRow* _tmp29_;
	GtkListBox* _tmp30_;
	DcChatRow* _tmp31_;
	gint _tmp32_;
	gint _tmp33_;
	GtkListBox* _tmp34_;
	GtkListBoxRow* _tmp35_;
	GtkListBoxRow* _tmp36_;
	GtkListBoxRow* _tmp37_;
	GtkListBox* _tmp38_;
	GtkListBoxRow* _tmp39_;
	GError* e;
	GError* _tmp40_;
	const gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	GError* _inner_error0_;
};

struct _DcWindowNoticeChatData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint chat_id;
	DcRpcClient* _tmp0_;
	GError* _inner_error0_;
};

struct _DcWindowSaveAttachmentData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gchar* src_path;
	gchar* name;
	GtkFileDialog* dialog;
	GtkFileDialog* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GtkFileDialog* _tmp4_;
	GFile* dest;
	GtkFileDialog* _tmp5_;
	GFile* _tmp6_;
	GFile* _tmp7_;
	GFile* src_file;
	GFile* _tmp8_;
	GFile* _tmp9_;
	GFile* _tmp10_;
	GError* e;
	GError* _tmp11_;
	GError* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	GError* _inner_error0_;
};

struct _DcWindowOnIncomingMsgData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint chat_id;
	gint msg_id;
	DcConversationView* view;
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	DcConversationView* _tmp2_;
	DcConversationView* _tmp3_;
	DcConversationView* _tmp4_;
	gboolean _tmp5_;
	DcSettingsManager* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	DcEventHandler* _tmp11_;
};

struct _DcWindowLoadAccountMenuData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	GtkListBox* _tmp0_;
	gboolean _tmp1_;
	DcRpcClient* _tmp2_;
	DcRpcClient* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	AdwActionRow* row;
	AdwActionRow* _tmp6_;
	AdwActionRow* _tmp7_;
	AdwActionRow* _tmp8_;
	GtkListBox* _tmp9_;
	AdwActionRow* _tmp10_;
	JsonNode* accounts_node;
	DcRpcClient* _tmp11_;
	JsonNode* _tmp12_;
	GtkListBox* _tmp13_;
	JsonNode* _tmp14_;
	JsonArray* accounts;
	JsonNode* _tmp15_;
	JsonArray* _tmp16_;
	JsonArray* _tmp17_;
	guint i;
	gboolean _tmp18_;
	guint _tmp19_;
	JsonArray* _tmp20_;
	JsonObject* acct;
	JsonArray* _tmp21_;
	JsonObject* _tmp22_;
	JsonObject* _tmp23_;
	gint id;
	JsonObject* _tmp24_;
	AdwActionRow* _tmp25_;
	DcRpcClient* _tmp26_;
	gint _tmp27_;
	gint _tmp28_;
	AdwActionRow* _tmp29_;
	GtkListBox* _tmp30_;
	JsonArray* _tmp31_;
	AdwActionRow* empty;
	AdwActionRow* _tmp32_;
	AdwActionRow* _tmp33_;
	AdwActionRow* _tmp34_;
	GtkListBox* _tmp35_;
	AdwActionRow* _tmp36_;
	GtkListBox* _tmp37_;
	AdwActionRow* _tmp38_;
	AdwActionRow* _tmp39_;
	GError* e;
	GtkListBox* _tmp40_;
	AdwActionRow* err_row;
	AdwActionRow* _tmp41_;
	AdwActionRow* _tmp42_;
	AdwActionRow* _tmp43_;
	AdwActionRow* _tmp44_;
	GError* _tmp45_;
	const gchar* _tmp46_;
	GtkListBox* _tmp47_;
	AdwActionRow* _tmp48_;
	GError* _inner_error0_;
};

struct _DcWindowBuildAccountMenuRowForIdData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint id;
	gboolean current;
	AdwActionRow* result;
	gboolean configured;
	DcRpcClient* _tmp0_;
	gchar* email;
	gchar* display_name;
	gchar* avatar;
	gchar* _tmp1_;
	DcRpcClient* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	DcRpcClient* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	DcRpcClient* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	AdwActionRow* _tmp16_;
	GError* _inner_error0_;
};

struct _Block2Data {
	int _ref_count_;
	DcWindow* self;
	gint id;
};

struct _Block3Data {
	int _ref_count_;
	DcWindow* self;
	AdwDialog* dialog;
};

struct _DcWindowAfterProfileCreatedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint new_id;
	gboolean changed;
};

struct _DcWindowAfterInvitationProfileCreatedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint new_id;
	gint chat_id;
	gboolean changed;
	const gchar* _tmp0_;
};

struct _DcWindowAfterSecondaryDeviceImportedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint new_id;
	gboolean changed;
};

struct _Block4Data {
	int _ref_count_;
	DcWindow* self;
	AdwAlertDialog* dialog;
	GtkEntry* email_entry;
	GtkPasswordEntry* pass_entry;
};

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

struct _DcWindowSwitchAccountFromMenuData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint acct_id;
	gboolean changed;
};

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

struct _Block5Data {
	int _ref_count_;
	DcWindow* self;
	gboolean edits_current_account;
};

struct _DcWindowAfterProfileDeletedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint deleted_id;
	gboolean was_current_account;
	gboolean switched_account;
	DcRpcClient* _tmp0_;
	const gchar* _tmp1_;
};

struct _DcWindowSwitchToFirstConfiguredAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint skip_id;
	gboolean result;
	JsonNode* accounts_node;
	DcRpcClient* _tmp0_;
	JsonNode* _tmp1_;
	JsonNode* _tmp2_;
	JsonArray* accounts;
	JsonNode* _tmp3_;
	JsonArray* _tmp4_;
	JsonArray* _tmp5_;
	guint i;
	gboolean _tmp6_;
	guint _tmp7_;
	JsonArray* _tmp8_;
	JsonObject* acct;
	JsonArray* _tmp9_;
	JsonObject* _tmp10_;
	JsonObject* _tmp11_;
	gint id;
	JsonObject* _tmp12_;
	gboolean _tmp13_;
	gboolean configured;
	gboolean _tmp14_;
	DcRpcClient* _tmp15_;
	gboolean _tmp16_;
	GError* e;
	GError* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	GError* _inner_error0_;
};

struct _DcWindowLoadProfileAvatarData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gchar* name;
	DcRpcClient* _tmp3_;
	gchar* _tmp4_;
	gchar* avatar;
	DcRpcClient* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	AdwAvatar* _tmp9_;
	AdwAvatar* _tmp10_;
	const gchar* _tmp11_;
	GdkTexture* _tmp12_;
	GdkTexture* _tmp13_;
	GError* _inner_error0_;
};

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

struct _DcWindowAfterGroupCreatedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	gint chat_id;
};

struct _Block6Data {
	int _ref_count_;
	DcWindow* self;
	AdwDialog* dialog;
	GtkEntry* entry;
	GtkLabel* status;
	GtkButton* add_btn;
};

struct _DcWindowUseInviteLinkData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	AdwDialog* dialog;
	GtkEntry* entry;
	GtkLabel* status;
	GtkButton* add_btn;
	gchar* invite_link;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	JsonObject* qr;
	DcRpcClient* _tmp6_;
	DcRpcClient* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	const gchar* _tmp10_;
	JsonObject* _tmp11_;
	gboolean _tmp12_;
	JsonObject* _tmp13_;
	JsonObject* _tmp14_;
	AdwDialog* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gchar* kind;
	JsonObject* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gboolean _tmp25_;
	gboolean _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	AdwDialog* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gint _tmp35_;
	gint _tmp36_;
	gint chat_id;
	DcRpcClient* _tmp37_;
	DcRpcClient* _tmp38_;
	gint _tmp39_;
	gint _tmp40_;
	const gchar* _tmp41_;
	GError* e;
	GError* _tmp42_;
	const gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	GError* _inner_error1_;
	AdwDialog* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gint _tmp51_;
	gint _tmp52_;
	GError* _inner_error0_;
};

struct _DcWindowReloadActiveAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcWindow* self;
	GListStore* _tmp0_;
	GtkListBox* _tmp1_;
	GtkSearchEntry* _tmp2_;
	GtkLabel* _tmp3_;
	AdwStatusPage* _tmp4_;
	DcRpcClient* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	DcRpcClient* _tmp8_;
	AdwAvatar* _tmp9_;
	AdwAvatar* _tmp10_;
	AdwStatusPage* _tmp11_;
	AdwStatusPage* _tmp12_;
	AdwStatusPage* _tmp13_;
	GtkStack* _tmp14_;
	AdwStatusPage* _tmp15_;
	AdwStatusPage* _tmp16_;
	AdwStatusPage* _tmp17_;
	gchar* _tmp18_;
	DcRpcClient* _tmp19_;
	gchar* _tmp20_;
	DcRpcClient* _tmp21_;
	DcRpcClient* _tmp22_;
	GtkStack* _tmp23_;
	gboolean _tmp24_;
	DcEventHandler* _tmp25_;
	DcEventHandler* _tmp26_;
	gboolean _tmp27_;
	gboolean _tmp28_;
	DcEventHandler* _tmp29_;
	GError* _inner_error0_;
};

static gint DcWindow_private_offset;
static gpointer dc_window_parent_class = NULL;

VALA_EXTERN GType dc_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcWindow, 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_conversation_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcConversationView, 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_image_viewer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcImageViewer, g_object_unref)
VALA_EXTERN GType dc_event_handler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcEventHandler, g_object_unref)
VALA_EXTERN GType dc_chat_context_menu_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatContextMenu, g_object_unref)
VALA_EXTERN GType dc_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcApplication, g_object_unref)
VALA_EXTERN DcWindow* dc_window_new (DcApplication* app);
VALA_EXTERN DcWindow* dc_window_construct (GType object_type,
                               DcApplication* app);
static void dc_window_build_ui (DcWindow* self);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static GtkPopover* dc_window_build_account_popover (DcWindow* self);
static void __lambda127_ (DcWindow* self);
static void dc_window_load_account_menu (DcWindow* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
static void dc_window_load_account_menu_finish (DcWindow* self,
                                         GAsyncResult* _res_);
static void ___lambda127__gtk_widget_map (GtkWidget* _sender,
                                   gpointer self);
static GMenuModel* dc_window_build_app_menu (DcWindow* self);
static void __lambda163_ (DcWindow* self);
static void ___lambda163__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                                    gpointer self);
static gboolean dc_window_filter_chats (DcWindow* self,
                                 GtkListBoxRow* row);
static gboolean _dc_window_filter_chats_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                           gpointer self);
static void dc_window_on_chat_selected (DcWindow* self,
                                 GtkListBoxRow* row);
static void _dc_window_on_chat_selected_gtk_list_box_row_selected (GtkListBox* _sender,
                                                            GtkListBoxRow* row,
                                                            gpointer self);
static void __lambda164_ (Block1Data* _data1_,
                   gint n,
                   gdouble x,
                   gdouble y);
VALA_EXTERN GType dc_chat_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatRow, g_object_unref)
VALA_EXTERN void dc_chat_context_menu_show (DcChatContextMenu* self,
                                gint chat_id,
                                gdouble x,
                                gdouble y,
                                GtkWidget* parent);
VALA_EXTERN gint dc_chat_row_get_chat_id (DcChatRow* self);
static void ___lambda164__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                              gint n_press,
                                              gdouble x,
                                              gdouble y,
                                              gpointer self);
static void __lambda165_ (DcWindow* self);
static void dc_window_toggle_message_search (DcWindow* self);
static void ___lambda165__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN GtkWidget* dc_image_viewer_get_widget (DcImageViewer* self);
static GtkRevealer* dc_window_build_connection_banner (DcWindow* self);
static gboolean dc_window_on_window_key_pressed (DcWindow* self,
                                          guint keyval,
                                          guint keycode,
                                          GdkModifierType state);
static gboolean _dc_window_on_window_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                guint keyval,
                                                                                guint keycode,
                                                                                GdkModifierType state,
                                                                                gpointer self);
static void dc_window_on_account_menu_row_activated (DcWindow* self,
                                              GtkListBoxRow* row);
static void _dc_window_on_account_menu_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                          GtkListBoxRow* row,
                                                                          gpointer self);
static void dc_window_try_connect_data_free (gpointer _data);
static void dc_window_try_connect (DcWindow* self,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_);
static void dc_window_try_connect_finish (DcWindow* self,
                                   GAsyncResult* _res_);
static gboolean dc_window_try_connect_co (DcWindowTryConnectData* _data_);
VALA_EXTERN DcRpcClient* dc_application_get_rpc (DcApplication* self);
VALA_EXTERN GType dc_rpc_server_source_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* dc_account_finder_find_rpc_server (const gchar* custom_path,
                                          DcRpcServerSource source);
VALA_EXTERN const gchar* dc_settings_manager_get_rpc_server_path (DcSettingsManager* self);
VALA_EXTERN DcRpcServerSource dc_settings_manager_get_rpc_server_source (DcSettingsManager* self);
VALA_EXTERN void dc_window_set_connection_status (DcWindow* self,
                                      gboolean connected,
                                      const gchar* reason);
static void dc_window_show_rpc_not_found (DcWindow* self);
VALA_EXTERN gchar* dc_account_finder_get_data_dir (gboolean use_desktop_store);
VALA_EXTERN void dc_window_show_toast (DcWindow* self,
                           const gchar* message);
VALA_EXTERN void dc_rpc_client_start (DcRpcClient* self,
                          gchar** argv,
                          gint argv_length1,
                          const gchar* cwd,
                          const gchar* accounts_path,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_start_finish (DcRpcClient* self,
                                 GAsyncResult* _res_,
                                 GError** error);
static void dc_window_try_connect_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_);
static void __lambda156_ (DcWindow* self,
                   const gchar* reason);
static void ___lambda156__dc_rpc_client_disconnected (DcRpcClient* _sender,
                                               const gchar* reason,
                                               gpointer self);
VALA_EXTERN void dc_account_finder_ensure_configured (DcRpcClient* rpc,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN gint dc_account_finder_ensure_configured_finish (GAsyncResult* _res_,
                                                 gchar** description,
                                                 gchar** toast_msg);
VALA_EXTERN DcEventHandler* dc_event_handler_new (DcRpcClient* rpc);
VALA_EXTERN DcEventHandler* dc_event_handler_construct (GType object_type,
                                            DcRpcClient* rpc);
VALA_EXTERN void dc_event_handler_set_app (DcEventHandler* self,
                               GApplication* a);
static void __lambda157_ (DcWindow* self);
VALA_EXTERN void dc_window_load_chats (DcWindow* self,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_);
VALA_EXTERN void dc_window_load_chats_finish (DcWindow* self,
                                  GAsyncResult* _res_);
static void ___lambda157__dc_event_handler_chats_reload_fired (DcEventHandler* _sender,
                                                        gpointer self);
static void __lambda158_ (DcWindow* self);
static DcConversationView* dc_window_current_view (DcWindow* self);
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 void ___lambda158__dc_event_handler_messages_reload_fired (DcEventHandler* _sender,
                                                           gpointer self);
static void __lambda159_ (DcWindow* self,
                   gint chat_id,
                   gint msg_id);
static void dc_window_on_incoming_msg (DcWindow* self,
                                gint chat_id,
                                gint msg_id,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
static void dc_window_on_incoming_msg_finish (DcWindow* self,
                                       GAsyncResult* _res_);
static void ___lambda159__dc_event_handler_incoming_msg_received (DcEventHandler* _sender,
                                                           gint chat_id,
                                                           gint msg_id,
                                                           gpointer self);
VALA_EXTERN GListStore* dc_window_get_chat_store (DcWindow* self);
VALA_EXTERN DcChatContextMenu* dc_chat_context_menu_new (DcWindow* window,
                                             DcRpcClient* rpc,
                                             GListStore* chat_store);
VALA_EXTERN DcChatContextMenu* dc_chat_context_menu_construct (GType object_type,
                                                   DcWindow* window,
                                                   DcRpcClient* rpc,
                                                   GListStore* chat_store);
VALA_EXTERN gint dc_rpc_client_get_account_id (DcRpcClient* self);
VALA_EXTERN void dc_rpc_client_get_config (DcRpcClient* self,
                               const gchar* key,
                               gint acct_id,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_config_finish (DcRpcClient* self,
                                        GAsyncResult* _res_,
                                        GError** error);
VALA_EXTERN void dc_rpc_client_set_self_email (DcRpcClient* self,
                                   const gchar* value);
static void dc_window_load_profile_avatar (DcWindow* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void dc_window_load_profile_avatar_finish (DcWindow* self,
                                           GAsyncResult* _res_);
VALA_EXTERN void dc_event_handler_start (DcEventHandler* self,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_);
VALA_EXTERN void dc_event_handler_start_finish (DcEventHandler* self,
                                    GAsyncResult* _res_);
static void dc_window_show_settings_dialog (DcWindow* self);
static void _dc_window_show_settings_dialog_gtk_button_clicked (GtkButton* _sender,
                                                         gpointer self);
VALA_EXTERN void dc_window_clear_chat_view (DcWindow* self);
static void dc_window_set_current_chat_id (DcWindow* self,
                                    gint value);
VALA_EXTERN gint dc_window_get_current_chat_id (DcWindow* self);
static DcConversationView* dc_window_get_or_create_view (DcWindow* self,
                                                  gint chat_id);
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 void dc_window_request_messages_reload (DcWindow* self);
VALA_EXTERN void dc_event_handler_schedule_messages_reload (DcEventHandler* self);
static void dc_window_load_chats_data_free (gpointer _data);
static gboolean dc_window_load_chats_co (DcWindowLoadChatsData* _data_);
VALA_EXTERN void dc_rpc_client_get_chatlist_entries (DcRpcClient* self,
                                         const gchar* query,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN JsonArray* dc_rpc_client_get_chatlist_entries_finish (DcRpcClient* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
static void dc_window_load_chats_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_get_chatlist_items_by_entries (DcRpcClient* self,
                                                  JsonArray* entries,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN JsonObject* dc_rpc_client_get_chatlist_items_by_entries_finish (DcRpcClient* self,
                                                                GAsyncResult* _res_,
                                                                GError** error);
VALA_EXTERN void dc_clear_listbox (GtkListBox* lb);
VALA_EXTERN GType dc_chat_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatEntry, g_object_unref)
VALA_EXTERN DcChatEntry* dc_rpc_client_parse_chat_item (gint chat_id,
                                            JsonObject* obj);
VALA_EXTERN DcChatRow* dc_chat_row_new (DcChatEntry* entry);
VALA_EXTERN DcChatRow* dc_chat_row_construct (GType object_type,
                                  DcChatEntry* entry);
VALA_EXTERN DcChatEntry* dc_find_chat_entry (GListStore* store,
                                 gint chat_id);
VALA_EXTERN const gchar* dc_chat_entry_get_name (DcChatEntry* self);
VALA_EXTERN void dc_conversation_view_on_reselected (DcConversationView* self);
VALA_EXTERN void dc_conversation_view_on_activated (DcConversationView* self);
static void dc_window_notice_chat (DcWindow* self,
                            gint chat_id,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_);
static void dc_window_notice_chat_finish (DcWindow* self,
                                   GAsyncResult* _res_);
static void dc_window_notice_chat_data_free (gpointer _data);
static gboolean dc_window_notice_chat_co (DcWindowNoticeChatData* _data_);
VALA_EXTERN void dc_rpc_client_marknoticed_chat (DcRpcClient* self,
                                     gint chat_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_marknoticed_chat_finish (DcRpcClient* self,
                                            GAsyncResult* _res_,
                                            GError** error);
static void dc_window_notice_chat_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_);
VALA_EXTERN void dc_window_show_image (DcWindow* self,
                           const gchar* path);
VALA_EXTERN void dc_image_viewer_show (DcImageViewer* self,
                           const gchar* path);
VALA_EXTERN void dc_window_show_image_list (DcWindow* self,
                                gchar** paths,
                                gint paths_length1,
                                gint start_index);
VALA_EXTERN void dc_image_viewer_show_list (DcImageViewer* self,
                                gchar** image_paths,
                                gint image_paths_length1,
                                gint start_index);
static void dc_window_save_attachment_data_free (gpointer _data);
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 gboolean dc_window_save_attachment_co (DcWindowSaveAttachmentData* _data_);
static void dc_window_save_attachment_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_);
VALA_EXTERN void dc_window_request_reload_chats (DcWindow* self);
VALA_EXTERN void dc_event_handler_schedule_chats_reload (DcEventHandler* self);
static void dc_window_on_incoming_msg_data_free (gpointer _data);
static gboolean dc_window_on_incoming_msg_co (DcWindowOnIncomingMsgData* _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 void dc_window_on_incoming_msg_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_);
VALA_EXTERN gboolean dc_settings_manager_get_notifications_enabled (DcSettingsManager* self);
VALA_EXTERN void dc_event_handler_send_notification (DcEventHandler* self,
                                         gint chat_id,
                                         gint msg_id,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN void dc_event_handler_send_notification_finish (DcEventHandler* self,
                                                GAsyncResult* _res_);
static void dc_window_load_account_menu_data_free (gpointer _data);
static gboolean dc_window_load_account_menu_co (DcWindowLoadAccountMenuData* _data_);
VALA_EXTERN gboolean dc_rpc_client_get_is_connected (DcRpcClient* self);
VALA_EXTERN void dc_rpc_client_get_all_accounts (DcRpcClient* self,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN JsonNode* dc_rpc_client_get_all_accounts_finish (DcRpcClient* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
static void dc_window_load_account_menu_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_);
static void _vala_JsonNode_free (JsonNode* self);
static void dc_window_build_account_menu_row_for_id (DcWindow* self,
                                              gint id,
                                              gboolean current,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
static AdwActionRow* dc_window_build_account_menu_row_for_id_finish (DcWindow* self,
                                                              GAsyncResult* _res_,
                                                              GError** error);
static AdwActionRow* dc_window_build_add_account_row (DcWindow* self);
static void dc_window_build_account_menu_row_for_id_data_free (gpointer _data);
static gboolean dc_window_build_account_menu_row_for_id_co (DcWindowBuildAccountMenuRowForIdData* _data_);
VALA_EXTERN void dc_rpc_client_is_configured (DcRpcClient* self,
                                  gint acct_id,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN gboolean dc_rpc_client_is_configured_finish (DcRpcClient* self,
                                             GAsyncResult* _res_,
                                             GError** error);
static void dc_window_build_account_menu_row_for_id_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_);
static AdwActionRow* dc_window_build_account_menu_row (DcWindow* self,
                                                gint id,
                                                gboolean configured,
                                                gboolean current,
                                                const gchar* email,
                                                const gchar* display_name,
                                                const gchar* avatar);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
VALA_EXTERN GdkTexture* dc_load_avatar (const gchar* path);
static void __lambda87_ (Block2Data* _data2_);
static void dc_window_show_profile_for_account (DcWindow* self,
                                         gint acct_id);
static void ___lambda87__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void dc_window_on_add_account (DcWindow* self);
static void dc_window_switch_account_from_menu (DcWindow* self,
                                         gint acct_id,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
static void dc_window_switch_account_from_menu_finish (DcWindow* self,
                                                GAsyncResult* _res_);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static AdwActionRow* dc_window_build_add_method_row (DcWindow* self,
                                              const gchar* icon_name,
                                              const gchar* title,
                                              const gchar* subtitle);
static void __lambda84_ (Block3Data* _data3_,
                  GtkListBoxRow* row);
static void dc_window_on_add_account_method_selected (DcWindow* self,
                                               const gchar* method);
static void ___lambda84__gtk_list_box_row_activated (GtkListBox* _sender,
                                              GtkListBoxRow* row,
                                              gpointer self);
static void __lambda126_ (DcWindow* self);
static void ___lambda126__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void dc_window_show_classic_email_dialog (DcWindow* self);
static void dc_window_show_secondary_device_dialog (DcWindow* self);
static void dc_window_show_create_profile_dialog (DcWindow* self);
static void dc_window_show_invitation_code_profile_dialog (DcWindow* self);
VALA_EXTERN GType dc_create_profile_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcCreateProfileDialog, g_object_unref)
VALA_EXTERN DcCreateProfileDialog* dc_create_profile_dialog_new (DcRpcClient* rpc,
                                                     DcEventHandler* events);
VALA_EXTERN DcCreateProfileDialog* dc_create_profile_dialog_construct (GType object_type,
                                                           DcRpcClient* rpc,
                                                           DcEventHandler* events);
static void __lambda118_ (DcWindow* self);
static void ___lambda118__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void __lambda119_ (DcWindow* self,
                   gint new_id);
static void dc_window_after_profile_created (DcWindow* self,
                                      gint new_id,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
static void dc_window_after_profile_created_finish (DcWindow* self,
                                             GAsyncResult* _res_);
static void ___lambda119__dc_create_profile_dialog_account_created (DcCreateProfileDialog* _sender,
                                                             gint new_account_id,
                                                             gpointer self);
static void dc_window_after_profile_created_data_free (gpointer _data);
static gboolean dc_window_after_profile_created_co (DcWindowAfterProfileCreatedData* _data_);
VALA_EXTERN void dc_window_switch_account (DcWindow* self,
                               gint acct_id,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gboolean dc_window_switch_account_finish (DcWindow* self,
                                          GAsyncResult* _res_);
static void dc_window_after_profile_created_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
VALA_EXTERN GType dc_invitation_code_profile_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcInvitationCodeProfileDialog, g_object_unref)
VALA_EXTERN DcInvitationCodeProfileDialog* dc_invitation_code_profile_dialog_new (DcRpcClient* rpc,
                                                                      DcEventHandler* events);
VALA_EXTERN DcInvitationCodeProfileDialog* dc_invitation_code_profile_dialog_construct (GType object_type,
                                                                            DcRpcClient* rpc,
                                                                            DcEventHandler* events);
static void __lambda124_ (DcWindow* self);
static void ___lambda124__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void __lambda125_ (DcWindow* self,
                   gint new_id,
                   gint chat_id);
static void dc_window_after_invitation_profile_created (DcWindow* self,
                                                 gint new_id,
                                                 gint chat_id,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static void dc_window_after_invitation_profile_created_finish (DcWindow* self,
                                                        GAsyncResult* _res_);
static void ___lambda125__dc_invitation_code_profile_dialog_account_created (DcInvitationCodeProfileDialog* _sender,
                                                                      gint new_account_id,
                                                                      gint chat_id,
                                                                      gpointer self);
static void dc_window_after_invitation_profile_created_data_free (gpointer _data);
static gboolean dc_window_after_invitation_profile_created_co (DcWindowAfterInvitationProfileCreatedData* _data_);
static void dc_window_after_invitation_profile_created_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_);
VALA_EXTERN void dc_window_select_chat_by_id (DcWindow* self,
                                  gint chat_id);
VALA_EXTERN GType dc_receive_backup_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcReceiveBackupDialog, g_object_unref)
VALA_EXTERN DcReceiveBackupDialog* dc_receive_backup_dialog_new (DcRpcClient* rpc,
                                                     DcEventHandler* events);
VALA_EXTERN DcReceiveBackupDialog* dc_receive_backup_dialog_construct (GType object_type,
                                                           DcRpcClient* rpc,
                                                           DcEventHandler* events);
static void __lambda112_ (DcWindow* self);
static void ___lambda112__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void __lambda113_ (DcWindow* self,
                   gint new_id);
static void dc_window_after_secondary_device_imported (DcWindow* self,
                                                gint new_id,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
static void dc_window_after_secondary_device_imported_finish (DcWindow* self,
                                                       GAsyncResult* _res_);
static void ___lambda113__dc_receive_backup_dialog_account_imported (DcReceiveBackupDialog* _sender,
                                                              gint new_account_id,
                                                              gpointer self);
static void dc_window_after_secondary_device_imported_data_free (gpointer _data);
static gboolean dc_window_after_secondary_device_imported_co (DcWindowAfterSecondaryDeviceImportedData* _data_);
static void dc_window_after_secondary_device_imported_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void __lambda85_ (Block4Data* _data4_);
static void ___lambda85__gtk_password_entry_activate (GtkPasswordEntry* _sender,
                                               gpointer self);
static void __lambda86_ (Block4Data* _data4_,
                  const gchar* resp);
static void dc_window_do_add_account (DcWindow* self,
                               const gchar* email,
                               const gchar* password,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
static void dc_window_do_add_account_finish (DcWindow* self,
                                      GAsyncResult* _res_);
static void ___lambda86__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                             const gchar* response,
                                             gpointer self);
static void dc_window_do_add_account_data_free (gpointer _data);
static gboolean dc_window_do_add_account_co (DcWindowDoAddAccountData* _data_);
VALA_EXTERN void dc_rpc_client_add_account (DcRpcClient* self,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_add_account_finish (DcRpcClient* self,
                                       GAsyncResult* _res_,
                                       GError** error);
static void dc_window_do_add_account_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_add_or_update_transport (DcRpcClient* self,
                                            gint acct_id,
                                            const gchar* email,
                                            const gchar* password,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_add_or_update_transport_finish (DcRpcClient* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
VALA_EXTERN void dc_rpc_client_stop_io (DcRpcClient* self,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_stop_io_finish (DcRpcClient* self,
                                   GAsyncResult* _res_,
                                   GError** error);
VALA_EXTERN void dc_rpc_client_select_account (DcRpcClient* self,
                                   gint acct_id,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_select_account_finish (DcRpcClient* self,
                                          GAsyncResult* _res_,
                                          GError** error);
VALA_EXTERN void dc_rpc_client_start_io (DcRpcClient* self,
                             gint acct_id,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_start_io_finish (DcRpcClient* self,
                                    GAsyncResult* _res_,
                                    GError** error);
VALA_EXTERN void dc_rpc_client_set_account_id (DcRpcClient* self,
                                   gint value);
VALA_EXTERN void dc_window_reload_active_account (DcWindow* self,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
VALA_EXTERN void dc_window_reload_active_account_finish (DcWindow* self,
                                             GAsyncResult* _res_);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
static void dc_window_switch_account_from_menu_data_free (gpointer _data);
static gboolean dc_window_switch_account_from_menu_co (DcWindowSwitchAccountFromMenuData* _data_);
static void dc_window_switch_account_from_menu_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static void dc_window_switch_account_data_free (gpointer _data);
static gboolean dc_window_switch_account_co (DcWindowSwitchAccountData* _data_);
static void dc_window_switch_account_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
VALA_EXTERN GType dc_profile_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcProfileDialog, g_object_unref)
VALA_EXTERN DcProfileDialog* dc_profile_dialog_new (DcRpcClient* rpc,
                                        gint acct_id);
VALA_EXTERN DcProfileDialog* dc_profile_dialog_construct (GType object_type,
                                              DcRpcClient* rpc,
                                              gint acct_id);
static void __lambda106_ (Block5Data* _data5_);
static void ___lambda106__dc_profile_dialog_profile_updated (DcProfileDialog* _sender,
                                                      gpointer self);
static void __lambda107_ (Block5Data* _data5_,
                   gint deleted_id);
static void dc_window_after_profile_deleted (DcWindow* self,
                                      gint deleted_id,
                                      gboolean was_current_account,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
static void dc_window_after_profile_deleted_finish (DcWindow* self,
                                             GAsyncResult* _res_);
static void ___lambda107__dc_profile_dialog_account_deleted (DcProfileDialog* _sender,
                                                      gint acct_id,
                                                      gpointer self);
static void dc_window_after_profile_deleted_data_free (gpointer _data);
static gboolean dc_window_after_profile_deleted_co (DcWindowAfterProfileDeletedData* _data_);
static void dc_window_switch_to_first_configured_account (DcWindow* self,
                                                   gint skip_id,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static gboolean dc_window_switch_to_first_configured_account_finish (DcWindow* self,
                                                              GAsyncResult* _res_);
static void dc_window_after_profile_deleted_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
static void dc_window_switch_to_first_configured_account_data_free (gpointer _data);
static gboolean dc_window_switch_to_first_configured_account_co (DcWindowSwitchToFirstConfiguredAccountData* _data_);
static void dc_window_switch_to_first_configured_account_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void dc_window_load_profile_avatar_data_free (gpointer _data);
static gboolean dc_window_load_profile_avatar_co (DcWindowLoadProfileAvatarData* _data_);
static void dc_window_load_profile_avatar_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void dc_window_on_new_chat (DcWindow* self);
VALA_EXTERN GType dc_contact_picker_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcContactPickerDialog, g_object_unref)
VALA_EXTERN DcContactPickerDialog* dc_contact_picker_dialog_new (DcRpcClient* rpc,
                                                     GListStore* chat_store,
                                                     const gchar* title);
VALA_EXTERN DcContactPickerDialog* dc_contact_picker_dialog_construct (GType object_type,
                                                           DcRpcClient* rpc,
                                                           GListStore* chat_store,
                                                           const gchar* title);
static void __lambda129_ (DcWindow* self);
static void ___lambda129__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void __lambda130_ (DcWindow* self,
                   gint contact_id,
                   const gchar* email);
static void dc_window_create_chat_by_email (DcWindow* self,
                                     const gchar* email,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void dc_window_create_chat_by_email_finish (DcWindow* self,
                                            GAsyncResult* _res_);
static void ___lambda130__dc_contact_picker_dialog_contact_picked (DcContactPickerDialog* _sender,
                                                            gint contact_id,
                                                            const gchar* email,
                                                            gpointer self);
static void dc_window_create_chat_by_email_data_free (gpointer _data);
static gboolean dc_window_create_chat_by_email_co (DcWindowCreateChatByEmailData* _data_);
VALA_EXTERN void dc_rpc_client_get_or_create_contact (DcRpcClient* self,
                                          const gchar* email,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_get_or_create_contact_finish (DcRpcClient* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
static void dc_window_create_chat_by_email_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_get_or_create_chat_by_contact (DcRpcClient* self,
                                                  gint contact_id,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_get_or_create_chat_by_contact_finish (DcRpcClient* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
static void dc_window_on_new_group (DcWindow* self);
VALA_EXTERN GType dc_new_group_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcNewGroupDialog, g_object_unref)
VALA_EXTERN DcNewGroupDialog* dc_new_group_dialog_new (DcRpcClient* rpc);
VALA_EXTERN DcNewGroupDialog* dc_new_group_dialog_construct (GType object_type,
                                                 DcRpcClient* rpc);
static void __lambda137_ (DcWindow* self);
static void ___lambda137__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void __lambda138_ (DcWindow* self,
                   gint chat_id);
static void dc_window_after_group_created (DcWindow* self,
                                    gint chat_id,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void dc_window_after_group_created_finish (DcWindow* self,
                                           GAsyncResult* _res_);
static void ___lambda138__dc_new_group_dialog_group_created (DcNewGroupDialog* _sender,
                                                      gint chat_id,
                                                      gpointer self);
static void dc_window_after_group_created_data_free (gpointer _data);
static gboolean dc_window_after_group_created_co (DcWindowAfterGroupCreatedData* _data_);
static void dc_window_after_group_created_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
VALA_EXTERN void dc_window_scroll_to_message (DcWindow* self,
                                  gint msg_id);
VALA_EXTERN void dc_conversation_view_scroll_to_message (DcConversationView* self,
                                             gint msg_id);
static void __lambda128_ (DcWindow* self);
static void ___lambda128__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda131_ (DcWindow* self);
static void ___lambda131__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda139_ (DcWindow* self);
static void dc_window_show_use_invite_link_dialog (DcWindow* self);
static void ___lambda139__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda145_ (DcWindow* self);
static void ___lambda145__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda146_ (DcWindow* self);
static void ___lambda146__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda160_ (DcWindow* self);
static void dc_window_show_keyboard_shortcuts_dialog (DcWindow* self);
static void ___lambda160__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void __lambda162_ (DcWindow* self);
static void dc_window_show_about_dialog (DcWindow* self);
static void ___lambda162__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
static void __lambda140_ (Block6Data* _data6_);
static void ___lambda140__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda141_ (Block6Data* _data6_);
static void dc_window_use_invite_link (DcWindow* self,
                                AdwDialog* dialog,
                                GtkEntry* entry,
                                GtkLabel* status,
                                GtkButton* add_btn,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
static void dc_window_use_invite_link_finish (DcWindow* self,
                                       GAsyncResult* _res_);
static void ___lambda141__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda142_ (Block6Data* _data6_);
static void ___lambda142__gtk_editable_changed (GtkEditable* _sender,
                                         gpointer self);
static void __lambda143_ (Block6Data* _data6_);
static void ___lambda143__gtk_entry_activate (GtkEntry* _sender,
                                       gpointer self);
static void __lambda144_ (DcWindow* self);
static void ___lambda144__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void dc_window_use_invite_link_data_free (gpointer _data);
static gboolean dc_window_use_invite_link_co (DcWindowUseInviteLinkData* _data_);
VALA_EXTERN void dc_rpc_client_check_qr (DcRpcClient* self,
                             gint acct_id,
                             const gchar* qr_text,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_);
VALA_EXTERN JsonObject* dc_rpc_client_check_qr_finish (DcRpcClient* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static void dc_window_use_invite_link_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_secure_join (DcRpcClient* self,
                                gint acct_id,
                                const gchar* qr_text,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_secure_join_finish (DcRpcClient* self,
                                       GAsyncResult* _res_,
                                       GError** error);
VALA_EXTERN GType dc_settings_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSettingsDialog, g_object_unref)
VALA_EXTERN DcSettingsDialog* dc_settings_dialog_new (DcWindow* window);
VALA_EXTERN DcSettingsDialog* dc_settings_dialog_construct (GType object_type,
                                                DcWindow* window);
static void __lambda155_ (DcWindow* self);
static void ___lambda155__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void dc_window_reload_active_account_data_free (gpointer _data);
static gboolean dc_window_reload_active_account_co (DcWindowReloadActiveAccountData* _data_);
static void dc_window_discard_all_views (DcWindow* self);
static void dc_window_reload_active_account_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
VALA_EXTERN gboolean dc_event_handler_get_is_listening (DcEventHandler* self);
VALA_EXTERN gboolean dc_image_viewer_get_visible (DcImageViewer* self);
VALA_EXTERN gboolean dc_image_viewer_handle_key (DcImageViewer* self,
                                     guint keyval);
VALA_EXTERN gboolean dc_conversation_view_close_search_if_active (DcConversationView* self);
VALA_EXTERN void dc_conversation_view_focus_entry (DcConversationView* self);
static void dc_window_show_quick_switch_dialog (DcWindow* self);
static void dc_window_refresh_current_chat (DcWindow* self);
VALA_EXTERN void dc_conversation_view_toggle_search (DcConversationView* self);
VALA_EXTERN GType dc_quick_switch_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcQuickSwitchDialog, g_object_unref)
VALA_EXTERN DcQuickSwitchDialog* dc_quick_switch_dialog_new (GListStore* chat_store);
VALA_EXTERN DcQuickSwitchDialog* dc_quick_switch_dialog_construct (GType object_type,
                                                       GListStore* chat_store);
static void __lambda170_ (DcWindow* self);
static void ___lambda170__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void __lambda171_ (DcWindow* self,
                   gint chat_id);
static void ___lambda171__dc_quick_switch_dialog_chat_selected (DcQuickSwitchDialog* _sender,
                                                         gint chat_id,
                                                         gpointer self);
VALA_EXTERN void dc_quick_switch_dialog_focus_entry (DcQuickSwitchDialog* self);
static void __lambda161_ (DcWindow* self);
static void ___lambda161__adw_dialog_closed (AdwDialog* _sender,
                                      gpointer self);
static void dc_window_set_chat_store (DcWindow* self,
                               GListStore* value);
VALA_EXTERN void dc_event_handler_set_active_chat_id (DcEventHandler* self,
                                          gint value);
static GObject * dc_window_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
static void _g_object_unref0_ (gpointer var);
VALA_EXTERN DcSettingsManager* dc_settings_manager_new (void);
VALA_EXTERN DcSettingsManager* dc_settings_manager_construct (GType object_type);
VALA_EXTERN DcImageViewer* dc_image_viewer_new (void);
VALA_EXTERN DcImageViewer* dc_image_viewer_construct (GType object_type);
VALA_EXTERN void dc_image_viewer_set_window (DcImageViewer* self,
                                 DcWindow* w);
VALA_EXTERN void dc_settings_manager_load (DcSettingsManager* self);
static gboolean _dc_window___lambda172_ (DcWindow* self);
static gboolean __dc_window___lambda172__gsource_func (gpointer self);
static void dc_window_finalize (GObject * obj);
static GType dc_window_get_type_once (void);
static void _vala_dc_window_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
static void _vala_dc_window_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 const gchar* DC_WINDOW_SHORTCUTS[18] = {"New chat", "<Control>n", "New group", "<Control>g", "Open settings", "<Control>comma", "Search in conversation", "<Control>f", "Quick switch chat", "<Control>k", "Refresh messages", "<Control>r", "Focus message entry", "Escape", "Close window", "<Control>w", "Quit application", "<Control>q"};

static inline gpointer
dc_window_get_instance_private (DcWindow* self)
{
	return G_STRUCT_MEMBER_P (self, DcWindow_private_offset);
}

DcWindow*
dc_window_construct (GType object_type,
                     DcApplication* app)
{
	DcWindow * self = NULL;
	g_return_val_if_fail (app != NULL, NULL);
	self = (DcWindow*) g_object_new (object_type, "application", app, "default-width", 920, "default-height", 640, "title", "Parla", NULL);
	return self;
}

DcWindow*
dc_window_new (DcApplication* app)
{
	return dc_window_construct (DC_TYPE_WINDOW, app);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		DcWindow* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->right_click);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
__lambda127_ (DcWindow* self)
{
	dc_window_load_account_menu (self, NULL, NULL);
}

static void
___lambda127__gtk_widget_map (GtkWidget* _sender,
                              gpointer self)
{
	__lambda127_ ((DcWindow*) self);
}

static void
__lambda163_ (DcWindow* self)
{
	GtkListBox* _tmp0_;
	_tmp0_ = self->priv->chat_listbox;
	gtk_list_box_invalidate_filter (_tmp0_);
}

static void
___lambda163__gtk_search_entry_search_changed (GtkSearchEntry* _sender,
                                               gpointer self)
{
	__lambda163_ ((DcWindow*) self);
}

static gboolean
_dc_window_filter_chats_gtk_list_box_filter_func (GtkListBoxRow* row,
                                                  gpointer self)
{
	gboolean result;
	result = dc_window_filter_chats ((DcWindow*) self, row);
	return result;
}

static void
_dc_window_on_chat_selected_gtk_list_box_row_selected (GtkListBox* _sender,
                                                       GtkListBoxRow* row,
                                                       gpointer self)
{
	dc_window_on_chat_selected ((DcWindow*) self, row);
}

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

static void
__lambda164_ (Block1Data* _data1_,
              gint n,
              gdouble x,
              gdouble y)
{
	DcWindow* self;
	GtkListBoxRow* row = NULL;
	GtkListBox* _tmp0_;
	GtkListBoxRow* _tmp1_;
	GtkListBoxRow* _tmp2_;
	GtkListBoxRow* _tmp3_;
	DcChatRow* chat_row = NULL;
	GtkListBoxRow* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	DcChatRow* _tmp7_;
	DcChatRow* _tmp8_;
	DcChatContextMenu* _tmp9_;
	self = _data1_->self;
	_tmp0_ = self->priv->chat_listbox;
	_tmp1_ = gtk_list_box_get_row_at_y (_tmp0_, (gint) y);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	row = _tmp2_;
	_tmp3_ = row;
	if (_tmp3_ == NULL) {
		_g_object_unref0 (row);
		return;
	}
	_tmp4_ = row;
	_tmp5_ = gtk_list_box_row_get_child (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_object_ref0 (DC_IS_CHAT_ROW (_tmp6_) ? ((DcChatRow*) _tmp6_) : NULL);
	chat_row = _tmp7_;
	_tmp8_ = chat_row;
	if (_tmp8_ == NULL) {
		_g_object_unref0 (chat_row);
		_g_object_unref0 (row);
		return;
	}
	gtk_gesture_set_state ((GtkGesture*) _data1_->right_click, GTK_EVENT_SEQUENCE_CLAIMED);
	_tmp9_ = self->priv->chat_menu;
	if (_tmp9_ != NULL) {
		DcChatContextMenu* _tmp10_;
		DcChatRow* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		GtkListBox* _tmp14_;
		_tmp10_ = self->priv->chat_menu;
		_tmp11_ = chat_row;
		_tmp12_ = dc_chat_row_get_chat_id (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = self->priv->chat_listbox;
		dc_chat_context_menu_show (_tmp10_, _tmp13_, x, y, (GtkWidget*) _tmp14_);
	}
	_g_object_unref0 (chat_row);
	_g_object_unref0 (row);
}

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

static void
__lambda165_ (DcWindow* self)
{
	dc_window_toggle_message_search (self);
}

static void
___lambda165__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda165_ ((DcWindow*) self);
}

static gboolean
_dc_window_on_window_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                       guint keyval,
                                                                       guint keycode,
                                                                       GdkModifierType state,
                                                                       gpointer self)
{
	gboolean result;
	result = dc_window_on_window_key_pressed ((DcWindow*) self, keyval, keycode, state);
	return result;
}

static void
dc_window_build_ui (DcWindow* self)
{
	Block1Data* _data1_;
	GtkBox* sidebar_box = NULL;
	GtkBox* _tmp0_;
	AdwHeaderBar* _tmp1_;
	AdwWindowTitle* title_widget = NULL;
	AdwWindowTitle* _tmp2_;
	AdwHeaderBar* _tmp3_;
	AdwAvatar* _tmp4_;
	GtkPopover* _tmp5_;
	GtkPopover* _tmp6_;
	GtkMenuButton* avatar_button = NULL;
	GtkMenuButton* _tmp7_;
	AdwAvatar* _tmp8_;
	GtkPopover* _tmp9_;
	AdwHeaderBar* _tmp10_;
	GtkMenuButton* menu_button = NULL;
	GtkMenuButton* _tmp11_;
	GMenuModel* _tmp12_;
	GMenuModel* _tmp13_;
	AdwHeaderBar* _tmp14_;
	AdwHeaderBar* _tmp15_;
	GtkSearchEntry* _tmp16_;
	GtkSearchEntry* _tmp17_;
	GtkSearchEntry* _tmp18_;
	GtkSearchEntry* _tmp19_;
	GtkSearchEntry* _tmp20_;
	GtkSearchEntry* _tmp21_;
	GtkSearchEntry* _tmp22_;
	GtkSearchEntry* _tmp23_;
	GtkScrolledWindow* chat_scroll = NULL;
	GtkScrolledWindow* _tmp24_;
	GtkListBox* _tmp25_;
	GtkListBox* _tmp26_;
	GtkListBox* _tmp27_;
	GtkListBox* _tmp28_;
	GtkListBox* _tmp29_;
	GtkGestureClick* _tmp30_;
	GtkListBox* _tmp31_;
	GtkEventController* _tmp32_;
	GtkListBox* _tmp33_;
	AdwNavigationPage* sidebar_page = NULL;
	AdwNavigationPage* _tmp34_;
	GtkBox* content_box = NULL;
	GtkBox* _tmp35_;
	AdwHeaderBar* _tmp36_;
	GtkLabel* _tmp37_;
	GtkLabel* _tmp38_;
	AdwHeaderBar* _tmp39_;
	GtkLabel* _tmp40_;
	AdwHeaderBar* _tmp41_;
	GtkButton* search_btn = NULL;
	GtkButton* _tmp42_;
	AdwHeaderBar* _tmp43_;
	AdwHeaderBar* _tmp44_;
	GtkStack* _tmp45_;
	GtkStack* _tmp46_;
	AdwStatusPage* _tmp47_;
	AdwStatusPage* _tmp48_;
	AdwStatusPage* _tmp49_;
	AdwStatusPage* _tmp50_;
	GtkStack* _tmp51_;
	AdwStatusPage* _tmp52_;
	GtkStack* _tmp53_;
	GtkStack* _tmp54_;
	AdwNavigationPage* content_page = NULL;
	AdwNavigationPage* _tmp55_;
	AdwNavigationSplitView* _tmp56_;
	AdwNavigationSplitView* _tmp57_;
	AdwNavigationSplitView* _tmp58_;
	AdwNavigationSplitView* _tmp59_;
	AdwNavigationSplitView* _tmp60_;
	AdwToastOverlay* _tmp61_;
	AdwToastOverlay* _tmp62_;
	AdwNavigationSplitView* _tmp63_;
	GtkOverlay* image_overlay = NULL;
	GtkOverlay* _tmp64_;
	AdwToastOverlay* _tmp65_;
	DcImageViewer* _tmp66_;
	GtkWidget* _tmp67_;
	GtkWidget* _tmp68_;
	GtkRevealer* _tmp69_;
	GtkRevealer* _tmp70_;
	GtkEventControllerKey* key_ctrl = NULL;
	GtkEventControllerKey* _tmp71_;
	GtkEventController* _tmp72_;
	g_return_if_fail (self != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp0_);
	sidebar_box = _tmp0_;
	_tmp1_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->sidebar_header);
	self->priv->sidebar_header = _tmp1_;
	_tmp2_ = (AdwWindowTitle*) adw_window_title_new ("Parla", "");
	g_object_ref_sink (_tmp2_);
	title_widget = _tmp2_;
	_tmp3_ = self->priv->sidebar_header;
	adw_header_bar_set_title_widget (_tmp3_, (GtkWidget*) title_widget);
	_tmp4_ = (AdwAvatar*) adw_avatar_new (24, "", TRUE);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->profile_avatar);
	self->priv->profile_avatar = _tmp4_;
	_tmp5_ = dc_window_build_account_popover (self);
	_g_object_unref0 (self->priv->account_popover);
	self->priv->account_popover = _tmp5_;
	_tmp6_ = self->priv->account_popover;
	g_signal_connect_object ((GtkWidget*) _tmp6_, "map", (GCallback) ___lambda127__gtk_widget_map, self, 0);
	_tmp7_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp7_);
	avatar_button = _tmp7_;
	_tmp8_ = self->priv->profile_avatar;
	gtk_menu_button_set_child (avatar_button, (GtkWidget*) _tmp8_);
	gtk_widget_add_css_class ((GtkWidget*) avatar_button, "flat");
	gtk_widget_add_css_class ((GtkWidget*) avatar_button, "circular");
	gtk_widget_set_tooltip_text ((GtkWidget*) avatar_button, "Account Menu");
	_tmp9_ = self->priv->account_popover;
	gtk_menu_button_set_popover (avatar_button, _tmp9_);
	_tmp10_ = self->priv->sidebar_header;
	adw_header_bar_pack_start (_tmp10_, (GtkWidget*) avatar_button);
	_tmp11_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp11_);
	menu_button = _tmp11_;
	gtk_menu_button_set_icon_name (menu_button, "open-menu-symbolic");
	gtk_widget_set_tooltip_text ((GtkWidget*) menu_button, "Main Menu");
	gtk_widget_add_css_class ((GtkWidget*) menu_button, "flat");
	_tmp12_ = dc_window_build_app_menu (self);
	_tmp13_ = _tmp12_;
	gtk_menu_button_set_menu_model (menu_button, _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = self->priv->sidebar_header;
	adw_header_bar_pack_end (_tmp14_, (GtkWidget*) menu_button);
	_tmp15_ = self->priv->sidebar_header;
	gtk_box_append (sidebar_box, (GtkWidget*) _tmp15_);
	_tmp16_ = (GtkSearchEntry*) gtk_search_entry_new ();
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->search_entry);
	self->priv->search_entry = _tmp16_;
	_tmp17_ = self->priv->search_entry;
	g_object_set (_tmp17_, "placeholder-text", "Search chats…", NULL);
	_tmp18_ = self->priv->search_entry;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp18_, 8);
	_tmp19_ = self->priv->search_entry;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp19_, 8);
	_tmp20_ = self->priv->search_entry;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp20_, 4);
	_tmp21_ = self->priv->search_entry;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp21_, 4);
	_tmp22_ = self->priv->search_entry;
	g_signal_connect_object (_tmp22_, "search-changed", (GCallback) ___lambda163__gtk_search_entry_search_changed, self, 0);
	_tmp23_ = self->priv->search_entry;
	gtk_box_append (sidebar_box, (GtkWidget*) _tmp23_);
	_tmp24_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp24_);
	chat_scroll = _tmp24_;
	gtk_widget_set_vexpand ((GtkWidget*) chat_scroll, TRUE);
	g_object_set (chat_scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp25_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (self->priv->chat_listbox);
	self->priv->chat_listbox = _tmp25_;
	_tmp26_ = self->priv->chat_listbox;
	gtk_list_box_set_selection_mode (_tmp26_, GTK_SELECTION_SINGLE);
	_tmp27_ = self->priv->chat_listbox;
	gtk_widget_add_css_class ((GtkWidget*) _tmp27_, "navigation-sidebar");
	_tmp28_ = self->priv->chat_listbox;
	gtk_list_box_set_filter_func (_tmp28_, _dc_window_filter_chats_gtk_list_box_filter_func, g_object_ref (self), g_object_unref);
	_tmp29_ = self->priv->chat_listbox;
	g_signal_connect_object (_tmp29_, "row-selected", (GCallback) _dc_window_on_chat_selected_gtk_list_box_row_selected, self, 0);
	_tmp30_ = (GtkGestureClick*) gtk_gesture_click_new ();
	_data1_->right_click = _tmp30_;
	gtk_gesture_single_set_button ((GtkGestureSingle*) _data1_->right_click, (guint) 3);
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _data1_->right_click, GTK_PHASE_CAPTURE);
	g_signal_connect_data (_data1_->right_click, "pressed", (GCallback) ___lambda164__gtk_gesture_click_pressed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp31_ = self->priv->chat_listbox;
	_tmp32_ = _g_object_ref0 ((GtkEventController*) _data1_->right_click);
	gtk_widget_add_controller ((GtkWidget*) _tmp31_, _tmp32_);
	_tmp33_ = self->priv->chat_listbox;
	gtk_scrolled_window_set_child (chat_scroll, (GtkWidget*) _tmp33_);
	gtk_box_append (sidebar_box, (GtkWidget*) chat_scroll);
	_tmp34_ = adw_navigation_page_new ((GtkWidget*) sidebar_box, "Chats");
	g_object_ref_sink (_tmp34_);
	sidebar_page = _tmp34_;
	_tmp35_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp35_);
	content_box = _tmp35_;
	_tmp36_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp36_);
	_g_object_unref0 (self->priv->content_header);
	self->priv->content_header = _tmp36_;
	_tmp37_ = (GtkLabel*) gtk_label_new ("Select a chat");
	g_object_ref_sink (_tmp37_);
	_g_object_unref0 (self->priv->content_title_label);
	self->priv->content_title_label = _tmp37_;
	_tmp38_ = self->priv->content_title_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp38_, "heading");
	_tmp39_ = self->priv->content_header;
	_tmp40_ = self->priv->content_title_label;
	adw_header_bar_set_title_widget (_tmp39_, (GtkWidget*) _tmp40_);
	_tmp41_ = self->priv->content_header;
	adw_header_bar_set_show_back_button (_tmp41_, TRUE);
	_tmp42_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-find-symbolic");
	g_object_ref_sink (_tmp42_);
	search_btn = _tmp42_;
	gtk_widget_set_tooltip_text ((GtkWidget*) search_btn, "Search in conversation (Ctrl+F)");
	g_signal_connect_object (search_btn, "clicked", (GCallback) ___lambda165__gtk_button_clicked, self, 0);
	_tmp43_ = self->priv->content_header;
	adw_header_bar_pack_end (_tmp43_, (GtkWidget*) search_btn);
	_tmp44_ = self->priv->content_header;
	gtk_box_append (content_box, (GtkWidget*) _tmp44_);
	_tmp45_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp45_);
	_g_object_unref0 (self->priv->content_stack);
	self->priv->content_stack = _tmp45_;
	_tmp46_ = self->priv->content_stack;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp46_, TRUE);
	_tmp47_ = (AdwStatusPage*) adw_status_page_new ();
	g_object_ref_sink (_tmp47_);
	_g_object_unref0 (self->priv->empty_status);
	self->priv->empty_status = _tmp47_;
	_tmp48_ = self->priv->empty_status;
	adw_status_page_set_icon_name (_tmp48_, "mail-send-receive-symbolic");
	_tmp49_ = self->priv->empty_status;
	adw_status_page_set_title (_tmp49_, "Parla");
	_tmp50_ = self->priv->empty_status;
	adw_status_page_set_description (_tmp50_, "Select a chat to start messaging,\nor wait for the connection…");
	_tmp51_ = self->priv->content_stack;
	_tmp52_ = self->priv->empty_status;
	gtk_stack_add_named (_tmp51_, (GtkWidget*) _tmp52_, "empty");
	_tmp53_ = self->priv->content_stack;
	gtk_stack_set_visible_child_name (_tmp53_, "empty");
	_tmp54_ = self->priv->content_stack;
	gtk_box_append (content_box, (GtkWidget*) _tmp54_);
	_tmp55_ = adw_navigation_page_new ((GtkWidget*) content_box, "Messages");
	g_object_ref_sink (_tmp55_);
	content_page = _tmp55_;
	_tmp56_ = (AdwNavigationSplitView*) adw_navigation_split_view_new ();
	g_object_ref_sink (_tmp56_);
	_g_object_unref0 (self->priv->split_view);
	self->priv->split_view = _tmp56_;
	_tmp57_ = self->priv->split_view;
	adw_navigation_split_view_set_sidebar (_tmp57_, sidebar_page);
	_tmp58_ = self->priv->split_view;
	adw_navigation_split_view_set_content (_tmp58_, content_page);
	_tmp59_ = self->priv->split_view;
	adw_navigation_split_view_set_max_sidebar_width (_tmp59_, (gdouble) 340);
	_tmp60_ = self->priv->split_view;
	adw_navigation_split_view_set_min_sidebar_width (_tmp60_, (gdouble) 260);
	_tmp61_ = (AdwToastOverlay*) adw_toast_overlay_new ();
	g_object_ref_sink (_tmp61_);
	_g_object_unref0 (self->priv->toast_overlay);
	self->priv->toast_overlay = _tmp61_;
	_tmp62_ = self->priv->toast_overlay;
	_tmp63_ = self->priv->split_view;
	adw_toast_overlay_set_child (_tmp62_, (GtkWidget*) _tmp63_);
	_tmp64_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp64_);
	image_overlay = _tmp64_;
	_tmp65_ = self->priv->toast_overlay;
	gtk_overlay_set_child (image_overlay, (GtkWidget*) _tmp65_);
	_tmp66_ = self->priv->image_viewer;
	_tmp67_ = dc_image_viewer_get_widget (_tmp66_);
	_tmp68_ = _tmp67_;
	gtk_overlay_add_overlay (image_overlay, _tmp68_);
	_tmp69_ = dc_window_build_connection_banner (self);
	_tmp70_ = _tmp69_;
	gtk_overlay_add_overlay (image_overlay, (GtkWidget*) _tmp70_);
	_g_object_unref0 (_tmp70_);
	adw_application_window_set_content ((AdwApplicationWindow*) self, (GtkWidget*) image_overlay);
	_tmp71_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	key_ctrl = _tmp71_;
	gtk_event_controller_set_propagation_phase ((GtkEventController*) key_ctrl, GTK_PHASE_CAPTURE);
	g_signal_connect_object (key_ctrl, "key-pressed", (GCallback) _dc_window_on_window_key_pressed_gtk_event_controller_key_key_pressed, self, 0);
	_tmp72_ = _g_object_ref0 ((GtkEventController*) key_ctrl);
	gtk_widget_add_controller (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp72_);
	_g_object_unref0 (key_ctrl);
	_g_object_unref0 (image_overlay);
	_g_object_unref0 (content_page);
	_g_object_unref0 (search_btn);
	_g_object_unref0 (content_box);
	_g_object_unref0 (sidebar_page);
	_g_object_unref0 (chat_scroll);
	_g_object_unref0 (menu_button);
	_g_object_unref0 (avatar_button);
	_g_object_unref0 (title_widget);
	_g_object_unref0 (sidebar_box);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static void
_dc_window_on_account_menu_row_activated_gtk_list_box_row_activated (GtkListBox* _sender,
                                                                     GtkListBoxRow* row,
                                                                     gpointer self)
{
	dc_window_on_account_menu_row_activated ((DcWindow*) self, row);
}

static GtkPopover*
dc_window_build_account_popover (DcWindow* self)
{
	GtkPopover* popover = NULL;
	GtkPopover* _tmp0_;
	GtkBox* box = NULL;
	GtkBox* _tmp1_;
	GtkLabel* title = NULL;
	GtkLabel* _tmp2_;
	GtkListBox* _tmp3_;
	GtkListBox* _tmp4_;
	GtkListBox* _tmp5_;
	GtkListBox* _tmp6_;
	GtkListBox* _tmp7_;
	GtkPopover* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkPopover*) gtk_popover_new ();
	g_object_ref_sink (_tmp0_);
	popover = _tmp0_;
	gtk_popover_set_has_arrow (popover, TRUE);
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	gtk_widget_set_margin_start ((GtkWidget*) box, 10);
	gtk_widget_set_margin_end ((GtkWidget*) box, 10);
	gtk_widget_set_margin_top ((GtkWidget*) box, 10);
	gtk_widget_set_margin_bottom ((GtkWidget*) box, 10);
	g_object_set ((GtkWidget*) box, "width-request", 300, NULL);
	_tmp2_ = (GtkLabel*) gtk_label_new ("Profiles");
	g_object_ref_sink (_tmp2_);
	title = _tmp2_;
	gtk_widget_add_css_class ((GtkWidget*) title, "heading");
	gtk_widget_set_halign ((GtkWidget*) title, GTK_ALIGN_START);
	gtk_label_set_xalign (title, (gfloat) 0);
	gtk_box_append (box, (GtkWidget*) title);
	_tmp3_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->account_menu_list);
	self->priv->account_menu_list = _tmp3_;
	_tmp4_ = self->priv->account_menu_list;
	gtk_list_box_set_selection_mode (_tmp4_, GTK_SELECTION_NONE);
	_tmp5_ = self->priv->account_menu_list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp5_, "boxed-list");
	_tmp6_ = self->priv->account_menu_list;
	g_signal_connect_object (_tmp6_, "row-activated", (GCallback) _dc_window_on_account_menu_row_activated_gtk_list_box_row_activated, self, 0);
	_tmp7_ = self->priv->account_menu_list;
	gtk_box_append (box, (GtkWidget*) _tmp7_);
	gtk_popover_set_child (popover, (GtkWidget*) box);
	result = popover;
	_g_object_unref0 (title);
	_g_object_unref0 (box);
	return result;
}

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

static void
dc_window_try_connect (DcWindow* self,
                       GAsyncReadyCallback _callback_,
                       gpointer _user_data_)
{
	DcWindowTryConnectData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowTryConnectData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_try_connect_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_window_try_connect_co (_data_);
}

static void
dc_window_try_connect_finish (DcWindow* self,
                              GAsyncResult* _res_)
{
	DcWindowTryConnectData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_try_connect_ready (GObject* source_object,
                             GAsyncResult* _res_,
                             gpointer _user_data_)
{
	DcWindowTryConnectData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_try_connect_co (_data_);
}

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 void
__lambda156_ (DcWindow* self,
              const gchar* reason)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (reason != NULL);
	_tmp0_ = g_strconcat ("Disconnected — ", reason, NULL);
	_tmp1_ = _tmp0_;
	dc_window_set_connection_status (self, FALSE, _tmp1_);
	_g_free0 (_tmp1_);
}

static void
___lambda156__dc_rpc_client_disconnected (DcRpcClient* _sender,
                                          const gchar* reason,
                                          gpointer self)
{
	__lambda156_ ((DcWindow*) self, reason);
}

static void
__lambda157_ (DcWindow* self)
{
	dc_window_load_chats (self, NULL, NULL);
}

static void
___lambda157__dc_event_handler_chats_reload_fired (DcEventHandler* _sender,
                                                   gpointer self)
{
	__lambda157_ ((DcWindow*) self);
}

static void
__lambda158_ (DcWindow* self)
{
	DcConversationView* v = NULL;
	DcConversationView* _tmp0_;
	DcConversationView* _tmp1_;
	_tmp0_ = dc_window_current_view (self);
	v = _tmp0_;
	_tmp1_ = v;
	if (_tmp1_ != NULL) {
		DcConversationView* _tmp2_;
		_tmp2_ = v;
		dc_conversation_view_reload_messages (_tmp2_, NULL, NULL);
	}
	_g_object_unref0 (v);
}

static void
___lambda158__dc_event_handler_messages_reload_fired (DcEventHandler* _sender,
                                                      gpointer self)
{
	__lambda158_ ((DcWindow*) self);
}

static void
__lambda159_ (DcWindow* self,
              gint chat_id,
              gint msg_id)
{
	dc_window_on_incoming_msg (self, chat_id, msg_id, NULL, NULL);
}

static void
___lambda159__dc_event_handler_incoming_msg_received (DcEventHandler* _sender,
                                                      gint chat_id,
                                                      gint msg_id,
                                                      gpointer self)
{
	__lambda159_ ((DcWindow*) self, chat_id, msg_id);
}

static gboolean
dc_window_try_connect_co (DcWindowTryConnectData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gtk_window_get_application ((GtkWindow*) _data_->self);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = dc_application_get_rpc (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, DC_TYPE_APPLICATION, DcApplication));
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->self->priv->rpc = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->self->priv->empty_status;
	adw_status_page_set_child (_data_->_tmp4_, NULL);
	_data_->_tmp5_ = _data_->self->priv->empty_status;
	adw_status_page_set_icon_name (_data_->_tmp5_, "mail-send-receive-symbolic");
	_data_->_tmp6_ = _data_->self->priv->empty_status;
	adw_status_page_set_title (_data_->_tmp6_, "Parla");
	_data_->_tmp7_ = _data_->self->priv->empty_status;
	adw_status_page_set_description (_data_->_tmp7_, "Select a chat to start messaging,\nor wait for the connection…");
	_data_->_tmp8_ = _data_->self->settings;
	_data_->_tmp9_ = dc_settings_manager_get_rpc_server_path (_data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = _data_->self->settings;
	_data_->_tmp12_ = dc_settings_manager_get_rpc_server_source (_data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = dc_account_finder_find_rpc_server (_data_->_tmp10_, _data_->_tmp13_);
	_data_->rpc_path = _data_->_tmp14_;
	_data_->_tmp15_ = _data_->rpc_path;
	if (_data_->_tmp15_ == NULL) {
		dc_window_set_connection_status (_data_->self, FALSE, "RPC server not found");
		dc_window_show_rpc_not_found (_data_->self);
		_g_free0 (_data_->rpc_path);
		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_->_tmp16_ = _data_->self->settings;
	_data_->_tmp17_ = dc_settings_manager_get_rpc_server_source (_data_->_tmp16_);
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->_tmp19_ = dc_account_finder_get_data_dir (_data_->_tmp18_ == DC_RPC_SERVER_SOURCE_DESKTOP);
	_data_->data_dir = _data_->_tmp19_;
	_data_->_tmp20_ = _data_->data_dir;
	if (_data_->_tmp20_ == NULL) {
		_data_->_tmp21_ = _data_->self->priv->empty_status;
		adw_status_page_set_icon_name (_data_->_tmp21_, "dialog-error-symbolic");
		_data_->_tmp22_ = _data_->self->priv->empty_status;
		adw_status_page_set_title (_data_->_tmp22_, "Desktop accounts not found");
		_data_->_tmp23_ = _data_->self->priv->empty_status;
		adw_status_page_set_description (_data_->_tmp23_, "Delta Chat Desktop's account store was not found.\n" "Open Settings to choose another server source.");
		dc_window_set_connection_status (_data_->self, FALSE, "Desktop accounts not found");
		_data_->_tmp24_ = _data_->self->priv->content_stack;
		gtk_stack_set_visible_child_name (_data_->_tmp24_, "empty");
		dc_window_show_toast (_data_->self, "Delta Chat Desktop accounts not found");
		_g_free0 (_data_->data_dir);
		_g_free0 (_data_->rpc_path);
		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_->_tmp25_ = _data_->data_dir;
	_data_->_tmp26_ = g_build_filename (_data_->_tmp25_, "accounts", NULL);
	_data_->accounts_path = _data_->_tmp26_;
	{
		_data_->_tmp27_ = _data_->self->priv->rpc;
		_data_->_tmp28_ = _data_->rpc_path;
		_data_->_tmp29_ = g_strdup (_data_->_tmp28_);
		_data_->_tmp30_ = g_new0 (gchar*, 1 + 1);
		_data_->_tmp30_[0] = _data_->_tmp29_;
		_data_->_tmp31_ = _data_->_tmp30_;
		_data_->_tmp31__length1 = 1;
		_data_->_tmp32_ = _data_->data_dir;
		_data_->_tmp33_ = _data_->accounts_path;
		_data_->_state_ = 1;
		dc_rpc_client_start (_data_->_tmp27_, _data_->_tmp31_, (gint) 1, _data_->_tmp32_, _data_->_tmp33_, dc_window_try_connect_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_start_finish (_data_->_tmp27_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp31_ = (_vala_array_free (_data_->_tmp31_, _data_->_tmp31__length1, (GDestroyNotify) g_free), NULL);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp34_ = _data_->e;
		_data_->_tmp35_ = _data_->_tmp34_->message;
		_data_->_tmp36_ = g_strdup (_data_->_tmp35_);
		_data_->msg = _data_->_tmp36_;
		_data_->_tmp38_ = _data_->msg;
		_data_->_tmp39_ = g_utf8_strdown (_data_->_tmp38_, (gssize) -1);
		_data_->_tmp40_ = _data_->_tmp39_;
		_data_->_tmp41_ = string_contains (_data_->_tmp40_, "already running");
		_g_free0 (_data_->_tmp40_);
		if (_data_->_tmp41_) {
			_data_->_tmp37_ = TRUE;
		} else {
			_data_->_tmp42_ = _data_->msg;
			_data_->_tmp43_ = g_utf8_strdown (_data_->_tmp42_, (gssize) -1);
			_data_->_tmp44_ = _data_->_tmp43_;
			_data_->_tmp37_ = string_contains (_data_->_tmp44_, "accounts.lock");
			_g_free0 (_data_->_tmp44_);
		}
		if (_data_->_tmp37_) {
			dc_window_show_toast (_data_->self, "Cannot connect - account store is already in use");
			_data_->_tmp45_ = _data_->self->priv->empty_status;
			adw_status_page_set_description (_data_->_tmp45_, "The Delta Chat account store is already in use.\n\n" "Close the other Delta Chat or Parla process, then restart this app.");
			dc_window_set_connection_status (_data_->self, FALSE, "Account store is already in use");
		} else {
			_data_->_tmp46_ = _data_->msg;
			_data_->_tmp47_ = g_strconcat ("RPC server error: ", _data_->_tmp46_, NULL);
			_data_->_tmp48_ = _data_->_tmp47_;
			dc_window_show_toast (_data_->self, _data_->_tmp48_);
			_g_free0 (_data_->_tmp48_);
			_data_->_tmp49_ = _data_->self->priv->empty_status;
			_data_->_tmp50_ = _data_->msg;
			_data_->_tmp51_ = g_markup_escape_text (_data_->_tmp50_, (gssize) -1);
			_data_->_tmp52_ = _data_->_tmp51_;
			_data_->_tmp53_ = g_strconcat ("Failed to start RPC server:\n\n", _data_->_tmp52_, NULL);
			_data_->_tmp54_ = _data_->_tmp53_;
			adw_status_page_set_description (_data_->_tmp49_, _data_->_tmp54_);
			_g_free0 (_data_->_tmp54_);
			_g_free0 (_data_->_tmp52_);
			dc_window_set_connection_status (_data_->self, FALSE, "Cannot reach RPC server");
		}
		_g_free0 (_data_->msg);
		_g_error_free0 (_data_->e);
		_g_free0 (_data_->accounts_path);
		_g_free0 (_data_->data_dir);
		_g_free0 (_data_->rpc_path);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->accounts_path);
		_g_free0 (_data_->data_dir);
		_g_free0 (_data_->rpc_path);
		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;
	}
	dc_window_set_connection_status (_data_->self, TRUE, NULL);
	_data_->_tmp55_ = _data_->self->priv->rpc;
	g_signal_connect_object (_data_->_tmp55_, "disconnected", (GCallback) ___lambda156__dc_rpc_client_disconnected, _data_->self, 0);
	_data_->_tmp56_ = _data_->self->priv->rpc;
	_data_->_tmp57_ = NULL;
	_data_->_tmp58_ = NULL;
	_data_->_state_ = 2;
	dc_account_finder_ensure_configured (_data_->_tmp56_, dc_window_try_connect_ready, _data_);
	return FALSE;
	_state_2:
	dc_account_finder_ensure_configured_finish (_data_->_res_, &_data_->_tmp57_, &_data_->_tmp58_);
	_g_free0 (_data_->acct_desc);
	_data_->acct_desc = _data_->_tmp57_;
	_g_free0 (_data_->acct_toast);
	_data_->acct_toast = _data_->_tmp58_;
	_data_->_tmp59_ = _data_->acct_toast;
	if (_data_->_tmp59_ != NULL) {
		_data_->_tmp60_ = _data_->acct_toast;
		dc_window_show_toast (_data_->self, _data_->_tmp60_);
	}
	_data_->_tmp61_ = _data_->acct_desc;
	if (_data_->_tmp61_ != NULL) {
		_data_->_tmp62_ = _data_->self->priv->empty_status;
		_data_->_tmp63_ = _data_->acct_desc;
		adw_status_page_set_description (_data_->_tmp62_, _data_->_tmp63_);
	}
	_data_->_tmp64_ = _data_->self->priv->rpc;
	_data_->_tmp65_ = dc_event_handler_new (_data_->_tmp64_);
	_g_object_unref0 (_data_->self->priv->events);
	_data_->self->priv->events = _data_->_tmp65_;
	_data_->_tmp66_ = _data_->self->priv->events;
	_data_->_tmp67_ = gtk_window_get_application ((GtkWindow*) _data_->self);
	_data_->_tmp68_ = _data_->_tmp67_;
	dc_event_handler_set_app (_data_->_tmp66_, (GApplication*) _data_->_tmp68_);
	_data_->_tmp69_ = _data_->self->priv->events;
	g_signal_connect_object (_data_->_tmp69_, "chats-reload-fired", (GCallback) ___lambda157__dc_event_handler_chats_reload_fired, _data_->self, 0);
	_data_->_tmp70_ = _data_->self->priv->events;
	g_signal_connect_object (_data_->_tmp70_, "messages-reload-fired", (GCallback) ___lambda158__dc_event_handler_messages_reload_fired, _data_->self, 0);
	_data_->_tmp71_ = _data_->self->priv->events;
	g_signal_connect_object (_data_->_tmp71_, "incoming-msg-received", (GCallback) ___lambda159__dc_event_handler_incoming_msg_received, _data_->self, 0);
	_data_->_tmp72_ = _data_->self->priv->rpc;
	_data_->_tmp73_ = _data_->self->priv->_chat_store;
	_data_->_tmp74_ = dc_chat_context_menu_new (_data_->self, _data_->_tmp72_, _data_->_tmp73_);
	_g_object_unref0 (_data_->self->priv->chat_menu);
	_data_->self->priv->chat_menu = _data_->_tmp74_;
	_data_->_tmp75_ = _data_->self->priv->rpc;
	_data_->_tmp76_ = dc_rpc_client_get_account_id (_data_->_tmp75_);
	_data_->_tmp77_ = _data_->_tmp76_;
	if (_data_->_tmp77_ > 0) {
		{
			_data_->_tmp79_ = _data_->self->priv->rpc;
			_data_->_state_ = 3;
			dc_rpc_client_get_config (_data_->_tmp79_, "addr", 0, dc_window_try_connect_ready, _data_);
			return FALSE;
			_state_3:
			_data_->_tmp80_ = dc_rpc_client_get_config_finish (_data_->_tmp79_, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp78_ = _data_->_tmp80_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_data_->_tmp81_ = _data_->self->priv->rpc;
			dc_rpc_client_set_self_email (_data_->_tmp81_, _data_->_tmp78_);
			_g_free0 (_data_->_tmp78_);
		}
		goto __finally1;
		__catch1_g_error:
		{
			g_clear_error (&_data_->_inner_error0_);
			_data_->_tmp82_ = _data_->self->priv->rpc;
			dc_rpc_client_set_self_email (_data_->_tmp82_, NULL);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->acct_toast);
			_g_free0 (_data_->acct_desc);
			_g_free0 (_data_->accounts_path);
			_g_free0 (_data_->data_dir);
			_g_free0 (_data_->rpc_path);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_state_ = 4;
		dc_window_load_chats (_data_->self, dc_window_try_connect_ready, _data_);
		return FALSE;
		_state_4:
		dc_window_load_chats_finish (_data_->self, _data_->_res_);
		_data_->_state_ = 5;
		dc_window_load_profile_avatar (_data_->self, dc_window_try_connect_ready, _data_);
		return FALSE;
		_state_5:
		dc_window_load_profile_avatar_finish (_data_->self, _data_->_res_);
		_data_->_tmp83_ = _data_->self->priv->events;
		dc_event_handler_start (_data_->_tmp83_, NULL, NULL);
	}
	_g_free0 (_data_->acct_toast);
	_g_free0 (_data_->acct_desc);
	_g_free0 (_data_->accounts_path);
	_g_free0 (_data_->data_dir);
	_g_free0 (_data_->rpc_path);
	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_window_show_settings_dialog_gtk_button_clicked (GtkButton* _sender,
                                                    gpointer self)
{
	dc_window_show_settings_dialog ((DcWindow*) self);
}

static void
dc_window_show_rpc_not_found (DcWindow* self)
{
	AdwStatusPage* _tmp0_;
	AdwStatusPage* _tmp1_;
	gboolean _tmp2_ = FALSE;
	DcSettingsManager* _tmp3_;
	DcRpcServerSource _tmp4_;
	DcRpcServerSource _tmp5_;
	GtkButton* btn = NULL;
	GtkButton* _tmp24_;
	AdwStatusPage* _tmp25_;
	GtkStack* _tmp26_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->empty_status;
	adw_status_page_set_icon_name (_tmp0_, "dialog-error-symbolic");
	_tmp1_ = self->priv->empty_status;
	adw_status_page_set_title (_tmp1_, "RPC server not found");
	_tmp3_ = self->settings;
	_tmp4_ = dc_settings_manager_get_rpc_server_source (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ == DC_RPC_SERVER_SOURCE_CUSTOM) {
		DcSettingsManager* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp6_ = self->settings;
		_tmp7_ = dc_settings_manager_get_rpc_server_path (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = strlen (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp2_ = _tmp10_ > 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		AdwStatusPage* _tmp11_;
		DcSettingsManager* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		_tmp11_ = self->priv->empty_status;
		_tmp12_ = self->settings;
		_tmp13_ = dc_settings_manager_get_rpc_server_path (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = g_markup_escape_text (_tmp14_, (gssize) -1);
		_tmp16_ = _tmp15_;
		_tmp17_ = g_strconcat ("Configured path is missing or not executable:\n", _tmp16_, NULL);
		_tmp18_ = _tmp17_;
		adw_status_page_set_description (_tmp11_, _tmp18_);
		_g_free0 (_tmp18_);
		_g_free0 (_tmp16_);
	} else {
		DcSettingsManager* _tmp19_;
		DcRpcServerSource _tmp20_;
		DcRpcServerSource _tmp21_;
		_tmp19_ = self->settings;
		_tmp20_ = dc_settings_manager_get_rpc_server_source (_tmp19_);
		_tmp21_ = _tmp20_;
		if (_tmp21_ == DC_RPC_SERVER_SOURCE_DESKTOP) {
			AdwStatusPage* _tmp22_;
			_tmp22_ = self->priv->empty_status;
			adw_status_page_set_description (_tmp22_, "Delta Chat Desktop's bundled server was not found.\n" "Open Settings to choose a standalone server.");
		} else {
			AdwStatusPage* _tmp23_;
			_tmp23_ = self->priv->empty_status;
			adw_status_page_set_description (_tmp23_, "Standalone deltachat-rpc-server was not found.\n" "Open Settings to choose a server source, or install it.");
		}
	}
	_tmp24_ = (GtkButton*) gtk_button_new_with_label ("Open Settings…");
	g_object_ref_sink (_tmp24_);
	btn = _tmp24_;
	gtk_widget_add_css_class ((GtkWidget*) btn, "suggested-action");
	gtk_widget_add_css_class ((GtkWidget*) btn, "pill");
	gtk_widget_set_halign ((GtkWidget*) btn, GTK_ALIGN_CENTER);
	g_signal_connect_object (btn, "clicked", (GCallback) _dc_window_show_settings_dialog_gtk_button_clicked, self, 0);
	_tmp25_ = self->priv->empty_status;
	adw_status_page_set_child (_tmp25_, (GtkWidget*) btn);
	_tmp26_ = self->priv->content_stack;
	gtk_stack_set_visible_child_name (_tmp26_, "empty");
	dc_window_show_toast (self, "deltachat-rpc-server not found");
	_g_object_unref0 (btn);
}

void
dc_window_clear_chat_view (DcWindow* self)
{
	GtkStack* _tmp0_;
	g_return_if_fail (self != NULL);
	dc_window_set_current_chat_id (self, 0);
	_tmp0_ = self->priv->content_stack;
	gtk_stack_set_visible_child_name (_tmp0_, "empty");
}

static DcConversationView*
dc_window_current_view (DcWindow* self)
{
	gint _tmp0_;
	gint _tmp1_;
	GHashTable* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gconstpointer _tmp5_;
	DcConversationView* _tmp6_;
	DcConversationView* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_window_get_current_chat_id (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ <= 0) {
		result = NULL;
		return result;
	}
	_tmp2_ = self->priv->views;
	_tmp3_ = dc_window_get_current_chat_id (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_hash_table_lookup (_tmp2_, (gpointer) ((gintptr) _tmp4_));
	_tmp6_ = _g_object_ref0 ((DcConversationView*) _tmp5_);
	result = _tmp6_;
	return result;
}

static DcConversationView*
dc_window_get_or_create_view (DcWindow* self,
                              gint chat_id)
{
	DcConversationView* v = NULL;
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	DcConversationView* _tmp2_;
	DcConversationView* _tmp3_;
	DcRpcClient* _tmp4_;
	DcSettingsManager* _tmp5_;
	DcConversationView* _tmp6_;
	GHashTable* _tmp7_;
	DcConversationView* _tmp8_;
	DcConversationView* _tmp9_;
	GtkStack* _tmp10_;
	DcConversationView* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	DcConversationView* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->views;
	_tmp1_ = g_hash_table_lookup (_tmp0_, (gpointer) ((gintptr) chat_id));
	_tmp2_ = _g_object_ref0 ((DcConversationView*) _tmp1_);
	v = _tmp2_;
	_tmp3_ = v;
	if (_tmp3_ != NULL) {
		result = v;
		return result;
	}
	_tmp4_ = self->priv->rpc;
	_tmp5_ = self->settings;
	_tmp6_ = dc_conversation_view_new (chat_id, self, _tmp4_, _tmp5_);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (v);
	v = _tmp6_;
	_tmp7_ = self->priv->views;
	_tmp8_ = v;
	_tmp9_ = _g_object_ref0 (_tmp8_);
	g_hash_table_insert (_tmp7_, (gpointer) ((gintptr) chat_id), _tmp9_);
	_tmp10_ = self->priv->content_stack;
	_tmp11_ = v;
	_tmp12_ = g_strdup_printf ("chat_%d", chat_id);
	_tmp13_ = _tmp12_;
	gtk_stack_add_named (_tmp10_, (GtkWidget*) _tmp11_, _tmp13_);
	_g_free0 (_tmp13_);
	result = v;
	return result;
}

void
dc_window_request_messages_reload (DcWindow* self)
{
	DcEventHandler* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->events;
	if (_tmp0_ != NULL) {
		DcEventHandler* _tmp1_;
		_tmp1_ = self->priv->events;
		dc_event_handler_schedule_messages_reload (_tmp1_);
	}
}

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

void
dc_window_load_chats (DcWindow* self,
                      GAsyncReadyCallback _callback_,
                      gpointer _user_data_)
{
	DcWindowLoadChatsData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowLoadChatsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_load_chats_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_window_load_chats_co (_data_);
}

void
dc_window_load_chats_finish (DcWindow* self,
                             GAsyncResult* _res_)
{
	DcWindowLoadChatsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_load_chats_ready (GObject* source_object,
                            GAsyncResult* _res_,
                            gpointer _user_data_)
{
	DcWindowLoadChatsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_load_chats_co (_data_);
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : NULL;
}

static gboolean
dc_window_load_chats_co (DcWindowLoadChatsData* _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_->_tmp3_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_chatlist_entries (_data_->_tmp3_, NULL, dc_window_load_chats_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp4_ = dc_rpc_client_get_chatlist_entries_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		_data_->entries = _data_->_tmp4_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp5_ = _data_->entries;
		if (_data_->_tmp5_ == NULL) {
			_json_array_unref0 (_data_->entries);
			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_->_tmp6_ = _data_->self->priv->rpc;
		_data_->_tmp7_ = _data_->entries;
		_data_->_state_ = 2;
		dc_rpc_client_get_chatlist_items_by_entries (_data_->_tmp6_, _data_->_tmp7_, dc_window_load_chats_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp8_ = dc_rpc_client_get_chatlist_items_by_entries_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		_data_->items = _data_->_tmp8_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_json_array_unref0 (_data_->entries);
			goto __catch0_g_error;
		}
		_data_->_tmp9_ = _data_->self->priv->_chat_store;
		g_list_store_remove_all (_data_->_tmp9_);
		_data_->_tmp10_ = _data_->self->priv->chat_listbox;
		dc_clear_listbox (_data_->_tmp10_);
		_data_->reselect_row = NULL;
		{
			_data_->i = (guint) 0;
			{
				_data_->_tmp11_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp11_) {
						_data_->_tmp12_ = _data_->i;
						_data_->i = _data_->_tmp12_ + 1;
					}
					_data_->_tmp11_ = FALSE;
					_data_->_tmp13_ = _data_->entries;
					if (!(_data_->i < json_array_get_length (_data_->_tmp13_))) {
						break;
					}
					_data_->_tmp14_ = _data_->entries;
					_data_->chat_id = (gint) json_array_get_int_element (_data_->_tmp14_, _data_->i);
					_data_->_tmp15_ = g_strdup_printf ("%i", _data_->chat_id);
					_data_->id_str = _data_->_tmp15_;
					_data_->_tmp17_ = _data_->items;
					if (_data_->_tmp17_ != NULL) {
						_data_->_tmp18_ = _data_->items;
						_data_->_tmp19_ = _data_->id_str;
						_data_->_tmp16_ = json_object_has_member (_data_->_tmp18_, _data_->_tmp19_);
					} else {
						_data_->_tmp16_ = FALSE;
					}
					if (_data_->_tmp16_) {
						_data_->_tmp20_ = _data_->items;
						_data_->_tmp21_ = _data_->id_str;
						_data_->_tmp22_ = json_object_get_object_member (_data_->_tmp20_, _data_->_tmp21_);
						_data_->_tmp23_ = _json_object_ref0 (_data_->_tmp22_);
						_data_->item = _data_->_tmp23_;
						_data_->_tmp24_ = _data_->item;
						_data_->_tmp25_ = dc_rpc_client_parse_chat_item (_data_->chat_id, _data_->_tmp24_);
						_data_->entry = _data_->_tmp25_;
						_data_->_tmp26_ = _data_->self->priv->_chat_store;
						_data_->_tmp27_ = _data_->entry;
						g_list_store_append (_data_->_tmp26_, (GObject*) _data_->_tmp27_);
						_data_->_tmp28_ = _data_->entry;
						_data_->_tmp29_ = dc_chat_row_new (_data_->_tmp28_);
						g_object_ref_sink (_data_->_tmp29_);
						_data_->chat_row = _data_->_tmp29_;
						_data_->_tmp30_ = _data_->self->priv->chat_listbox;
						_data_->_tmp31_ = _data_->chat_row;
						gtk_list_box_append (_data_->_tmp30_, (GtkWidget*) _data_->_tmp31_);
						_data_->_tmp32_ = dc_window_get_current_chat_id (_data_->self);
						_data_->_tmp33_ = _data_->_tmp32_;
						if (_data_->chat_id == _data_->_tmp33_) {
							_data_->_tmp34_ = _data_->self->priv->chat_listbox;
							_data_->_tmp35_ = gtk_list_box_get_row_at_index (_data_->_tmp34_, (gint) _data_->i);
							_data_->_tmp36_ = _g_object_ref0 (_data_->_tmp35_);
							_g_object_unref0 (_data_->reselect_row);
							_data_->reselect_row = _data_->_tmp36_;
						}
						_g_object_unref0 (_data_->chat_row);
						_g_object_unref0 (_data_->entry);
						_json_object_unref0 (_data_->item);
					}
					_g_free0 (_data_->id_str);
				}
			}
		}
		_data_->_tmp37_ = _data_->reselect_row;
		if (_data_->_tmp37_ != NULL) {
			_data_->self->priv->suppress_reselect_scroll = TRUE;
			_data_->_tmp38_ = _data_->self->priv->chat_listbox;
			_data_->_tmp39_ = _data_->reselect_row;
			gtk_list_box_select_row (_data_->_tmp38_, _data_->_tmp39_);
			_data_->self->priv->suppress_reselect_scroll = FALSE;
		}
		_g_object_unref0 (_data_->reselect_row);
		_json_object_unref0 (_data_->items);
		_json_array_unref0 (_data_->entries);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp40_ = _data_->e;
		_data_->_tmp41_ = _data_->_tmp40_->message;
		_data_->_tmp42_ = g_strconcat ("Failed to load chats: ", _data_->_tmp41_, NULL);
		_data_->_tmp43_ = _data_->_tmp42_;
		dc_window_show_toast (_data_->self, _data_->_tmp43_);
		_g_free0 (_data_->_tmp43_);
		_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 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 gboolean
dc_window_filter_chats (DcWindow* self,
                        GtkListBoxRow* row)
{
	gchar* query = NULL;
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	DcChatRow* chat_row = NULL;
	GtkWidget* _tmp10_;
	GtkWidget* _tmp11_;
	DcChatRow* _tmp12_;
	DcChatRow* _tmp13_;
	DcChatEntry* entry = NULL;
	GListStore* _tmp14_;
	DcChatRow* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	DcChatEntry* _tmp18_;
	DcChatEntry* _tmp19_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (row != NULL, FALSE);
	_tmp0_ = self->priv->search_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_strip (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_utf8_strdown (_tmp4_, (gssize) -1);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	query = _tmp6_;
	_tmp7_ = query;
	_tmp8_ = strlen (_tmp7_);
	_tmp9_ = _tmp8_;
	if (_tmp9_ == 0) {
		result = TRUE;
		_g_free0 (query);
		return result;
	}
	_tmp10_ = gtk_list_box_row_get_child (row);
	_tmp11_ = _tmp10_;
	_tmp12_ = _g_object_ref0 (DC_IS_CHAT_ROW (_tmp11_) ? ((DcChatRow*) _tmp11_) : NULL);
	chat_row = _tmp12_;
	_tmp13_ = chat_row;
	if (_tmp13_ == NULL) {
		result = TRUE;
		_g_object_unref0 (chat_row);
		_g_free0 (query);
		return result;
	}
	_tmp14_ = self->priv->_chat_store;
	_tmp15_ = chat_row;
	_tmp16_ = dc_chat_row_get_chat_id (_tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = dc_find_chat_entry (_tmp14_, _tmp17_);
	entry = _tmp18_;
	_tmp19_ = entry;
	if (_tmp19_ != NULL) {
		DcChatEntry* _tmp20_;
		const gchar* _tmp21_;
		const gchar* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		const gchar* _tmp25_;
		gboolean _tmp26_;
		_tmp20_ = entry;
		_tmp21_ = dc_chat_entry_get_name (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = g_utf8_strdown (_tmp22_, (gssize) -1);
		_tmp24_ = _tmp23_;
		_tmp25_ = query;
		_tmp26_ = string_contains (_tmp24_, _tmp25_);
		_g_free0 (_tmp24_);
		result = _tmp26_;
		_g_object_unref0 (entry);
		_g_object_unref0 (chat_row);
		_g_free0 (query);
		return result;
	}
	result = TRUE;
	_g_object_unref0 (entry);
	_g_object_unref0 (chat_row);
	_g_free0 (query);
	return result;
}

static void
dc_window_on_chat_selected (DcWindow* self,
                            GtkListBoxRow* row)
{
	DcChatRow* chat_row = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	DcChatRow* _tmp2_;
	DcChatRow* _tmp3_;
	gint chat_id = 0;
	DcChatRow* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	DcConversationView* view = NULL;
	DcConversationView* _tmp12_;
	DcChatEntry* entry = NULL;
	GListStore* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	DcChatEntry* _tmp16_;
	DcChatEntry* _tmp17_;
	GtkStack* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	DcConversationView* _tmp25_;
	gint _tmp26_;
	gint _tmp27_;
	AdwNavigationSplitView* _tmp28_;
	g_return_if_fail (self != NULL);
	if (row == NULL) {
		return;
	}
	_tmp0_ = gtk_list_box_row_get_child (row);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (DC_IS_CHAT_ROW (_tmp1_) ? ((DcChatRow*) _tmp1_) : NULL);
	chat_row = _tmp2_;
	_tmp3_ = chat_row;
	if (_tmp3_ == NULL) {
		_g_object_unref0 (chat_row);
		return;
	}
	_tmp4_ = chat_row;
	_tmp5_ = dc_chat_row_get_chat_id (_tmp4_);
	_tmp6_ = _tmp5_;
	chat_id = _tmp6_;
	_tmp7_ = dc_window_get_current_chat_id (self);
	_tmp8_ = _tmp7_;
	if (chat_id == _tmp8_) {
		DcConversationView* v = NULL;
		DcConversationView* _tmp9_;
		DcConversationView* _tmp10_;
		if (self->priv->suppress_reselect_scroll) {
			_g_object_unref0 (chat_row);
			return;
		}
		_tmp9_ = dc_window_current_view (self);
		v = _tmp9_;
		_tmp10_ = v;
		if (_tmp10_ != NULL) {
			DcConversationView* _tmp11_;
			_tmp11_ = v;
			dc_conversation_view_on_reselected (_tmp11_);
		}
		_g_object_unref0 (v);
		_g_object_unref0 (chat_row);
		return;
	}
	_tmp12_ = dc_window_get_or_create_view (self, chat_id);
	view = _tmp12_;
	dc_window_set_current_chat_id (self, chat_id);
	_tmp13_ = self->priv->_chat_store;
	_tmp14_ = dc_window_get_current_chat_id (self);
	_tmp15_ = _tmp14_;
	_tmp16_ = dc_find_chat_entry (_tmp13_, _tmp15_);
	entry = _tmp16_;
	_tmp17_ = entry;
	if (_tmp17_ != NULL) {
		GtkLabel* _tmp18_;
		DcChatEntry* _tmp19_;
		const gchar* _tmp20_;
		const gchar* _tmp21_;
		_tmp18_ = self->priv->content_title_label;
		_tmp19_ = entry;
		_tmp20_ = dc_chat_entry_get_name (_tmp19_);
		_tmp21_ = _tmp20_;
		gtk_label_set_label (_tmp18_, _tmp21_);
	}
	_tmp22_ = self->priv->content_stack;
	_tmp23_ = g_strdup_printf ("chat_%d", chat_id);
	_tmp24_ = _tmp23_;
	gtk_stack_set_visible_child_name (_tmp22_, _tmp24_);
	_g_free0 (_tmp24_);
	_tmp25_ = view;
	dc_conversation_view_on_activated (_tmp25_);
	_tmp26_ = dc_window_get_current_chat_id (self);
	_tmp27_ = _tmp26_;
	dc_window_notice_chat (self, _tmp27_, NULL, NULL);
	_tmp28_ = self->priv->split_view;
	adw_navigation_split_view_set_show_content (_tmp28_, TRUE);
	_g_object_unref0 (entry);
	_g_object_unref0 (view);
	_g_object_unref0 (chat_row);
}

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

static void
dc_window_notice_chat (DcWindow* self,
                       gint chat_id,
                       GAsyncReadyCallback _callback_,
                       gpointer _user_data_)
{
	DcWindowNoticeChatData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowNoticeChatData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_notice_chat_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	dc_window_notice_chat_co (_data_);
}

static void
dc_window_notice_chat_finish (DcWindow* self,
                              GAsyncResult* _res_)
{
	DcWindowNoticeChatData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_notice_chat_ready (GObject* source_object,
                             GAsyncResult* _res_,
                             gpointer _user_data_)
{
	DcWindowNoticeChatData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_notice_chat_co (_data_);
}

static gboolean
dc_window_notice_chat_co (DcWindowNoticeChatData* _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_->_state_ = 1;
		dc_rpc_client_marknoticed_chat (_data_->_tmp0_, _data_->chat_id, dc_window_notice_chat_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_marknoticed_chat_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__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_window_show_image (DcWindow* self,
                      const gchar* path)
{
	DcImageViewer* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (path != NULL);
	_tmp0_ = self->priv->image_viewer;
	dc_image_viewer_show (_tmp0_, path);
}

void
dc_window_show_image_list (DcWindow* self,
                           gchar** paths,
                           gint paths_length1,
                           gint start_index)
{
	DcImageViewer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->image_viewer;
	dc_image_viewer_show_list (_tmp0_, paths, (gint) paths_length1, start_index);
}

static void
dc_window_save_attachment_data_free (gpointer _data)
{
	DcWindowSaveAttachmentData* _data_;
	_data_ = _data;
	_g_free0 (_data_->src_path);
	_g_free0 (_data_->name);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowSaveAttachmentData, _data_);
}

void
dc_window_save_attachment (DcWindow* self,
                           const gchar* src_path,
                           const gchar* name,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_)
{
	DcWindowSaveAttachmentData* _data_;
	DcWindow* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (src_path != NULL);
	_data_ = g_slice_new0 (DcWindowSaveAttachmentData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_save_attachment_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (src_path);
	_g_free0 (_data_->src_path);
	_data_->src_path = _tmp1_;
	_tmp2_ = g_strdup (name);
	_g_free0 (_data_->name);
	_data_->name = _tmp2_;
	dc_window_save_attachment_co (_data_);
}

void
dc_window_save_attachment_finish (DcWindow* self,
                                  GAsyncResult* _res_)
{
	DcWindowSaveAttachmentData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_save_attachment_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_)
{
	DcWindowSaveAttachmentData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_save_attachment_co (_data_);
}

static gboolean
dc_window_save_attachment_co (DcWindowSaveAttachmentData* _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_ = gtk_file_dialog_new ();
	_data_->dialog = _data_->_tmp0_;
	_data_->_tmp2_ = g_strdup (_data_->name);
	_data_->_tmp1_ = _data_->_tmp2_;
	if (_data_->_tmp1_ == NULL) {
		_data_->_tmp3_ = g_path_get_basename (_data_->src_path);
		_g_free0 (_data_->_tmp1_);
		_data_->_tmp1_ = _data_->_tmp3_;
	}
	_data_->_tmp4_ = _data_->dialog;
	gtk_file_dialog_set_initial_name (_data_->_tmp4_, _data_->_tmp1_);
	{
		_data_->_tmp5_ = _data_->dialog;
		_data_->_state_ = 1;
		gtk_file_dialog_save (_data_->_tmp5_, (GtkWindow*) _data_->self, NULL, dc_window_save_attachment_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = gtk_file_dialog_save_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
		_data_->dest = _data_->_tmp6_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp7_ = _data_->dest;
		if (_data_->_tmp7_ == NULL) {
			_g_object_unref0 (_data_->dest);
			_g_free0 (_data_->_tmp1_);
			_g_object_unref0 (_data_->dialog);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp8_ = g_file_new_for_path (_data_->src_path);
		_data_->src_file = _data_->_tmp8_;
		_data_->_tmp9_ = _data_->src_file;
		_data_->_tmp10_ = _data_->dest;
		_data_->_state_ = 2;
		g_file_copy_async (_data_->_tmp9_, _data_->_tmp10_, G_FILE_COPY_OVERWRITE, G_PRIORITY_DEFAULT, NULL, NULL, NULL, dc_window_save_attachment_ready, _data_);
		return FALSE;
		_state_2:
		g_file_copy_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->src_file);
			_g_object_unref0 (_data_->dest);
			goto __catch0_g_error;
		}
		dc_window_show_toast (_data_->self, "File saved");
		_g_object_unref0 (_data_->src_file);
		_g_object_unref0 (_data_->dest);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp11_ = _data_->e;
		if (g_error_matches (_data_->_tmp11_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
			_g_error_free0 (_data_->e);
			_g_free0 (_data_->_tmp1_);
			_g_object_unref0 (_data_->dialog);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp12_ = _data_->e;
		_data_->_tmp13_ = _data_->_tmp12_->message;
		_data_->_tmp14_ = g_strconcat ("Save failed: ", _data_->_tmp13_, NULL);
		_data_->_tmp15_ = _data_->_tmp14_;
		dc_window_show_toast (_data_->self, _data_->_tmp15_);
		_g_free0 (_data_->_tmp15_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->_tmp1_);
		_g_object_unref0 (_data_->dialog);
		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_free0 (_data_->_tmp1_);
	_g_object_unref0 (_data_->dialog);
	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_window_request_reload_chats (DcWindow* self)
{
	DcEventHandler* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->events;
	if (_tmp0_ != NULL) {
		DcEventHandler* _tmp1_;
		_tmp1_ = self->priv->events;
		dc_event_handler_schedule_chats_reload (_tmp1_);
	}
}

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

static void
dc_window_on_incoming_msg (DcWindow* self,
                           gint chat_id,
                           gint msg_id,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_)
{
	DcWindowOnIncomingMsgData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowOnIncomingMsgData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_on_incoming_msg_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	_data_->msg_id = msg_id;
	dc_window_on_incoming_msg_co (_data_);
}

static void
dc_window_on_incoming_msg_finish (DcWindow* self,
                                  GAsyncResult* _res_)
{
	DcWindowOnIncomingMsgData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_on_incoming_msg_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_)
{
	DcWindowOnIncomingMsgData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_on_incoming_msg_co (_data_);
}

static gboolean
dc_window_on_incoming_msg_co (DcWindowOnIncomingMsgData* _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->views;
	_data_->_tmp1_ = g_hash_table_lookup (_data_->_tmp0_, (gpointer) ((gintptr) _data_->chat_id));
	_data_->_tmp2_ = _g_object_ref0 ((DcConversationView*) _data_->_tmp1_);
	_data_->view = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->view;
	if (_data_->_tmp3_ != NULL) {
		_data_->_tmp4_ = _data_->view;
		_data_->_state_ = 1;
		dc_conversation_view_handle_incoming_msg (_data_->_tmp4_, _data_->msg_id, dc_window_on_incoming_msg_ready, _data_);
		return FALSE;
		_state_1:
		dc_conversation_view_handle_incoming_msg_finish (_data_->_tmp4_, _data_->_res_);
	}
	_data_->_tmp6_ = _data_->self->settings;
	_data_->_tmp7_ = dc_settings_manager_get_notifications_enabled (_data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	if (_data_->_tmp8_) {
		g_object_get ((GtkWindow*) _data_->self, "is-active", &_data_->_tmp9_, NULL);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp5_ = !_data_->_tmp10_;
	} else {
		_data_->_tmp5_ = FALSE;
	}
	if (_data_->_tmp5_) {
		_data_->_tmp11_ = _data_->self->priv->events;
		_data_->_state_ = 2;
		dc_event_handler_send_notification (_data_->_tmp11_, _data_->chat_id, _data_->msg_id, dc_window_on_incoming_msg_ready, _data_);
		return FALSE;
		_state_2:
		dc_event_handler_send_notification_finish (_data_->_tmp11_, _data_->_res_);
	}
	dc_window_request_reload_chats (_data_->self);
	_g_object_unref0 (_data_->view);
	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_window_load_account_menu_data_free (gpointer _data)
{
	DcWindowLoadAccountMenuData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowLoadAccountMenuData, _data_);
}

static void
dc_window_load_account_menu (DcWindow* self,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_)
{
	DcWindowLoadAccountMenuData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowLoadAccountMenuData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_load_account_menu_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_window_load_account_menu_co (_data_);
}

static void
dc_window_load_account_menu_finish (DcWindow* self,
                                    GAsyncResult* _res_)
{
	DcWindowLoadAccountMenuData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_load_account_menu_ready (GObject* source_object,
                                   GAsyncResult* _res_,
                                   gpointer _user_data_)
{
	DcWindowLoadAccountMenuData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_load_account_menu_co (_data_);
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

static gpointer
_json_array_ref0 (gpointer self)
{
	return self ? json_array_ref (self) : NULL;
}

static gboolean
dc_window_load_account_menu_co (DcWindowLoadAccountMenuData* _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->account_menu_list;
	dc_clear_listbox (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->self->priv->rpc;
	if (_data_->_tmp2_ == NULL) {
		_data_->_tmp1_ = TRUE;
	} else {
		_data_->_tmp3_ = _data_->self->priv->rpc;
		_data_->_tmp4_ = dc_rpc_client_get_is_connected (_data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp1_ = !_data_->_tmp5_;
	}
	if (_data_->_tmp1_) {
		_data_->_tmp6_ = (AdwActionRow*) adw_action_row_new ();
		g_object_ref_sink (_data_->_tmp6_);
		_data_->row = _data_->_tmp6_;
		_data_->_tmp7_ = _data_->row;
		adw_preferences_row_set_title ((AdwPreferencesRow*) _data_->_tmp7_, "Not connected");
		_data_->_tmp8_ = _data_->row;
		adw_action_row_set_subtitle (_data_->_tmp8_, "Open Settings to configure the RPC server");
		_data_->_tmp9_ = _data_->self->priv->account_menu_list;
		_data_->_tmp10_ = _data_->row;
		gtk_list_box_append (_data_->_tmp9_, (GtkWidget*) _data_->_tmp10_);
		_g_object_unref0 (_data_->row);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp11_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_all_accounts (_data_->_tmp11_, dc_window_load_account_menu_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp12_ = dc_rpc_client_get_all_accounts_finish (_data_->_tmp11_, _data_->_res_, &_data_->_inner_error0_);
		_data_->accounts_node = _data_->_tmp12_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp13_ = _data_->self->priv->account_menu_list;
		dc_clear_listbox (_data_->_tmp13_);
		_data_->_tmp14_ = _data_->accounts_node;
		if (_data_->_tmp14_ == NULL) {
			__vala_JsonNode_free0 (_data_->accounts_node);
			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_->accounts_node;
		_data_->_tmp16_ = json_node_get_array (_data_->_tmp15_);
		_data_->_tmp17_ = _json_array_ref0 (_data_->_tmp16_);
		_data_->accounts = _data_->_tmp17_;
		{
			_data_->i = (guint) 0;
			{
				_data_->_tmp18_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp18_) {
						_data_->_tmp19_ = _data_->i;
						_data_->i = _data_->_tmp19_ + 1;
					}
					_data_->_tmp18_ = FALSE;
					_data_->_tmp20_ = _data_->accounts;
					if (!(_data_->i < json_array_get_length (_data_->_tmp20_))) {
						break;
					}
					_data_->_tmp21_ = _data_->accounts;
					_data_->_tmp22_ = json_array_get_object_element (_data_->_tmp21_, _data_->i);
					_data_->_tmp23_ = _json_object_ref0 (_data_->_tmp22_);
					_data_->acct = _data_->_tmp23_;
					_data_->_tmp24_ = _data_->acct;
					_data_->id = (gint) json_object_get_int_member (_data_->_tmp24_, "id");
					_data_->_tmp26_ = _data_->self->priv->rpc;
					_data_->_tmp27_ = dc_rpc_client_get_account_id (_data_->_tmp26_);
					_data_->_tmp28_ = _data_->_tmp27_;
					_data_->_state_ = 2;
					dc_window_build_account_menu_row_for_id (_data_->self, _data_->id, _data_->id == _data_->_tmp28_, dc_window_load_account_menu_ready, _data_);
					return FALSE;
					_state_2:
					_data_->_tmp29_ = dc_window_build_account_menu_row_for_id_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
					_data_->_tmp25_ = _data_->_tmp29_;
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						_json_object_unref0 (_data_->acct);
						_json_array_unref0 (_data_->accounts);
						__vala_JsonNode_free0 (_data_->accounts_node);
						goto __catch0_g_error;
					}
					_data_->_tmp30_ = _data_->self->priv->account_menu_list;
					gtk_list_box_append (_data_->_tmp30_, (GtkWidget*) _data_->_tmp25_);
					_g_object_unref0 (_data_->_tmp25_);
					_json_object_unref0 (_data_->acct);
				}
			}
		}
		_data_->_tmp31_ = _data_->accounts;
		if (json_array_get_length (_data_->_tmp31_) == ((guint) 0)) {
			_data_->_tmp32_ = (AdwActionRow*) adw_action_row_new ();
			g_object_ref_sink (_data_->_tmp32_);
			_data_->empty = _data_->_tmp32_;
			_data_->_tmp33_ = _data_->empty;
			adw_preferences_row_set_title ((AdwPreferencesRow*) _data_->_tmp33_, "No accounts");
			_data_->_tmp34_ = _data_->empty;
			adw_action_row_set_subtitle (_data_->_tmp34_, "Add an account to get started");
			_data_->_tmp35_ = _data_->self->priv->account_menu_list;
			_data_->_tmp36_ = _data_->empty;
			gtk_list_box_append (_data_->_tmp35_, (GtkWidget*) _data_->_tmp36_);
			_g_object_unref0 (_data_->empty);
		}
		_data_->_tmp37_ = _data_->self->priv->account_menu_list;
		_data_->_tmp38_ = dc_window_build_add_account_row (_data_->self);
		_data_->_tmp39_ = _data_->_tmp38_;
		gtk_list_box_append (_data_->_tmp37_, (GtkWidget*) _data_->_tmp39_);
		_g_object_unref0 (_data_->_tmp39_);
		_json_array_unref0 (_data_->accounts);
		__vala_JsonNode_free0 (_data_->accounts_node);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp40_ = _data_->self->priv->account_menu_list;
		dc_clear_listbox (_data_->_tmp40_);
		_data_->_tmp41_ = (AdwActionRow*) adw_action_row_new ();
		g_object_ref_sink (_data_->_tmp41_);
		_data_->err_row = _data_->_tmp41_;
		_data_->_tmp42_ = _data_->err_row;
		adw_preferences_row_set_use_markup ((AdwPreferencesRow*) _data_->_tmp42_, FALSE);
		_data_->_tmp43_ = _data_->err_row;
		adw_preferences_row_set_title ((AdwPreferencesRow*) _data_->_tmp43_, "Error loading accounts");
		_data_->_tmp44_ = _data_->err_row;
		_data_->_tmp45_ = _data_->e;
		_data_->_tmp46_ = _data_->_tmp45_->message;
		adw_action_row_set_subtitle (_data_->_tmp44_, _data_->_tmp46_);
		_data_->_tmp47_ = _data_->self->priv->account_menu_list;
		_data_->_tmp48_ = _data_->err_row;
		gtk_list_box_append (_data_->_tmp47_, (GtkWidget*) _data_->_tmp48_);
		_g_object_unref0 (_data_->err_row);
		_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 AdwActionRow*
dc_window_build_add_account_row (DcWindow* self)
{
	AdwActionRow* row = NULL;
	AdwActionRow* _tmp0_;
	GtkImage* icon = NULL;
	GtkImage* _tmp1_;
	AdwActionRow* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) row, "Add Profile");
	gtk_list_box_row_set_activatable ((GtkListBoxRow*) row, TRUE);
	g_object_set_data_full ((GObject*) row, "acct-id", (gpointer) ((gintptr) -1), NULL);
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("list-add-symbolic");
	g_object_ref_sink (_tmp1_);
	icon = _tmp1_;
	gtk_widget_set_valign ((GtkWidget*) icon, GTK_ALIGN_CENTER);
	adw_action_row_add_prefix (row, (GtkWidget*) icon);
	result = row;
	_g_object_unref0 (icon);
	return result;
}

static void
dc_window_build_account_menu_row_for_id_data_free (gpointer _data)
{
	DcWindowBuildAccountMenuRowForIdData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowBuildAccountMenuRowForIdData, _data_);
}

static void
dc_window_build_account_menu_row_for_id (DcWindow* self,
                                         gint id,
                                         gboolean current,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_)
{
	DcWindowBuildAccountMenuRowForIdData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowBuildAccountMenuRowForIdData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_build_account_menu_row_for_id_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->id = id;
	_data_->current = current;
	dc_window_build_account_menu_row_for_id_co (_data_);
}

static AdwActionRow*
dc_window_build_account_menu_row_for_id_finish (DcWindow* self,
                                                GAsyncResult* _res_,
                                                GError** error)
{
	AdwActionRow* result;
	DcWindowBuildAccountMenuRowForIdData* _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_window_build_account_menu_row_for_id_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_)
{
	DcWindowBuildAccountMenuRowForIdData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_build_account_menu_row_for_id_co (_data_);
}

static gboolean
dc_window_build_account_menu_row_for_id_co (DcWindowBuildAccountMenuRowForIdData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->rpc;
	_data_->_state_ = 1;
	dc_rpc_client_is_configured (_data_->_tmp0_, _data_->id, dc_window_build_account_menu_row_for_id_ready, _data_);
	return FALSE;
	_state_1:
	_data_->configured = dc_rpc_client_is_configured_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->email = NULL;
	_data_->display_name = NULL;
	_data_->avatar = NULL;
	if (_data_->configured) {
		{
			_data_->_tmp2_ = _data_->self->priv->rpc;
			_data_->_state_ = 2;
			dc_rpc_client_get_config (_data_->_tmp2_, "addr", _data_->id, dc_window_build_account_menu_row_for_id_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp3_ = dc_rpc_client_get_config_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp1_ = _data_->_tmp3_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp4_ = _data_->_tmp1_;
			_data_->_tmp1_ = NULL;
			_g_free0 (_data_->email);
			_data_->email = _data_->_tmp4_;
			_data_->_tmp6_ = _data_->self->priv->rpc;
			_data_->_state_ = 3;
			dc_rpc_client_get_config (_data_->_tmp6_, "displayname", _data_->id, dc_window_build_account_menu_row_for_id_ready, _data_);
			return FALSE;
			_state_3:
			_data_->_tmp7_ = dc_rpc_client_get_config_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp5_ = _data_->_tmp7_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_free0 (_data_->_tmp1_);
				goto __catch0_g_error;
			}
			_data_->_tmp8_ = _data_->_tmp5_;
			_data_->_tmp5_ = NULL;
			_g_free0 (_data_->display_name);
			_data_->display_name = _data_->_tmp8_;
			_data_->_tmp10_ = _data_->self->priv->rpc;
			_data_->_state_ = 4;
			dc_rpc_client_get_config (_data_->_tmp10_, "selfavatar", _data_->id, dc_window_build_account_menu_row_for_id_ready, _data_);
			return FALSE;
			_state_4:
			_data_->_tmp11_ = dc_rpc_client_get_config_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp9_ = _data_->_tmp11_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_free0 (_data_->_tmp5_);
				_g_free0 (_data_->_tmp1_);
				goto __catch0_g_error;
			}
			_data_->_tmp12_ = _data_->_tmp9_;
			_data_->_tmp9_ = NULL;
			_g_free0 (_data_->avatar);
			_data_->avatar = _data_->_tmp12_;
			_g_free0 (_data_->_tmp9_);
			_g_free0 (_data_->_tmp5_);
			_g_free0 (_data_->_tmp1_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_data_->_inner_error0_);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_free0 (_data_->avatar);
			_g_free0 (_data_->display_name);
			_g_free0 (_data_->email);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->_tmp13_ = _data_->email;
	_data_->_tmp14_ = _data_->display_name;
	_data_->_tmp15_ = _data_->avatar;
	_data_->_tmp16_ = dc_window_build_account_menu_row (_data_->self, _data_->id, _data_->configured, _data_->current, _data_->_tmp13_, _data_->_tmp14_, _data_->_tmp15_);
	_data_->result = _data_->_tmp16_;
	_g_free0 (_data_->avatar);
	_g_free0 (_data_->display_name);
	_g_free0 (_data_->email);
	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 Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		DcWindow* self;
		self = _data2_->self;
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static void
__lambda87_ (Block2Data* _data2_)
{
	DcWindow* self;
	GtkPopover* _tmp0_;
	self = _data2_->self;
	_tmp0_ = self->priv->account_popover;
	gtk_popover_popdown (_tmp0_);
	dc_window_show_profile_for_account (self, _data2_->id);
}

static void
___lambda87__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda87_ (self);
}

static AdwActionRow*
dc_window_build_account_menu_row (DcWindow* self,
                                  gint id,
                                  gboolean configured,
                                  gboolean current,
                                  const gchar* email,
                                  const gchar* display_name,
                                  const gchar* avatar)
{
	Block2Data* _data2_;
	gchar* title = NULL;
	gboolean _tmp0_ = FALSE;
	AdwActionRow* row = NULL;
	AdwActionRow* _tmp9_;
	AdwActionRow* _tmp10_;
	AdwActionRow* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_ = NULL;
	AdwActionRow* _tmp14_;
	gboolean _tmp15_ = FALSE;
	AdwActionRow* _tmp16_;
	AdwActionRow* _tmp17_;
	AdwAvatar* avatar_widget = NULL;
	const gchar* _tmp19_;
	AdwAvatar* _tmp20_;
	AdwAvatar* _tmp21_;
	GdkTexture* _tmp22_;
	GdkTexture* _tmp23_;
	AdwActionRow* _tmp24_;
	AdwAvatar* _tmp25_;
	GtkButton* edit_btn = NULL;
	GtkButton* _tmp26_;
	GtkButton* _tmp27_;
	GtkButton* _tmp28_;
	GtkButton* _tmp29_;
	GtkButton* _tmp30_;
	GtkButton* _tmp31_;
	AdwActionRow* _tmp32_;
	GtkButton* _tmp33_;
	AdwActionRow* result;
	g_return_val_if_fail (self != NULL, NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_data2_->id = id;
	if (display_name != NULL) {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (display_name);
		_tmp2_ = _tmp1_;
		_tmp0_ = _tmp2_ > 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup (display_name);
		_g_free0 (title);
		title = _tmp3_;
	} else {
		if (configured) {
			gchar* _tmp4_ = NULL;
			gchar* _tmp5_;
			gchar* _tmp7_;
			_tmp5_ = g_strdup (email);
			_tmp4_ = _tmp5_;
			if (_tmp4_ == NULL) {
				gchar* _tmp6_;
				_tmp6_ = g_strdup_printf ("Account #%d", _data2_->id);
				_g_free0 (_tmp4_);
				_tmp4_ = _tmp6_;
			}
			_tmp7_ = _tmp4_;
			_tmp4_ = NULL;
			_g_free0 (title);
			title = _tmp7_;
			_g_free0 (_tmp4_);
		} else {
			gchar* _tmp8_;
			_tmp8_ = g_strdup ("Unconfigured account");
			_g_free0 (title);
			title = _tmp8_;
		}
	}
	_tmp9_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp9_);
	row = _tmp9_;
	_tmp10_ = row;
	adw_preferences_row_set_use_markup ((AdwPreferencesRow*) _tmp10_, FALSE);
	_tmp11_ = row;
	_tmp12_ = title;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp11_, _tmp12_);
	_tmp13_ = email;
	if (_tmp13_ == NULL) {
		_tmp13_ = "";
	}
	_tmp14_ = row;
	adw_action_row_set_subtitle (_tmp14_, _tmp13_);
	if (configured) {
		_tmp15_ = !current;
	} else {
		_tmp15_ = FALSE;
	}
	_tmp16_ = row;
	gtk_list_box_row_set_activatable ((GtkListBoxRow*) _tmp16_, _tmp15_);
	_tmp17_ = row;
	g_object_set_data_full ((GObject*) _tmp17_, "acct-id", (gpointer) ((gintptr) _data2_->id), NULL);
	if (current) {
		AdwActionRow* _tmp18_;
		_tmp18_ = row;
		gtk_widget_add_css_class ((GtkWidget*) _tmp18_, "current-account-row");
	}
	_tmp19_ = title;
	_tmp20_ = (AdwAvatar*) adw_avatar_new (32, _tmp19_, TRUE);
	g_object_ref_sink (_tmp20_);
	avatar_widget = _tmp20_;
	_tmp21_ = avatar_widget;
	_tmp22_ = dc_load_avatar (avatar);
	_tmp23_ = _tmp22_;
	adw_avatar_set_custom_image (_tmp21_, (GdkPaintable*) _tmp23_);
	_g_object_unref0 (_tmp23_);
	_tmp24_ = row;
	_tmp25_ = avatar_widget;
	adw_action_row_add_prefix (_tmp24_, (GtkWidget*) _tmp25_);
	_tmp26_ = (GtkButton*) gtk_button_new_from_icon_name ("preferences-system-symbolic");
	g_object_ref_sink (_tmp26_);
	edit_btn = _tmp26_;
	_tmp27_ = edit_btn;
	gtk_widget_set_valign ((GtkWidget*) _tmp27_, GTK_ALIGN_CENTER);
	_tmp28_ = edit_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp28_, "flat");
	_tmp29_ = edit_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp29_, "Edit profile");
	_tmp30_ = edit_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp30_, configured);
	_tmp31_ = edit_btn;
	g_signal_connect_data (_tmp31_, "clicked", (GCallback) ___lambda87__gtk_button_clicked, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp32_ = row;
	_tmp33_ = edit_btn;
	adw_action_row_add_suffix (_tmp32_, (GtkWidget*) _tmp33_);
	if (!configured) {
		GtkLabel* status = NULL;
		GtkLabel* _tmp34_;
		GtkLabel* _tmp35_;
		GtkLabel* _tmp36_;
		GtkLabel* _tmp37_;
		AdwActionRow* _tmp38_;
		GtkLabel* _tmp39_;
		_tmp34_ = (GtkLabel*) gtk_label_new ("Not configured");
		g_object_ref_sink (_tmp34_);
		status = _tmp34_;
		_tmp35_ = status;
		gtk_widget_add_css_class ((GtkWidget*) _tmp35_, "caption");
		_tmp36_ = status;
		gtk_widget_add_css_class ((GtkWidget*) _tmp36_, "dim-label");
		_tmp37_ = status;
		gtk_widget_set_valign ((GtkWidget*) _tmp37_, GTK_ALIGN_CENTER);
		_tmp38_ = row;
		_tmp39_ = status;
		adw_action_row_add_suffix (_tmp38_, (GtkWidget*) _tmp39_);
		_g_object_unref0 (status);
	}
	result = row;
	_g_object_unref0 (edit_btn);
	_g_object_unref0 (avatar_widget);
	_g_free0 (title);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return result;
}

static void
dc_window_on_account_menu_row_activated (DcWindow* self,
                                         GtkListBoxRow* row)
{
	AdwActionRow* action_row = NULL;
	AdwActionRow* _tmp0_;
	AdwActionRow* _tmp1_;
	gint acct_id = 0;
	AdwActionRow* _tmp2_;
	gconstpointer _tmp3_;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	AdwActionRow* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	GtkPopover* _tmp13_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (row, adw_action_row_get_type ()) ? ((AdwActionRow*) row) : NULL);
	action_row = _tmp0_;
	_tmp1_ = action_row;
	if (_tmp1_ == NULL) {
		_g_object_unref0 (action_row);
		return;
	}
	_tmp2_ = action_row;
	_tmp3_ = g_object_get_data ((GObject*) _tmp2_, "acct-id");
	acct_id = (gint) ((gintptr) _tmp3_);
	if (acct_id == -1) {
		GtkPopover* _tmp4_;
		_tmp4_ = self->priv->account_popover;
		gtk_popover_popdown (_tmp4_);
		dc_window_on_add_account (self);
		_g_object_unref0 (action_row);
		return;
	}
	_tmp7_ = action_row;
	_tmp8_ = gtk_list_box_row_get_activatable ((GtkListBoxRow*) _tmp7_);
	_tmp9_ = _tmp8_;
	if (!_tmp9_) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = acct_id <= 0;
	}
	if (_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		DcRpcClient* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp10_ = self->priv->rpc;
		_tmp11_ = dc_rpc_client_get_account_id (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp5_ = acct_id == _tmp12_;
	}
	if (_tmp5_) {
		_g_object_unref0 (action_row);
		return;
	}
	_tmp13_ = self->priv->account_popover;
	gtk_popover_popdown (_tmp13_);
	dc_window_switch_account_from_menu (self, acct_id, NULL, NULL);
	_g_object_unref0 (action_row);
}

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

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

static void
__lambda84_ (Block3Data* _data3_,
             GtkListBoxRow* row)
{
	DcWindow* self;
	gchar* method = NULL;
	gconstpointer _tmp0_;
	gchar* _tmp1_;
	AdwDialog* _tmp2_;
	self = _data3_->self;
	g_return_if_fail (row != NULL);
	_tmp0_ = g_object_get_data ((GObject*) row, "add-method");
	_tmp1_ = g_strdup ((const gchar*) _tmp0_);
	method = _tmp1_;
	_tmp2_ = _data3_->dialog;
	adw_dialog_close (_tmp2_);
	dc_window_on_add_account_method_selected (self, method);
	_g_free0 (method);
}

static void
___lambda84__gtk_list_box_row_activated (GtkListBox* _sender,
                                         GtkListBoxRow* row,
                                         gpointer self)
{
	__lambda84_ (self, row);
}

static void
__lambda126_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda126__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda126_ ((DcWindow*) self);
}

static void
dc_window_on_add_account (DcWindow* self)
{
	Block3Data* _data3_;
	AdwDialog* _tmp0_;
	AdwDialog* _tmp1_;
	AdwDialog* _tmp2_;
	AdwDialog* _tmp3_;
	GtkBox* box = NULL;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	AdwHeaderBar* _tmp6_;
	AdwHeaderBar* _tmp7_;
	GtkLabel* intro = NULL;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkBox* _tmp14_;
	GtkLabel* _tmp15_;
	GtkListBox* list = NULL;
	GtkListBox* _tmp16_;
	GtkListBox* _tmp17_;
	GtkListBox* _tmp18_;
	GtkListBox* _tmp19_;
	GtkListBox* _tmp20_;
	GtkListBox* _tmp21_;
	GtkListBox* _tmp22_;
	GtkListBox* _tmp23_;
	AdwActionRow* _tmp24_;
	AdwActionRow* _tmp25_;
	GtkListBox* _tmp26_;
	AdwActionRow* _tmp27_;
	AdwActionRow* _tmp28_;
	GtkListBox* _tmp29_;
	AdwActionRow* _tmp30_;
	AdwActionRow* _tmp31_;
	GtkListBox* _tmp32_;
	AdwActionRow* _tmp33_;
	AdwActionRow* _tmp34_;
	GtkListBox* _tmp35_;
	GtkBox* _tmp36_;
	GtkListBox* _tmp37_;
	AdwDialog* _tmp38_;
	GtkBox* _tmp39_;
	AdwDialog* _tmp40_;
	AdwDialog* _tmp41_;
	AdwDialog* _tmp42_;
	AdwDialog* _tmp43_;
	g_return_if_fail (self != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = self->priv->active_modal;
	if (_tmp0_ != NULL) {
		block3_data_unref (_data3_);
		_data3_ = NULL;
		return;
	}
	_tmp1_ = adw_dialog_new ();
	g_object_ref_sink (_tmp1_);
	_data3_->dialog = _tmp1_;
	_tmp2_ = _data3_->dialog;
	adw_dialog_set_title (_tmp2_, "Add Profile");
	_tmp3_ = _data3_->dialog;
	adw_dialog_set_content_width (_tmp3_, 460);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp4_);
	box = _tmp4_;
	_tmp5_ = box;
	_tmp6_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp6_);
	_tmp7_ = _tmp6_;
	gtk_box_append (_tmp5_, (GtkWidget*) _tmp7_);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = (GtkLabel*) gtk_label_new ("Choose how you want to add an account.");
	g_object_ref_sink (_tmp8_);
	intro = _tmp8_;
	_tmp9_ = intro;
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_START);
	_tmp10_ = intro;
	_tmp11_ = intro;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp11_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp10_, 12);
	_tmp12_ = intro;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp12_, 12);
	_tmp13_ = intro;
	gtk_widget_add_css_class ((GtkWidget*) _tmp13_, "dim-label");
	_tmp14_ = box;
	_tmp15_ = intro;
	gtk_box_append (_tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp16_);
	list = _tmp16_;
	_tmp17_ = list;
	gtk_list_box_set_selection_mode (_tmp17_, GTK_SELECTION_NONE);
	_tmp18_ = list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp18_, "boxed-list");
	_tmp19_ = list;
	_tmp20_ = list;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp20_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp19_, 12);
	_tmp21_ = list;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp21_, 8);
	_tmp22_ = list;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp22_, 12);
	_tmp23_ = list;
	_tmp24_ = dc_window_build_add_method_row (self, "contact-new-symbolic", "Create new profile", "Pick a chatmail relay and create a new account");
	_tmp25_ = _tmp24_;
	gtk_list_box_append (_tmp23_, (GtkWidget*) _tmp25_);
	_g_object_unref0 (_tmp25_);
	_tmp26_ = list;
	_tmp27_ = dc_window_build_add_method_row (self, "phone-symbolic", "Add as secondary device", "Synchronize from another device on the same network");
	_tmp28_ = _tmp27_;
	gtk_list_box_append (_tmp26_, (GtkWidget*) _tmp28_);
	_g_object_unref0 (_tmp28_);
	_tmp29_ = list;
	_tmp30_ = dc_window_build_add_method_row (self, "mail-message-new-symbolic", "Use classic email address", "Sign in with an existing email account");
	_tmp31_ = _tmp30_;
	gtk_list_box_append (_tmp29_, (GtkWidget*) _tmp31_);
	_g_object_unref0 (_tmp31_);
	_tmp32_ = list;
	_tmp33_ = dc_window_build_add_method_row (self, "mail-attachment-symbolic", "Use invitation code", "Join via a dcaccount: link or QR code");
	_tmp34_ = _tmp33_;
	gtk_list_box_append (_tmp32_, (GtkWidget*) _tmp34_);
	_g_object_unref0 (_tmp34_);
	_tmp35_ = list;
	g_signal_connect_data (_tmp35_, "row-activated", (GCallback) ___lambda84__gtk_list_box_row_activated, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	_tmp36_ = box;
	_tmp37_ = list;
	gtk_box_append (_tmp36_, (GtkWidget*) _tmp37_);
	_tmp38_ = _data3_->dialog;
	_tmp39_ = box;
	adw_dialog_set_child (_tmp38_, (GtkWidget*) _tmp39_);
	_tmp40_ = _data3_->dialog;
	_tmp41_ = _g_object_ref0 (_tmp40_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp41_;
	_tmp42_ = _data3_->dialog;
	g_signal_connect_object (_tmp42_, "closed", (GCallback) ___lambda126__adw_dialog_closed, self, 0);
	_tmp43_ = _data3_->dialog;
	adw_dialog_present (_tmp43_, (GtkWidget*) self);
	_g_object_unref0 (list);
	_g_object_unref0 (intro);
	_g_object_unref0 (box);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

static AdwActionRow*
dc_window_build_add_method_row (DcWindow* self,
                                const gchar* icon_name,
                                const gchar* title,
                                const gchar* subtitle)
{
	AdwActionRow* row = NULL;
	AdwActionRow* _tmp0_;
	gchar* _tmp1_;
	GtkImage* icon = NULL;
	GtkImage* _tmp2_;
	GtkImage* chevron = NULL;
	GtkImage* _tmp3_;
	AdwActionRow* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (icon_name != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (subtitle != NULL, NULL);
	_tmp0_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) row, title);
	adw_action_row_set_subtitle (row, subtitle);
	gtk_list_box_row_set_activatable ((GtkListBoxRow*) row, TRUE);
	_tmp1_ = g_strdup (title);
	g_object_set_data_full ((GObject*) row, "add-method", _tmp1_, g_free);
	_tmp2_ = (GtkImage*) gtk_image_new_from_icon_name (icon_name);
	g_object_ref_sink (_tmp2_);
	icon = _tmp2_;
	gtk_widget_set_valign ((GtkWidget*) icon, GTK_ALIGN_CENTER);
	adw_action_row_add_prefix (row, (GtkWidget*) icon);
	_tmp3_ = (GtkImage*) gtk_image_new_from_icon_name ("go-next-symbolic");
	g_object_ref_sink (_tmp3_);
	chevron = _tmp3_;
	gtk_widget_set_valign ((GtkWidget*) chevron, GTK_ALIGN_CENTER);
	gtk_widget_add_css_class ((GtkWidget*) chevron, "dim-label");
	adw_action_row_add_suffix (row, (GtkWidget*) chevron);
	result = row;
	_g_object_unref0 (chevron);
	_g_object_unref0 (icon);
	return result;
}

static void
dc_window_on_add_account_method_selected (DcWindow* self,
                                          const gchar* method)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (method != NULL);
	if (g_strcmp0 (method, "Use classic email address") == 0) {
		dc_window_show_classic_email_dialog (self);
	} else {
		if (g_strcmp0 (method, "Add as secondary device") == 0) {
			dc_window_show_secondary_device_dialog (self);
		} else {
			if (g_strcmp0 (method, "Create new profile") == 0) {
				dc_window_show_create_profile_dialog (self);
			} else {
				if (g_strcmp0 (method, "Use invitation code") == 0) {
					dc_window_show_invitation_code_profile_dialog (self);
				} else {
					gchar* _tmp0_;
					gchar* _tmp1_;
					_tmp0_ = g_strconcat (method, ": not yet implemented", NULL);
					_tmp1_ = _tmp0_;
					dc_window_show_toast (self, _tmp1_);
					_g_free0 (_tmp1_);
				}
			}
		}
	}
}

static void
__lambda118_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda118__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda118_ ((DcWindow*) self);
}

static void
__lambda119_ (DcWindow* self,
              gint new_id)
{
	dc_window_after_profile_created (self, new_id, NULL, NULL);
}

static void
___lambda119__dc_create_profile_dialog_account_created (DcCreateProfileDialog* _sender,
                                                        gint new_account_id,
                                                        gpointer self)
{
	__lambda119_ ((DcWindow*) self, new_account_id);
}

static void
dc_window_show_create_profile_dialog (DcWindow* self)
{
	AdwDialog* _tmp0_;
	DcEventHandler* _tmp1_;
	DcCreateProfileDialog* dialog = NULL;
	DcRpcClient* _tmp2_;
	DcEventHandler* _tmp3_;
	DcCreateProfileDialog* _tmp4_;
	DcCreateProfileDialog* _tmp5_;
	AdwDialog* _tmp6_;
	DcCreateProfileDialog* _tmp7_;
	DcCreateProfileDialog* _tmp8_;
	DcCreateProfileDialog* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->active_modal;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp1_ = self->priv->events;
	if (_tmp1_ == NULL) {
		dc_window_show_toast (self, "RPC not ready");
		return;
	}
	_tmp2_ = self->priv->rpc;
	_tmp3_ = self->priv->events;
	_tmp4_ = dc_create_profile_dialog_new (_tmp2_, _tmp3_);
	g_object_ref_sink (_tmp4_);
	dialog = _tmp4_;
	_tmp5_ = dialog;
	_tmp6_ = _g_object_ref0 ((AdwDialog*) _tmp5_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp6_;
	_tmp7_ = dialog;
	g_signal_connect_object ((AdwDialog*) _tmp7_, "closed", (GCallback) ___lambda118__adw_dialog_closed, self, 0);
	_tmp8_ = dialog;
	g_signal_connect_object (_tmp8_, "account-created", (GCallback) ___lambda119__dc_create_profile_dialog_account_created, self, 0);
	_tmp9_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp9_, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

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

static void
dc_window_after_profile_created (DcWindow* self,
                                 gint new_id,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	DcWindowAfterProfileCreatedData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowAfterProfileCreatedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_after_profile_created_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->new_id = new_id;
	dc_window_after_profile_created_co (_data_);
}

static void
dc_window_after_profile_created_finish (DcWindow* self,
                                        GAsyncResult* _res_)
{
	DcWindowAfterProfileCreatedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_after_profile_created_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	DcWindowAfterProfileCreatedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_after_profile_created_co (_data_);
}

static gboolean
dc_window_after_profile_created_co (DcWindowAfterProfileCreatedData* _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_->_state_ = 1;
	dc_window_switch_account (_data_->self, _data_->new_id, dc_window_after_profile_created_ready, _data_);
	return FALSE;
	_state_1:
	_data_->changed = dc_window_switch_account_finish (_data_->self, _data_->_res_);
	if (_data_->changed) {
		dc_window_show_toast (_data_->self, "Profile created");
		_data_->_state_ = 2;
		dc_window_load_account_menu (_data_->self, dc_window_after_profile_created_ready, _data_);
		return FALSE;
		_state_2:
		dc_window_load_account_menu_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
__lambda124_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda124__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda124_ ((DcWindow*) self);
}

static void
__lambda125_ (DcWindow* self,
              gint new_id,
              gint chat_id)
{
	dc_window_after_invitation_profile_created (self, new_id, chat_id, NULL, NULL);
}

static void
___lambda125__dc_invitation_code_profile_dialog_account_created (DcInvitationCodeProfileDialog* _sender,
                                                                 gint new_account_id,
                                                                 gint chat_id,
                                                                 gpointer self)
{
	__lambda125_ ((DcWindow*) self, new_account_id, chat_id);
}

static void
dc_window_show_invitation_code_profile_dialog (DcWindow* self)
{
	AdwDialog* _tmp0_;
	DcEventHandler* _tmp1_;
	DcInvitationCodeProfileDialog* dialog = NULL;
	DcRpcClient* _tmp2_;
	DcEventHandler* _tmp3_;
	DcInvitationCodeProfileDialog* _tmp4_;
	DcInvitationCodeProfileDialog* _tmp5_;
	AdwDialog* _tmp6_;
	DcInvitationCodeProfileDialog* _tmp7_;
	DcInvitationCodeProfileDialog* _tmp8_;
	DcInvitationCodeProfileDialog* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->active_modal;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp1_ = self->priv->events;
	if (_tmp1_ == NULL) {
		dc_window_show_toast (self, "RPC not ready");
		return;
	}
	_tmp2_ = self->priv->rpc;
	_tmp3_ = self->priv->events;
	_tmp4_ = dc_invitation_code_profile_dialog_new (_tmp2_, _tmp3_);
	g_object_ref_sink (_tmp4_);
	dialog = _tmp4_;
	_tmp5_ = dialog;
	_tmp6_ = _g_object_ref0 ((AdwDialog*) _tmp5_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp6_;
	_tmp7_ = dialog;
	g_signal_connect_object ((AdwDialog*) _tmp7_, "closed", (GCallback) ___lambda124__adw_dialog_closed, self, 0);
	_tmp8_ = dialog;
	g_signal_connect_object (_tmp8_, "account-created", (GCallback) ___lambda125__dc_invitation_code_profile_dialog_account_created, self, 0);
	_tmp9_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp9_, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

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

static void
dc_window_after_invitation_profile_created (DcWindow* self,
                                            gint new_id,
                                            gint chat_id,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	DcWindowAfterInvitationProfileCreatedData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowAfterInvitationProfileCreatedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_after_invitation_profile_created_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->new_id = new_id;
	_data_->chat_id = chat_id;
	dc_window_after_invitation_profile_created_co (_data_);
}

static void
dc_window_after_invitation_profile_created_finish (DcWindow* self,
                                                   GAsyncResult* _res_)
{
	DcWindowAfterInvitationProfileCreatedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_after_invitation_profile_created_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_)
{
	DcWindowAfterInvitationProfileCreatedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_after_invitation_profile_created_co (_data_);
}

static gboolean
dc_window_after_invitation_profile_created_co (DcWindowAfterInvitationProfileCreatedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	dc_window_switch_account (_data_->self, _data_->new_id, dc_window_after_invitation_profile_created_ready, _data_);
	return FALSE;
	_state_1:
	_data_->changed = dc_window_switch_account_finish (_data_->self, _data_->_res_);
	if (_data_->changed) {
		_data_->_state_ = 2;
		dc_window_load_account_menu (_data_->self, dc_window_after_invitation_profile_created_ready, _data_);
		return FALSE;
		_state_2:
		dc_window_load_account_menu_finish (_data_->self, _data_->_res_);
		if (_data_->chat_id > 0) {
			_data_->_state_ = 3;
			dc_window_load_chats (_data_->self, dc_window_after_invitation_profile_created_ready, _data_);
			return FALSE;
			_state_3:
			dc_window_load_chats_finish (_data_->self, _data_->_res_);
			dc_window_select_chat_by_id (_data_->self, _data_->chat_id);
		}
		if (_data_->chat_id > 0) {
			_data_->_tmp0_ = "Profile created and invitation accepted";
		} else {
			_data_->_tmp0_ = "Profile created";
		}
		dc_window_show_toast (_data_->self, _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;
}

static void
__lambda112_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda112__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda112_ ((DcWindow*) self);
}

static void
__lambda113_ (DcWindow* self,
              gint new_id)
{
	dc_window_after_secondary_device_imported (self, new_id, NULL, NULL);
}

static void
___lambda113__dc_receive_backup_dialog_account_imported (DcReceiveBackupDialog* _sender,
                                                         gint new_account_id,
                                                         gpointer self)
{
	__lambda113_ ((DcWindow*) self, new_account_id);
}

static void
dc_window_show_secondary_device_dialog (DcWindow* self)
{
	AdwDialog* _tmp0_;
	DcEventHandler* _tmp1_;
	DcReceiveBackupDialog* dialog = NULL;
	DcRpcClient* _tmp2_;
	DcEventHandler* _tmp3_;
	DcReceiveBackupDialog* _tmp4_;
	DcReceiveBackupDialog* _tmp5_;
	AdwDialog* _tmp6_;
	DcReceiveBackupDialog* _tmp7_;
	DcReceiveBackupDialog* _tmp8_;
	DcReceiveBackupDialog* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->active_modal;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp1_ = self->priv->events;
	if (_tmp1_ == NULL) {
		dc_window_show_toast (self, "RPC not ready");
		return;
	}
	_tmp2_ = self->priv->rpc;
	_tmp3_ = self->priv->events;
	_tmp4_ = dc_receive_backup_dialog_new (_tmp2_, _tmp3_);
	g_object_ref_sink (_tmp4_);
	dialog = _tmp4_;
	_tmp5_ = dialog;
	_tmp6_ = _g_object_ref0 ((AdwDialog*) _tmp5_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp6_;
	_tmp7_ = dialog;
	g_signal_connect_object ((AdwDialog*) _tmp7_, "closed", (GCallback) ___lambda112__adw_dialog_closed, self, 0);
	_tmp8_ = dialog;
	g_signal_connect_object (_tmp8_, "account-imported", (GCallback) ___lambda113__dc_receive_backup_dialog_account_imported, self, 0);
	_tmp9_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp9_, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

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

static void
dc_window_after_secondary_device_imported (DcWindow* self,
                                           gint new_id,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	DcWindowAfterSecondaryDeviceImportedData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowAfterSecondaryDeviceImportedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_after_secondary_device_imported_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->new_id = new_id;
	dc_window_after_secondary_device_imported_co (_data_);
}

static void
dc_window_after_secondary_device_imported_finish (DcWindow* self,
                                                  GAsyncResult* _res_)
{
	DcWindowAfterSecondaryDeviceImportedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_after_secondary_device_imported_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	DcWindowAfterSecondaryDeviceImportedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_after_secondary_device_imported_co (_data_);
}

static gboolean
dc_window_after_secondary_device_imported_co (DcWindowAfterSecondaryDeviceImportedData* _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_->_state_ = 1;
	dc_window_switch_account (_data_->self, _data_->new_id, dc_window_after_secondary_device_imported_ready, _data_);
	return FALSE;
	_state_1:
	_data_->changed = dc_window_switch_account_finish (_data_->self, _data_->_res_);
	if (_data_->changed) {
		dc_window_show_toast (_data_->self, "Profile imported");
		_data_->_state_ = 2;
		dc_window_load_account_menu (_data_->self, dc_window_after_secondary_device_imported_ready, _data_);
		return FALSE;
		_state_2:
		dc_window_load_account_menu_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 Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		DcWindow* self;
		self = _data4_->self;
		_g_object_unref0 (_data4_->pass_entry);
		_g_object_unref0 (_data4_->email_entry);
		_g_object_unref0 (_data4_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static void
__lambda85_ (Block4Data* _data4_)
{
	DcWindow* self;
	self = _data4_->self;
	g_signal_emit_by_name (_data4_->dialog, "response", "add");
}

static void
___lambda85__gtk_password_entry_activate (GtkPasswordEntry* _sender,
                                          gpointer self)
{
	__lambda85_ (self);
}

static void
__lambda86_ (Block4Data* _data4_,
             const gchar* resp)
{
	DcWindow* self;
	self = _data4_->self;
	g_return_if_fail (resp != NULL);
	if (g_strcmp0 (resp, "add") == 0) {
		gchar* email = NULL;
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* password = NULL;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gboolean _tmp6_ = FALSE;
		gboolean _tmp7_ = FALSE;
		const gchar* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp0_ = gtk_editable_get_text ((GtkEditable*) _data4_->email_entry);
		_tmp1_ = _tmp0_;
		_tmp2_ = string_strip (_tmp1_);
		email = _tmp2_;
		_tmp3_ = gtk_editable_get_text ((GtkEditable*) _data4_->pass_entry);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strdup (_tmp4_);
		password = _tmp5_;
		_tmp8_ = email;
		_tmp9_ = strlen (_tmp8_);
		_tmp10_ = _tmp9_;
		if (_tmp10_ > 0) {
			const gchar* _tmp11_;
			_tmp11_ = email;
			_tmp7_ = string_contains (_tmp11_, "@");
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			const gchar* _tmp12_;
			gint _tmp13_;
			gint _tmp14_;
			_tmp12_ = password;
			_tmp13_ = strlen (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp6_ = _tmp14_ > 0;
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			_tmp15_ = email;
			_tmp16_ = password;
			dc_window_do_add_account (self, _tmp15_, _tmp16_, NULL, NULL);
		}
		_g_free0 (password);
		_g_free0 (email);
	}
}

static void
___lambda86__adw_alert_dialog_response (AdwAlertDialog* _sender,
                                        const gchar* response,
                                        gpointer self)
{
	__lambda86_ (self, response);
}

static void
dc_window_show_classic_email_dialog (DcWindow* self)
{
	Block4Data* _data4_;
	AdwAlertDialog* _tmp0_;
	GtkBox* box = NULL;
	GtkBox* _tmp1_;
	GtkEntry* _tmp2_;
	GtkPasswordEntry* _tmp3_;
	g_return_if_fail (self != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = g_object_ref (self);
	_tmp0_ = (AdwAlertDialog*) adw_alert_dialog_new ("Use classic email address", "Enter your email and password.");
	g_object_ref_sink (_tmp0_);
	_data4_->dialog = _tmp0_;
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	_tmp2_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp2_);
	_data4_->email_entry = _tmp2_;
	gtk_entry_set_placeholder_text (_data4_->email_entry, "user@example.com");
	gtk_entry_set_input_purpose (_data4_->email_entry, GTK_INPUT_PURPOSE_EMAIL);
	gtk_box_append (box, (GtkWidget*) _data4_->email_entry);
	_tmp3_ = (GtkPasswordEntry*) gtk_password_entry_new ();
	g_object_ref_sink (_tmp3_);
	_data4_->pass_entry = _tmp3_;
	g_object_set (_data4_->pass_entry, "placeholder-text", "Password", NULL);
	gtk_password_entry_set_show_peek_icon (_data4_->pass_entry, TRUE);
	gtk_box_append (box, (GtkWidget*) _data4_->pass_entry);
	adw_alert_dialog_set_extra_child (_data4_->dialog, (GtkWidget*) box);
	adw_alert_dialog_add_response (_data4_->dialog, "cancel", "Cancel");
	adw_alert_dialog_add_response (_data4_->dialog, "add", "Add");
	adw_alert_dialog_set_response_appearance (_data4_->dialog, "add", ADW_RESPONSE_SUGGESTED);
	adw_alert_dialog_set_default_response (_data4_->dialog, "add");
	g_signal_connect_data (_data4_->pass_entry, "activate", (GCallback) ___lambda85__gtk_password_entry_activate, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	g_signal_connect_data (_data4_->dialog, "response", (GCallback) ___lambda86__adw_alert_dialog_response, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	adw_dialog_present ((AdwDialog*) _data4_->dialog, (GtkWidget*) self);
	_g_object_unref0 (box);
	block4_data_unref (_data4_);
	_data4_ = NULL;
}

static void
dc_window_do_add_account_data_free (gpointer _data)
{
	DcWindowDoAddAccountData* _data_;
	_data_ = _data;
	_g_free0 (_data_->email);
	_g_free0 (_data_->password);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowDoAddAccountData, _data_);
}

static void
dc_window_do_add_account (DcWindow* self,
                          const gchar* email,
                          const gchar* password,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	DcWindowDoAddAccountData* _data_;
	DcWindow* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (email != NULL);
	g_return_if_fail (password != NULL);
	_data_ = g_slice_new0 (DcWindowDoAddAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_do_add_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (email);
	_g_free0 (_data_->email);
	_data_->email = _tmp1_;
	_tmp2_ = g_strdup (password);
	_g_free0 (_data_->password);
	_data_->password = _tmp2_;
	dc_window_do_add_account_co (_data_);
}

static void
dc_window_do_add_account_finish (DcWindow* self,
                                 GAsyncResult* _res_)
{
	DcWindowDoAddAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_do_add_account_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	DcWindowDoAddAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_do_add_account_co (_data_);
}

static gboolean
dc_window_do_add_account_co (DcWindowDoAddAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		case 7:
		goto _state_7;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_add_account (_data_->_tmp0_, dc_window_do_add_account_ready, _data_);
		return FALSE;
		_state_1:
		_data_->acct_id = dc_rpc_client_add_account_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp1_ = _data_->self->priv->rpc;
		_data_->_state_ = 2;
		dc_rpc_client_add_or_update_transport (_data_->_tmp1_, _data_->acct_id, _data_->email, _data_->password, dc_window_do_add_account_ready, _data_);
		return FALSE;
		_state_2:
		dc_rpc_client_add_or_update_transport_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->self->priv->rpc;
		_data_->_tmp3_ = dc_rpc_client_get_account_id (_data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		if (_data_->_tmp4_ > 0) {
			_data_->_tmp5_ = _data_->self->priv->rpc;
			_data_->_state_ = 3;
			dc_rpc_client_stop_io (_data_->_tmp5_, dc_window_do_add_account_ready, _data_);
			return FALSE;
			_state_3:
			dc_rpc_client_stop_io_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		_data_->_tmp6_ = _data_->self->priv->rpc;
		_data_->_state_ = 4;
		dc_rpc_client_select_account (_data_->_tmp6_, _data_->acct_id, dc_window_do_add_account_ready, _data_);
		return FALSE;
		_state_4:
		dc_rpc_client_select_account_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp7_ = _data_->self->priv->rpc;
		_data_->_state_ = 5;
		dc_rpc_client_start_io (_data_->_tmp7_, _data_->acct_id, dc_window_do_add_account_ready, _data_);
		return FALSE;
		_state_5:
		dc_rpc_client_start_io_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp8_ = _data_->self->priv->rpc;
		dc_rpc_client_set_account_id (_data_->_tmp8_, _data_->acct_id);
		_data_->_state_ = 6;
		dc_window_reload_active_account (_data_->self, dc_window_do_add_account_ready, _data_);
		return FALSE;
		_state_6:
		dc_window_reload_active_account_finish (_data_->self, _data_->_res_);
		_data_->_state_ = 7;
		dc_window_load_account_menu (_data_->self, dc_window_do_add_account_ready, _data_);
		return FALSE;
		_state_7:
		dc_window_load_account_menu_finish (_data_->self, _data_->_res_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp9_ = _data_->e;
		_data_->_tmp10_ = _data_->_tmp9_->message;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp10_);
		_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_window_switch_account_from_menu_data_free (gpointer _data)
{
	DcWindowSwitchAccountFromMenuData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowSwitchAccountFromMenuData, _data_);
}

static void
dc_window_switch_account_from_menu (DcWindow* self,
                                    gint acct_id,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	DcWindowSwitchAccountFromMenuData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowSwitchAccountFromMenuData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_switch_account_from_menu_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->acct_id = acct_id;
	dc_window_switch_account_from_menu_co (_data_);
}

static void
dc_window_switch_account_from_menu_finish (DcWindow* self,
                                           GAsyncResult* _res_)
{
	DcWindowSwitchAccountFromMenuData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_switch_account_from_menu_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	DcWindowSwitchAccountFromMenuData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_switch_account_from_menu_co (_data_);
}

static gboolean
dc_window_switch_account_from_menu_co (DcWindowSwitchAccountFromMenuData* _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_->_state_ = 1;
	dc_window_switch_account (_data_->self, _data_->acct_id, dc_window_switch_account_from_menu_ready, _data_);
	return FALSE;
	_state_1:
	_data_->changed = dc_window_switch_account_finish (_data_->self, _data_->_res_);
	if (_data_->changed) {
		_data_->_state_ = 2;
		dc_window_load_account_menu (_data_->self, dc_window_switch_account_from_menu_ready, _data_);
		return FALSE;
		_state_2:
		dc_window_load_account_menu_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_window_switch_account_data_free (gpointer _data)
{
	DcWindowSwitchAccountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowSwitchAccountData, _data_);
}

void
dc_window_switch_account (DcWindow* self,
                          gint acct_id,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	DcWindowSwitchAccountData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowSwitchAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_switch_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->acct_id = acct_id;
	dc_window_switch_account_co (_data_);
}

gboolean
dc_window_switch_account_finish (DcWindow* self,
                                 GAsyncResult* _res_)
{
	gboolean result;
	DcWindowSwitchAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
dc_window_switch_account_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	DcWindowSwitchAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_switch_account_co (_data_);
}

static gboolean
dc_window_switch_account_co (DcWindowSwitchAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->acct_id <= 0) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp1_ = _data_->self->priv->rpc;
		_data_->_tmp2_ = dc_rpc_client_get_account_id (_data_->_tmp1_);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp0_ = _data_->acct_id == _data_->_tmp3_;
	}
	if (_data_->_tmp0_) {
		_data_->result = FALSE;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp4_ = _data_->self->priv->rpc;
		_data_->_tmp5_ = dc_rpc_client_get_account_id (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		if (_data_->_tmp6_ > 0) {
			_data_->_tmp7_ = _data_->self->priv->rpc;
			_data_->_state_ = 1;
			dc_rpc_client_stop_io (_data_->_tmp7_, dc_window_switch_account_ready, _data_);
			return FALSE;
			_state_1:
			dc_rpc_client_stop_io_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		_data_->_tmp8_ = _data_->self->priv->rpc;
		_data_->_state_ = 2;
		dc_rpc_client_select_account (_data_->_tmp8_, _data_->acct_id, dc_window_switch_account_ready, _data_);
		return FALSE;
		_state_2:
		dc_rpc_client_select_account_finish (_data_->_tmp8_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp9_ = _data_->self->priv->rpc;
		_data_->_state_ = 3;
		dc_rpc_client_start_io (_data_->_tmp9_, _data_->acct_id, dc_window_switch_account_ready, _data_);
		return FALSE;
		_state_3:
		dc_rpc_client_start_io_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp10_ = _data_->self->priv->rpc;
		dc_rpc_client_set_account_id (_data_->_tmp10_, _data_->acct_id);
		_data_->_state_ = 4;
		dc_window_reload_active_account (_data_->self, dc_window_switch_account_ready, _data_);
		return FALSE;
		_state_4:
		dc_window_reload_active_account_finish (_data_->self, _data_->_res_);
		_data_->result = TRUE;
		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;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp11_ = _data_->e;
		_data_->_tmp12_ = _data_->_tmp11_->message;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp12_);
		_data_->result = FALSE;
		_g_error_free0 (_data_->e);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
	g_clear_error (&_data_->_inner_error0_);
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

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

static void
__lambda106_ (Block5Data* _data5_)
{
	DcWindow* self;
	self = _data5_->self;
	if (_data5_->edits_current_account) {
		dc_window_load_profile_avatar (self, NULL, NULL);
	}
	dc_window_load_account_menu (self, NULL, NULL);
}

static void
___lambda106__dc_profile_dialog_profile_updated (DcProfileDialog* _sender,
                                                 gpointer self)
{
	__lambda106_ (self);
}

static void
__lambda107_ (Block5Data* _data5_,
              gint deleted_id)
{
	DcWindow* self;
	self = _data5_->self;
	dc_window_after_profile_deleted (self, deleted_id, _data5_->edits_current_account, NULL, NULL);
}

static void
___lambda107__dc_profile_dialog_account_deleted (DcProfileDialog* _sender,
                                                 gint acct_id,
                                                 gpointer self)
{
	__lambda107_ (self, acct_id);
}

static void
dc_window_show_profile_for_account (DcWindow* self,
                                    gint acct_id)
{
	Block5Data* _data5_;
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	DcProfileDialog* dialog = NULL;
	DcRpcClient* _tmp3_;
	DcProfileDialog* _tmp4_;
	DcProfileDialog* _tmp5_;
	DcProfileDialog* _tmp6_;
	DcProfileDialog* _tmp7_;
	g_return_if_fail (self != NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->self = g_object_ref (self);
	if (acct_id <= 0) {
		block5_data_unref (_data5_);
		_data5_ = NULL;
		return;
	}
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_rpc_client_get_account_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_data5_->edits_current_account = acct_id == _tmp2_;
	_tmp3_ = self->priv->rpc;
	_tmp4_ = dc_profile_dialog_new (_tmp3_, acct_id);
	g_object_ref_sink (_tmp4_);
	dialog = _tmp4_;
	_tmp5_ = dialog;
	g_signal_connect_data (_tmp5_, "profile-updated", (GCallback) ___lambda106__dc_profile_dialog_profile_updated, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	_tmp6_ = dialog;
	g_signal_connect_data (_tmp6_, "account-deleted", (GCallback) ___lambda107__dc_profile_dialog_account_deleted, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	_tmp7_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp7_, (GtkWidget*) self);
	_g_object_unref0 (dialog);
	block5_data_unref (_data5_);
	_data5_ = NULL;
}

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

static void
dc_window_after_profile_deleted (DcWindow* self,
                                 gint deleted_id,
                                 gboolean was_current_account,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	DcWindowAfterProfileDeletedData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowAfterProfileDeletedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_after_profile_deleted_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->deleted_id = deleted_id;
	_data_->was_current_account = was_current_account;
	dc_window_after_profile_deleted_co (_data_);
}

static void
dc_window_after_profile_deleted_finish (DcWindow* self,
                                        GAsyncResult* _res_)
{
	DcWindowAfterProfileDeletedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_after_profile_deleted_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	DcWindowAfterProfileDeletedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_after_profile_deleted_co (_data_);
}

static gboolean
dc_window_after_profile_deleted_co (DcWindowAfterProfileDeletedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->switched_account = FALSE;
	if (_data_->was_current_account) {
		_data_->_state_ = 1;
		dc_window_switch_to_first_configured_account (_data_->self, _data_->deleted_id, dc_window_after_profile_deleted_ready, _data_);
		return FALSE;
		_state_1:
		_data_->switched_account = dc_window_switch_to_first_configured_account_finish (_data_->self, _data_->_res_);
		if (!_data_->switched_account) {
			_data_->_tmp0_ = _data_->self->priv->rpc;
			dc_rpc_client_set_account_id (_data_->_tmp0_, 0);
			_data_->_state_ = 2;
			dc_window_reload_active_account (_data_->self, dc_window_after_profile_deleted_ready, _data_);
			return FALSE;
			_state_2:
			dc_window_reload_active_account_finish (_data_->self, _data_->_res_);
		}
	}
	_data_->_state_ = 3;
	dc_window_load_account_menu (_data_->self, dc_window_after_profile_deleted_ready, _data_);
	return FALSE;
	_state_3:
	dc_window_load_account_menu_finish (_data_->self, _data_->_res_);
	if (_data_->switched_account) {
		_data_->_tmp1_ = "Profile deleted; switched profile";
	} else {
		_data_->_tmp1_ = "Profile deleted";
	}
	dc_window_show_toast (_data_->self, _data_->_tmp1_);
	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_window_switch_to_first_configured_account_data_free (gpointer _data)
{
	DcWindowSwitchToFirstConfiguredAccountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowSwitchToFirstConfiguredAccountData, _data_);
}

static void
dc_window_switch_to_first_configured_account (DcWindow* self,
                                              gint skip_id,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	DcWindowSwitchToFirstConfiguredAccountData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowSwitchToFirstConfiguredAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_switch_to_first_configured_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->skip_id = skip_id;
	dc_window_switch_to_first_configured_account_co (_data_);
}

static gboolean
dc_window_switch_to_first_configured_account_finish (DcWindow* self,
                                                     GAsyncResult* _res_)
{
	gboolean result;
	DcWindowSwitchToFirstConfiguredAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
dc_window_switch_to_first_configured_account_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	DcWindowSwitchToFirstConfiguredAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_switch_to_first_configured_account_co (_data_);
}

static gboolean
dc_window_switch_to_first_configured_account_co (DcWindowSwitchToFirstConfiguredAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_all_accounts (_data_->_tmp0_, dc_window_switch_to_first_configured_account_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = dc_rpc_client_get_all_accounts_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		_data_->accounts_node = _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->accounts_node;
		if (_data_->_tmp2_ == NULL) {
			_data_->result = FALSE;
			__vala_JsonNode_free0 (_data_->accounts_node);
			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_->accounts_node;
		_data_->_tmp4_ = json_node_get_array (_data_->_tmp3_);
		_data_->_tmp5_ = _json_array_ref0 (_data_->_tmp4_);
		_data_->accounts = _data_->_tmp5_;
		{
			_data_->i = (guint) 0;
			{
				_data_->_tmp6_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp6_) {
						_data_->_tmp7_ = _data_->i;
						_data_->i = _data_->_tmp7_ + 1;
					}
					_data_->_tmp6_ = FALSE;
					_data_->_tmp8_ = _data_->accounts;
					if (!(_data_->i < json_array_get_length (_data_->_tmp8_))) {
						break;
					}
					_data_->_tmp9_ = _data_->accounts;
					_data_->_tmp10_ = json_array_get_object_element (_data_->_tmp9_, _data_->i);
					_data_->_tmp11_ = _json_object_ref0 (_data_->_tmp10_);
					_data_->acct = _data_->_tmp11_;
					_data_->_tmp12_ = _data_->acct;
					_data_->id = (gint) json_object_get_int_member (_data_->_tmp12_, "id");
					if (_data_->id <= 0) {
						_data_->_tmp13_ = TRUE;
					} else {
						_data_->_tmp13_ = _data_->id == _data_->skip_id;
					}
					if (_data_->_tmp13_) {
						_json_object_unref0 (_data_->acct);
						continue;
					}
					_data_->configured = FALSE;
					{
						_data_->_tmp15_ = _data_->self->priv->rpc;
						_data_->_state_ = 2;
						dc_rpc_client_is_configured (_data_->_tmp15_, _data_->id, dc_window_switch_to_first_configured_account_ready, _data_);
						return FALSE;
						_state_2:
						_data_->_tmp14_ = dc_rpc_client_is_configured_finish (_data_->_tmp15_, _data_->_res_, &_data_->_inner_error0_);
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							goto __catch1_g_error;
						}
						_data_->configured = _data_->_tmp14_;
					}
					goto __finally1;
					__catch1_g_error:
					{
						g_clear_error (&_data_->_inner_error0_);
						_json_object_unref0 (_data_->acct);
						continue;
					}
					__finally1:
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						_json_object_unref0 (_data_->acct);
						_json_array_unref0 (_data_->accounts);
						__vala_JsonNode_free0 (_data_->accounts_node);
						goto __catch0_g_error;
					}
					if (_data_->configured) {
						_data_->_state_ = 3;
						dc_window_switch_account (_data_->self, _data_->id, dc_window_switch_to_first_configured_account_ready, _data_);
						return FALSE;
						_state_3:
						_data_->_tmp16_ = dc_window_switch_account_finish (_data_->self, _data_->_res_);
					} else {
						_data_->_tmp16_ = FALSE;
					}
					if (_data_->_tmp16_) {
						_data_->result = TRUE;
						_json_object_unref0 (_data_->acct);
						_json_array_unref0 (_data_->accounts);
						__vala_JsonNode_free0 (_data_->accounts_node);
						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;
					}
					_json_object_unref0 (_data_->acct);
				}
			}
		}
		_json_array_unref0 (_data_->accounts);
		__vala_JsonNode_free0 (_data_->accounts_node);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp17_ = _data_->e;
		_data_->_tmp18_ = _data_->_tmp17_->message;
		_data_->_tmp19_ = g_strconcat ("Failed to select another profile: ", _data_->_tmp18_, NULL);
		_data_->_tmp20_ = _data_->_tmp19_;
		dc_window_show_toast (_data_->self, _data_->_tmp20_);
		_g_free0 (_data_->_tmp20_);
		_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;
	}
	_data_->result = FALSE;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_window_load_profile_avatar (DcWindow* self,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DcWindowLoadProfileAvatarData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowLoadProfileAvatarData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_load_profile_avatar_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_window_load_profile_avatar_co (_data_);
}

static void
dc_window_load_profile_avatar_finish (DcWindow* self,
                                      GAsyncResult* _res_)
{
	DcWindowLoadProfileAvatarData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_load_profile_avatar_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DcWindowLoadProfileAvatarData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_load_profile_avatar_co (_data_);
}

static gboolean
dc_window_load_profile_avatar_co (DcWindowLoadProfileAvatarData* _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_->_tmp3_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_config (_data_->_tmp3_, "displayname", 0, dc_window_load_profile_avatar_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp4_ = dc_rpc_client_get_config_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		_data_->name = _data_->_tmp4_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp5_ = _data_->self->priv->rpc;
		_data_->_state_ = 2;
		dc_rpc_client_get_config (_data_->_tmp5_, "selfavatar", 0, dc_window_load_profile_avatar_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp6_ = dc_rpc_client_get_config_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
		_data_->avatar = _data_->_tmp6_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->name);
			goto __catch0_g_error;
		}
		_data_->_tmp8_ = _data_->name;
		_data_->_tmp7_ = _data_->_tmp8_;
		if (_data_->_tmp7_ == NULL) {
			_data_->_tmp7_ = "";
		}
		_data_->_tmp9_ = _data_->self->priv->profile_avatar;
		adw_avatar_set_text (_data_->_tmp9_, _data_->_tmp7_);
		_data_->_tmp10_ = _data_->self->priv->profile_avatar;
		_data_->_tmp11_ = _data_->avatar;
		_data_->_tmp12_ = dc_load_avatar (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		adw_avatar_set_custom_image (_data_->_tmp10_, (GdkPaintable*) _data_->_tmp13_);
		_g_object_unref0 (_data_->_tmp13_);
		_g_free0 (_data_->avatar);
		_g_free0 (_data_->name);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__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
__lambda129_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda129__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda129_ ((DcWindow*) self);
}

static void
__lambda130_ (DcWindow* self,
              gint contact_id,
              const gchar* email)
{
	g_return_if_fail (email != NULL);
	dc_window_create_chat_by_email (self, email, NULL, NULL);
}

static void
___lambda130__dc_contact_picker_dialog_contact_picked (DcContactPickerDialog* _sender,
                                                       gint contact_id,
                                                       const gchar* email,
                                                       gpointer self)
{
	__lambda130_ ((DcWindow*) self, contact_id, email);
}

static void
dc_window_on_new_chat (DcWindow* self)
{
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	AdwDialog* _tmp3_;
	DcContactPickerDialog* picker = NULL;
	DcRpcClient* _tmp4_;
	DcContactPickerDialog* _tmp5_;
	DcContactPickerDialog* _tmp6_;
	AdwDialog* _tmp7_;
	DcContactPickerDialog* _tmp8_;
	DcContactPickerDialog* _tmp9_;
	DcContactPickerDialog* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_rpc_client_get_account_id (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ <= 0) {
		return;
	}
	_tmp3_ = self->priv->active_modal;
	if (_tmp3_ != NULL) {
		return;
	}
	_tmp4_ = self->priv->rpc;
	_tmp5_ = dc_contact_picker_dialog_new (_tmp4_, NULL, NULL);
	g_object_ref_sink (_tmp5_);
	picker = _tmp5_;
	_tmp6_ = picker;
	_tmp7_ = _g_object_ref0 ((AdwDialog*) _tmp6_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp7_;
	_tmp8_ = picker;
	g_signal_connect_object ((AdwDialog*) _tmp8_, "closed", (GCallback) ___lambda129__adw_dialog_closed, self, 0);
	_tmp9_ = picker;
	g_signal_connect_object (_tmp9_, "contact-picked", (GCallback) ___lambda130__dc_contact_picker_dialog_contact_picked, self, 0);
	_tmp10_ = picker;
	adw_dialog_present ((AdwDialog*) _tmp10_, (GtkWidget*) self);
	_g_object_unref0 (picker);
}

static void
dc_window_create_chat_by_email_data_free (gpointer _data)
{
	DcWindowCreateChatByEmailData* _data_;
	_data_ = _data;
	_g_free0 (_data_->email);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowCreateChatByEmailData, _data_);
}

static void
dc_window_create_chat_by_email (DcWindow* self,
                                const gchar* email,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	DcWindowCreateChatByEmailData* _data_;
	DcWindow* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (email != NULL);
	_data_ = g_slice_new0 (DcWindowCreateChatByEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_create_chat_by_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (email);
	_g_free0 (_data_->email);
	_data_->email = _tmp1_;
	dc_window_create_chat_by_email_co (_data_);
}

static void
dc_window_create_chat_by_email_finish (DcWindow* self,
                                       GAsyncResult* _res_)
{
	DcWindowCreateChatByEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_create_chat_by_email_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	DcWindowCreateChatByEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_create_chat_by_email_co (_data_);
}

static gboolean
dc_window_create_chat_by_email_co (DcWindowCreateChatByEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_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_->_tmp3_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_or_create_contact (_data_->_tmp3_, _data_->email, dc_window_create_chat_by_email_ready, _data_);
		return FALSE;
		_state_1:
		_data_->contact_id = dc_rpc_client_get_or_create_contact_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = _data_->self->priv->rpc;
		_data_->_state_ = 2;
		dc_rpc_client_get_or_create_chat_by_contact (_data_->_tmp4_, _data_->contact_id, dc_window_create_chat_by_email_ready, _data_);
		return FALSE;
		_state_2:
		_data_->chat_id = dc_rpc_client_get_or_create_chat_by_contact_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_state_ = 3;
		dc_window_load_chats (_data_->self, dc_window_create_chat_by_email_ready, _data_);
		return FALSE;
		_state_3:
		dc_window_load_chats_finish (_data_->self, _data_->_res_);
		dc_window_select_chat_by_id (_data_->self, _data_->chat_id);
		_data_->_tmp5_ = g_strconcat ("Chat created with ", _data_->email, NULL);
		_data_->_tmp6_ = _data_->_tmp5_;
		dc_window_show_toast (_data_->self, _data_->_tmp6_);
		_g_free0 (_data_->_tmp6_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp7_ = _data_->e;
		_data_->_tmp8_ = _data_->_tmp7_->message;
		_data_->_tmp9_ = g_strconcat ("Failed to create chat: ", _data_->_tmp8_, NULL);
		_data_->_tmp10_ = _data_->_tmp9_;
		dc_window_show_toast (_data_->self, _data_->_tmp10_);
		_g_free0 (_data_->_tmp10_);
		_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
__lambda137_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda137__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda137_ ((DcWindow*) self);
}

static void
__lambda138_ (DcWindow* self,
              gint chat_id)
{
	dc_window_after_group_created (self, chat_id, NULL, NULL);
}

static void
___lambda138__dc_new_group_dialog_group_created (DcNewGroupDialog* _sender,
                                                 gint chat_id,
                                                 gpointer self)
{
	__lambda138_ ((DcWindow*) self, chat_id);
}

static void
dc_window_on_new_group (DcWindow* self)
{
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	AdwDialog* _tmp3_;
	DcNewGroupDialog* dialog = NULL;
	DcRpcClient* _tmp4_;
	DcNewGroupDialog* _tmp5_;
	DcNewGroupDialog* _tmp6_;
	AdwDialog* _tmp7_;
	DcNewGroupDialog* _tmp8_;
	DcNewGroupDialog* _tmp9_;
	DcNewGroupDialog* _tmp10_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_rpc_client_get_account_id (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ <= 0) {
		return;
	}
	_tmp3_ = self->priv->active_modal;
	if (_tmp3_ != NULL) {
		return;
	}
	_tmp4_ = self->priv->rpc;
	_tmp5_ = dc_new_group_dialog_new (_tmp4_);
	g_object_ref_sink (_tmp5_);
	dialog = _tmp5_;
	_tmp6_ = dialog;
	_tmp7_ = _g_object_ref0 ((AdwDialog*) _tmp6_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp7_;
	_tmp8_ = dialog;
	g_signal_connect_object ((AdwDialog*) _tmp8_, "closed", (GCallback) ___lambda137__adw_dialog_closed, self, 0);
	_tmp9_ = dialog;
	g_signal_connect_object (_tmp9_, "group-created", (GCallback) ___lambda138__dc_new_group_dialog_group_created, self, 0);
	_tmp10_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp10_, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

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

static void
dc_window_after_group_created (DcWindow* self,
                               gint chat_id,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DcWindowAfterGroupCreatedData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowAfterGroupCreatedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_after_group_created_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	dc_window_after_group_created_co (_data_);
}

static void
dc_window_after_group_created_finish (DcWindow* self,
                                      GAsyncResult* _res_)
{
	DcWindowAfterGroupCreatedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_after_group_created_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DcWindowAfterGroupCreatedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_after_group_created_co (_data_);
}

static gboolean
dc_window_after_group_created_co (DcWindowAfterGroupCreatedData* _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_window_load_chats (_data_->self, dc_window_after_group_created_ready, _data_);
	return FALSE;
	_state_1:
	dc_window_load_chats_finish (_data_->self, _data_->_res_);
	dc_window_select_chat_by_id (_data_->self, _data_->chat_id);
	dc_window_show_toast (_data_->self, "Group created");
	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_window_scroll_to_message (DcWindow* self,
                             gint msg_id)
{
	DcConversationView* v = NULL;
	DcConversationView* _tmp0_;
	DcConversationView* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = dc_window_current_view (self);
	v = _tmp0_;
	_tmp1_ = v;
	if (_tmp1_ != NULL) {
		DcConversationView* _tmp2_;
		_tmp2_ = v;
		dc_conversation_view_scroll_to_message (_tmp2_, msg_id);
	}
	_g_object_unref0 (v);
}

static void
__lambda128_ (DcWindow* self)
{
	dc_window_on_new_chat (self);
}

static void
___lambda128__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda128_ ((DcWindow*) self);
}

static void
__lambda131_ (DcWindow* self)
{
	dc_window_on_new_group (self);
}

static void
___lambda131__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda131_ ((DcWindow*) self);
}

static void
__lambda139_ (DcWindow* self)
{
	dc_window_show_use_invite_link_dialog (self);
}

static void
___lambda139__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda139_ ((DcWindow*) self);
}

static void
__lambda145_ (DcWindow* self)
{
	dc_window_load_chats (self, NULL, NULL);
}

static void
___lambda145__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda145_ ((DcWindow*) self);
}

static void
__lambda146_ (DcWindow* self)
{
	dc_window_show_settings_dialog (self);
}

static void
___lambda146__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda146_ ((DcWindow*) self);
}

static void
__lambda160_ (DcWindow* self)
{
	dc_window_show_keyboard_shortcuts_dialog (self);
}

static void
___lambda160__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda160_ ((DcWindow*) self);
}

static void
__lambda162_ (DcWindow* self)
{
	dc_window_show_about_dialog (self);
}

static void
___lambda162__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	__lambda162_ ((DcWindow*) self);
}

static GMenuModel*
dc_window_build_app_menu (DcWindow* self)
{
	GSimpleAction* a = NULL;
	GSimpleAction* _tmp0_;
	GSimpleAction* _tmp1_;
	GSimpleAction* _tmp2_;
	GSimpleAction* _tmp3_;
	GSimpleAction* _tmp4_;
	GSimpleAction* _tmp5_;
	GSimpleAction* _tmp6_;
	GSimpleAction* _tmp7_;
	GSimpleAction* _tmp8_;
	GSimpleAction* _tmp9_;
	GSimpleAction* _tmp10_;
	GSimpleAction* _tmp11_;
	GSimpleAction* _tmp12_;
	GSimpleAction* _tmp13_;
	GSimpleAction* _tmp14_;
	GSimpleAction* _tmp15_;
	GSimpleAction* _tmp16_;
	GSimpleAction* _tmp17_;
	GSimpleAction* _tmp18_;
	GSimpleAction* _tmp19_;
	GSimpleAction* _tmp20_;
	GMenu* s1 = NULL;
	GMenu* _tmp21_;
	GMenu* s2 = NULL;
	GMenu* _tmp22_;
	GMenu* s3 = NULL;
	GMenu* _tmp23_;
	GMenu* menu = NULL;
	GMenu* _tmp24_;
	GMenuModel* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_simple_action_new ("new-chat", NULL);
	_g_object_unref0 (a);
	a = _tmp0_;
	_tmp1_ = a;
	g_signal_connect_object (_tmp1_, "activate", (GCallback) ___lambda128__g_simple_action_activate, self, 0);
	_tmp2_ = a;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp2_);
	_tmp3_ = g_simple_action_new ("new-group", NULL);
	_g_object_unref0 (a);
	a = _tmp3_;
	_tmp4_ = a;
	g_signal_connect_object (_tmp4_, "activate", (GCallback) ___lambda131__g_simple_action_activate, self, 0);
	_tmp5_ = a;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp5_);
	_tmp6_ = g_simple_action_new ("use-invite-link", NULL);
	_g_object_unref0 (a);
	a = _tmp6_;
	_tmp7_ = a;
	g_signal_connect_object (_tmp7_, "activate", (GCallback) ___lambda139__g_simple_action_activate, self, 0);
	_tmp8_ = a;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp8_);
	_tmp9_ = g_simple_action_new ("refresh", NULL);
	_g_object_unref0 (a);
	a = _tmp9_;
	_tmp10_ = a;
	g_signal_connect_object (_tmp10_, "activate", (GCallback) ___lambda145__g_simple_action_activate, self, 0);
	_tmp11_ = a;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp11_);
	_tmp12_ = g_simple_action_new ("settings", NULL);
	_g_object_unref0 (a);
	a = _tmp12_;
	_tmp13_ = a;
	g_signal_connect_object (_tmp13_, "activate", (GCallback) ___lambda146__g_simple_action_activate, self, 0);
	_tmp14_ = a;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp14_);
	_tmp15_ = g_simple_action_new ("shortcuts", NULL);
	_g_object_unref0 (a);
	a = _tmp15_;
	_tmp16_ = a;
	g_signal_connect_object (_tmp16_, "activate", (GCallback) ___lambda160__g_simple_action_activate, self, 0);
	_tmp17_ = a;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp17_);
	_tmp18_ = g_simple_action_new ("about", NULL);
	_g_object_unref0 (a);
	a = _tmp18_;
	_tmp19_ = a;
	g_signal_connect_object (_tmp19_, "activate", (GCallback) ___lambda162__g_simple_action_activate, self, 0);
	_tmp20_ = a;
	g_action_map_add_action ((GActionMap*) self, (GAction*) _tmp20_);
	_tmp21_ = g_menu_new ();
	s1 = _tmp21_;
	g_menu_append (s1, "New Chat", "win.new-chat");
	g_menu_append (s1, "New Group", "win.new-group");
	g_menu_append (s1, "Use Invite Link", "win.use-invite-link");
	_tmp22_ = g_menu_new ();
	s2 = _tmp22_;
	g_menu_append (s2, "Settings", "win.settings");
	_tmp23_ = g_menu_new ();
	s3 = _tmp23_;
	g_menu_append (s3, "Shortcuts", "win.shortcuts");
	g_menu_append (s3, "About", "win.about");
	_tmp24_ = g_menu_new ();
	menu = _tmp24_;
	g_menu_append_section (menu, NULL, (GMenuModel*) s1);
	g_menu_append_section (menu, NULL, (GMenuModel*) s2);
	g_menu_append_section (menu, NULL, (GMenuModel*) s3);
	result = (GMenuModel*) menu;
	_g_object_unref0 (s3);
	_g_object_unref0 (s2);
	_g_object_unref0 (s1);
	_g_object_unref0 (a);
	return result;
}

static void
dc_window_show_about_dialog (DcWindow* self)
{
	AdwAboutDialog* about = NULL;
	AdwAboutDialog* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = (AdwAboutDialog*) adw_about_dialog_new ();
	g_object_ref_sink (_tmp0_);
	about = _tmp0_;
	adw_about_dialog_set_application_name (about, "Parla");
	adw_about_dialog_set_application_icon (about, "io.github.trufae.Parla");
	adw_about_dialog_set_version (about, PARLA_VERSION);
	adw_about_dialog_set_developer_name (about, "pancake");
	_tmp1_ = g_strdup ("pancake");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	adw_about_dialog_set_developers (about, _tmp3_);
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	adw_about_dialog_set_license_type (about, GTK_LICENSE_GPL_3_0);
	adw_about_dialog_set_website (about, "https://github.com/trufae/parla");
	adw_about_dialog_set_issue_url (about, "https://github.com/trufae/parla/issues");
	adw_about_dialog_set_comments (about, "A Delta Chat client for GNOME");
	adw_about_dialog_set_release_notes_version (about, PARLA_VERSION);
	adw_about_dialog_set_release_notes (about, "<ul>" "<li>Show user cache and server quota stats</li>" "<li>Download and update chatmail jsonrpc server</li>" "<li>No longer depends on deltachat desktop by default</li>" "</ul>" "<p>Version 0.2.4</p>" "<ul>" "<li>Account creation</li>" "<li>Enter chat via invite link</li>" "<li>Manage relay profiles</li>" "<li>Discover new relays from contacts</li>" "<li>Profile lists available in the avatar circle</li>" "<li>Support import/export secondary device</li>" "<li>Prompt before destructive actions</li>" "<li>Next/prev picture with arrows</li>" "</ul>" "<p>Version 0.2.2</p>" "<ul>" "<li>Focusable conversation list</li>" "<li>Paste images from clipboard</li>" "<li>Add delivery indicators</li>" "<li>Add forward message action</li>" "<li>Improve delete experience</li>" "<li>Composebar with emoji-picker</li>" "</ul>" "<p>Version 0.2.1</p>" "<ul>" "<li>Add factory reset option in settings</li>" "<li>Custom path to the JSONRPC server</li>" "<li>Use ESC to focus the composebar</li>" "<li>Faster conversation loads</li>" "</ul>");
	adw_dialog_present ((AdwDialog*) about, (GtkWidget*) self);
	_g_object_unref0 (about);
}

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		DcWindow* self;
		self = _data6_->self;
		_g_object_unref0 (_data6_->add_btn);
		_g_object_unref0 (_data6_->status);
		_g_object_unref0 (_data6_->entry);
		_g_object_unref0 (_data6_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}

static void
__lambda140_ (Block6Data* _data6_)
{
	DcWindow* self;
	AdwDialog* _tmp0_;
	self = _data6_->self;
	_tmp0_ = _data6_->dialog;
	adw_dialog_close (_tmp0_);
}

static void
___lambda140__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda140_ (self);
}

static void
__lambda141_ (Block6Data* _data6_)
{
	DcWindow* self;
	AdwDialog* _tmp0_;
	GtkEntry* _tmp1_;
	GtkLabel* _tmp2_;
	GtkButton* _tmp3_;
	self = _data6_->self;
	_tmp0_ = _data6_->dialog;
	_tmp1_ = _data6_->entry;
	_tmp2_ = _data6_->status;
	_tmp3_ = _data6_->add_btn;
	dc_window_use_invite_link (self, _tmp0_, _tmp1_, _tmp2_, _tmp3_, NULL, NULL);
}

static void
___lambda141__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda141_ (self);
}

static void
__lambda142_ (Block6Data* _data6_)
{
	DcWindow* self;
	GtkButton* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	GtkLabel* _tmp8_;
	self = _data6_->self;
	_tmp0_ = _data6_->add_btn;
	_tmp1_ = _data6_->entry;
	_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_strip (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = strlen (_tmp5_);
	_tmp7_ = _tmp6_;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, _tmp7_ > 0);
	_g_free0 (_tmp5_);
	_tmp8_ = _data6_->status;
	gtk_label_set_label (_tmp8_, "");
}

static void
___lambda142__gtk_editable_changed (GtkEditable* _sender,
                                    gpointer self)
{
	__lambda142_ (self);
}

static void
__lambda143_ (Block6Data* _data6_)
{
	DcWindow* self;
	GtkButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	self = _data6_->self;
	_tmp0_ = _data6_->add_btn;
	_tmp1_ = gtk_widget_get_sensitive ((GtkWidget*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		AdwDialog* _tmp3_;
		GtkEntry* _tmp4_;
		GtkLabel* _tmp5_;
		GtkButton* _tmp6_;
		_tmp3_ = _data6_->dialog;
		_tmp4_ = _data6_->entry;
		_tmp5_ = _data6_->status;
		_tmp6_ = _data6_->add_btn;
		dc_window_use_invite_link (self, _tmp3_, _tmp4_, _tmp5_, _tmp6_, NULL, NULL);
	}
}

static void
___lambda143__gtk_entry_activate (GtkEntry* _sender,
                                  gpointer self)
{
	__lambda143_ (self);
}

static void
__lambda144_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda144__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda144_ ((DcWindow*) self);
}

static void
dc_window_show_use_invite_link_dialog (DcWindow* self)
{
	Block6Data* _data6_;
	AdwDialog* _tmp0_;
	DcRpcClient* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	AdwDialog* _tmp4_;
	AdwDialog* _tmp5_;
	AdwDialog* _tmp6_;
	GtkBox* box = NULL;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	AdwHeaderBar* _tmp9_;
	AdwHeaderBar* _tmp10_;
	GtkBox* content = NULL;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	GtkBox* _tmp13_;
	GtkBox* _tmp14_;
	GtkBox* _tmp15_;
	GtkLabel* label = NULL;
	GtkLabel* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkBox* _tmp21_;
	GtkLabel* _tmp22_;
	GtkEntry* _tmp23_;
	GtkEntry* _tmp24_;
	GtkEntry* _tmp25_;
	GtkEntry* _tmp26_;
	GtkBox* _tmp27_;
	GtkEntry* _tmp28_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	GtkLabel* _tmp31_;
	GtkLabel* _tmp32_;
	GtkLabel* _tmp33_;
	GtkBox* _tmp34_;
	GtkLabel* _tmp35_;
	GtkBox* actions = NULL;
	GtkBox* _tmp36_;
	GtkBox* _tmp37_;
	GtkBox* _tmp38_;
	GtkButton* cancel_btn = NULL;
	GtkButton* _tmp39_;
	GtkButton* _tmp40_;
	GtkBox* _tmp41_;
	GtkButton* _tmp42_;
	GtkButton* _tmp43_;
	GtkButton* _tmp44_;
	GtkButton* _tmp45_;
	GtkButton* _tmp46_;
	GtkBox* _tmp47_;
	GtkButton* _tmp48_;
	GtkBox* _tmp49_;
	GtkBox* _tmp50_;
	GtkEntry* _tmp51_;
	GtkEntry* _tmp52_;
	GtkBox* _tmp53_;
	GtkBox* _tmp54_;
	AdwDialog* _tmp55_;
	GtkBox* _tmp56_;
	AdwDialog* _tmp57_;
	AdwDialog* _tmp58_;
	AdwDialog* _tmp59_;
	AdwDialog* _tmp60_;
	GtkEntry* _tmp61_;
	g_return_if_fail (self != NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->self = g_object_ref (self);
	_tmp0_ = self->priv->active_modal;
	if (_tmp0_ != NULL) {
		block6_data_unref (_data6_);
		_data6_ = NULL;
		return;
	}
	_tmp1_ = self->priv->rpc;
	_tmp2_ = dc_rpc_client_get_account_id (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ <= 0) {
		dc_window_show_toast (self, "No active profile");
		block6_data_unref (_data6_);
		_data6_ = NULL;
		return;
	}
	_tmp4_ = adw_dialog_new ();
	g_object_ref_sink (_tmp4_);
	_data6_->dialog = _tmp4_;
	_tmp5_ = _data6_->dialog;
	adw_dialog_set_title (_tmp5_, "Use Invite Link");
	_tmp6_ = _data6_->dialog;
	adw_dialog_set_content_width (_tmp6_, 460);
	_tmp7_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp7_);
	box = _tmp7_;
	_tmp8_ = box;
	_tmp9_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp9_);
	_tmp10_ = _tmp9_;
	gtk_box_append (_tmp8_, (GtkWidget*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
	g_object_ref_sink (_tmp11_);
	content = _tmp11_;
	_tmp12_ = content;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp12_, 18);
	_tmp13_ = content;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp13_, 18);
	_tmp14_ = content;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp14_, 12);
	_tmp15_ = content;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp15_, 18);
	_tmp16_ = (GtkLabel*) gtk_label_new ("Paste a Delta Chat invite link.");
	g_object_ref_sink (_tmp16_);
	label = _tmp16_;
	_tmp17_ = label;
	gtk_widget_set_halign ((GtkWidget*) _tmp17_, GTK_ALIGN_START);
	_tmp18_ = label;
	gtk_label_set_xalign (_tmp18_, (gfloat) 0);
	_tmp19_ = label;
	gtk_label_set_wrap (_tmp19_, TRUE);
	_tmp20_ = label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp20_, "dim-label");
	_tmp21_ = content;
	_tmp22_ = label;
	gtk_box_append (_tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp23_);
	_data6_->entry = _tmp23_;
	_tmp24_ = _data6_->entry;
	gtk_entry_set_placeholder_text (_tmp24_, "https://i.delta.chat/#...");
	_tmp25_ = _data6_->entry;
	gtk_entry_set_input_purpose (_tmp25_, GTK_INPUT_PURPOSE_URL);
	_tmp26_ = _data6_->entry;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp26_, TRUE);
	_tmp27_ = content;
	_tmp28_ = _data6_->entry;
	gtk_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp29_);
	_data6_->status = _tmp29_;
	_tmp30_ = _data6_->status;
	gtk_widget_set_halign ((GtkWidget*) _tmp30_, GTK_ALIGN_START);
	_tmp31_ = _data6_->status;
	gtk_label_set_xalign (_tmp31_, (gfloat) 0);
	_tmp32_ = _data6_->status;
	gtk_label_set_wrap (_tmp32_, TRUE);
	_tmp33_ = _data6_->status;
	gtk_widget_add_css_class ((GtkWidget*) _tmp33_, "dim-label");
	_tmp34_ = content;
	_tmp35_ = _data6_->status;
	gtk_box_append (_tmp34_, (GtkWidget*) _tmp35_);
	_tmp36_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp36_);
	actions = _tmp36_;
	_tmp37_ = actions;
	gtk_widget_set_halign ((GtkWidget*) _tmp37_, GTK_ALIGN_END);
	_tmp38_ = actions;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp38_, 6);
	_tmp39_ = (GtkButton*) gtk_button_new_with_label ("Cancel");
	g_object_ref_sink (_tmp39_);
	cancel_btn = _tmp39_;
	_tmp40_ = cancel_btn;
	g_signal_connect_data (_tmp40_, "clicked", (GCallback) ___lambda140__gtk_button_clicked, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	_tmp41_ = actions;
	_tmp42_ = cancel_btn;
	gtk_box_append (_tmp41_, (GtkWidget*) _tmp42_);
	_tmp43_ = (GtkButton*) gtk_button_new_with_label ("Add");
	g_object_ref_sink (_tmp43_);
	_data6_->add_btn = _tmp43_;
	_tmp44_ = _data6_->add_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp44_, "suggested-action");
	_tmp45_ = _data6_->add_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp45_, FALSE);
	_tmp46_ = _data6_->add_btn;
	g_signal_connect_data (_tmp46_, "clicked", (GCallback) ___lambda141__gtk_button_clicked, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	_tmp47_ = actions;
	_tmp48_ = _data6_->add_btn;
	gtk_box_append (_tmp47_, (GtkWidget*) _tmp48_);
	_tmp49_ = content;
	_tmp50_ = actions;
	gtk_box_append (_tmp49_, (GtkWidget*) _tmp50_);
	_tmp51_ = _data6_->entry;
	g_signal_connect_data ((GtkEditable*) _tmp51_, "changed", (GCallback) ___lambda142__gtk_editable_changed, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	_tmp52_ = _data6_->entry;
	g_signal_connect_data (_tmp52_, "activate", (GCallback) ___lambda143__gtk_entry_activate, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
	_tmp53_ = box;
	_tmp54_ = content;
	gtk_box_append (_tmp53_, (GtkWidget*) _tmp54_);
	_tmp55_ = _data6_->dialog;
	_tmp56_ = box;
	adw_dialog_set_child (_tmp55_, (GtkWidget*) _tmp56_);
	_tmp57_ = _data6_->dialog;
	_tmp58_ = _g_object_ref0 (_tmp57_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp58_;
	_tmp59_ = _data6_->dialog;
	g_signal_connect_object (_tmp59_, "closed", (GCallback) ___lambda144__adw_dialog_closed, self, 0);
	_tmp60_ = _data6_->dialog;
	adw_dialog_present (_tmp60_, (GtkWidget*) self);
	_tmp61_ = _data6_->entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp61_);
	_g_object_unref0 (cancel_btn);
	_g_object_unref0 (actions);
	_g_object_unref0 (label);
	_g_object_unref0 (content);
	_g_object_unref0 (box);
	block6_data_unref (_data6_);
	_data6_ = NULL;
}

static void
dc_window_use_invite_link_data_free (gpointer _data)
{
	DcWindowUseInviteLinkData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->dialog);
	_g_object_unref0 (_data_->entry);
	_g_object_unref0 (_data_->status);
	_g_object_unref0 (_data_->add_btn);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcWindowUseInviteLinkData, _data_);
}

static void
dc_window_use_invite_link (DcWindow* self,
                           AdwDialog* dialog,
                           GtkEntry* entry,
                           GtkLabel* status,
                           GtkButton* add_btn,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_)
{
	DcWindowUseInviteLinkData* _data_;
	DcWindow* _tmp0_;
	AdwDialog* _tmp1_;
	GtkEntry* _tmp2_;
	GtkLabel* _tmp3_;
	GtkButton* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (dialog != NULL);
	g_return_if_fail (entry != NULL);
	g_return_if_fail (status != NULL);
	g_return_if_fail (add_btn != NULL);
	_data_ = g_slice_new0 (DcWindowUseInviteLinkData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_use_invite_link_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (dialog);
	_g_object_unref0 (_data_->dialog);
	_data_->dialog = _tmp1_;
	_tmp2_ = _g_object_ref0 (entry);
	_g_object_unref0 (_data_->entry);
	_data_->entry = _tmp2_;
	_tmp3_ = _g_object_ref0 (status);
	_g_object_unref0 (_data_->status);
	_data_->status = _tmp3_;
	_tmp4_ = _g_object_ref0 (add_btn);
	_g_object_unref0 (_data_->add_btn);
	_data_->add_btn = _tmp4_;
	dc_window_use_invite_link_co (_data_);
}

static void
dc_window_use_invite_link_finish (DcWindow* self,
                                  GAsyncResult* _res_)
{
	DcWindowUseInviteLinkData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_use_invite_link_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_)
{
	DcWindowUseInviteLinkData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_use_invite_link_co (_data_);
}

static gboolean
dc_window_use_invite_link_co (DcWindowUseInviteLinkData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gtk_editable_get_text ((GtkEditable*) _data_->entry);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = string_strip (_data_->_tmp1_);
	_data_->invite_link = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->invite_link;
	_data_->_tmp4_ = strlen (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	if (_data_->_tmp5_ == 0) {
		_g_free0 (_data_->invite_link);
		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;
	}
	gtk_widget_set_sensitive ((GtkWidget*) _data_->add_btn, FALSE);
	gtk_widget_set_sensitive ((GtkWidget*) _data_->entry, FALSE);
	gtk_label_set_label (_data_->status, "Checking invite link…");
	{
		_data_->_tmp6_ = _data_->self->priv->rpc;
		_data_->_tmp7_ = _data_->self->priv->rpc;
		_data_->_tmp8_ = dc_rpc_client_get_account_id (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = _data_->invite_link;
		_data_->_state_ = 1;
		dc_rpc_client_check_qr (_data_->_tmp6_, _data_->_tmp9_, _data_->_tmp10_, dc_window_use_invite_link_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp11_ = dc_rpc_client_check_qr_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		_data_->qr = _data_->_tmp11_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp13_ = _data_->qr;
		if (_data_->_tmp13_ == NULL) {
			_data_->_tmp12_ = TRUE;
		} else {
			_data_->_tmp14_ = _data_->qr;
			_data_->_tmp12_ = !json_object_has_member (_data_->_tmp14_, "kind");
		}
		if (_data_->_tmp12_) {
			gtk_label_set_label (_data_->status, "This is not a valid invite link.");
			_json_object_unref0 (_data_->qr);
			{
				_data_->_tmp15_ = _data_->self->priv->active_modal;
				if (_data_->_tmp15_ == _data_->dialog) {
					gtk_widget_set_sensitive ((GtkWidget*) _data_->entry, TRUE);
					_data_->_tmp16_ = gtk_editable_get_text ((GtkEditable*) _data_->entry);
					_data_->_tmp17_ = _data_->_tmp16_;
					_data_->_tmp18_ = string_strip (_data_->_tmp17_);
					_data_->_tmp19_ = _data_->_tmp18_;
					_data_->_tmp20_ = strlen (_data_->_tmp19_);
					_data_->_tmp21_ = _data_->_tmp20_;
					gtk_widget_set_sensitive ((GtkWidget*) _data_->add_btn, _data_->_tmp21_ > 0);
					_g_free0 (_data_->_tmp19_);
				}
			}
			_g_free0 (_data_->invite_link);
			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_->_tmp22_ = _data_->qr;
		_data_->_tmp23_ = json_object_get_string_member (_data_->_tmp22_, "kind");
		_data_->_tmp24_ = g_strdup (_data_->_tmp23_);
		_data_->kind = _data_->_tmp24_;
		_data_->_tmp27_ = _data_->kind;
		if (g_strcmp0 (_data_->_tmp27_, "askVerifyContact") != 0) {
			_data_->_tmp28_ = _data_->kind;
			_data_->_tmp26_ = g_strcmp0 (_data_->_tmp28_, "askVerifyGroup") != 0;
		} else {
			_data_->_tmp26_ = FALSE;
		}
		if (_data_->_tmp26_) {
			_data_->_tmp29_ = _data_->kind;
			_data_->_tmp25_ = g_strcmp0 (_data_->_tmp29_, "askJoinBroadcast") != 0;
		} else {
			_data_->_tmp25_ = FALSE;
		}
		if (_data_->_tmp25_) {
			gtk_label_set_label (_data_->status, "This is not a contact, group, or channel invite link.");
			_g_free0 (_data_->kind);
			_json_object_unref0 (_data_->qr);
			{
				_data_->_tmp30_ = _data_->self->priv->active_modal;
				if (_data_->_tmp30_ == _data_->dialog) {
					gtk_widget_set_sensitive ((GtkWidget*) _data_->entry, TRUE);
					_data_->_tmp31_ = gtk_editable_get_text ((GtkEditable*) _data_->entry);
					_data_->_tmp32_ = _data_->_tmp31_;
					_data_->_tmp33_ = string_strip (_data_->_tmp32_);
					_data_->_tmp34_ = _data_->_tmp33_;
					_data_->_tmp35_ = strlen (_data_->_tmp34_);
					_data_->_tmp36_ = _data_->_tmp35_;
					gtk_widget_set_sensitive ((GtkWidget*) _data_->add_btn, _data_->_tmp36_ > 0);
					_g_free0 (_data_->_tmp34_);
				}
			}
			_g_free0 (_data_->invite_link);
			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;
		}
		gtk_label_set_label (_data_->status, "Accepting invite link…");
		_data_->_tmp37_ = _data_->self->priv->rpc;
		_data_->_tmp38_ = _data_->self->priv->rpc;
		_data_->_tmp39_ = dc_rpc_client_get_account_id (_data_->_tmp38_);
		_data_->_tmp40_ = _data_->_tmp39_;
		_data_->_tmp41_ = _data_->invite_link;
		_data_->_state_ = 2;
		dc_rpc_client_secure_join (_data_->_tmp37_, _data_->_tmp40_, _data_->_tmp41_, dc_window_use_invite_link_ready, _data_);
		return FALSE;
		_state_2:
		_data_->chat_id = dc_rpc_client_secure_join_finish (_data_->_tmp37_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->kind);
			_json_object_unref0 (_data_->qr);
			goto __catch0_g_error;
		}
		_data_->_state_ = 3;
		dc_window_load_chats (_data_->self, dc_window_use_invite_link_ready, _data_);
		return FALSE;
		_state_3:
		dc_window_load_chats_finish (_data_->self, _data_->_res_);
		dc_window_select_chat_by_id (_data_->self, _data_->chat_id);
		adw_dialog_close (_data_->dialog);
		dc_window_show_toast (_data_->self, "Invite link accepted");
		_g_free0 (_data_->kind);
		_json_object_unref0 (_data_->qr);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp42_ = _data_->e;
		_data_->_tmp43_ = _data_->_tmp42_->message;
		_data_->_tmp44_ = g_strconcat ("Invite link failed: ", _data_->_tmp43_, NULL);
		_data_->_tmp45_ = _data_->_tmp44_;
		gtk_label_set_label (_data_->status, _data_->_tmp45_);
		_g_free0 (_data_->_tmp45_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	{
		_data_->_tmp46_ = _data_->self->priv->active_modal;
		if (_data_->_tmp46_ == _data_->dialog) {
			gtk_widget_set_sensitive ((GtkWidget*) _data_->entry, TRUE);
			_data_->_tmp47_ = gtk_editable_get_text ((GtkEditable*) _data_->entry);
			_data_->_tmp48_ = _data_->_tmp47_;
			_data_->_tmp49_ = string_strip (_data_->_tmp48_);
			_data_->_tmp50_ = _data_->_tmp49_;
			_data_->_tmp51_ = strlen (_data_->_tmp50_);
			_data_->_tmp52_ = _data_->_tmp51_;
			gtk_widget_set_sensitive ((GtkWidget*) _data_->add_btn, _data_->_tmp52_ > 0);
			_g_free0 (_data_->_tmp50_);
		}
	}
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->invite_link);
		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_free0 (_data_->invite_link);
	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
__lambda155_ (DcWindow* self)
{
	gboolean _tmp0_ = FALSE;
	DcRpcClient* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
	_tmp1_ = self->priv->rpc;
	_tmp2_ = dc_rpc_client_get_is_connected (_tmp1_);
	_tmp3_ = _tmp2_;
	if (!_tmp3_) {
		DcSettingsManager* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp4_ = self->settings;
		_tmp5_ = dc_settings_manager_get_rpc_server_path (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = strlen (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp8_ > 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		dc_window_try_connect (self, NULL, NULL);
	}
}

static void
___lambda155__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda155_ ((DcWindow*) self);
}

static void
dc_window_show_settings_dialog (DcWindow* self)
{
	AdwDialog* _tmp0_;
	DcSettingsDialog* dialog = NULL;
	DcSettingsDialog* _tmp1_;
	DcSettingsDialog* _tmp2_;
	AdwDialog* _tmp3_;
	DcSettingsDialog* _tmp4_;
	DcSettingsDialog* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->active_modal;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp1_ = dc_settings_dialog_new (self);
	g_object_ref_sink (_tmp1_);
	dialog = _tmp1_;
	_tmp2_ = dialog;
	_tmp3_ = _g_object_ref0 ((AdwDialog*) _tmp2_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp3_;
	_tmp4_ = dialog;
	g_signal_connect_object ((AdwDialog*) _tmp4_, "closed", (GCallback) ___lambda155__adw_dialog_closed, self, 0);
	_tmp5_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp5_, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

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

void
dc_window_reload_active_account (DcWindow* self,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	DcWindowReloadActiveAccountData* _data_;
	DcWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcWindowReloadActiveAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_window_reload_active_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_window_reload_active_account_co (_data_);
}

void
dc_window_reload_active_account_finish (DcWindow* self,
                                        GAsyncResult* _res_)
{
	DcWindowReloadActiveAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_window_reload_active_account_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	DcWindowReloadActiveAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_window_reload_active_account_co (_data_);
}

static gboolean
dc_window_reload_active_account_co (DcWindowReloadActiveAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	dc_window_discard_all_views (_data_->self);
	_data_->_tmp0_ = _data_->self->priv->_chat_store;
	g_list_store_remove_all (_data_->_tmp0_);
	_data_->_tmp1_ = _data_->self->priv->chat_listbox;
	dc_clear_listbox (_data_->_tmp1_);
	_data_->_tmp2_ = _data_->self->priv->search_entry;
	gtk_editable_set_text ((GtkEditable*) _data_->_tmp2_, "");
	_data_->_tmp3_ = _data_->self->priv->content_title_label;
	gtk_label_set_label (_data_->_tmp3_, "Select a chat");
	_data_->_tmp4_ = _data_->self->priv->empty_status;
	adw_status_page_set_child (_data_->_tmp4_, NULL);
	_data_->_tmp5_ = _data_->self->priv->rpc;
	_data_->_tmp6_ = dc_rpc_client_get_account_id (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	if (_data_->_tmp7_ <= 0) {
		_data_->_tmp8_ = _data_->self->priv->rpc;
		dc_rpc_client_set_self_email (_data_->_tmp8_, NULL);
		_data_->_tmp9_ = _data_->self->priv->profile_avatar;
		adw_avatar_set_text (_data_->_tmp9_, "");
		_data_->_tmp10_ = _data_->self->priv->profile_avatar;
		adw_avatar_set_custom_image (_data_->_tmp10_, NULL);
		_data_->_tmp11_ = _data_->self->priv->empty_status;
		adw_status_page_set_icon_name (_data_->_tmp11_, "avatar-default-symbolic");
		_data_->_tmp12_ = _data_->self->priv->empty_status;
		adw_status_page_set_title (_data_->_tmp12_, "No Profile Loaded");
		_data_->_tmp13_ = _data_->self->priv->empty_status;
		adw_status_page_set_description (_data_->_tmp13_, "Add or select a profile from the profile menu.");
		_data_->_tmp14_ = _data_->self->priv->content_stack;
		gtk_stack_set_visible_child_name (_data_->_tmp14_, "empty");
		dc_window_set_current_chat_id (_data_->self, 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_->_tmp15_ = _data_->self->priv->empty_status;
	adw_status_page_set_icon_name (_data_->_tmp15_, "mail-send-receive-symbolic");
	_data_->_tmp16_ = _data_->self->priv->empty_status;
	adw_status_page_set_title (_data_->_tmp16_, "Parla");
	_data_->_tmp17_ = _data_->self->priv->empty_status;
	adw_status_page_set_description (_data_->_tmp17_, "Select a chat to start messaging.");
	{
		_data_->_tmp19_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_config (_data_->_tmp19_, "addr", 0, dc_window_reload_active_account_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp20_ = dc_rpc_client_get_config_finish (_data_->_tmp19_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp18_ = _data_->_tmp20_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp21_ = _data_->self->priv->rpc;
		dc_rpc_client_set_self_email (_data_->_tmp21_, _data_->_tmp18_);
		_g_free0 (_data_->_tmp18_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
		_data_->_tmp22_ = _data_->self->priv->rpc;
		dc_rpc_client_set_self_email (_data_->_tmp22_, NULL);
	}
	__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;
	}
	dc_window_set_current_chat_id (_data_->self, 0);
	_data_->_tmp23_ = _data_->self->priv->content_stack;
	gtk_stack_set_visible_child_name (_data_->_tmp23_, "empty");
	_data_->_state_ = 2;
	dc_window_load_chats (_data_->self, dc_window_reload_active_account_ready, _data_);
	return FALSE;
	_state_2:
	dc_window_load_chats_finish (_data_->self, _data_->_res_);
	_data_->_state_ = 3;
	dc_window_load_profile_avatar (_data_->self, dc_window_reload_active_account_ready, _data_);
	return FALSE;
	_state_3:
	dc_window_load_profile_avatar_finish (_data_->self, _data_->_res_);
	_data_->_tmp25_ = _data_->self->priv->events;
	if (_data_->_tmp25_ != NULL) {
		_data_->_tmp26_ = _data_->self->priv->events;
		_data_->_tmp27_ = dc_event_handler_get_is_listening (_data_->_tmp26_);
		_data_->_tmp28_ = _data_->_tmp27_;
		_data_->_tmp24_ = !_data_->_tmp28_;
	} else {
		_data_->_tmp24_ = FALSE;
	}
	if (_data_->_tmp24_) {
		_data_->_tmp29_ = _data_->self->priv->events;
		dc_event_handler_start (_data_->_tmp29_, NULL, 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_window_discard_all_views (DcWindow* self)
{
	GHashTableIter iter = {0};
	GHashTable* _tmp0_;
	gint k = 0;
	DcConversationView* v = NULL;
	GHashTable* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->views;
	g_hash_table_iter_init (&iter, _tmp0_);
	while (TRUE) {
		gconstpointer _tmp1_ = NULL;
		gconstpointer _tmp2_ = NULL;
		gboolean _tmp3_;
		DcConversationView* _tmp4_;
		GtkStack* _tmp5_;
		DcConversationView* _tmp6_;
		_tmp3_ = g_hash_table_iter_next (&iter, (gpointer*) (&_tmp1_), (gpointer*) (&_tmp2_));
		k = (gint) ((gintptr) _tmp1_);
		_g_object_unref0 (v);
		_tmp4_ = _g_object_ref0 ((DcConversationView*) _tmp2_);
		v = _tmp4_;
		if (!_tmp3_) {
			break;
		}
		_tmp5_ = self->priv->content_stack;
		_tmp6_ = v;
		gtk_stack_remove (_tmp5_, (GtkWidget*) _tmp6_);
	}
	_tmp7_ = self->priv->views;
	g_hash_table_remove_all (_tmp7_);
	_g_object_unref0 (v);
}

static gboolean
dc_window_on_window_key_pressed (DcWindow* self,
                                 guint keyval,
                                 guint keycode,
                                 GdkModifierType state)
{
	DcImageViewer* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->image_viewer;
	_tmp1_ = dc_image_viewer_get_visible (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		DcImageViewer* _tmp3_;
		_tmp3_ = self->priv->image_viewer;
		result = dc_image_viewer_handle_key (_tmp3_, keyval);
		return result;
	}
	if (keyval == GDK_KEY_Escape) {
		DcConversationView* v = NULL;
		DcConversationView* _tmp13_;
		DcConversationView* _tmp14_;
		{
			GtkWidget* w = NULL;
			GtkWidget* _tmp4_;
			GtkWidget* _tmp5_;
			g_object_get ((GtkWindow*) self, "focus-widget", &_tmp4_, NULL);
			_tmp5_ = _tmp4_;
			w = _tmp5_;
			{
				gboolean _tmp6_ = FALSE;
				_tmp6_ = TRUE;
				while (TRUE) {
					GtkWidget* _tmp10_;
					GtkWidget* _tmp11_;
					if (!_tmp6_) {
						GtkWidget* _tmp7_;
						GtkWidget* _tmp8_;
						GtkWidget* _tmp9_;
						_tmp7_ = w;
						_tmp8_ = gtk_widget_get_parent (_tmp7_);
						_tmp9_ = _g_object_ref0 (_tmp8_);
						_g_object_unref0 (w);
						w = _tmp9_;
					}
					_tmp6_ = FALSE;
					_tmp10_ = w;
					if (!(_tmp10_ != NULL)) {
						break;
					}
					_tmp11_ = w;
					if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, adw_dialog_get_type ())) {
						GtkWidget* _tmp12_;
						_tmp12_ = w;
						adw_dialog_close (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, adw_dialog_get_type (), AdwDialog));
						break;
					}
				}
			}
			_g_object_unref0 (w);
		}
		_tmp13_ = dc_window_current_view (self);
		v = _tmp13_;
		_tmp14_ = v;
		if (_tmp14_ != NULL) {
			DcConversationView* _tmp15_;
			DcConversationView* _tmp16_;
			_tmp15_ = v;
			dc_conversation_view_close_search_if_active (_tmp15_);
			_tmp16_ = v;
			dc_conversation_view_focus_entry (_tmp16_);
		}
		result = TRUE;
		_g_object_unref0 (v);
		return result;
	}
	if ((state & GDK_CONTROL_MASK) == 0) {
		result = FALSE;
		return result;
	}
	switch (keyval) {
		case GDK_KEY_n:
		case GDK_KEY_N:
		{
			dc_window_on_new_chat (self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_g:
		case GDK_KEY_G:
		{
			dc_window_on_new_group (self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_comma:
		{
			dc_window_show_settings_dialog (self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_f:
		case GDK_KEY_F:
		{
			dc_window_toggle_message_search (self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_k:
		case GDK_KEY_K:
		{
			dc_window_show_quick_switch_dialog (self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_r:
		case GDK_KEY_R:
		{
			dc_window_refresh_current_chat (self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_w:
		case GDK_KEY_W:
		{
			gtk_window_close ((GtkWindow*) self);
			result = TRUE;
			return result;
		}
		case GDK_KEY_q:
		case GDK_KEY_Q:
		{
			GtkApplication* _tmp17_;
			GtkApplication* _tmp18_;
			_tmp17_ = gtk_window_get_application ((GtkWindow*) self);
			_tmp18_ = _tmp17_;
			g_application_quit ((GApplication*) _tmp18_);
			result = TRUE;
			return result;
		}
		default:
		break;
	}
	result = FALSE;
	return result;
}

static void
dc_window_toggle_message_search (DcWindow* self)
{
	DcConversationView* v = NULL;
	DcConversationView* _tmp0_;
	DcConversationView* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = dc_window_current_view (self);
	v = _tmp0_;
	_tmp1_ = v;
	if (_tmp1_ != NULL) {
		DcConversationView* _tmp2_;
		_tmp2_ = v;
		dc_conversation_view_toggle_search (_tmp2_);
	}
	_g_object_unref0 (v);
}

static void
dc_window_refresh_current_chat (DcWindow* self)
{
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (self != NULL);
	dc_window_request_reload_chats (self);
	_tmp0_ = dc_window_get_current_chat_id (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ > 0) {
		dc_window_request_messages_reload (self);
	}
}

static void
__lambda170_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda170__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda170_ ((DcWindow*) self);
}

static void
__lambda171_ (DcWindow* self,
              gint chat_id)
{
	dc_window_select_chat_by_id (self, chat_id);
}

static void
___lambda171__dc_quick_switch_dialog_chat_selected (DcQuickSwitchDialog* _sender,
                                                    gint chat_id,
                                                    gpointer self)
{
	__lambda171_ ((DcWindow*) self, chat_id);
}

static void
dc_window_show_quick_switch_dialog (DcWindow* self)
{
	DcRpcClient* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GListStore* _tmp3_;
	AdwDialog* _tmp4_;
	DcQuickSwitchDialog* dialog = NULL;
	GListStore* _tmp5_;
	DcQuickSwitchDialog* _tmp6_;
	DcQuickSwitchDialog* _tmp7_;
	AdwDialog* _tmp8_;
	DcQuickSwitchDialog* _tmp9_;
	DcQuickSwitchDialog* _tmp10_;
	DcQuickSwitchDialog* _tmp11_;
	DcQuickSwitchDialog* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_rpc_client_get_account_id (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ <= 0) {
		return;
	}
	_tmp3_ = self->priv->_chat_store;
	if (g_list_model_get_n_items ((GListModel*) _tmp3_) == ((guint) 0)) {
		return;
	}
	_tmp4_ = self->priv->active_modal;
	if (_tmp4_ != NULL) {
		return;
	}
	_tmp5_ = self->priv->_chat_store;
	_tmp6_ = dc_quick_switch_dialog_new (_tmp5_);
	g_object_ref_sink (_tmp6_);
	dialog = _tmp6_;
	_tmp7_ = dialog;
	_tmp8_ = _g_object_ref0 ((AdwDialog*) _tmp7_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp8_;
	_tmp9_ = dialog;
	g_signal_connect_object ((AdwDialog*) _tmp9_, "closed", (GCallback) ___lambda170__adw_dialog_closed, self, 0);
	_tmp10_ = dialog;
	g_signal_connect_object (_tmp10_, "chat-selected", (GCallback) ___lambda171__dc_quick_switch_dialog_chat_selected, self, 0);
	_tmp11_ = dialog;
	adw_dialog_present ((AdwDialog*) _tmp11_, (GtkWidget*) self);
	_tmp12_ = dialog;
	dc_quick_switch_dialog_focus_entry (_tmp12_);
	_g_object_unref0 (dialog);
}

void
dc_window_select_chat_by_id (DcWindow* self,
                             gint chat_id)
{
	gint idx = 0;
	GtkListBoxRow* row = NULL;
	g_return_if_fail (self != NULL);
	idx = 0;
	while (TRUE) {
		GtkListBox* _tmp0_;
		GtkListBoxRow* _tmp1_;
		GtkListBoxRow* _tmp2_;
		GtkListBoxRow* _tmp3_;
		DcChatRow* chat_row = NULL;
		GtkListBoxRow* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		DcChatRow* _tmp7_;
		gboolean _tmp8_ = FALSE;
		DcChatRow* _tmp9_;
		gint _tmp16_;
		_tmp0_ = self->priv->chat_listbox;
		_tmp1_ = gtk_list_box_get_row_at_index (_tmp0_, idx);
		_tmp2_ = _g_object_ref0 (_tmp1_);
		_g_object_unref0 (row);
		row = _tmp2_;
		_tmp3_ = row;
		if (!(_tmp3_ != NULL)) {
			break;
		}
		_tmp4_ = row;
		_tmp5_ = gtk_list_box_row_get_child (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = _g_object_ref0 (DC_IS_CHAT_ROW (_tmp6_) ? ((DcChatRow*) _tmp6_) : NULL);
		chat_row = _tmp7_;
		_tmp9_ = chat_row;
		if (_tmp9_ != NULL) {
			DcChatRow* _tmp10_;
			gint _tmp11_;
			gint _tmp12_;
			_tmp10_ = chat_row;
			_tmp11_ = dc_chat_row_get_chat_id (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp8_ = _tmp12_ == chat_id;
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			GtkListBox* _tmp13_;
			GtkListBoxRow* _tmp14_;
			GtkListBoxRow* _tmp15_;
			_tmp13_ = self->priv->chat_listbox;
			_tmp14_ = row;
			gtk_list_box_select_row (_tmp13_, _tmp14_);
			_tmp15_ = row;
			dc_window_on_chat_selected (self, _tmp15_);
			_g_object_unref0 (chat_row);
			_g_object_unref0 (row);
			return;
		}
		_tmp16_ = idx;
		idx = _tmp16_ + 1;
		_g_object_unref0 (chat_row);
	}
	_g_object_unref0 (row);
}

static void
__lambda161_ (DcWindow* self)
{
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = NULL;
}

static void
___lambda161__adw_dialog_closed (AdwDialog* _sender,
                                 gpointer self)
{
	__lambda161_ ((DcWindow*) self);
}

static void
dc_window_show_keyboard_shortcuts_dialog (DcWindow* self)
{
	AdwDialog* _tmp0_;
	AdwDialog* dialog = NULL;
	AdwDialog* _tmp1_;
	AdwDialog* _tmp2_;
	AdwDialog* _tmp3_;
	AdwDialog* _tmp4_;
	GtkBox* box = NULL;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	AdwHeaderBar* _tmp7_;
	AdwHeaderBar* _tmp8_;
	GtkListBox* list = NULL;
	GtkListBox* _tmp9_;
	GtkListBox* _tmp10_;
	GtkListBox* _tmp11_;
	GtkListBox* _tmp12_;
	GtkListBox* _tmp13_;
	GtkListBox* _tmp14_;
	GtkListBox* _tmp15_;
	GtkBox* _tmp27_;
	GtkListBox* _tmp28_;
	AdwDialog* _tmp29_;
	GtkBox* _tmp30_;
	AdwDialog* _tmp31_;
	AdwDialog* _tmp32_;
	AdwDialog* _tmp33_;
	AdwDialog* _tmp34_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->active_modal;
	if (_tmp0_ != NULL) {
		return;
	}
	_tmp1_ = adw_dialog_new ();
	g_object_ref_sink (_tmp1_);
	dialog = _tmp1_;
	_tmp2_ = dialog;
	adw_dialog_set_title (_tmp2_, "Shortcuts");
	_tmp3_ = dialog;
	adw_dialog_set_content_width (_tmp3_, 400);
	_tmp4_ = dialog;
	adw_dialog_set_content_height (_tmp4_, 380);
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp5_);
	box = _tmp5_;
	_tmp6_ = box;
	_tmp7_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	gtk_box_append (_tmp6_, (GtkWidget*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	_tmp9_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp9_);
	list = _tmp9_;
	_tmp10_ = list;
	gtk_list_box_set_selection_mode (_tmp10_, GTK_SELECTION_NONE);
	_tmp11_ = list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp11_, "boxed-list");
	_tmp12_ = list;
	_tmp13_ = list;
	_tmp14_ = list;
	_tmp15_ = list;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp15_, 12);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp14_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp13_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp12_, 12);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp16_ = FALSE;
			_tmp16_ = TRUE;
			while (TRUE) {
				AdwActionRow* row = NULL;
				AdwActionRow* _tmp17_;
				AdwActionRow* _tmp18_;
				const gchar* _tmp19_;
				GtkShortcutLabel* lbl = NULL;
				const gchar* _tmp20_;
				GtkShortcutLabel* _tmp21_;
				GtkShortcutLabel* _tmp22_;
				AdwActionRow* _tmp23_;
				GtkShortcutLabel* _tmp24_;
				GtkListBox* _tmp25_;
				AdwActionRow* _tmp26_;
				if (!_tmp16_) {
					i += 2;
				}
				_tmp16_ = FALSE;
				if (!((i + 1) < G_N_ELEMENTS (DC_WINDOW_SHORTCUTS))) {
					break;
				}
				_tmp17_ = (AdwActionRow*) adw_action_row_new ();
				g_object_ref_sink (_tmp17_);
				row = _tmp17_;
				_tmp18_ = row;
				_tmp19_ = DC_WINDOW_SHORTCUTS[i];
				adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp18_, _tmp19_);
				_tmp20_ = DC_WINDOW_SHORTCUTS[i + 1];
				_tmp21_ = (GtkShortcutLabel*) gtk_shortcut_label_new (_tmp20_);
				g_object_ref_sink (_tmp21_);
				lbl = _tmp21_;
				_tmp22_ = lbl;
				gtk_widget_set_valign ((GtkWidget*) _tmp22_, GTK_ALIGN_CENTER);
				_tmp23_ = row;
				_tmp24_ = lbl;
				adw_action_row_add_suffix (_tmp23_, (GtkWidget*) _tmp24_);
				_tmp25_ = list;
				_tmp26_ = row;
				gtk_list_box_append (_tmp25_, (GtkWidget*) _tmp26_);
				_g_object_unref0 (lbl);
				_g_object_unref0 (row);
			}
		}
	}
	_tmp27_ = box;
	_tmp28_ = list;
	gtk_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = dialog;
	_tmp30_ = box;
	adw_dialog_set_child (_tmp29_, (GtkWidget*) _tmp30_);
	_tmp31_ = dialog;
	_tmp32_ = _g_object_ref0 (_tmp31_);
	_g_object_unref0 (self->priv->active_modal);
	self->priv->active_modal = _tmp32_;
	_tmp33_ = dialog;
	g_signal_connect_object (_tmp33_, "closed", (GCallback) ___lambda161__adw_dialog_closed, self, 0);
	_tmp34_ = dialog;
	adw_dialog_present (_tmp34_, (GtkWidget*) self);
	_g_object_unref0 (list);
	_g_object_unref0 (box);
	_g_object_unref0 (dialog);
}

void
dc_window_show_toast (DcWindow* self,
                      const gchar* message)
{
	AdwToast* toast = NULL;
	AdwToast* _tmp0_;
	AdwToastOverlay* _tmp1_;
	AdwToast* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = adw_toast_new (message);
	toast = _tmp0_;
	adw_toast_set_timeout (toast, (guint) 4);
	_tmp1_ = self->priv->toast_overlay;
	_tmp2_ = _g_object_ref0 (toast);
	adw_toast_overlay_add_toast (_tmp1_, _tmp2_);
	_g_object_unref0 (toast);
}

/**
         * Build the floating "disconnected" banner that slides in from the
         * top when the RPC server can't be reached. Non-interactive so it
         * never intercepts clicks meant for the chat below.
         */
static GtkRevealer*
dc_window_build_connection_banner (DcWindow* self)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	GtkImage* icon = NULL;
	GtkImage* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkRevealer* _tmp5_;
	GtkRevealer* _tmp6_;
	GtkRevealer* _tmp7_;
	GtkRevealer* _tmp8_;
	GtkRevealer* _tmp9_;
	GtkRevealer* _tmp10_;
	GtkRevealer* _tmp11_;
	GtkRevealer* _tmp12_;
	GtkRevealer* _tmp13_;
	GtkRevealer* _tmp14_;
	GtkRevealer* _tmp15_;
	GtkRevealer* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) box, "connection-banner");
	_tmp1_ = (GtkImage*) gtk_image_new_from_icon_name ("network-offline-symbolic");
	g_object_ref_sink (_tmp1_);
	icon = _tmp1_;
	gtk_image_set_pixel_size (icon, 14);
	gtk_box_append (box, (GtkWidget*) icon);
	_tmp2_ = (GtkLabel*) gtk_label_new ("Not connected");
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->connection_banner_label);
	self->priv->connection_banner_label = _tmp2_;
	_tmp3_ = self->priv->connection_banner_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp3_, "connection-banner-label");
	_tmp4_ = self->priv->connection_banner_label;
	gtk_box_append (box, (GtkWidget*) _tmp4_);
	_tmp5_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->connection_banner);
	self->priv->connection_banner = _tmp5_;
	_tmp6_ = self->priv->connection_banner;
	gtk_revealer_set_child (_tmp6_, (GtkWidget*) box);
	_tmp7_ = self->priv->connection_banner;
	gtk_revealer_set_reveal_child (_tmp7_, FALSE);
	_tmp8_ = self->priv->connection_banner;
	gtk_revealer_set_transition_type (_tmp8_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
	_tmp9_ = self->priv->connection_banner;
	gtk_revealer_set_transition_duration (_tmp9_, (guint) 200);
	_tmp10_ = self->priv->connection_banner;
	gtk_widget_set_halign ((GtkWidget*) _tmp10_, GTK_ALIGN_CENTER);
	_tmp11_ = self->priv->connection_banner;
	gtk_widget_set_valign ((GtkWidget*) _tmp11_, GTK_ALIGN_START);
	_tmp12_ = self->priv->connection_banner;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp12_, 8);
	_tmp13_ = self->priv->connection_banner;
	gtk_widget_set_can_target ((GtkWidget*) _tmp13_, FALSE);
	_tmp14_ = self->priv->connection_banner;
	_tmp15_ = _g_object_ref0 (_tmp14_);
	result = _tmp15_;
	_g_object_unref0 (icon);
	_g_object_unref0 (box);
	return result;
}

/**
         * Show/hide the floating network banner. Pass null reason to hide.
         */
void
dc_window_set_connection_status (DcWindow* self,
                                 gboolean connected,
                                 const gchar* reason)
{
	GtkRevealer* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->connection_banner;
	if (_tmp0_ == NULL) {
		return;
	}
	if (connected) {
		GtkRevealer* _tmp1_;
		_tmp1_ = self->priv->connection_banner;
		gtk_revealer_set_reveal_child (_tmp1_, FALSE);
	} else {
		const gchar* _tmp2_ = NULL;
		GtkLabel* _tmp3_;
		GtkRevealer* _tmp4_;
		_tmp2_ = reason;
		if (_tmp2_ == NULL) {
			_tmp2_ = "Not connected";
		}
		_tmp3_ = self->priv->connection_banner_label;
		gtk_label_set_label (_tmp3_, _tmp2_);
		_tmp4_ = self->priv->connection_banner;
		gtk_revealer_set_reveal_child (_tmp4_, TRUE);
	}
}

GListStore*
dc_window_get_chat_store (DcWindow* self)
{
	GListStore* result;
	GListStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_chat_store;
	result = _tmp0_;
	return result;
}

static void
dc_window_set_chat_store (DcWindow* self,
                          GListStore* value)
{
	GListStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_window_get_chat_store (self);
	if (old_value != value) {
		GListStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_chat_store);
		self->priv->_chat_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dc_window_properties[DC_WINDOW_CHAT_STORE_PROPERTY]);
	}
}

gint
dc_window_get_current_chat_id (DcWindow* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_current_chat_id;
	return result;
}

static void
dc_window_set_current_chat_id (DcWindow* self,
                               gint value)
{
	DcEventHandler* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->_current_chat_id = value;
	_tmp0_ = self->priv->events;
	if (_tmp0_ != NULL) {
		DcEventHandler* _tmp1_;
		_tmp1_ = self->priv->events;
		dc_event_handler_set_active_chat_id (_tmp1_, value);
	}
	g_object_notify_by_pspec ((GObject *) self, dc_window_properties[DC_WINDOW_CURRENT_CHAT_ID_PROPERTY]);
}

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

static gboolean
_dc_window___lambda172_ (DcWindow* self)
{
	gboolean result;
	dc_window_try_connect (self, NULL, NULL);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
__dc_window___lambda172__gsource_func (gpointer self)
{
	gboolean result;
	result = _dc_window___lambda172_ ((DcWindow*) self);
	return result;
}

static GObject *
dc_window_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DcWindow * self;
	GListStore* _tmp0_;
	GListStore* _tmp1_;
	GHashFunc _tmp2_;
	GEqualFunc _tmp3_;
	GHashTable* _tmp4_;
	DcSettingsManager* _tmp5_;
	DcImageViewer* _tmp6_;
	DcImageViewer* _tmp7_;
	DcSettingsManager* _tmp8_;
	parent_class = G_OBJECT_CLASS (dc_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_WINDOW, DcWindow);
	_tmp0_ = g_list_store_new (DC_TYPE_CHAT_ENTRY);
	_tmp1_ = _tmp0_;
	dc_window_set_chat_store (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = g_direct_hash;
	_tmp3_ = g_direct_equal;
	_tmp4_ = g_hash_table_new_full (_tmp2_, _tmp3_, NULL, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->views);
	self->priv->views = _tmp4_;
	_tmp5_ = dc_settings_manager_new ();
	_g_object_unref0 (self->settings);
	self->settings = _tmp5_;
	_tmp6_ = dc_image_viewer_new ();
	_g_object_unref0 (self->priv->image_viewer);
	self->priv->image_viewer = _tmp6_;
	_tmp7_ = self->priv->image_viewer;
	dc_image_viewer_set_window (_tmp7_, self);
	dc_window_build_ui (self);
	_tmp8_ = self->settings;
	dc_settings_manager_load (_tmp8_);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, __dc_window___lambda172__gsource_func, g_object_ref (self), g_object_unref);
	return obj;
}

static void
dc_window_class_init (DcWindowClass * klass,
                      gpointer klass_data)
{
	dc_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcWindow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_window_set_property;
	G_OBJECT_CLASS (klass)->constructor = dc_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = dc_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_WINDOW_CHAT_STORE_PROPERTY, dc_window_properties[DC_WINDOW_CHAT_STORE_PROPERTY] = g_param_spec_object ("chat-store", "chat-store", "chat-store", g_list_store_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_WINDOW_CURRENT_CHAT_ID_PROPERTY, dc_window_properties[DC_WINDOW_CURRENT_CHAT_ID_PROPERTY] = g_param_spec_int ("current-chat-id", "current-chat-id", "current-chat-id", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dc_window_instance_init (DcWindow * self,
                         gpointer klass)
{
	self->priv = dc_window_get_instance_private (self);
	self->priv->_current_chat_id = 0;
	self->priv->suppress_reselect_scroll = FALSE;
	self->priv->active_modal = NULL;
}

static void
dc_window_finalize (GObject * obj)
{
	DcWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_WINDOW, DcWindow);
	_g_object_unref0 (self->priv->toast_overlay);
	_g_object_unref0 (self->priv->split_view);
	_g_object_unref0 (self->priv->sidebar_header);
	_g_object_unref0 (self->priv->content_header);
	_g_object_unref0 (self->priv->content_title_label);
	_g_object_unref0 (self->priv->search_entry);
	_g_object_unref0 (self->priv->chat_listbox);
	_g_object_unref0 (self->priv->_chat_store);
	_g_hash_table_unref0 (self->priv->views);
	_g_object_unref0 (self->priv->empty_status);
	_g_object_unref0 (self->priv->content_stack);
	_g_object_unref0 (self->priv->connection_banner);
	_g_object_unref0 (self->priv->connection_banner_label);
	_g_object_unref0 (self->priv->profile_avatar);
	_g_object_unref0 (self->priv->account_popover);
	_g_object_unref0 (self->priv->account_menu_list);
	_g_object_unref0 (self->settings);
	_g_object_unref0 (self->priv->image_viewer);
	_g_object_unref0 (self->priv->events);
	_g_object_unref0 (self->priv->chat_menu);
	_g_object_unref0 (self->priv->active_modal);
	G_OBJECT_CLASS (dc_window_parent_class)->finalize (obj);
}

static GType
dc_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcWindow), 0, (GInstanceInitFunc) dc_window_instance_init, NULL };
	GType dc_window_type_id;
	dc_window_type_id = g_type_register_static (adw_application_window_get_type (), "DcWindow", &g_define_type_info, 0);
	DcWindow_private_offset = g_type_add_instance_private (dc_window_type_id, sizeof (DcWindowPrivate));
	return dc_window_type_id;
}

GType
dc_window_get_type (void)
{
	static volatile gsize dc_window_type_id__once = 0;
	if (g_once_init_enter (&dc_window_type_id__once)) {
		GType dc_window_type_id;
		dc_window_type_id = dc_window_get_type_once ();
		g_once_init_leave (&dc_window_type_id__once, dc_window_type_id);
	}
	return dc_window_type_id__once;
}

static void
_vala_dc_window_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	DcWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_WINDOW, DcWindow);
	switch (property_id) {
		case DC_WINDOW_CHAT_STORE_PROPERTY:
		g_value_set_object (value, dc_window_get_chat_store (self));
		break;
		case DC_WINDOW_CURRENT_CHAT_ID_PROPERTY:
		g_value_set_int (value, dc_window_get_current_chat_id (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_window_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec)
{
	DcWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_WINDOW, DcWindow);
	switch (property_id) {
		case DC_WINDOW_CHAT_STORE_PROPERTY:
		dc_window_set_chat_store (self, g_value_get_object (value));
		break;
		case DC_WINDOW_CURRENT_CHAT_ID_PROPERTY:
		dc_window_set_current_chat_id (self, g_value_get_int (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);
}

