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

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

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

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#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_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;
typedef struct _Block121Data Block121Data;
typedef struct _DcCleanupPendingAccountData DcCleanupPendingAccountData;

#define DC_TYPE_ACCOUNT_PROGRESS_PAGE (dc_account_progress_page_get_type ())
#define DC_ACCOUNT_PROGRESS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_ACCOUNT_PROGRESS_PAGE, DcAccountProgressPage))
#define DC_ACCOUNT_PROGRESS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_ACCOUNT_PROGRESS_PAGE, DcAccountProgressPageClass))
#define DC_IS_ACCOUNT_PROGRESS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_ACCOUNT_PROGRESS_PAGE))
#define DC_IS_ACCOUNT_PROGRESS_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_ACCOUNT_PROGRESS_PAGE))
#define DC_ACCOUNT_PROGRESS_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_ACCOUNT_PROGRESS_PAGE, DcAccountProgressPageClass))

typedef struct _DcAccountProgressPage DcAccountProgressPage;
typedef struct _DcAccountProgressPageClass DcAccountProgressPageClass;
typedef struct _DcAccountProgressPagePrivate DcAccountProgressPagePrivate;
enum  {
	DC_ACCOUNT_PROGRESS_PAGE_0_PROPERTY,
	DC_ACCOUNT_PROGRESS_PAGE_NUM_PROPERTIES
};
static GParamSpec* dc_account_progress_page_properties[DC_ACCOUNT_PROGRESS_PAGE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	DC_ACCOUNT_PROGRESS_PAGE_CANCEL_REQUESTED_SIGNAL,
	DC_ACCOUNT_PROGRESS_PAGE_NUM_SIGNALS
};
static guint dc_account_progress_page_signals[DC_ACCOUNT_PROGRESS_PAGE_NUM_SIGNALS] = {0};

#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 _DcCreateProfileDialogPrivate DcCreateProfileDialogPrivate;

#define DC_TYPE_RELAY_PICKER (dc_relay_picker_get_type ())
#define DC_RELAY_PICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RELAY_PICKER, DcRelayPicker))
#define DC_RELAY_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RELAY_PICKER, DcRelayPickerClass))
#define DC_IS_RELAY_PICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RELAY_PICKER))
#define DC_IS_RELAY_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RELAY_PICKER))
#define DC_RELAY_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RELAY_PICKER, DcRelayPickerClass))

typedef struct _DcRelayPicker DcRelayPicker;
typedef struct _DcRelayPickerClass DcRelayPickerClass;
enum  {
	DC_CREATE_PROFILE_DIALOG_0_PROPERTY,
	DC_CREATE_PROFILE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_create_profile_dialog_properties[DC_CREATE_PROFILE_DIALOG_NUM_PROPERTIES];
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcCreateProfileDialogDoCreateData DcCreateProfileDialogDoCreateData;
enum  {
	DC_CREATE_PROFILE_DIALOG_ACCOUNT_CREATED_SIGNAL,
	DC_CREATE_PROFILE_DIALOG_NUM_SIGNALS
};
static guint dc_create_profile_dialog_signals[DC_CREATE_PROFILE_DIALOG_NUM_SIGNALS] = {0};

#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 _DcInvitationCodeProfileDialogPrivate DcInvitationCodeProfileDialogPrivate;
enum  {
	DC_INVITATION_CODE_PROFILE_DIALOG_0_PROPERTY,
	DC_INVITATION_CODE_PROFILE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_invitation_code_profile_dialog_properties[DC_INVITATION_CODE_PROFILE_DIALOG_NUM_PROPERTIES];
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))

#define DC_TYPE_CHATMAIL_RELAY (dc_chatmail_relay_get_type ())
typedef struct _DcChatmailRelay DcChatmailRelay;
typedef struct _DcInvitationCodeProfileDialogStartCreateData DcInvitationCodeProfileDialogStartCreateData;
typedef struct _DcInvitationCodeProfileDialogFailNewAccountData DcInvitationCodeProfileDialogFailNewAccountData;
enum  {
	DC_INVITATION_CODE_PROFILE_DIALOG_ACCOUNT_CREATED_SIGNAL,
	DC_INVITATION_CODE_PROFILE_DIALOG_NUM_SIGNALS
};
static guint dc_invitation_code_profile_dialog_signals[DC_INVITATION_CODE_PROFILE_DIALOG_NUM_SIGNALS] = {0};

#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 _DcReceiveBackupDialogPrivate DcReceiveBackupDialogPrivate;
enum  {
	DC_RECEIVE_BACKUP_DIALOG_0_PROPERTY,
	DC_RECEIVE_BACKUP_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_receive_backup_dialog_properties[DC_RECEIVE_BACKUP_DIALOG_NUM_PROPERTIES];
typedef struct _DcReceiveBackupDialogStartImportData DcReceiveBackupDialogStartImportData;
enum  {
	DC_RECEIVE_BACKUP_DIALOG_ACCOUNT_IMPORTED_SIGNAL,
	DC_RECEIVE_BACKUP_DIALOG_NUM_SIGNALS
};
static guint dc_receive_backup_dialog_signals[DC_RECEIVE_BACKUP_DIALOG_NUM_SIGNALS] = {0};

struct _Block121Data {
	int _ref_count_;
	DcRpcClient* rpc;
};

struct _DcCleanupPendingAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcRpcClient* rpc;
	gint account_id;
	gboolean stop_first;
	GError* _inner_error0_;
};

struct _DcAccountProgressPage {
	GtkBox parent_instance;
	DcAccountProgressPagePrivate * priv;
};

struct _DcAccountProgressPageClass {
	GtkBoxClass parent_class;
};

struct _DcAccountProgressPagePrivate {
	GtkProgressBar* progress_bar;
	GtkLabel* progress_label;
	GtkLabel* status_label;
};

struct _DcCreateProfileDialog {
	AdwDialog parent_instance;
	DcCreateProfileDialogPrivate * priv;
};

struct _DcCreateProfileDialogClass {
	AdwDialogClass parent_class;
};

struct _DcCreateProfileDialogPrivate {
	DcRpcClient* rpc;
	DcEventHandler* events;
	GtkStack* stack;
	GtkEntry* name_entry;
	DcRelayPicker* relay_picker;
	GtkButton* create_btn;
	DcAccountProgressPage* progress_page;
	gint new_account_id;
	gboolean create_running;
	gboolean create_finished;
	gboolean cancelled;
	gulong progress_handler_id;
};

struct _DcCreateProfileDialogDoCreateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcCreateProfileDialog* self;
	gchar* display_name;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* domain;
	DcRelayPicker* _tmp4_;
	gchar* _tmp5_;
	gchar* qr_link;
	DcRelayPicker* _tmp6_;
	gchar* _tmp7_;
	GtkStack* _tmp8_;
	DcAccountProgressPage* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	DcEventHandler* _tmp13_;
	gulong _tmp14_;
	gint _tmp15_;
	DcRpcClient* _tmp16_;
	GError* e;
	GError* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	gint _tmp22_;
	gint _tmp23_;
	DcRpcClient* _tmp24_;
	const gchar* _tmp25_;
	DcRpcClient* _tmp26_;
	const gchar* _tmp27_;
	GError* _vala1_e;
	gint aid;
	DcRpcClient* _tmp28_;
	GError* _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gint created;
	GError* _inner_error0_;
};

struct _DcInvitationCodeProfileDialog {
	AdwDialog parent_instance;
	DcInvitationCodeProfileDialogPrivate * priv;
};

struct _DcInvitationCodeProfileDialogClass {
	AdwDialogClass parent_class;
};

struct _DcInvitationCodeProfileDialogPrivate {
	DcRpcClient* rpc;
	DcEventHandler* events;
	GtkStack* stack;
	GtkEntry* invite_entry;
	GtkButton* start_btn;
	DcAccountProgressPage* progress_page;
	gint new_account_id;
	gboolean create_running;
	gboolean create_finished;
	gulong progress_handler_id;
};

struct _DcChatmailRelay {
	const gchar* domain;
	const gchar* location;
};

struct _DcInvitationCodeProfileDialogStartCreateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcInvitationCodeProfileDialog* self;
	gchar* invite_link;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	GtkStack* _tmp7_;
	DcAccountProgressPage* _tmp8_;
	DcEventHandler* _tmp9_;
	gulong _tmp10_;
	gint _tmp11_;
	DcRpcClient* _tmp12_;
	GError* e;
	GError* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	JsonObject* qr;
	JsonObject* _tmp17_;
	DcRpcClient* _tmp18_;
	const gchar* _tmp19_;
	JsonObject* _tmp20_;
	JsonObject* _tmp21_;
	GError* _vala1_e;
	GError* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gboolean _tmp26_;
	JsonObject* _tmp27_;
	JsonObject* _tmp28_;
	gchar* kind;
	JsonObject* _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_;
	gint chat_id;
	gboolean _tmp32_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	DcAccountProgressPage* _tmp35_;
	DcRpcClient* _tmp36_;
	const gchar* _tmp37_;
	GError* _vala2_e;
	GError* _tmp38_;
	const gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	gboolean _tmp42_;
	gboolean _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	const gchar* _tmp46_;
	DcAccountProgressPage* _tmp47_;
	DcRpcClient* _tmp48_;
	DcChatmailRelay _tmp49_;
	const gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	DcAccountProgressPage* _tmp53_;
	gint _tmp54_;
	DcRpcClient* _tmp55_;
	const gchar* _tmp56_;
	GError* _vala3_e;
	GError* _tmp57_;
	const gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	gint created;
	GError* _inner_error0_;
};

struct _DcInvitationCodeProfileDialogFailNewAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcInvitationCodeProfileDialog* self;
	gchar* message;
	gint aid;
	DcRpcClient* _tmp0_;
};

struct _DcReceiveBackupDialog {
	AdwDialog parent_instance;
	DcReceiveBackupDialogPrivate * priv;
};

struct _DcReceiveBackupDialogClass {
	AdwDialogClass parent_class;
};

struct _DcReceiveBackupDialogPrivate {
	DcRpcClient* rpc;
	DcEventHandler* events;
	GtkStack* stack;
	GtkEntry* url_entry;
	GtkButton* start_btn;
	DcAccountProgressPage* progress_page;
	gint new_account_id;
	gboolean import_running;
	gboolean import_finished;
	gulong progress_handler_id;
};

struct _DcReceiveBackupDialogStartImportData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcReceiveBackupDialog* self;
	gchar* qr;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	GtkStack* _tmp7_;
	DcEventHandler* _tmp8_;
	gulong _tmp9_;
	gint _tmp10_;
	DcRpcClient* _tmp11_;
	GError* e;
	GError* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	DcRpcClient* _tmp16_;
	const gchar* _tmp17_;
	GError* _vala1_e;
	DcRpcClient* _tmp18_;
	GError* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gint imported;
	GError* _inner_error0_;
};

static gint DcAccountProgressPage_private_offset;
static gpointer dc_account_progress_page_parent_class = NULL;
static gint DcCreateProfileDialog_private_offset;
static gpointer dc_create_profile_dialog_parent_class = NULL;
static gint DcInvitationCodeProfileDialog_private_offset;
static gpointer dc_invitation_code_profile_dialog_parent_class = NULL;
static gint DcReceiveBackupDialog_private_offset;
static gpointer dc_receive_backup_dialog_parent_class = NULL;

VALA_EXTERN GtkBox* dc_account_setup_content (void);
VALA_EXTERN GtkLabel* dc_account_setup_intro (const gchar* text);
VALA_EXTERN GtkLabel* dc_account_setup_heading (const gchar* text);
VALA_EXTERN GtkBox* dc_account_setup_action_row (gboolean with_margin);
VALA_EXTERN GtkStack* dc_account_setup_stack (GtkWidget* input_page,
                                  GtkWidget* progress_page);
VALA_EXTERN GtkBox* dc_account_setup_shell (GtkStack* stack);
VALA_EXTERN GtkStack* dc_account_setup_dialog (AdwDialog* dialog,
                                   const gchar* title,
                                   GtkWidget* input_page,
                                   GtkWidget* progress_page);
VALA_EXTERN void dc_install_escape_close (AdwDialog* dialog);
VALA_EXTERN GtkButton* dc_account_setup_action (GtkBox* content,
                                    const gchar* label,
                                    gboolean with_margin);
VALA_EXTERN GtkEntry* dc_account_setup_entry (const gchar* placeholder,
                                  gboolean hexpand,
                                  GtkInputPurpose purpose);
VALA_EXTERN GType dc_event_handler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcEventHandler, g_object_unref)
VALA_EXTERN void dc_disconnect_progress_handler (DcEventHandler* events,
                                     gulong* handler_id);
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
VALA_EXTERN void dc_stop_ongoing_account (DcRpcClient* rpc,
                              gint account_id);
static Block121Data* block121_data_ref (Block121Data* _data121_);
static void block121_data_unref (void * _userdata_);
VALA_EXTERN void dc_rpc_client_stop_ongoing_process (DcRpcClient* self,
                                         gint acct_id,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_stop_ongoing_process_finish (DcRpcClient* self,
                                                GAsyncResult* _res_,
                                                GError** error);
static void __lambda150_ (Block121Data* _data121_,
                   GObject* obj,
                   GAsyncResult* res);
static void ___lambda150__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void dc_cleanup_pending_account_data_free (gpointer _data);
VALA_EXTERN void dc_cleanup_pending_account (DcRpcClient* rpc,
                                 gint account_id,
                                 gboolean stop_first,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN void dc_cleanup_pending_account_finish (GAsyncResult* _res_);
static gboolean dc_cleanup_pending_account_co (DcCleanupPendingAccountData* _data_);
static void dc_cleanup_pending_account_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_remove_account (DcRpcClient* self,
                                   gint acct_id,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_remove_account_finish (DcRpcClient* self,
                                          GAsyncResult* _res_,
                                          GError** error);
VALA_EXTERN void dc_cleanup_unfinished_account (DcRpcClient* rpc,
                                    gint* account_id,
                                    gboolean finished);
VALA_EXTERN gboolean dc_close_if_idle (AdwDialog* dialog,
                           gboolean running);
VALA_EXTERN GType dc_account_progress_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcAccountProgressPage, g_object_unref)
VALA_EXTERN DcAccountProgressPage* dc_account_progress_page_new (const gchar* initial_status,
                                                     gboolean wrap_status);
VALA_EXTERN DcAccountProgressPage* dc_account_progress_page_construct (GType object_type,
                                                           const gchar* initial_status,
                                                           gboolean wrap_status);
static void __lambda147_ (DcAccountProgressPage* self);
static void ___lambda147__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN void dc_account_progress_page_set_status (DcAccountProgressPage* self,
                                          const gchar* status);
VALA_EXTERN void dc_account_progress_page_set_permille (DcAccountProgressPage* self,
                                            gint progress,
                                            const gchar* comment,
                                            const gchar* active_status);
static void dc_account_progress_page_finalize (GObject * obj);
static GType dc_account_progress_page_get_type_once (void);
VALA_EXTERN GType dc_create_profile_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcCreateProfileDialog, g_object_unref)
VALA_EXTERN GType dc_relay_picker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRelayPicker, 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 GtkWidget* dc_create_profile_dialog_build_input_page (DcCreateProfileDialog* self);
static GtkWidget* dc_create_profile_dialog_build_progress_page (DcCreateProfileDialog* self);
static void dc_create_profile_dialog_on_dialog_closed (DcCreateProfileDialog* self);
static void _dc_create_profile_dialog_on_dialog_closed_adw_dialog_closed (AdwDialog* _sender,
                                                                   gpointer self);
VALA_EXTERN DcRelayPicker* dc_relay_picker_new (DcRpcClient* rpc);
VALA_EXTERN DcRelayPicker* dc_relay_picker_construct (GType object_type,
                                          DcRpcClient* rpc);
static void __lambda308_ (DcCreateProfileDialog* self);
static void dc_create_profile_dialog_do_create (DcCreateProfileDialog* self,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
static void dc_create_profile_dialog_do_create_finish (DcCreateProfileDialog* self,
                                                GAsyncResult* _res_);
static void ___lambda308__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_create_profile_dialog_cancel_create (DcCreateProfileDialog* self);
static void _dc_create_profile_dialog_cancel_create_dc_account_progress_page_cancel_requested (DcAccountProgressPage* _sender,
                                                                                        gpointer self);
static void dc_create_profile_dialog_do_create_data_free (gpointer _data);
static gboolean dc_create_profile_dialog_do_create_co (DcCreateProfileDialogDoCreateData* _data_);
VALA_EXTERN gchar* dc_relay_picker_get_selected_domain (DcRelayPicker* self);
VALA_EXTERN gchar* dc_relay_picker_get_chatmail_qr (DcRelayPicker* self);
static void dc_create_profile_dialog_on_configure_progress (DcCreateProfileDialog* self,
                                                     gint ctx,
                                                     gint progress,
                                                     const gchar* comment);
static void _dc_create_profile_dialog_on_configure_progress_dc_event_handler_configure_progress (DcEventHandler* _sender,
                                                                                          gint context_id,
                                                                                          gint progress,
                                                                                          const gchar* comment,
                                                                                          gpointer self);
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_create_profile_dialog_do_create_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static void dc_create_profile_dialog_cleanup_signal (DcCreateProfileDialog* self);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
VALA_EXTERN void dc_rpc_client_batch_set_config (DcRpcClient* self,
                                     const gchar* key,
                                     const gchar* val,
                                     gint acct_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_batch_set_config_finish (DcRpcClient* self,
                                            GAsyncResult* _res_,
                                            GError** error);
VALA_EXTERN void dc_rpc_client_add_transport_from_qr (DcRpcClient* self,
                                          gint acct_id,
                                          const gchar* qr_text,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_add_transport_from_qr_finish (DcRpcClient* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
static void dc_create_profile_dialog_finalize (GObject * obj);
static GType dc_create_profile_dialog_get_type_once (void);
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 GtkWidget* dc_invitation_code_profile_dialog_build_input_page (DcInvitationCodeProfileDialog* self);
static GtkWidget* dc_invitation_code_profile_dialog_build_progress_page (DcInvitationCodeProfileDialog* self);
static void dc_invitation_code_profile_dialog_on_dialog_closed (DcInvitationCodeProfileDialog* self);
static void _dc_invitation_code_profile_dialog_on_dialog_closed_adw_dialog_closed (AdwDialog* _sender,
                                                                            gpointer self);
static void dc_invitation_code_profile_dialog_update_start_sensitivity (DcInvitationCodeProfileDialog* self);
static void _dc_invitation_code_profile_dialog_update_start_sensitivity_gtk_editable_changed (GtkEditable* _sender,
                                                                                       gpointer self);
static void __lambda310_ (DcInvitationCodeProfileDialog* self);
static void dc_invitation_code_profile_dialog_start_create (DcInvitationCodeProfileDialog* self,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static void dc_invitation_code_profile_dialog_start_create_finish (DcInvitationCodeProfileDialog* self,
                                                            GAsyncResult* _res_);
static void ___lambda310__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_invitation_code_profile_dialog_cancel_create (DcInvitationCodeProfileDialog* self);
static void _dc_invitation_code_profile_dialog_cancel_create_dc_account_progress_page_cancel_requested (DcAccountProgressPage* _sender,
                                                                                                 gpointer self);
static void dc_invitation_code_profile_dialog_start_create_data_free (gpointer _data);
static gboolean dc_invitation_code_profile_dialog_start_create_co (DcInvitationCodeProfileDialogStartCreateData* _data_);
static void dc_invitation_code_profile_dialog_on_configure_progress (DcInvitationCodeProfileDialog* self,
                                                              gint ctx,
                                                              gint progress,
                                                              const gchar* comment);
static void _dc_invitation_code_profile_dialog_on_configure_progress_dc_event_handler_configure_progress (DcEventHandler* _sender,
                                                                                                   gint context_id,
                                                                                                   gint progress,
                                                                                                   const gchar* comment,
                                                                                                   gpointer self);
static void dc_invitation_code_profile_dialog_start_create_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
static void dc_invitation_code_profile_dialog_cleanup_signal (DcInvitationCodeProfileDialog* self);
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_invitation_code_profile_dialog_fail_new_account (DcInvitationCodeProfileDialog* self,
                                                         const gchar* message,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static void dc_invitation_code_profile_dialog_fail_new_account_finish (DcInvitationCodeProfileDialog* self,
                                                                GAsyncResult* _res_);
VALA_EXTERN gchar* dc_build_chatmail_qr (const gchar* domain);
VALA_EXTERN GType dc_chatmail_relay_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DcChatmailRelay* dc_chatmail_relay_dup (const DcChatmailRelay* self);
VALA_EXTERN void dc_chatmail_relay_free (DcChatmailRelay* self);
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);
static void dc_invitation_code_profile_dialog_fail_new_account_data_free (gpointer _data);
static gboolean dc_invitation_code_profile_dialog_fail_new_account_co (DcInvitationCodeProfileDialogFailNewAccountData* _data_);
static void dc_invitation_code_profile_dialog_fail_new_account_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_);
static void g_cclosure_user_marshal_VOID__INT_INT (GClosure * closure,
                                            GValue * return_value,
                                            guint n_param_values,
                                            const GValue * param_values,
                                            gpointer invocation_hint,
                                            gpointer marshal_data);
static void dc_invitation_code_profile_dialog_finalize (GObject * obj);
static GType dc_invitation_code_profile_dialog_get_type_once (void);
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 GtkWidget* dc_receive_backup_dialog_build_input_page (DcReceiveBackupDialog* self);
static GtkWidget* dc_receive_backup_dialog_build_progress_page (DcReceiveBackupDialog* self);
static void dc_receive_backup_dialog_on_dialog_closed (DcReceiveBackupDialog* self);
static void _dc_receive_backup_dialog_on_dialog_closed_adw_dialog_closed (AdwDialog* _sender,
                                                                   gpointer self);
static void dc_receive_backup_dialog_update_start_sensitivity (DcReceiveBackupDialog* self);
static void _dc_receive_backup_dialog_update_start_sensitivity_gtk_editable_changed (GtkEditable* _sender,
                                                                              gpointer self);
static void __lambda306_ (DcReceiveBackupDialog* self);
static void dc_receive_backup_dialog_start_import (DcReceiveBackupDialog* self,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
static void dc_receive_backup_dialog_start_import_finish (DcReceiveBackupDialog* self,
                                                   GAsyncResult* _res_);
static void ___lambda306__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_receive_backup_dialog_cancel_import (DcReceiveBackupDialog* self);
static void _dc_receive_backup_dialog_cancel_import_dc_account_progress_page_cancel_requested (DcAccountProgressPage* _sender,
                                                                                        gpointer self);
static void dc_receive_backup_dialog_start_import_data_free (gpointer _data);
static gboolean dc_receive_backup_dialog_start_import_co (DcReceiveBackupDialogStartImportData* _data_);
static void dc_receive_backup_dialog_on_imex_progress (DcReceiveBackupDialog* self,
                                                gint ctx,
                                                gint progress);
static void _dc_receive_backup_dialog_on_imex_progress_dc_event_handler_imex_progress (DcEventHandler* _sender,
                                                                                gint context_id,
                                                                                gint progress,
                                                                                gpointer self);
static void dc_receive_backup_dialog_start_import_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void dc_receive_backup_dialog_cleanup_signal (DcReceiveBackupDialog* self);
VALA_EXTERN void dc_rpc_client_get_backup (DcRpcClient* self,
                               gint acct_id,
                               const gchar* qr_text,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_get_backup_finish (DcRpcClient* self,
                                      GAsyncResult* _res_,
                                      GError** error);
static void dc_receive_backup_dialog_finalize (GObject * obj);
static GType dc_receive_backup_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

VALA_EXTERN const DcChatmailRelay DC_CHATMAIL_RELAYS[26];

GtkBox*
dc_account_setup_content (void)
{
	GtkBox* content = NULL;
	GtkBox* _tmp0_;
	GtkBox* result;
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp0_);
	content = _tmp0_;
	gtk_widget_set_margin_end ((GtkWidget*) content, 18);
	gtk_widget_set_margin_start ((GtkWidget*) content, 18);
	gtk_widget_set_margin_top ((GtkWidget*) content, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) content, 18);
	result = content;
	return result;
}

GtkLabel*
dc_account_setup_intro (const gchar* text)
{
	GtkLabel* intro = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* result;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (text);
	g_object_ref_sink (_tmp0_);
	intro = _tmp0_;
	gtk_label_set_wrap (intro, TRUE);
	gtk_label_set_xalign (intro, (gfloat) 0);
	gtk_widget_add_css_class ((GtkWidget*) intro, "dim-label");
	result = intro;
	return result;
}

GtkLabel*
dc_account_setup_heading (const gchar* text)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* result;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (text);
	g_object_ref_sink (_tmp0_);
	label = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) label, "heading");
	gtk_label_set_xalign (label, (gfloat) 0);
	result = label;
	return result;
}

GtkBox*
dc_account_setup_action_row (gboolean with_margin)
{
	GtkBox* row = NULL;
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkBox* result;
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	_tmp1_ = row;
	gtk_widget_set_halign ((GtkWidget*) _tmp1_, GTK_ALIGN_END);
	if (with_margin) {
		GtkBox* _tmp2_;
		_tmp2_ = row;
		gtk_widget_set_margin_top ((GtkWidget*) _tmp2_, 6);
	}
	result = row;
	return result;
}

GtkStack*
dc_account_setup_stack (GtkWidget* input_page,
                        GtkWidget* progress_page)
{
	GtkStack* stack = NULL;
	GtkStack* _tmp0_;
	GtkStack* result;
	g_return_val_if_fail (input_page != NULL, NULL);
	g_return_val_if_fail (progress_page != NULL, NULL);
	_tmp0_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp0_);
	stack = _tmp0_;
	gtk_stack_set_transition_type (stack, GTK_STACK_TRANSITION_TYPE_CROSSFADE);
	gtk_stack_set_transition_duration (stack, (guint) 180);
	gtk_widget_set_vexpand ((GtkWidget*) stack, TRUE);
	gtk_stack_add_named (stack, input_page, "input");
	gtk_stack_add_named (stack, progress_page, "progress");
	result = stack;
	return result;
}

GtkBox*
dc_account_setup_shell (GtkStack* stack)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	AdwHeaderBar* _tmp1_;
	AdwHeaderBar* _tmp2_;
	GtkBox* result;
	g_return_val_if_fail (stack != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	gtk_box_append (box, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	gtk_box_append (box, (GtkWidget*) stack);
	result = box;
	return result;
}

GtkStack*
dc_account_setup_dialog (AdwDialog* dialog,
                         const gchar* title,
                         GtkWidget* input_page,
                         GtkWidget* progress_page)
{
	GtkStack* stack = NULL;
	GtkStack* _tmp0_;
	GtkBox* _tmp1_;
	GtkBox* _tmp2_;
	GtkStack* result;
	g_return_val_if_fail (dialog != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (input_page != NULL, NULL);
	g_return_val_if_fail (progress_page != NULL, NULL);
	adw_dialog_set_title (dialog, title);
	adw_dialog_set_content_width (dialog, 480);
	adw_dialog_set_can_close (dialog, TRUE);
	_tmp0_ = dc_account_setup_stack (input_page, progress_page);
	stack = _tmp0_;
	_tmp1_ = dc_account_setup_shell (stack);
	_tmp2_ = _tmp1_;
	adw_dialog_set_child (dialog, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	dc_install_escape_close (dialog);
	result = stack;
	return result;
}

GtkButton*
dc_account_setup_action (GtkBox* content,
                         const gchar* label,
                         gboolean with_margin)
{
	GtkBox* row = NULL;
	GtkBox* _tmp0_;
	GtkButton* button = NULL;
	GtkButton* _tmp1_;
	GtkButton* result;
	g_return_val_if_fail (content != NULL, NULL);
	g_return_val_if_fail (label != NULL, NULL);
	_tmp0_ = dc_account_setup_action_row (with_margin);
	row = _tmp0_;
	_tmp1_ = (GtkButton*) gtk_button_new_with_label (label);
	g_object_ref_sink (_tmp1_);
	button = _tmp1_;
	gtk_widget_add_css_class ((GtkWidget*) button, "suggested-action");
	gtk_box_append (row, (GtkWidget*) button);
	gtk_box_append (content, (GtkWidget*) row);
	result = button;
	_g_object_unref0 (row);
	return result;
}

GtkEntry*
dc_account_setup_entry (const gchar* placeholder,
                        gboolean hexpand,
                        GtkInputPurpose purpose)
{
	GtkEntry* entry = NULL;
	GtkEntry* _tmp0_;
	GtkEntry* result;
	g_return_val_if_fail (placeholder != NULL, NULL);
	_tmp0_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp0_);
	entry = _tmp0_;
	gtk_entry_set_placeholder_text (entry, placeholder);
	gtk_entry_set_input_purpose (entry, purpose);
	gtk_widget_set_hexpand ((GtkWidget*) entry, hexpand);
	gtk_entry_set_activates_default (entry, TRUE);
	result = entry;
	return result;
}

void
dc_disconnect_progress_handler (DcEventHandler* events,
                                gulong* handler_id)
{
	g_return_if_fail (events != NULL);
	if ((*handler_id) == ((gulong) 0)) {
		return;
	}
	g_signal_handler_disconnect ((GObject*) events, *handler_id);
	*handler_id = (gulong) 0;
}

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

static Block121Data*
block121_data_ref (Block121Data* _data121_)
{
	g_atomic_int_inc (&_data121_->_ref_count_);
	return _data121_;
}

static void
block121_data_unref (void * _userdata_)
{
	Block121Data* _data121_;
	_data121_ = (Block121Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data121_->_ref_count_)) {
		_g_object_unref0 (_data121_->rpc);
		g_slice_free (Block121Data, _data121_);
	}
}

static void
__lambda150_ (Block121Data* _data121_,
              GObject* obj,
              GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		dc_rpc_client_stop_ongoing_process_finish (_data121_->rpc, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda150__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda150_ (self, source_object, res);
	block121_data_unref (self);
}

void
dc_stop_ongoing_account (DcRpcClient* rpc,
                         gint account_id)
{
	Block121Data* _data121_;
	DcRpcClient* _tmp0_;
	g_return_if_fail (rpc != NULL);
	_data121_ = g_slice_new0 (Block121Data);
	_data121_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (_data121_->rpc);
	_data121_->rpc = _tmp0_;
	if (account_id <= 0) {
		block121_data_unref (_data121_);
		_data121_ = NULL;
		return;
	}
	dc_rpc_client_stop_ongoing_process (_data121_->rpc, account_id, ___lambda150__gasync_ready_callback, block121_data_ref (_data121_));
	block121_data_unref (_data121_);
	_data121_ = NULL;
}

static void
dc_cleanup_pending_account_data_free (gpointer _data)
{
	DcCleanupPendingAccountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->rpc);
	g_slice_free (DcCleanupPendingAccountData, _data_);
}

void
dc_cleanup_pending_account (DcRpcClient* rpc,
                            gint account_id,
                            gboolean stop_first,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_)
{
	DcCleanupPendingAccountData* _data_;
	DcRpcClient* _tmp0_;
	g_return_if_fail (rpc != NULL);
	_data_ = g_slice_new0 (DcCleanupPendingAccountData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_cleanup_pending_account_data_free);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (_data_->rpc);
	_data_->rpc = _tmp0_;
	_data_->account_id = account_id;
	_data_->stop_first = stop_first;
	dc_cleanup_pending_account_co (_data_);
}

void
dc_cleanup_pending_account_finish (GAsyncResult* _res_)
{
	DcCleanupPendingAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_cleanup_pending_account_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	DcCleanupPendingAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_cleanup_pending_account_co (_data_);
}

static gboolean
dc_cleanup_pending_account_co (DcCleanupPendingAccountData* _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:
	if (_data_->account_id <= 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;
	}
	if (_data_->stop_first) {
		{
			_data_->_state_ = 1;
			dc_rpc_client_stop_ongoing_process (_data_->rpc, _data_->account_id, dc_cleanup_pending_account_ready, _data_);
			return FALSE;
			_state_1:
			dc_rpc_client_stop_ongoing_process_finish (_data_->rpc, _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;
		}
	}
	{
		_data_->_state_ = 2;
		dc_rpc_client_remove_account (_data_->rpc, _data_->account_id, dc_cleanup_pending_account_ready, _data_);
		return FALSE;
		_state_2:
		dc_rpc_client_remove_account_finish (_data_->rpc, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally1:
	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_cleanup_unfinished_account (DcRpcClient* rpc,
                               gint* account_id,
                               gboolean finished)
{
	gboolean _tmp0_ = FALSE;
	gint aid = 0;
	g_return_if_fail (rpc != NULL);
	if (finished) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = (*account_id) <= 0;
	}
	if (_tmp0_) {
		return;
	}
	aid = *account_id;
	*account_id = 0;
	dc_cleanup_pending_account (rpc, aid, TRUE, NULL, NULL);
}

gboolean
dc_close_if_idle (AdwDialog* dialog,
                  gboolean running)
{
	gboolean result;
	g_return_val_if_fail (dialog != NULL, FALSE);
	if (running) {
		result = FALSE;
		return result;
	}
	adw_dialog_close (dialog);
	result = TRUE;
	return result;
}

static inline gpointer
dc_account_progress_page_get_instance_private (DcAccountProgressPage* self)
{
	return G_STRUCT_MEMBER_P (self, DcAccountProgressPage_private_offset);
}

static void
__lambda147_ (DcAccountProgressPage* self)
{
	g_signal_emit (self, dc_account_progress_page_signals[DC_ACCOUNT_PROGRESS_PAGE_CANCEL_REQUESTED_SIGNAL], 0);
}

static void
___lambda147__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda147_ ((DcAccountProgressPage*) self);
}

DcAccountProgressPage*
dc_account_progress_page_construct (GType object_type,
                                    const gchar* initial_status,
                                    gboolean wrap_status)
{
	DcAccountProgressPage * self = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkProgressBar* _tmp4_;
	GtkProgressBar* _tmp5_;
	GtkProgressBar* _tmp6_;
	GtkProgressBar* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkBox* actions = NULL;
	GtkBox* _tmp12_;
	GtkButton* cancel_btn = NULL;
	GtkButton* _tmp13_;
	g_return_val_if_fail (initial_status != NULL, NULL);
	self = (DcAccountProgressPage*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 12, NULL);
	gtk_widget_set_margin_end ((GtkWidget*) self, 18);
	gtk_widget_set_margin_start ((GtkWidget*) self, 18);
	gtk_widget_set_margin_top ((GtkWidget*) self, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 18);
	gtk_widget_set_valign ((GtkWidget*) self, GTK_ALIGN_CENTER);
	_tmp0_ = (GtkLabel*) gtk_label_new (initial_status);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->status_label);
	self->priv->status_label = _tmp0_;
	_tmp1_ = self->priv->status_label;
	gtk_label_set_xalign (_tmp1_, (gfloat) 0);
	_tmp2_ = self->priv->status_label;
	gtk_label_set_wrap (_tmp2_, wrap_status);
	_tmp3_ = self->priv->status_label;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp3_);
	_tmp4_ = (GtkProgressBar*) gtk_progress_bar_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->progress_bar);
	self->priv->progress_bar = _tmp4_;
	_tmp5_ = self->priv->progress_bar;
	gtk_progress_bar_set_fraction (_tmp5_, 0.0);
	_tmp6_ = self->priv->progress_bar;
	gtk_progress_bar_set_show_text (_tmp6_, FALSE);
	_tmp7_ = self->priv->progress_bar;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp7_);
	_tmp8_ = (GtkLabel*) gtk_label_new ("0 %");
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->progress_label);
	self->priv->progress_label = _tmp8_;
	_tmp9_ = self->priv->progress_label;
	gtk_label_set_xalign (_tmp9_, (gfloat) 0);
	_tmp10_ = self->priv->progress_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp10_, "dim-label");
	_tmp11_ = self->priv->progress_label;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp11_);
	_tmp12_ = dc_account_setup_action_row (TRUE);
	actions = _tmp12_;
	_tmp13_ = (GtkButton*) gtk_button_new_with_label ("Cancel");
	g_object_ref_sink (_tmp13_);
	cancel_btn = _tmp13_;
	gtk_widget_add_css_class ((GtkWidget*) cancel_btn, "destructive-action");
	g_signal_connect_object (cancel_btn, "clicked", (GCallback) ___lambda147__gtk_button_clicked, self, 0);
	gtk_box_append (actions, (GtkWidget*) cancel_btn);
	gtk_box_append ((GtkBox*) self, (GtkWidget*) actions);
	_g_object_unref0 (cancel_btn);
	_g_object_unref0 (actions);
	return self;
}

DcAccountProgressPage*
dc_account_progress_page_new (const gchar* initial_status,
                              gboolean wrap_status)
{
	return dc_account_progress_page_construct (DC_TYPE_ACCOUNT_PROGRESS_PAGE, initial_status, wrap_status);
}

void
dc_account_progress_page_set_status (DcAccountProgressPage* self,
                                     const gchar* status)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (status != NULL);
	_tmp0_ = self->priv->status_label;
	gtk_label_set_label (_tmp0_, status);
}

void
dc_account_progress_page_set_permille (DcAccountProgressPage* self,
                                       gint progress,
                                       const gchar* comment,
                                       const gchar* active_status)
{
	gdouble fraction = 0.0;
	GtkProgressBar* _tmp1_;
	GtkLabel* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	g_return_if_fail (self != NULL);
	if (progress == 0) {
		const gchar* _tmp0_ = NULL;
		_tmp0_ = comment;
		if (_tmp0_ == NULL) {
			_tmp0_ = "Failed";
		}
		dc_account_progress_page_set_status (self, _tmp0_);
		return;
	}
	fraction = ((gdouble) progress) / 1000.0;
	if (fraction > 1.0) {
		fraction = 1.0;
	}
	_tmp1_ = self->priv->progress_bar;
	gtk_progress_bar_set_fraction (_tmp1_, fraction);
	_tmp2_ = self->priv->progress_label;
	_tmp3_ = g_strdup_printf ("%d %%", (gint) (fraction * 100));
	_tmp4_ = _tmp3_;
	gtk_label_set_label (_tmp2_, _tmp4_);
	_g_free0 (_tmp4_);
	if (comment != NULL) {
		gint _tmp6_;
		gint _tmp7_;
		_tmp6_ = strlen (comment);
		_tmp7_ = _tmp6_;
		_tmp5_ = _tmp7_ > 0;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		dc_account_progress_page_set_status (self, comment);
	} else {
		if (progress >= 1000) {
			dc_account_progress_page_set_status (self, "Finishing…");
		} else {
			if (active_status != NULL) {
				dc_account_progress_page_set_status (self, active_status);
			}
		}
	}
}

static void
dc_account_progress_page_class_init (DcAccountProgressPageClass * klass,
                                     gpointer klass_data)
{
	dc_account_progress_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcAccountProgressPage_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_account_progress_page_finalize;
	dc_account_progress_page_signals[DC_ACCOUNT_PROGRESS_PAGE_CANCEL_REQUESTED_SIGNAL] = g_signal_new ("cancel-requested", DC_TYPE_ACCOUNT_PROGRESS_PAGE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
dc_account_progress_page_instance_init (DcAccountProgressPage * self,
                                        gpointer klass)
{
	self->priv = dc_account_progress_page_get_instance_private (self);
}

static void
dc_account_progress_page_finalize (GObject * obj)
{
	DcAccountProgressPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_ACCOUNT_PROGRESS_PAGE, DcAccountProgressPage);
	_g_object_unref0 (self->priv->progress_bar);
	_g_object_unref0 (self->priv->progress_label);
	_g_object_unref0 (self->priv->status_label);
	G_OBJECT_CLASS (dc_account_progress_page_parent_class)->finalize (obj);
}

static GType
dc_account_progress_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcAccountProgressPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_account_progress_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcAccountProgressPage), 0, (GInstanceInitFunc) dc_account_progress_page_instance_init, NULL };
	GType dc_account_progress_page_type_id;
	dc_account_progress_page_type_id = g_type_register_static (gtk_box_get_type (), "DcAccountProgressPage", &g_define_type_info, 0);
	DcAccountProgressPage_private_offset = g_type_add_instance_private (dc_account_progress_page_type_id, sizeof (DcAccountProgressPagePrivate));
	return dc_account_progress_page_type_id;
}

GType
dc_account_progress_page_get_type (void)
{
	static volatile gsize dc_account_progress_page_type_id__once = 0;
	if (g_once_init_enter (&dc_account_progress_page_type_id__once)) {
		GType dc_account_progress_page_type_id;
		dc_account_progress_page_type_id = dc_account_progress_page_get_type_once ();
		g_once_init_leave (&dc_account_progress_page_type_id__once, dc_account_progress_page_type_id);
	}
	return dc_account_progress_page_type_id__once;
}

static inline gpointer
dc_create_profile_dialog_get_instance_private (DcCreateProfileDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcCreateProfileDialog_private_offset);
}

static void
_dc_create_profile_dialog_on_dialog_closed_adw_dialog_closed (AdwDialog* _sender,
                                                              gpointer self)
{
	dc_create_profile_dialog_on_dialog_closed ((DcCreateProfileDialog*) self);
}

DcCreateProfileDialog*
dc_create_profile_dialog_construct (GType object_type,
                                    DcRpcClient* rpc,
                                    DcEventHandler* events)
{
	DcCreateProfileDialog * self = NULL;
	DcRpcClient* _tmp0_;
	DcEventHandler* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	GtkStack* _tmp6_;
	g_return_val_if_fail (rpc != NULL, NULL);
	g_return_val_if_fail (events != NULL, NULL);
	self = (DcCreateProfileDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	_tmp1_ = _g_object_ref0 (events);
	_g_object_unref0 (self->priv->events);
	self->priv->events = _tmp1_;
	_tmp2_ = dc_create_profile_dialog_build_input_page (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = dc_create_profile_dialog_build_progress_page (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = dc_account_setup_dialog ((AdwDialog*) self, "Create New Profile", _tmp3_, _tmp5_);
	_g_object_unref0 (self->priv->stack);
	self->priv->stack = _tmp6_;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) _dc_create_profile_dialog_on_dialog_closed_adw_dialog_closed, self, 0);
	return self;
}

DcCreateProfileDialog*
dc_create_profile_dialog_new (DcRpcClient* rpc,
                              DcEventHandler* events)
{
	return dc_create_profile_dialog_construct (DC_TYPE_CREATE_PROFILE_DIALOG, rpc, events);
}

static void
__lambda308_ (DcCreateProfileDialog* self)
{
	dc_create_profile_dialog_do_create (self, NULL, NULL);
}

static void
___lambda308__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda308_ ((DcCreateProfileDialog*) self);
}

static GtkWidget*
dc_create_profile_dialog_build_input_page (DcCreateProfileDialog* self)
{
	GtkBox* content = NULL;
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkEntry* _tmp5_;
	GtkEntry* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	DcRpcClient* _tmp9_;
	DcRelayPicker* _tmp10_;
	DcRelayPicker* _tmp11_;
	GtkLabel* hint = NULL;
	GtkLabel* _tmp12_;
	GtkButton* _tmp13_;
	GtkButton* _tmp14_;
	GtkButton* _tmp15_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_account_setup_content ();
	content = _tmp0_;
	_tmp1_ = dc_account_setup_intro ("Pick a chatmail relay or enter a custom server. The server will assign" \
" you an email " "address and password automatically — encryption keys are " "generated on this device.");
	_tmp2_ = _tmp1_;
	gtk_box_append (content, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = dc_account_setup_heading ("Display Name");
	_tmp4_ = _tmp3_;
	gtk_box_append (content, (GtkWidget*) _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = dc_account_setup_entry ("Your name", FALSE, GTK_INPUT_PURPOSE_FREE_FORM);
	_g_object_unref0 (self->priv->name_entry);
	self->priv->name_entry = _tmp5_;
	_tmp6_ = self->priv->name_entry;
	gtk_box_append (content, (GtkWidget*) _tmp6_);
	_tmp7_ = dc_account_setup_heading ("Server");
	_tmp8_ = _tmp7_;
	gtk_box_append (content, (GtkWidget*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	_tmp9_ = self->priv->rpc;
	_tmp10_ = dc_relay_picker_new (_tmp9_);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->relay_picker);
	self->priv->relay_picker = _tmp10_;
	_tmp11_ = self->priv->relay_picker;
	gtk_box_append (content, (GtkWidget*) _tmp11_);
	_tmp12_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp12_);
	hint = _tmp12_;
	gtk_label_set_use_markup (hint, TRUE);
	gtk_label_set_xalign (hint, (gfloat) 0);
	gtk_label_set_wrap (hint, TRUE);
	gtk_widget_add_css_class ((GtkWidget*) hint, "dim-label");
	gtk_widget_add_css_class ((GtkWidget*) hint, "caption");
	gtk_label_set_label (hint, "See <a href=\"https://chatmail.at/relays\">" "chatmail.at/relays</a> for the full list.");
	gtk_box_append (content, (GtkWidget*) hint);
	_tmp13_ = dc_account_setup_action (content, "Create Profile", TRUE);
	_g_object_unref0 (self->priv->create_btn);
	self->priv->create_btn = _tmp13_;
	_tmp14_ = self->priv->create_btn;
	g_signal_connect_object (_tmp14_, "clicked", (GCallback) ___lambda308__gtk_button_clicked, self, 0);
	_tmp15_ = self->priv->create_btn;
	adw_dialog_set_default_widget ((AdwDialog*) self, (GtkWidget*) _tmp15_);
	result = (GtkWidget*) content;
	_g_object_unref0 (hint);
	return result;
}

static void
_dc_create_profile_dialog_cancel_create_dc_account_progress_page_cancel_requested (DcAccountProgressPage* _sender,
                                                                                   gpointer self)
{
	dc_create_profile_dialog_cancel_create ((DcCreateProfileDialog*) self);
}

static GtkWidget*
dc_create_profile_dialog_build_progress_page (DcCreateProfileDialog* self)
{
	DcAccountProgressPage* _tmp0_;
	DcAccountProgressPage* _tmp1_;
	DcAccountProgressPage* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_account_progress_page_new ("Contacting server…", FALSE);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->progress_page);
	self->priv->progress_page = _tmp0_;
	_tmp1_ = self->priv->progress_page;
	g_signal_connect_object (_tmp1_, "cancel-requested", (GCallback) _dc_create_profile_dialog_cancel_create_dc_account_progress_page_cancel_requested, self, 0);
	_tmp2_ = self->priv->progress_page;
	_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
	result = _tmp3_;
	return result;
}

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

static void
dc_create_profile_dialog_do_create (DcCreateProfileDialog* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	DcCreateProfileDialogDoCreateData* _data_;
	DcCreateProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcCreateProfileDialogDoCreateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_create_profile_dialog_do_create_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_create_profile_dialog_do_create_co (_data_);
}

static void
dc_create_profile_dialog_do_create_finish (DcCreateProfileDialog* self,
                                           GAsyncResult* _res_)
{
	DcCreateProfileDialogDoCreateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

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 void
_dc_create_profile_dialog_on_configure_progress_dc_event_handler_configure_progress (DcEventHandler* _sender,
                                                                                     gint context_id,
                                                                                     gint progress,
                                                                                     const gchar* comment,
                                                                                     gpointer self)
{
	dc_create_profile_dialog_on_configure_progress ((DcCreateProfileDialog*) self, context_id, progress, comment);
}

static void
dc_create_profile_dialog_do_create_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	DcCreateProfileDialogDoCreateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_create_profile_dialog_do_create_co (_data_);
}

static gboolean
dc_create_profile_dialog_do_create_co (DcCreateProfileDialogDoCreateData* _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_->self->priv->create_running) {
		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_->_tmp0_ = _data_->self->priv->name_entry;
	_data_->_tmp1_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = string_strip (_data_->_tmp2_);
	_data_->display_name = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->self->priv->relay_picker;
	_data_->_tmp5_ = dc_relay_picker_get_selected_domain (_data_->_tmp4_);
	_data_->domain = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->self->priv->relay_picker;
	_data_->_tmp7_ = dc_relay_picker_get_chatmail_qr (_data_->_tmp6_);
	_data_->qr_link = _data_->_tmp7_;
	_data_->self->priv->create_running = TRUE;
	_data_->_tmp8_ = _data_->self->priv->stack;
	gtk_stack_set_visible_child_name (_data_->_tmp8_, "progress");
	_data_->_tmp9_ = _data_->self->priv->progress_page;
	_data_->_tmp10_ = _data_->domain;
	_data_->_tmp11_ = g_strdup_printf ("Creating profile on %s…", _data_->_tmp10_);
	_data_->_tmp12_ = _data_->_tmp11_;
	dc_account_progress_page_set_status (_data_->_tmp9_, _data_->_tmp12_);
	_g_free0 (_data_->_tmp12_);
	_data_->_tmp13_ = _data_->self->priv->events;
	_data_->_tmp14_ = g_signal_connect_object (_data_->_tmp13_, "configure-progress", (GCallback) _dc_create_profile_dialog_on_configure_progress_dc_event_handler_configure_progress, _data_->self, 0);
	_data_->self->priv->progress_handler_id = _data_->_tmp14_;
	{
		_data_->_tmp16_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_add_account (_data_->_tmp16_, dc_create_profile_dialog_do_create_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp15_ = dc_rpc_client_add_account_finish (_data_->_tmp16_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->self->priv->new_account_id = _data_->_tmp15_;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		dc_create_profile_dialog_cleanup_signal (_data_->self);
		_data_->self->priv->create_running = FALSE;
		if (!_data_->self->priv->cancelled) {
			_data_->_tmp17_ = _data_->e;
			_data_->_tmp18_ = _data_->_tmp17_->message;
			_data_->_tmp19_ = g_strconcat ("Failed to create account: ", _data_->_tmp18_, NULL);
			_data_->_tmp20_ = _data_->_tmp19_;
			dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp20_);
			_g_free0 (_data_->_tmp20_);
			adw_dialog_close ((AdwDialog*) _data_->self);
		}
		_g_error_free0 (_data_->e);
		_g_free0 (_data_->qr_link);
		_g_free0 (_data_->domain);
		_g_free0 (_data_->display_name);
		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_->qr_link);
		_g_free0 (_data_->domain);
		_g_free0 (_data_->display_name);
		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;
	}
	if (_data_->self->priv->cancelled) {
		dc_create_profile_dialog_cleanup_signal (_data_->self);
		_data_->self->priv->create_running = FALSE;
		_g_free0 (_data_->qr_link);
		_g_free0 (_data_->domain);
		_g_free0 (_data_->display_name);
		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_->_tmp21_ = _data_->display_name;
	_data_->_tmp22_ = strlen (_data_->_tmp21_);
	_data_->_tmp23_ = _data_->_tmp22_;
	if (_data_->_tmp23_ > 0) {
		{
			_data_->_tmp24_ = _data_->self->priv->rpc;
			_data_->_tmp25_ = _data_->display_name;
			_data_->_state_ = 2;
			dc_rpc_client_batch_set_config (_data_->_tmp24_, "displayname", _data_->_tmp25_, _data_->self->priv->new_account_id, dc_create_profile_dialog_do_create_ready, _data_);
			return FALSE;
			_state_2:
			dc_rpc_client_batch_set_config_finish (_data_->_tmp24_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
		}
		goto __finally1;
		__catch1_g_error:
		{
			g_clear_error (&_data_->_inner_error0_);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->qr_link);
			_g_free0 (_data_->domain);
			_g_free0 (_data_->display_name);
			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;
		}
	}
	if (_data_->self->priv->cancelled) {
		dc_create_profile_dialog_cleanup_signal (_data_->self);
		_data_->self->priv->create_running = FALSE;
		_g_free0 (_data_->qr_link);
		_g_free0 (_data_->domain);
		_g_free0 (_data_->display_name);
		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_->_tmp26_ = _data_->self->priv->rpc;
		_data_->_tmp27_ = _data_->qr_link;
		_data_->_state_ = 3;
		dc_rpc_client_add_transport_from_qr (_data_->_tmp26_, _data_->self->priv->new_account_id, _data_->_tmp27_, dc_create_profile_dialog_do_create_ready, _data_);
		return FALSE;
		_state_3:
		dc_rpc_client_add_transport_from_qr_finish (_data_->_tmp26_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch2_g_error;
		}
	}
	goto __finally2;
	__catch2_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		dc_create_profile_dialog_cleanup_signal (_data_->self);
		_data_->self->priv->create_running = FALSE;
		if (_data_->self->priv->cancelled) {
			_g_error_free0 (_data_->_vala1_e);
			_g_free0 (_data_->qr_link);
			_g_free0 (_data_->domain);
			_g_free0 (_data_->display_name);
			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_->aid = _data_->self->priv->new_account_id;
		_data_->self->priv->new_account_id = 0;
		_data_->_tmp28_ = _data_->self->priv->rpc;
		_data_->_state_ = 4;
		dc_cleanup_pending_account (_data_->_tmp28_, _data_->aid, FALSE, dc_create_profile_dialog_do_create_ready, _data_);
		return FALSE;
		_state_4:
		dc_cleanup_pending_account_finish (_data_->_res_);
		_data_->_tmp29_ = _data_->_vala1_e;
		_data_->_tmp30_ = _data_->_tmp29_->message;
		_data_->_tmp31_ = g_strconcat ("Profile creation failed: ", _data_->_tmp30_, NULL);
		_data_->_tmp32_ = _data_->_tmp31_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp32_);
		_g_free0 (_data_->_tmp32_);
		adw_dialog_close ((AdwDialog*) _data_->self);
		_g_error_free0 (_data_->_vala1_e);
		_g_free0 (_data_->qr_link);
		_g_free0 (_data_->domain);
		_g_free0 (_data_->display_name);
		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;
	}
	__finally2:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->qr_link);
		_g_free0 (_data_->domain);
		_g_free0 (_data_->display_name);
		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_create_profile_dialog_cleanup_signal (_data_->self);
	_data_->self->priv->create_running = FALSE;
	if (_data_->self->priv->cancelled) {
		_g_free0 (_data_->qr_link);
		_g_free0 (_data_->domain);
		_g_free0 (_data_->display_name);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->create_finished = TRUE;
	_data_->created = _data_->self->priv->new_account_id;
	_data_->self->priv->new_account_id = 0;
	g_signal_emit (_data_->self, dc_create_profile_dialog_signals[DC_CREATE_PROFILE_DIALOG_ACCOUNT_CREATED_SIGNAL], 0, _data_->created);
	adw_dialog_close ((AdwDialog*) _data_->self);
	_g_free0 (_data_->qr_link);
	_g_free0 (_data_->domain);
	_g_free0 (_data_->display_name);
	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_create_profile_dialog_on_configure_progress (DcCreateProfileDialog* self,
                                                gint ctx,
                                                gint progress,
                                                const gchar* comment)
{
	DcAccountProgressPage* _tmp0_;
	g_return_if_fail (self != NULL);
	if (ctx != self->priv->new_account_id) {
		return;
	}
	_tmp0_ = self->priv->progress_page;
	dc_account_progress_page_set_permille (_tmp0_, progress, comment, NULL);
}

static void
dc_create_profile_dialog_cleanup_signal (DcCreateProfileDialog* self)
{
	DcEventHandler* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->events;
	dc_disconnect_progress_handler (_tmp0_, &self->priv->progress_handler_id);
}

static void
dc_create_profile_dialog_cancel_create (DcCreateProfileDialog* self)
{
	g_return_if_fail (self != NULL);
	if (!self->priv->create_running) {
		adw_dialog_close ((AdwDialog*) self);
		return;
	}
	self->priv->cancelled = TRUE;
	adw_dialog_close ((AdwDialog*) self);
}

static void
dc_create_profile_dialog_on_dialog_closed (DcCreateProfileDialog* self)
{
	DcRpcClient* _tmp0_;
	g_return_if_fail (self != NULL);
	dc_create_profile_dialog_cleanup_signal (self);
	_tmp0_ = self->priv->rpc;
	dc_cleanup_unfinished_account (_tmp0_, &self->priv->new_account_id, self->priv->create_finished);
}

static void
dc_create_profile_dialog_class_init (DcCreateProfileDialogClass * klass,
                                     gpointer klass_data)
{
	dc_create_profile_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcCreateProfileDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_create_profile_dialog_finalize;
	dc_create_profile_dialog_signals[DC_CREATE_PROFILE_DIALOG_ACCOUNT_CREATED_SIGNAL] = g_signal_new ("account-created", DC_TYPE_CREATE_PROFILE_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
dc_create_profile_dialog_instance_init (DcCreateProfileDialog * self,
                                        gpointer klass)
{
	self->priv = dc_create_profile_dialog_get_instance_private (self);
	self->priv->new_account_id = 0;
	self->priv->create_running = FALSE;
	self->priv->create_finished = FALSE;
	self->priv->cancelled = FALSE;
	self->priv->progress_handler_id = (gulong) 0;
}

static void
dc_create_profile_dialog_finalize (GObject * obj)
{
	DcCreateProfileDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_CREATE_PROFILE_DIALOG, DcCreateProfileDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->events);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->name_entry);
	_g_object_unref0 (self->priv->relay_picker);
	_g_object_unref0 (self->priv->create_btn);
	_g_object_unref0 (self->priv->progress_page);
	G_OBJECT_CLASS (dc_create_profile_dialog_parent_class)->finalize (obj);
}

static GType
dc_create_profile_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcCreateProfileDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_create_profile_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcCreateProfileDialog), 0, (GInstanceInitFunc) dc_create_profile_dialog_instance_init, NULL };
	GType dc_create_profile_dialog_type_id;
	dc_create_profile_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcCreateProfileDialog", &g_define_type_info, 0);
	DcCreateProfileDialog_private_offset = g_type_add_instance_private (dc_create_profile_dialog_type_id, sizeof (DcCreateProfileDialogPrivate));
	return dc_create_profile_dialog_type_id;
}

GType
dc_create_profile_dialog_get_type (void)
{
	static volatile gsize dc_create_profile_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_create_profile_dialog_type_id__once)) {
		GType dc_create_profile_dialog_type_id;
		dc_create_profile_dialog_type_id = dc_create_profile_dialog_get_type_once ();
		g_once_init_leave (&dc_create_profile_dialog_type_id__once, dc_create_profile_dialog_type_id);
	}
	return dc_create_profile_dialog_type_id__once;
}

static inline gpointer
dc_invitation_code_profile_dialog_get_instance_private (DcInvitationCodeProfileDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcInvitationCodeProfileDialog_private_offset);
}

static void
_dc_invitation_code_profile_dialog_on_dialog_closed_adw_dialog_closed (AdwDialog* _sender,
                                                                       gpointer self)
{
	dc_invitation_code_profile_dialog_on_dialog_closed ((DcInvitationCodeProfileDialog*) self);
}

DcInvitationCodeProfileDialog*
dc_invitation_code_profile_dialog_construct (GType object_type,
                                             DcRpcClient* rpc,
                                             DcEventHandler* events)
{
	DcInvitationCodeProfileDialog * self = NULL;
	DcRpcClient* _tmp0_;
	DcEventHandler* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	GtkStack* _tmp6_;
	g_return_val_if_fail (rpc != NULL, NULL);
	g_return_val_if_fail (events != NULL, NULL);
	self = (DcInvitationCodeProfileDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	_tmp1_ = _g_object_ref0 (events);
	_g_object_unref0 (self->priv->events);
	self->priv->events = _tmp1_;
	_tmp2_ = dc_invitation_code_profile_dialog_build_input_page (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = dc_invitation_code_profile_dialog_build_progress_page (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = dc_account_setup_dialog ((AdwDialog*) self, "Use Invitation Code", _tmp3_, _tmp5_);
	_g_object_unref0 (self->priv->stack);
	self->priv->stack = _tmp6_;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) _dc_invitation_code_profile_dialog_on_dialog_closed_adw_dialog_closed, self, 0);
	return self;
}

DcInvitationCodeProfileDialog*
dc_invitation_code_profile_dialog_new (DcRpcClient* rpc,
                                       DcEventHandler* events)
{
	return dc_invitation_code_profile_dialog_construct (DC_TYPE_INVITATION_CODE_PROFILE_DIALOG, rpc, events);
}

static void
_dc_invitation_code_profile_dialog_update_start_sensitivity_gtk_editable_changed (GtkEditable* _sender,
                                                                                  gpointer self)
{
	dc_invitation_code_profile_dialog_update_start_sensitivity ((DcInvitationCodeProfileDialog*) self);
}

static void
__lambda310_ (DcInvitationCodeProfileDialog* self)
{
	dc_invitation_code_profile_dialog_start_create (self, NULL, NULL);
}

static void
___lambda310__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda310_ ((DcInvitationCodeProfileDialog*) self);
}

static GtkWidget*
dc_invitation_code_profile_dialog_build_input_page (DcInvitationCodeProfileDialog* self)
{
	GtkBox* content = NULL;
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkEntry* _tmp3_;
	GtkEntry* _tmp4_;
	GtkEntry* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_account_setup_content ();
	content = _tmp0_;
	_tmp1_ = dc_account_setup_intro ("Paste a Delta Chat account or invitation link. Account links " "use the linked server; contact and group invites create a new " "chatmail profile first.");
	_tmp2_ = _tmp1_;
	gtk_box_append (content, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = dc_account_setup_entry ("dcaccount:example.org or https://i.delta.chat/#...", TRUE, GTK_INPUT_PURPOSE_URL);
	_g_object_unref0 (self->priv->invite_entry);
	self->priv->invite_entry = _tmp3_;
	_tmp4_ = self->priv->invite_entry;
	g_signal_connect_object ((GtkEditable*) _tmp4_, "changed", (GCallback) _dc_invitation_code_profile_dialog_update_start_sensitivity_gtk_editable_changed, self, 0);
	_tmp5_ = self->priv->invite_entry;
	gtk_box_append (content, (GtkWidget*) _tmp5_);
	_tmp6_ = dc_account_setup_action (content, "Create Profile", FALSE);
	_g_object_unref0 (self->priv->start_btn);
	self->priv->start_btn = _tmp6_;
	_tmp7_ = self->priv->start_btn;
	g_signal_connect_object (_tmp7_, "clicked", (GCallback) ___lambda310__gtk_button_clicked, self, 0);
	_tmp8_ = self->priv->start_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp8_, FALSE);
	_tmp9_ = self->priv->start_btn;
	adw_dialog_set_default_widget ((AdwDialog*) self, (GtkWidget*) _tmp9_);
	result = (GtkWidget*) content;
	return result;
}

static void
_dc_invitation_code_profile_dialog_cancel_create_dc_account_progress_page_cancel_requested (DcAccountProgressPage* _sender,
                                                                                            gpointer self)
{
	dc_invitation_code_profile_dialog_cancel_create ((DcInvitationCodeProfileDialog*) self);
}

static GtkWidget*
dc_invitation_code_profile_dialog_build_progress_page (DcInvitationCodeProfileDialog* self)
{
	DcAccountProgressPage* _tmp0_;
	DcAccountProgressPage* _tmp1_;
	DcAccountProgressPage* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_account_progress_page_new ("Checking invitation…", TRUE);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->progress_page);
	self->priv->progress_page = _tmp0_;
	_tmp1_ = self->priv->progress_page;
	g_signal_connect_object (_tmp1_, "cancel-requested", (GCallback) _dc_invitation_code_profile_dialog_cancel_create_dc_account_progress_page_cancel_requested, self, 0);
	_tmp2_ = self->priv->progress_page;
	_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
	result = _tmp3_;
	return result;
}

static void
dc_invitation_code_profile_dialog_update_start_sensitivity (DcInvitationCodeProfileDialog* self)
{
	GtkButton* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->start_btn;
	_tmp1_ = self->priv->invite_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_);
}

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

static void
dc_invitation_code_profile_dialog_start_create (DcInvitationCodeProfileDialog* self,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	DcInvitationCodeProfileDialogStartCreateData* _data_;
	DcInvitationCodeProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcInvitationCodeProfileDialogStartCreateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_invitation_code_profile_dialog_start_create_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_invitation_code_profile_dialog_start_create_co (_data_);
}

static void
dc_invitation_code_profile_dialog_start_create_finish (DcInvitationCodeProfileDialog* self,
                                                       GAsyncResult* _res_)
{
	DcInvitationCodeProfileDialogStartCreateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
_dc_invitation_code_profile_dialog_on_configure_progress_dc_event_handler_configure_progress (DcEventHandler* _sender,
                                                                                              gint context_id,
                                                                                              gint progress,
                                                                                              const gchar* comment,
                                                                                              gpointer self)
{
	dc_invitation_code_profile_dialog_on_configure_progress ((DcInvitationCodeProfileDialog*) self, context_id, progress, comment);
}

static void
dc_invitation_code_profile_dialog_start_create_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	DcInvitationCodeProfileDialogStartCreateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_invitation_code_profile_dialog_start_create_co (_data_);
}

static gboolean
dc_invitation_code_profile_dialog_start_create_co (DcInvitationCodeProfileDialogStartCreateData* _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;
		case 8:
		goto _state_8;
		case 9:
		goto _state_9;
		case 10:
		goto _state_10;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->create_running) {
		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_->_tmp0_ = _data_->self->priv->invite_entry;
	_data_->_tmp1_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = string_strip (_data_->_tmp2_);
	_data_->invite_link = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->invite_link;
	_data_->_tmp5_ = strlen (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	if (_data_->_tmp6_ == 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;
	}
	_data_->self->priv->create_running = TRUE;
	_data_->_tmp7_ = _data_->self->priv->stack;
	gtk_stack_set_visible_child_name (_data_->_tmp7_, "progress");
	_data_->_tmp8_ = _data_->self->priv->progress_page;
	dc_account_progress_page_set_status (_data_->_tmp8_, "Checking invitation…");
	_data_->_tmp9_ = _data_->self->priv->events;
	_data_->_tmp10_ = g_signal_connect_object (_data_->_tmp9_, "configure-progress", (GCallback) _dc_invitation_code_profile_dialog_on_configure_progress_dc_event_handler_configure_progress, _data_->self, 0);
	_data_->self->priv->progress_handler_id = _data_->_tmp10_;
	{
		_data_->_tmp12_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_add_account (_data_->_tmp12_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp11_ = dc_rpc_client_add_account_finish (_data_->_tmp12_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->self->priv->new_account_id = _data_->_tmp11_;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		dc_invitation_code_profile_dialog_cleanup_signal (_data_->self);
		_data_->self->priv->create_running = FALSE;
		_data_->_tmp13_ = _data_->e;
		_data_->_tmp14_ = _data_->_tmp13_->message;
		_data_->_tmp15_ = g_strconcat ("Failed to create account: ", _data_->_tmp14_, NULL);
		_data_->_tmp16_ = _data_->_tmp15_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp16_);
		_g_free0 (_data_->_tmp16_);
		adw_dialog_close ((AdwDialog*) _data_->self);
		_g_error_free0 (_data_->e);
		_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;
	}
	__finally0:
	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;
	}
	_data_->qr = NULL;
	{
		_data_->_tmp18_ = _data_->self->priv->rpc;
		_data_->_tmp19_ = _data_->invite_link;
		_data_->_state_ = 2;
		dc_rpc_client_check_qr (_data_->_tmp18_, _data_->self->priv->new_account_id, _data_->_tmp19_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp20_ = dc_rpc_client_check_qr_finish (_data_->_tmp18_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp17_ = _data_->_tmp20_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_data_->_tmp21_ = _data_->_tmp17_;
		_data_->_tmp17_ = NULL;
		_json_object_unref0 (_data_->qr);
		_data_->qr = _data_->_tmp21_;
		_json_object_unref0 (_data_->_tmp17_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp22_ = _data_->_vala1_e;
		_data_->_tmp23_ = _data_->_tmp22_->message;
		_data_->_tmp24_ = g_strconcat ("Invitation code failed: ", _data_->_tmp23_, NULL);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_state_ = 3;
		dc_invitation_code_profile_dialog_fail_new_account (_data_->self, _data_->_tmp25_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
		return FALSE;
		_state_3:
		dc_invitation_code_profile_dialog_fail_new_account_finish (_data_->self, _data_->_res_);
		_g_free0 (_data_->_tmp25_);
		_g_error_free0 (_data_->_vala1_e);
		_json_object_unref0 (_data_->qr);
		_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;
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_json_object_unref0 (_data_->qr);
		_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;
	}
	_data_->_tmp27_ = _data_->qr;
	if (_data_->_tmp27_ == NULL) {
		_data_->_tmp26_ = TRUE;
	} else {
		_data_->_tmp28_ = _data_->qr;
		_data_->_tmp26_ = !json_object_has_member (_data_->_tmp28_, "kind");
	}
	if (_data_->_tmp26_) {
		_data_->_state_ = 4;
		dc_invitation_code_profile_dialog_fail_new_account (_data_->self, "This is not a valid Delta Chat invitation code.", dc_invitation_code_profile_dialog_start_create_ready, _data_);
		return FALSE;
		_state_4:
		dc_invitation_code_profile_dialog_fail_new_account_finish (_data_->self, _data_->_res_);
		_json_object_unref0 (_data_->qr);
		_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_->_tmp29_ = _data_->qr;
	_data_->_tmp30_ = json_object_get_string_member (_data_->_tmp29_, "kind");
	_data_->_tmp31_ = g_strdup (_data_->_tmp30_);
	_data_->kind = _data_->_tmp31_;
	_data_->chat_id = 0;
	_data_->_tmp33_ = _data_->kind;
	if (g_strcmp0 (_data_->_tmp33_, "account") == 0) {
		_data_->_tmp32_ = TRUE;
	} else {
		_data_->_tmp34_ = _data_->kind;
		_data_->_tmp32_ = g_strcmp0 (_data_->_tmp34_, "login") == 0;
	}
	if (_data_->_tmp32_) {
		_data_->_tmp35_ = _data_->self->priv->progress_page;
		dc_account_progress_page_set_status (_data_->_tmp35_, "Creating profile…");
		{
			_data_->_tmp36_ = _data_->self->priv->rpc;
			_data_->_tmp37_ = _data_->invite_link;
			_data_->_state_ = 5;
			dc_rpc_client_add_transport_from_qr (_data_->_tmp36_, _data_->self->priv->new_account_id, _data_->_tmp37_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
			return FALSE;
			_state_5:
			dc_rpc_client_add_transport_from_qr_finish (_data_->_tmp36_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch2_g_error;
			}
		}
		goto __finally2;
		__catch2_g_error:
		{
			_data_->_vala2_e = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp38_ = _data_->_vala2_e;
			_data_->_tmp39_ = _data_->_tmp38_->message;
			_data_->_tmp40_ = g_strconcat ("Profile creation failed: ", _data_->_tmp39_, NULL);
			_data_->_tmp41_ = _data_->_tmp40_;
			_data_->_state_ = 6;
			dc_invitation_code_profile_dialog_fail_new_account (_data_->self, _data_->_tmp41_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
			return FALSE;
			_state_6:
			dc_invitation_code_profile_dialog_fail_new_account_finish (_data_->self, _data_->_res_);
			_g_free0 (_data_->_tmp41_);
			_g_error_free0 (_data_->_vala2_e);
			_g_free0 (_data_->kind);
			_json_object_unref0 (_data_->qr);
			_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;
		}
		__finally2:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->kind);
			_json_object_unref0 (_data_->qr);
			_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;
		}
	} else {
		_data_->_tmp44_ = _data_->kind;
		if (g_strcmp0 (_data_->_tmp44_, "askVerifyContact") == 0) {
			_data_->_tmp43_ = TRUE;
		} else {
			_data_->_tmp45_ = _data_->kind;
			_data_->_tmp43_ = g_strcmp0 (_data_->_tmp45_, "askVerifyGroup") == 0;
		}
		if (_data_->_tmp43_) {
			_data_->_tmp42_ = TRUE;
		} else {
			_data_->_tmp46_ = _data_->kind;
			_data_->_tmp42_ = g_strcmp0 (_data_->_tmp46_, "askJoinBroadcast") == 0;
		}
		if (_data_->_tmp42_) {
			_data_->_tmp47_ = _data_->self->priv->progress_page;
			dc_account_progress_page_set_status (_data_->_tmp47_, "Creating profile…");
			{
				_data_->_tmp48_ = _data_->self->priv->rpc;
				_data_->_tmp49_ = DC_CHATMAIL_RELAYS[0];
				_data_->_tmp50_ = _data_->_tmp49_.domain;
				_data_->_tmp51_ = dc_build_chatmail_qr (_data_->_tmp50_);
				_data_->_tmp52_ = _data_->_tmp51_;
				_data_->_state_ = 7;
				dc_rpc_client_add_transport_from_qr (_data_->_tmp48_, _data_->self->priv->new_account_id, _data_->_tmp52_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
				return FALSE;
				_state_7:
				dc_rpc_client_add_transport_from_qr_finish (_data_->_tmp48_, _data_->_res_, &_data_->_inner_error0_);
				_g_free0 (_data_->_tmp52_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch3_g_error;
				}
				_data_->_tmp53_ = _data_->self->priv->progress_page;
				dc_account_progress_page_set_status (_data_->_tmp53_, "Accepting invitation…");
				_data_->_tmp55_ = _data_->self->priv->rpc;
				_data_->_tmp56_ = _data_->invite_link;
				_data_->_state_ = 8;
				dc_rpc_client_secure_join (_data_->_tmp55_, _data_->self->priv->new_account_id, _data_->_tmp56_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
				return FALSE;
				_state_8:
				_data_->_tmp54_ = dc_rpc_client_secure_join_finish (_data_->_tmp55_, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch3_g_error;
				}
				_data_->chat_id = _data_->_tmp54_;
			}
			goto __finally3;
			__catch3_g_error:
			{
				_data_->_vala3_e = _data_->_inner_error0_;
				_data_->_inner_error0_ = NULL;
				_data_->_tmp57_ = _data_->_vala3_e;
				_data_->_tmp58_ = _data_->_tmp57_->message;
				_data_->_tmp59_ = g_strconcat ("Invitation failed: ", _data_->_tmp58_, NULL);
				_data_->_tmp60_ = _data_->_tmp59_;
				_data_->_state_ = 9;
				dc_invitation_code_profile_dialog_fail_new_account (_data_->self, _data_->_tmp60_, dc_invitation_code_profile_dialog_start_create_ready, _data_);
				return FALSE;
				_state_9:
				dc_invitation_code_profile_dialog_fail_new_account_finish (_data_->self, _data_->_res_);
				_g_free0 (_data_->_tmp60_);
				_g_error_free0 (_data_->_vala3_e);
				_g_free0 (_data_->kind);
				_json_object_unref0 (_data_->qr);
				_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;
			}
			__finally3:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_free0 (_data_->kind);
				_json_object_unref0 (_data_->qr);
				_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;
			}
		} else {
			_data_->_state_ = 10;
			dc_invitation_code_profile_dialog_fail_new_account (_data_->self, "This code cannot be used to create a profile.", dc_invitation_code_profile_dialog_start_create_ready, _data_);
			return FALSE;
			_state_10:
			dc_invitation_code_profile_dialog_fail_new_account_finish (_data_->self, _data_->_res_);
			_g_free0 (_data_->kind);
			_json_object_unref0 (_data_->qr);
			_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;
		}
	}
	dc_invitation_code_profile_dialog_cleanup_signal (_data_->self);
	_data_->self->priv->create_finished = TRUE;
	_data_->self->priv->create_running = FALSE;
	_data_->created = _data_->self->priv->new_account_id;
	_data_->self->priv->new_account_id = 0;
	g_signal_emit (_data_->self, dc_invitation_code_profile_dialog_signals[DC_INVITATION_CODE_PROFILE_DIALOG_ACCOUNT_CREATED_SIGNAL], 0, _data_->created, _data_->chat_id);
	adw_dialog_close ((AdwDialog*) _data_->self);
	_g_free0 (_data_->kind);
	_json_object_unref0 (_data_->qr);
	_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
dc_invitation_code_profile_dialog_fail_new_account_data_free (gpointer _data)
{
	DcInvitationCodeProfileDialogFailNewAccountData* _data_;
	_data_ = _data;
	_g_free0 (_data_->message);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcInvitationCodeProfileDialogFailNewAccountData, _data_);
}

static void
dc_invitation_code_profile_dialog_fail_new_account (DcInvitationCodeProfileDialog* self,
                                                    const gchar* message,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	DcInvitationCodeProfileDialogFailNewAccountData* _data_;
	DcInvitationCodeProfileDialog* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_data_ = g_slice_new0 (DcInvitationCodeProfileDialogFailNewAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_invitation_code_profile_dialog_fail_new_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (message);
	_g_free0 (_data_->message);
	_data_->message = _tmp1_;
	dc_invitation_code_profile_dialog_fail_new_account_co (_data_);
}

static void
dc_invitation_code_profile_dialog_fail_new_account_finish (DcInvitationCodeProfileDialog* self,
                                                           GAsyncResult* _res_)
{
	DcInvitationCodeProfileDialogFailNewAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_invitation_code_profile_dialog_fail_new_account_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_)
{
	DcInvitationCodeProfileDialogFailNewAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_invitation_code_profile_dialog_fail_new_account_co (_data_);
}

static gboolean
dc_invitation_code_profile_dialog_fail_new_account_co (DcInvitationCodeProfileDialogFailNewAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	dc_invitation_code_profile_dialog_cleanup_signal (_data_->self);
	_data_->self->priv->create_running = FALSE;
	if (_data_->self->priv->new_account_id > 0) {
		_data_->aid = _data_->self->priv->new_account_id;
		_data_->self->priv->new_account_id = 0;
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_cleanup_pending_account (_data_->_tmp0_, _data_->aid, TRUE, dc_invitation_code_profile_dialog_fail_new_account_ready, _data_);
		return FALSE;
		_state_1:
		dc_cleanup_pending_account_finish (_data_->_res_);
	}
	dc_show_error ((GtkWidget*) _data_->self, _data_->message);
	adw_dialog_close ((AdwDialog*) _data_->self);
	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_invitation_code_profile_dialog_on_configure_progress (DcInvitationCodeProfileDialog* self,
                                                         gint ctx,
                                                         gint progress,
                                                         const gchar* comment)
{
	DcAccountProgressPage* _tmp0_;
	g_return_if_fail (self != NULL);
	if (ctx != self->priv->new_account_id) {
		return;
	}
	_tmp0_ = self->priv->progress_page;
	dc_account_progress_page_set_permille (_tmp0_, progress, comment, NULL);
}

static void
dc_invitation_code_profile_dialog_cleanup_signal (DcInvitationCodeProfileDialog* self)
{
	DcEventHandler* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->events;
	dc_disconnect_progress_handler (_tmp0_, &self->priv->progress_handler_id);
}

static void
dc_invitation_code_profile_dialog_cancel_create (DcInvitationCodeProfileDialog* self)
{
	DcRpcClient* _tmp0_;
	g_return_if_fail (self != NULL);
	if (dc_close_if_idle ((AdwDialog*) self, self->priv->create_running)) {
		return;
	}
	_tmp0_ = self->priv->rpc;
	dc_stop_ongoing_account (_tmp0_, self->priv->new_account_id);
}

static void
dc_invitation_code_profile_dialog_on_dialog_closed (DcInvitationCodeProfileDialog* self)
{
	DcRpcClient* _tmp0_;
	g_return_if_fail (self != NULL);
	dc_invitation_code_profile_dialog_cleanup_signal (self);
	_tmp0_ = self->priv->rpc;
	dc_cleanup_unfinished_account (_tmp0_, &self->priv->new_account_id, self->priv->create_finished);
}

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

static void
dc_invitation_code_profile_dialog_class_init (DcInvitationCodeProfileDialogClass * klass,
                                              gpointer klass_data)
{
	dc_invitation_code_profile_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcInvitationCodeProfileDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_invitation_code_profile_dialog_finalize;
	dc_invitation_code_profile_dialog_signals[DC_INVITATION_CODE_PROFILE_DIALOG_ACCOUNT_CREATED_SIGNAL] = g_signal_new ("account-created", DC_TYPE_INVITATION_CODE_PROFILE_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
}

static void
dc_invitation_code_profile_dialog_instance_init (DcInvitationCodeProfileDialog * self,
                                                 gpointer klass)
{
	self->priv = dc_invitation_code_profile_dialog_get_instance_private (self);
	self->priv->new_account_id = 0;
	self->priv->create_running = FALSE;
	self->priv->create_finished = FALSE;
	self->priv->progress_handler_id = (gulong) 0;
}

static void
dc_invitation_code_profile_dialog_finalize (GObject * obj)
{
	DcInvitationCodeProfileDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_INVITATION_CODE_PROFILE_DIALOG, DcInvitationCodeProfileDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->events);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->invite_entry);
	_g_object_unref0 (self->priv->start_btn);
	_g_object_unref0 (self->priv->progress_page);
	G_OBJECT_CLASS (dc_invitation_code_profile_dialog_parent_class)->finalize (obj);
}

static GType
dc_invitation_code_profile_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcInvitationCodeProfileDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_invitation_code_profile_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcInvitationCodeProfileDialog), 0, (GInstanceInitFunc) dc_invitation_code_profile_dialog_instance_init, NULL };
	GType dc_invitation_code_profile_dialog_type_id;
	dc_invitation_code_profile_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcInvitationCodeProfileDialog", &g_define_type_info, 0);
	DcInvitationCodeProfileDialog_private_offset = g_type_add_instance_private (dc_invitation_code_profile_dialog_type_id, sizeof (DcInvitationCodeProfileDialogPrivate));
	return dc_invitation_code_profile_dialog_type_id;
}

GType
dc_invitation_code_profile_dialog_get_type (void)
{
	static volatile gsize dc_invitation_code_profile_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_invitation_code_profile_dialog_type_id__once)) {
		GType dc_invitation_code_profile_dialog_type_id;
		dc_invitation_code_profile_dialog_type_id = dc_invitation_code_profile_dialog_get_type_once ();
		g_once_init_leave (&dc_invitation_code_profile_dialog_type_id__once, dc_invitation_code_profile_dialog_type_id);
	}
	return dc_invitation_code_profile_dialog_type_id__once;
}

static inline gpointer
dc_receive_backup_dialog_get_instance_private (DcReceiveBackupDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcReceiveBackupDialog_private_offset);
}

static void
_dc_receive_backup_dialog_on_dialog_closed_adw_dialog_closed (AdwDialog* _sender,
                                                              gpointer self)
{
	dc_receive_backup_dialog_on_dialog_closed ((DcReceiveBackupDialog*) self);
}

DcReceiveBackupDialog*
dc_receive_backup_dialog_construct (GType object_type,
                                    DcRpcClient* rpc,
                                    DcEventHandler* events)
{
	DcReceiveBackupDialog * self = NULL;
	DcRpcClient* _tmp0_;
	DcEventHandler* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	GtkStack* _tmp6_;
	g_return_val_if_fail (rpc != NULL, NULL);
	g_return_val_if_fail (events != NULL, NULL);
	self = (DcReceiveBackupDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	_tmp1_ = _g_object_ref0 (events);
	_g_object_unref0 (self->priv->events);
	self->priv->events = _tmp1_;
	_tmp2_ = dc_receive_backup_dialog_build_input_page (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = dc_receive_backup_dialog_build_progress_page (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = dc_account_setup_dialog ((AdwDialog*) self, "Add as Secondary Device", _tmp3_, _tmp5_);
	_g_object_unref0 (self->priv->stack);
	self->priv->stack = _tmp6_;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) _dc_receive_backup_dialog_on_dialog_closed_adw_dialog_closed, self, 0);
	return self;
}

DcReceiveBackupDialog*
dc_receive_backup_dialog_new (DcRpcClient* rpc,
                              DcEventHandler* events)
{
	return dc_receive_backup_dialog_construct (DC_TYPE_RECEIVE_BACKUP_DIALOG, rpc, events);
}

static void
_dc_receive_backup_dialog_update_start_sensitivity_gtk_editable_changed (GtkEditable* _sender,
                                                                         gpointer self)
{
	dc_receive_backup_dialog_update_start_sensitivity ((DcReceiveBackupDialog*) self);
}

static void
__lambda306_ (DcReceiveBackupDialog* self)
{
	dc_receive_backup_dialog_start_import (self, NULL, NULL);
}

static void
___lambda306__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda306_ ((DcReceiveBackupDialog*) self);
}

static GtkWidget*
dc_receive_backup_dialog_build_input_page (DcReceiveBackupDialog* self)
{
	GtkBox* content = NULL;
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkEntry* _tmp3_;
	GtkEntry* _tmp4_;
	GtkEntry* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_account_setup_content ();
	content = _tmp0_;
	_tmp1_ = dc_account_setup_intro ("On your existing device, open Settings → " "“Add Second Device” and copy the setup code shown there. " "Paste it below.");
	_tmp2_ = _tmp1_;
	gtk_box_append (content, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = dc_account_setup_entry ("DCBACKUP2:…", TRUE, GTK_INPUT_PURPOSE_FREE_FORM);
	_g_object_unref0 (self->priv->url_entry);
	self->priv->url_entry = _tmp3_;
	_tmp4_ = self->priv->url_entry;
	g_signal_connect_object ((GtkEditable*) _tmp4_, "changed", (GCallback) _dc_receive_backup_dialog_update_start_sensitivity_gtk_editable_changed, self, 0);
	_tmp5_ = self->priv->url_entry;
	gtk_box_append (content, (GtkWidget*) _tmp5_);
	_tmp6_ = dc_account_setup_action (content, "Start Import", FALSE);
	_g_object_unref0 (self->priv->start_btn);
	self->priv->start_btn = _tmp6_;
	_tmp7_ = self->priv->start_btn;
	g_signal_connect_object (_tmp7_, "clicked", (GCallback) ___lambda306__gtk_button_clicked, self, 0);
	_tmp8_ = self->priv->start_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp8_, FALSE);
	_tmp9_ = self->priv->start_btn;
	adw_dialog_set_default_widget ((AdwDialog*) self, (GtkWidget*) _tmp9_);
	result = (GtkWidget*) content;
	return result;
}

static void
_dc_receive_backup_dialog_cancel_import_dc_account_progress_page_cancel_requested (DcAccountProgressPage* _sender,
                                                                                   gpointer self)
{
	dc_receive_backup_dialog_cancel_import ((DcReceiveBackupDialog*) self);
}

static GtkWidget*
dc_receive_backup_dialog_build_progress_page (DcReceiveBackupDialog* self)
{
	DcAccountProgressPage* _tmp0_;
	DcAccountProgressPage* _tmp1_;
	DcAccountProgressPage* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_account_progress_page_new ("Connecting…", FALSE);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->progress_page);
	self->priv->progress_page = _tmp0_;
	_tmp1_ = self->priv->progress_page;
	g_signal_connect_object (_tmp1_, "cancel-requested", (GCallback) _dc_receive_backup_dialog_cancel_import_dc_account_progress_page_cancel_requested, self, 0);
	_tmp2_ = self->priv->progress_page;
	_tmp3_ = _g_object_ref0 ((GtkWidget*) _tmp2_);
	result = _tmp3_;
	return result;
}

static void
dc_receive_backup_dialog_update_start_sensitivity (DcReceiveBackupDialog* self)
{
	GtkButton* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->start_btn;
	_tmp1_ = self->priv->url_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_);
}

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

static void
dc_receive_backup_dialog_start_import (DcReceiveBackupDialog* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	DcReceiveBackupDialogStartImportData* _data_;
	DcReceiveBackupDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcReceiveBackupDialogStartImportData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_receive_backup_dialog_start_import_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_receive_backup_dialog_start_import_co (_data_);
}

static void
dc_receive_backup_dialog_start_import_finish (DcReceiveBackupDialog* self,
                                              GAsyncResult* _res_)
{
	DcReceiveBackupDialogStartImportData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
_dc_receive_backup_dialog_on_imex_progress_dc_event_handler_imex_progress (DcEventHandler* _sender,
                                                                           gint context_id,
                                                                           gint progress,
                                                                           gpointer self)
{
	dc_receive_backup_dialog_on_imex_progress ((DcReceiveBackupDialog*) self, context_id, progress);
}

static void
dc_receive_backup_dialog_start_import_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	DcReceiveBackupDialogStartImportData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_receive_backup_dialog_start_import_co (_data_);
}

static gboolean
dc_receive_backup_dialog_start_import_co (DcReceiveBackupDialogStartImportData* _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:
	if (_data_->self->priv->import_running) {
		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_->_tmp0_ = _data_->self->priv->url_entry;
	_data_->_tmp1_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = string_strip (_data_->_tmp2_);
	_data_->qr = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->qr;
	_data_->_tmp5_ = strlen (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	if (_data_->_tmp6_ == 0) {
		_g_free0 (_data_->qr);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->import_running = TRUE;
	_data_->_tmp7_ = _data_->self->priv->stack;
	gtk_stack_set_visible_child_name (_data_->_tmp7_, "progress");
	_data_->_tmp8_ = _data_->self->priv->events;
	_data_->_tmp9_ = g_signal_connect_object (_data_->_tmp8_, "imex-progress", (GCallback) _dc_receive_backup_dialog_on_imex_progress_dc_event_handler_imex_progress, _data_->self, 0);
	_data_->self->priv->progress_handler_id = _data_->_tmp9_;
	{
		_data_->_tmp11_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_add_account (_data_->_tmp11_, dc_receive_backup_dialog_start_import_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp10_ = dc_rpc_client_add_account_finish (_data_->_tmp11_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->self->priv->new_account_id = _data_->_tmp10_;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		dc_receive_backup_dialog_cleanup_signal (_data_->self);
		_data_->self->priv->import_running = FALSE;
		_data_->_tmp12_ = _data_->e;
		_data_->_tmp13_ = _data_->_tmp12_->message;
		_data_->_tmp14_ = g_strconcat ("Failed to create account: ", _data_->_tmp13_, NULL);
		_data_->_tmp15_ = _data_->_tmp14_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp15_);
		_g_free0 (_data_->_tmp15_);
		adw_dialog_close ((AdwDialog*) _data_->self);
		_g_error_free0 (_data_->e);
		_g_free0 (_data_->qr);
		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_->qr);
		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_->_tmp16_ = _data_->self->priv->rpc;
		_data_->_tmp17_ = _data_->qr;
		_data_->_state_ = 2;
		dc_rpc_client_get_backup (_data_->_tmp16_, _data_->self->priv->new_account_id, _data_->_tmp17_, dc_receive_backup_dialog_start_import_ready, _data_);
		return FALSE;
		_state_2:
		dc_rpc_client_get_backup_finish (_data_->_tmp16_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		dc_receive_backup_dialog_cleanup_signal (_data_->self);
		_data_->self->priv->import_running = FALSE;
		if (_data_->self->priv->new_account_id > 0) {
			_data_->_tmp18_ = _data_->self->priv->rpc;
			_data_->_state_ = 3;
			dc_cleanup_pending_account (_data_->_tmp18_, _data_->self->priv->new_account_id, FALSE, dc_receive_backup_dialog_start_import_ready, _data_);
			return FALSE;
			_state_3:
			dc_cleanup_pending_account_finish (_data_->_res_);
			_data_->self->priv->new_account_id = 0;
		}
		_data_->_tmp19_ = _data_->_vala1_e;
		_data_->_tmp20_ = _data_->_tmp19_->message;
		_data_->_tmp21_ = g_strconcat ("Import failed: ", _data_->_tmp20_, NULL);
		_data_->_tmp22_ = _data_->_tmp21_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp22_);
		_g_free0 (_data_->_tmp22_);
		adw_dialog_close ((AdwDialog*) _data_->self);
		_g_error_free0 (_data_->_vala1_e);
		_g_free0 (_data_->qr);
		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;
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->qr);
		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_receive_backup_dialog_cleanup_signal (_data_->self);
	_data_->self->priv->import_finished = TRUE;
	_data_->self->priv->import_running = FALSE;
	_data_->imported = _data_->self->priv->new_account_id;
	_data_->self->priv->new_account_id = 0;
	g_signal_emit (_data_->self, dc_receive_backup_dialog_signals[DC_RECEIVE_BACKUP_DIALOG_ACCOUNT_IMPORTED_SIGNAL], 0, _data_->imported);
	adw_dialog_close ((AdwDialog*) _data_->self);
	_g_free0 (_data_->qr);
	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_receive_backup_dialog_on_imex_progress (DcReceiveBackupDialog* self,
                                           gint ctx,
                                           gint progress)
{
	DcAccountProgressPage* _tmp0_;
	g_return_if_fail (self != NULL);
	if (ctx != self->priv->new_account_id) {
		return;
	}
	_tmp0_ = self->priv->progress_page;
	dc_account_progress_page_set_permille (_tmp0_, progress, NULL, "Transferring…");
}

static void
dc_receive_backup_dialog_cleanup_signal (DcReceiveBackupDialog* self)
{
	DcEventHandler* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->events;
	dc_disconnect_progress_handler (_tmp0_, &self->priv->progress_handler_id);
}

static void
dc_receive_backup_dialog_cancel_import (DcReceiveBackupDialog* self)
{
	DcRpcClient* _tmp0_;
	g_return_if_fail (self != NULL);
	if (dc_close_if_idle ((AdwDialog*) self, self->priv->import_running)) {
		return;
	}
	_tmp0_ = self->priv->rpc;
	dc_stop_ongoing_account (_tmp0_, self->priv->new_account_id);
}

static void
dc_receive_backup_dialog_on_dialog_closed (DcReceiveBackupDialog* self)
{
	DcRpcClient* _tmp0_;
	g_return_if_fail (self != NULL);
	dc_receive_backup_dialog_cleanup_signal (self);
	_tmp0_ = self->priv->rpc;
	dc_cleanup_unfinished_account (_tmp0_, &self->priv->new_account_id, self->priv->import_finished);
}

static void
dc_receive_backup_dialog_class_init (DcReceiveBackupDialogClass * klass,
                                     gpointer klass_data)
{
	dc_receive_backup_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcReceiveBackupDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_receive_backup_dialog_finalize;
	dc_receive_backup_dialog_signals[DC_RECEIVE_BACKUP_DIALOG_ACCOUNT_IMPORTED_SIGNAL] = g_signal_new ("account-imported", DC_TYPE_RECEIVE_BACKUP_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
dc_receive_backup_dialog_instance_init (DcReceiveBackupDialog * self,
                                        gpointer klass)
{
	self->priv = dc_receive_backup_dialog_get_instance_private (self);
	self->priv->new_account_id = 0;
	self->priv->import_running = FALSE;
	self->priv->import_finished = FALSE;
	self->priv->progress_handler_id = (gulong) 0;
}

static void
dc_receive_backup_dialog_finalize (GObject * obj)
{
	DcReceiveBackupDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_RECEIVE_BACKUP_DIALOG, DcReceiveBackupDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->events);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->url_entry);
	_g_object_unref0 (self->priv->start_btn);
	_g_object_unref0 (self->priv->progress_page);
	G_OBJECT_CLASS (dc_receive_backup_dialog_parent_class)->finalize (obj);
}

static GType
dc_receive_backup_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcReceiveBackupDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_receive_backup_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcReceiveBackupDialog), 0, (GInstanceInitFunc) dc_receive_backup_dialog_instance_init, NULL };
	GType dc_receive_backup_dialog_type_id;
	dc_receive_backup_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcReceiveBackupDialog", &g_define_type_info, 0);
	DcReceiveBackupDialog_private_offset = g_type_add_instance_private (dc_receive_backup_dialog_type_id, sizeof (DcReceiveBackupDialogPrivate));
	return dc_receive_backup_dialog_type_id;
}

GType
dc_receive_backup_dialog_get_type (void)
{
	static volatile gsize dc_receive_backup_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_receive_backup_dialog_type_id__once)) {
		GType dc_receive_backup_dialog_type_id;
		dc_receive_backup_dialog_type_id = dc_receive_backup_dialog_get_type_once ();
		g_once_init_leave (&dc_receive_backup_dialog_type_id__once, dc_receive_backup_dialog_type_id);
	}
	return dc_receive_backup_dialog_type_id__once;
}

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

