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

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

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

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

typedef struct _DcProfileDialog DcProfileDialog;
typedef struct _DcProfileDialogClass DcProfileDialogClass;
typedef struct _DcProfileDialogPrivate DcProfileDialogPrivate;

#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;
enum  {
	DC_PROFILE_DIALOG_0_PROPERTY,
	DC_PROFILE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_profile_dialog_properties[DC_PROFILE_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _DcProfileDialogLoadProfileData DcProfileDialogLoadProfileData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcProfileDialogDoSaveData DcProfileDialogDoSaveData;

#define DC_TYPE_INVITE_CODE_DIALOG (dc_invite_code_dialog_get_type ())
#define DC_INVITE_CODE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_INVITE_CODE_DIALOG, DcInviteCodeDialog))
#define DC_INVITE_CODE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_INVITE_CODE_DIALOG, DcInviteCodeDialogClass))
#define DC_IS_INVITE_CODE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_INVITE_CODE_DIALOG))
#define DC_IS_INVITE_CODE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_INVITE_CODE_DIALOG))
#define DC_INVITE_CODE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_INVITE_CODE_DIALOG, DcInviteCodeDialogClass))

typedef struct _DcInviteCodeDialog DcInviteCodeDialog;
typedef struct _DcInviteCodeDialogClass DcInviteCodeDialogClass;

#define DC_TYPE_SECOND_DEVICE_DIALOG (dc_second_device_dialog_get_type ())
#define DC_SECOND_DEVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_SECOND_DEVICE_DIALOG, DcSecondDeviceDialog))
#define DC_SECOND_DEVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_SECOND_DEVICE_DIALOG, DcSecondDeviceDialogClass))
#define DC_IS_SECOND_DEVICE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_SECOND_DEVICE_DIALOG))
#define DC_IS_SECOND_DEVICE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_SECOND_DEVICE_DIALOG))
#define DC_SECOND_DEVICE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_SECOND_DEVICE_DIALOG, DcSecondDeviceDialogClass))

typedef struct _DcSecondDeviceDialog DcSecondDeviceDialog;
typedef struct _DcSecondDeviceDialogClass DcSecondDeviceDialogClass;

#define DC_TYPE_RELAYS_DIALOG (dc_relays_dialog_get_type ())
#define DC_RELAYS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RELAYS_DIALOG, DcRelaysDialog))
#define DC_RELAYS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RELAYS_DIALOG, DcRelaysDialogClass))
#define DC_IS_RELAYS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RELAYS_DIALOG))
#define DC_IS_RELAYS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RELAYS_DIALOG))
#define DC_RELAYS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RELAYS_DIALOG, DcRelaysDialogClass))

typedef struct _DcRelaysDialog DcRelaysDialog;
typedef struct _DcRelaysDialogClass DcRelaysDialogClass;
typedef void (*DcVoidFunc) (gpointer user_data);
typedef struct _DcProfileDialogDoDeleteAccountData DcProfileDialogDoDeleteAccountData;
typedef struct _DcProfileDialogPickAvatarData DcProfileDialogPickAvatarData;
enum  {
	DC_PROFILE_DIALOG_PROFILE_UPDATED_SIGNAL,
	DC_PROFILE_DIALOG_ACCOUNT_DELETED_SIGNAL,
	DC_PROFILE_DIALOG_NUM_SIGNALS
};
static guint dc_profile_dialog_signals[DC_PROFILE_DIALOG_NUM_SIGNALS] = {0};
typedef struct _DcInviteCodeDialogPrivate DcInviteCodeDialogPrivate;
enum  {
	DC_INVITE_CODE_DIALOG_0_PROPERTY,
	DC_INVITE_CODE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_invite_code_dialog_properties[DC_INVITE_CODE_DIALOG_NUM_PROPERTIES];
typedef struct _DcInviteCodeDialogLoadInviteCodeData DcInviteCodeDialogLoadInviteCodeData;
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
typedef struct _DcSecondDeviceDialogPrivate DcSecondDeviceDialogPrivate;
enum  {
	DC_SECOND_DEVICE_DIALOG_0_PROPERTY,
	DC_SECOND_DEVICE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_second_device_dialog_properties[DC_SECOND_DEVICE_DIALOG_NUM_PROPERTIES];
typedef struct _DcSecondDeviceDialogStartTransferData DcSecondDeviceDialogStartTransferData;

struct _DcProfileDialog {
	AdwDialog parent_instance;
	DcProfileDialogPrivate * priv;
};

struct _DcProfileDialogClass {
	AdwDialogClass parent_class;
};

struct _DcProfileDialogPrivate {
	DcRpcClient* rpc;
	gint account_id;
	AdwAvatar* avatar_widget;
	GtkEntry* name_entry;
	GtkEntry* status_entry;
	GtkLabel* email_label;
	gchar* avatar_path;
	gboolean avatar_changed;
};

struct _DcProfileDialogLoadProfileData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcProfileDialog* self;
	gchar* name;
	DcRpcClient* _tmp0_;
	gchar* _tmp1_;
	gchar* status;
	DcRpcClient* _tmp2_;
	gchar* _tmp3_;
	gchar* email;
	DcRpcClient* _tmp4_;
	gchar* _tmp5_;
	gchar* avatar;
	DcRpcClient* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	GtkEntry* _tmp9_;
	const gchar* _tmp10_;
	AdwAvatar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	GtkEntry* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	GtkLabel* _tmp17_;
	const gchar* _tmp18_;
	gboolean _tmp19_;
	gboolean _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	gint _tmp23_;
	gint _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	gchar* _tmp27_;
	AdwAvatar* _tmp28_;
	const gchar* _tmp29_;
	GdkTexture* _tmp30_;
	GdkTexture* _tmp31_;
	GError* _inner_error0_;
};

struct _DcProfileDialogDoSaveData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcProfileDialog* self;
	DcRpcClient* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	DcRpcClient* _tmp6_;
	GtkEntry* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gboolean _tmp12_;
	const gchar* _tmp13_;
	DcRpcClient* _tmp14_;
	const gchar* _tmp15_;
	GError* e;
	GError* _tmp16_;
	const gchar* _tmp17_;
	GError* _inner_error0_;
};

struct _DcProfileDialogDoDeleteAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcProfileDialog* self;
	DcRpcClient* _tmp0_;
	DcRpcClient* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	DcRpcClient* _tmp4_;
	GError* e;
	GError* _tmp5_;
	const gchar* _tmp6_;
	GError* _inner_error0_;
};

struct _DcProfileDialogPickAvatarData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcProfileDialog* self;
	gchar* path;
	GtkRoot* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	AdwAvatar* _tmp5_;
	const gchar* _tmp6_;
	GdkTexture* _tmp7_;
	GdkTexture* _tmp8_;
};

struct _DcInviteCodeDialog {
	AdwDialog parent_instance;
	DcInviteCodeDialogPrivate * priv;
};

struct _DcInviteCodeDialogClass {
	AdwDialogClass parent_class;
};

struct _DcInviteCodeDialogPrivate {
	DcRpcClient* rpc;
	gint account_id;
	GtkLabel* status_label;
	GtkPicture* qr_picture;
	GtkTextView* qr_text_view;
	GtkScrolledWindow* qr_text_scroll;
	GtkButton* copy_btn;
	gchar* invite_text;
	gboolean closing;
};

struct _DcInviteCodeDialogLoadInviteCodeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcInviteCodeDialog* self;
	gchar* text;
	DcRpcClient* _tmp0_;
	gchar* _tmp1_;
	gchar* svg;
	DcRpcClient* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	GError* e;
	GError* _tmp7_;
	const gchar* _tmp8_;
	GError* _inner_error0_;
};

struct _DcSecondDeviceDialog {
	AdwDialog parent_instance;
	DcSecondDeviceDialogPrivate * priv;
};

struct _DcSecondDeviceDialogClass {
	AdwDialogClass parent_class;
};

struct _DcSecondDeviceDialogPrivate {
	DcRpcClient* rpc;
	gint account_id;
	GtkLabel* status_label;
	GtkPicture* qr_picture;
	GtkTextView* qr_text_view;
	GtkScrolledWindow* qr_text_scroll;
	GtkButton* copy_btn;
	gchar* qr_text;
	gboolean closing;
	gboolean provider_running;
};

struct _DcSecondDeviceDialogStartTransferData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcSecondDeviceDialog* self;
	DcRpcClient* _tmp0_;
	gchar* text;
	DcRpcClient* _tmp1_;
	gchar* _tmp2_;
	gchar* svg;
	DcRpcClient* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	GError* e;
	GError* _tmp8_;
	const gchar* _tmp9_;
	GError* _inner_error0_;
};

static gint DcProfileDialog_private_offset;
static gpointer dc_profile_dialog_parent_class = NULL;
static gint DcInviteCodeDialog_private_offset;
static gpointer dc_invite_code_dialog_parent_class = NULL;
static gint DcSecondDeviceDialog_private_offset;
static gpointer dc_second_device_dialog_parent_class = NULL;

VALA_EXTERN GType dc_profile_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcProfileDialog, g_object_unref)
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
VALA_EXTERN DcProfileDialog* dc_profile_dialog_new (DcRpcClient* rpc,
                                        gint acct_id);
VALA_EXTERN DcProfileDialog* dc_profile_dialog_construct (GType object_type,
                                              DcRpcClient* rpc,
                                              gint acct_id);
VALA_EXTERN gint dc_rpc_client_get_account_id (DcRpcClient* self);
static void __lambda87_ (DcProfileDialog* self);
static void dc_profile_dialog_do_save (DcProfileDialog* self,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
static void dc_profile_dialog_do_save_finish (DcProfileDialog* self,
                                       GAsyncResult* _res_);
static void ___lambda87__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda88_ (DcProfileDialog* self);
static void dc_profile_dialog_pick_avatar (DcProfileDialog* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void dc_profile_dialog_pick_avatar_finish (DcProfileDialog* self,
                                           GAsyncResult* _res_);
static void ___lambda88__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda89_ (DcProfileDialog* self);
static void ___lambda89__gtk_editable_changed (GtkEditable* _sender,
                                        gpointer self);
static void dc_profile_dialog_show_invite_code_dialog (DcProfileDialog* self);
static void _dc_profile_dialog_show_invite_code_dialog_gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self);
static void dc_profile_dialog_show_relays_dialog (DcProfileDialog* self);
static void _dc_profile_dialog_show_relays_dialog_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
static void dc_profile_dialog_show_second_device_dialog (DcProfileDialog* self);
static void _dc_profile_dialog_show_second_device_dialog_gtk_button_clicked (GtkButton* _sender,
                                                                      gpointer self);
static void dc_profile_dialog_confirm_delete_account (DcProfileDialog* self);
static void _dc_profile_dialog_confirm_delete_account_gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self);
static void dc_profile_dialog_load_profile (DcProfileDialog* self,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void dc_profile_dialog_load_profile_finish (DcProfileDialog* self,
                                            GAsyncResult* _res_);
static void dc_profile_dialog_load_profile_data_free (gpointer _data);
static gboolean dc_profile_dialog_load_profile_co (DcProfileDialogLoadProfileData* _data_);
VALA_EXTERN void dc_rpc_client_get_config (DcRpcClient* self,
                               const gchar* key,
                               gint acct_id,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_config_finish (DcRpcClient* self,
                                        GAsyncResult* _res_,
                                        GError** error);
static void dc_profile_dialog_load_profile_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
VALA_EXTERN GdkTexture* dc_load_avatar (const gchar* path);
static void dc_profile_dialog_do_save_data_free (gpointer _data);
static gboolean dc_profile_dialog_do_save_co (DcProfileDialogDoSaveData* _data_);
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);
static void dc_profile_dialog_do_save_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
VALA_EXTERN GType dc_invite_code_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcInviteCodeDialog, g_object_unref)
VALA_EXTERN DcInviteCodeDialog* dc_invite_code_dialog_new (DcRpcClient* rpc,
                                               gint acct_id);
VALA_EXTERN DcInviteCodeDialog* dc_invite_code_dialog_construct (GType object_type,
                                                     DcRpcClient* rpc,
                                                     gint acct_id);
VALA_EXTERN GType dc_second_device_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSecondDeviceDialog, g_object_unref)
VALA_EXTERN DcSecondDeviceDialog* dc_second_device_dialog_new (DcRpcClient* rpc,
                                                   gint acct_id);
VALA_EXTERN DcSecondDeviceDialog* dc_second_device_dialog_construct (GType object_type,
                                                         DcRpcClient* rpc,
                                                         gint acct_id);
VALA_EXTERN GType dc_relays_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRelaysDialog, g_object_unref)
VALA_EXTERN DcRelaysDialog* dc_relays_dialog_new (DcRpcClient* rpc,
                                      gint acct_id);
VALA_EXTERN DcRelaysDialog* dc_relays_dialog_construct (GType object_type,
                                            DcRpcClient* rpc,
                                            gint acct_id);
VALA_EXTERN void dc_confirm_action (GtkWidget* parent,
                        const gchar* title,
                        const gchar* body,
                        const gchar* action_id,
                        const gchar* action_label,
                        DcVoidFunc on_confirm,
                        gpointer on_confirm_target,
                        GDestroyNotify on_confirm_target_destroy_notify);
static void __lambda101_ (DcProfileDialog* self);
static void dc_profile_dialog_do_delete_account (DcProfileDialog* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void dc_profile_dialog_do_delete_account_finish (DcProfileDialog* self,
                                                 GAsyncResult* _res_);
static void ___lambda101__dc_void_func (gpointer self);
static void dc_profile_dialog_do_delete_account_data_free (gpointer _data);
static gboolean dc_profile_dialog_do_delete_account_co (DcProfileDialogDoDeleteAccountData* _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);
static void dc_profile_dialog_do_delete_account_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_set_account_id (DcRpcClient* self,
                                   gint value);
static void dc_profile_dialog_pick_avatar_data_free (gpointer _data);
static gboolean dc_profile_dialog_pick_avatar_co (DcProfileDialogPickAvatarData* _data_);
VALA_EXTERN void dc_pick_image_file (GtkWindow* parent,
                         const gchar* title,
                         GAsyncReadyCallback _callback_,
                         gpointer _user_data_);
VALA_EXTERN gchar* dc_pick_image_file_finish (GAsyncResult* _res_);
static void dc_profile_dialog_pick_avatar_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void dc_profile_dialog_finalize (GObject * obj);
static GType dc_profile_dialog_get_type_once (void);
static void dc_invite_code_dialog_copy_invite_text (DcInviteCodeDialog* self);
static void _dc_invite_code_dialog_copy_invite_text_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
static void __lambda90_ (DcInviteCodeDialog* self);
static void ___lambda90__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
VALA_EXTERN void dc_install_escape_close (AdwDialog* dialog);
static void __lambda91_ (DcInviteCodeDialog* self);
static void ___lambda91__adw_dialog_closed (AdwDialog* _sender,
                                     gpointer self);
static void dc_invite_code_dialog_load_invite_code (DcInviteCodeDialog* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void dc_invite_code_dialog_load_invite_code_finish (DcInviteCodeDialog* self,
                                                    GAsyncResult* _res_);
static void dc_invite_code_dialog_load_invite_code_data_free (gpointer _data);
static gboolean dc_invite_code_dialog_load_invite_code_co (DcInviteCodeDialogLoadInviteCodeData* _data_);
VALA_EXTERN void dc_rpc_client_get_chat_securejoin_qr_code (DcRpcClient* self,
                                                gint acct_id,
                                                gint chat_id,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_chat_securejoin_qr_code_finish (DcRpcClient* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
static void dc_invite_code_dialog_load_invite_code_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_create_qr_svg (DcRpcClient* self,
                                  const gchar* text,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_create_qr_svg_finish (DcRpcClient* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static void dc_invite_code_dialog_show_qr (DcInviteCodeDialog* self,
                                    const gchar* text,
                                    const gchar* svg);
static void dc_invite_code_dialog_show_invite_error (DcInviteCodeDialog* self,
                                              const gchar* message);
static void dc_invite_code_dialog_finalize (GObject * obj);
static GType dc_invite_code_dialog_get_type_once (void);
static void dc_second_device_dialog_copy_qr_text (DcSecondDeviceDialog* self);
static void _dc_second_device_dialog_copy_qr_text_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
static void __lambda98_ (DcSecondDeviceDialog* self);
static void ___lambda98__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void dc_second_device_dialog_on_closed (DcSecondDeviceDialog* self);
static void _dc_second_device_dialog_on_closed_adw_dialog_closed (AdwDialog* _sender,
                                                           gpointer self);
static void dc_second_device_dialog_start_transfer (DcSecondDeviceDialog* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void dc_second_device_dialog_start_transfer_finish (DcSecondDeviceDialog* self,
                                                    GAsyncResult* _res_);
static void dc_second_device_dialog_start_transfer_data_free (gpointer _data);
static gboolean dc_second_device_dialog_start_transfer_co (DcSecondDeviceDialogStartTransferData* _data_);
VALA_EXTERN void dc_rpc_client_provide_backup (DcRpcClient* self,
                                   gint acct_id,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_provide_backup_finish (DcRpcClient* self,
                                          GAsyncResult* _res_,
                                          GError** error);
static void __lambda100_ (DcSecondDeviceDialog* self,
                   GObject* obj,
                   GAsyncResult* res);
static void dc_second_device_dialog_show_transfer_error (DcSecondDeviceDialog* self,
                                                  const gchar* message);
static void ___lambda100__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
VALA_EXTERN void dc_rpc_client_get_backup_qr (DcRpcClient* self,
                                  gint acct_id,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_backup_qr_finish (DcRpcClient* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static void dc_second_device_dialog_start_transfer_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void dc_second_device_dialog_show_qr (DcSecondDeviceDialog* self,
                                      const gchar* text,
                                      const gchar* svg);
static void dc_second_device_dialog_stop_provider (DcSecondDeviceDialog* self);
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 ___lambda99_ (DcSecondDeviceDialog* self,
                   GObject* obj,
                   GAsyncResult* res);
static void ____lambda99__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void dc_second_device_dialog_finalize (GObject * obj);
static GType dc_second_device_dialog_get_type_once (void);

static inline gpointer
dc_profile_dialog_get_instance_private (DcProfileDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcProfileDialog_private_offset);
}

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

static void
__lambda87_ (DcProfileDialog* self)
{
	dc_profile_dialog_do_save (self, NULL, NULL);
}

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

static void
__lambda88_ (DcProfileDialog* self)
{
	dc_profile_dialog_pick_avatar (self, NULL, NULL);
}

static void
___lambda88__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda88_ ((DcProfileDialog*) self);
}

static void
__lambda89_ (DcProfileDialog* self)
{
	const gchar* _tmp0_ = NULL;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	AdwAvatar* _tmp9_;
	_tmp1_ = self->priv->name_entry;
	_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ > 0) {
		GtkEntry* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = self->priv->name_entry;
		_tmp7_ = gtk_editable_get_text ((GtkEditable*) _tmp6_);
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp8_;
	} else {
		_tmp0_ = "";
	}
	_tmp9_ = self->priv->avatar_widget;
	adw_avatar_set_text (_tmp9_, _tmp0_);
}

static void
___lambda89__gtk_editable_changed (GtkEditable* _sender,
                                   gpointer self)
{
	__lambda89_ ((DcProfileDialog*) self);
}

static void
_dc_profile_dialog_show_invite_code_dialog_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self)
{
	dc_profile_dialog_show_invite_code_dialog ((DcProfileDialog*) self);
}

static void
_dc_profile_dialog_show_relays_dialog_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self)
{
	dc_profile_dialog_show_relays_dialog ((DcProfileDialog*) self);
}

static void
_dc_profile_dialog_show_second_device_dialog_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self)
{
	dc_profile_dialog_show_second_device_dialog ((DcProfileDialog*) self);
}

static void
_dc_profile_dialog_confirm_delete_account_gtk_button_clicked (GtkButton* _sender,
                                                              gpointer self)
{
	dc_profile_dialog_confirm_delete_account ((DcProfileDialog*) self);
}

DcProfileDialog*
dc_profile_dialog_construct (GType object_type,
                             DcRpcClient* rpc,
                             gint acct_id)
{
	DcProfileDialog * self = NULL;
	DcRpcClient* _tmp0_;
	gint _tmp1_ = 0;
	GtkBox* box = NULL;
	GtkBox* _tmp4_;
	AdwHeaderBar* header = NULL;
	AdwHeaderBar* _tmp5_;
	GtkButton* save_btn = NULL;
	GtkButton* _tmp6_;
	GtkBox* content = NULL;
	GtkBox* _tmp7_;
	AdwAvatar* _tmp8_;
	AdwAvatar* _tmp9_;
	AdwAvatar* _tmp10_;
	GtkButton* avatar_btn = NULL;
	GtkButton* _tmp11_;
	GtkSeparator* _tmp12_;
	GtkSeparator* _tmp13_;
	GtkLabel* name_lbl = NULL;
	GtkLabel* _tmp14_;
	GtkEntry* _tmp15_;
	GtkEntry* _tmp16_;
	GtkEntry* _tmp17_;
	GtkEntry* _tmp18_;
	GtkLabel* status_lbl = NULL;
	GtkLabel* _tmp19_;
	GtkEntry* _tmp20_;
	GtkEntry* _tmp21_;
	GtkEntry* _tmp22_;
	GtkLabel* email_lbl = NULL;
	GtkLabel* _tmp23_;
	GtkLabel* _tmp24_;
	GtkLabel* _tmp25_;
	GtkLabel* _tmp26_;
	GtkLabel* _tmp27_;
	GtkLabel* _tmp28_;
	GtkSeparator* _tmp29_;
	GtkSeparator* _tmp30_;
	GtkBox* invite_code_box = NULL;
	GtkBox* _tmp31_;
	GtkButton* invite_code_btn = NULL;
	GtkButton* _tmp32_;
	GtkLabel* invite_code_label = NULL;
	GtkLabel* _tmp33_;
	GtkBox* relays_box = NULL;
	GtkBox* _tmp34_;
	GtkButton* relays_btn = NULL;
	GtkButton* _tmp35_;
	GtkLabel* relays_label = NULL;
	GtkLabel* _tmp36_;
	GtkBox* second_device_box = NULL;
	GtkBox* _tmp37_;
	GtkButton* second_device_btn = NULL;
	GtkButton* _tmp38_;
	GtkLabel* second_device_label = NULL;
	GtkLabel* _tmp39_;
	GtkBox* delete_box = NULL;
	GtkBox* _tmp40_;
	GtkButton* delete_btn = NULL;
	GtkButton* _tmp41_;
	GtkLabel* delete_label = NULL;
	GtkLabel* _tmp42_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp43_;
	g_return_val_if_fail (rpc != NULL, NULL);
	self = (DcProfileDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	if (acct_id > 0) {
		_tmp1_ = acct_id;
	} else {
		gint _tmp2_;
		gint _tmp3_;
		_tmp2_ = dc_rpc_client_get_account_id (rpc);
		_tmp3_ = _tmp2_;
		_tmp1_ = _tmp3_;
	}
	self->priv->account_id = _tmp1_;
	adw_dialog_set_title ((AdwDialog*) self, "My Profile");
	adw_dialog_set_content_width ((AdwDialog*) self, 360);
	adw_dialog_set_content_height ((AdwDialog*) self, 420);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp4_);
	box = _tmp4_;
	_tmp5_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp5_);
	header = _tmp5_;
	_tmp6_ = (GtkButton*) gtk_button_new_with_label ("Save");
	g_object_ref_sink (_tmp6_);
	save_btn = _tmp6_;
	gtk_widget_add_css_class ((GtkWidget*) save_btn, "suggested-action");
	g_signal_connect_object (save_btn, "clicked", (GCallback) ___lambda87__gtk_button_clicked, self, 0);
	adw_header_bar_pack_end (header, (GtkWidget*) save_btn);
	gtk_box_append (box, (GtkWidget*) header);
	_tmp7_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp7_);
	content = _tmp7_;
	gtk_widget_set_margin_start ((GtkWidget*) content, 16);
	gtk_widget_set_margin_end ((GtkWidget*) content, 16);
	gtk_widget_set_margin_top ((GtkWidget*) content, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) content, 16);
	_tmp8_ = (AdwAvatar*) adw_avatar_new (96, "", TRUE);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->avatar_widget);
	self->priv->avatar_widget = _tmp8_;
	_tmp9_ = self->priv->avatar_widget;
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	_tmp10_ = self->priv->avatar_widget;
	gtk_box_append (content, (GtkWidget*) _tmp10_);
	_tmp11_ = (GtkButton*) gtk_button_new_with_label ("Change Avatar");
	g_object_ref_sink (_tmp11_);
	avatar_btn = _tmp11_;
	gtk_widget_set_halign ((GtkWidget*) avatar_btn, GTK_ALIGN_CENTER);
	gtk_widget_add_css_class ((GtkWidget*) avatar_btn, "flat");
	g_signal_connect_object (avatar_btn, "clicked", (GCallback) ___lambda88__gtk_button_clicked, self, 0);
	gtk_box_append (content, (GtkWidget*) avatar_btn);
	_tmp12_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp12_);
	_tmp13_ = _tmp12_;
	gtk_box_append (content, (GtkWidget*) _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = (GtkLabel*) gtk_label_new ("Display Name");
	g_object_ref_sink (_tmp14_);
	name_lbl = _tmp14_;
	gtk_widget_add_css_class ((GtkWidget*) name_lbl, "heading");
	gtk_widget_set_halign ((GtkWidget*) name_lbl, GTK_ALIGN_START);
	gtk_box_append (content, (GtkWidget*) name_lbl);
	_tmp15_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->name_entry);
	self->priv->name_entry = _tmp15_;
	_tmp16_ = self->priv->name_entry;
	gtk_entry_set_placeholder_text (_tmp16_, "Your name");
	_tmp17_ = self->priv->name_entry;
	g_signal_connect_object ((GtkEditable*) _tmp17_, "changed", (GCallback) ___lambda89__gtk_editable_changed, self, 0);
	_tmp18_ = self->priv->name_entry;
	gtk_box_append (content, (GtkWidget*) _tmp18_);
	_tmp19_ = (GtkLabel*) gtk_label_new ("Status");
	g_object_ref_sink (_tmp19_);
	status_lbl = _tmp19_;
	gtk_widget_add_css_class ((GtkWidget*) status_lbl, "heading");
	gtk_widget_set_halign ((GtkWidget*) status_lbl, GTK_ALIGN_START);
	gtk_box_append (content, (GtkWidget*) status_lbl);
	_tmp20_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->status_entry);
	self->priv->status_entry = _tmp20_;
	_tmp21_ = self->priv->status_entry;
	gtk_entry_set_placeholder_text (_tmp21_, "Your status message");
	_tmp22_ = self->priv->status_entry;
	gtk_box_append (content, (GtkWidget*) _tmp22_);
	_tmp23_ = (GtkLabel*) gtk_label_new ("Email");
	g_object_ref_sink (_tmp23_);
	email_lbl = _tmp23_;
	gtk_widget_add_css_class ((GtkWidget*) email_lbl, "heading");
	gtk_widget_set_halign ((GtkWidget*) email_lbl, GTK_ALIGN_START);
	gtk_box_append (content, (GtkWidget*) email_lbl);
	_tmp24_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->email_label);
	self->priv->email_label = _tmp24_;
	_tmp25_ = self->priv->email_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp25_, GTK_ALIGN_START);
	_tmp26_ = self->priv->email_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp26_, "dim-label");
	_tmp27_ = self->priv->email_label;
	gtk_label_set_selectable (_tmp27_, TRUE);
	_tmp28_ = self->priv->email_label;
	gtk_box_append (content, (GtkWidget*) _tmp28_);
	_tmp29_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp29_);
	_tmp30_ = _tmp29_;
	gtk_box_append (content, (GtkWidget*) _tmp30_);
	_g_object_unref0 (_tmp30_);
	_tmp31_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp31_);
	invite_code_box = _tmp31_;
	gtk_widget_set_margin_top ((GtkWidget*) invite_code_box, 4);
	_tmp32_ = (GtkButton*) gtk_button_new_with_label ("Invite Code");
	g_object_ref_sink (_tmp32_);
	invite_code_btn = _tmp32_;
	gtk_widget_set_tooltip_text ((GtkWidget*) invite_code_btn, "Show a contact invite QR code");
	g_signal_connect_object (invite_code_btn, "clicked", (GCallback) _dc_profile_dialog_show_invite_code_dialog_gtk_button_clicked, self, 0);
	gtk_box_append (invite_code_box, (GtkWidget*) invite_code_btn);
	_tmp33_ = (GtkLabel*) gtk_label_new ("Share your contact");
	g_object_ref_sink (_tmp33_);
	invite_code_label = _tmp33_;
	gtk_widget_add_css_class ((GtkWidget*) invite_code_label, "dim-label");
	gtk_widget_set_valign ((GtkWidget*) invite_code_label, GTK_ALIGN_CENTER);
	gtk_label_set_wrap (invite_code_label, TRUE);
	gtk_label_set_xalign (invite_code_label, (gfloat) 0);
	gtk_widget_set_hexpand ((GtkWidget*) invite_code_label, TRUE);
	gtk_box_append (invite_code_box, (GtkWidget*) invite_code_label);
	gtk_box_append (content, (GtkWidget*) invite_code_box);
	_tmp34_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp34_);
	relays_box = _tmp34_;
	gtk_widget_set_margin_top ((GtkWidget*) relays_box, 4);
	_tmp35_ = (GtkButton*) gtk_button_new_with_label ("Relays...");
	g_object_ref_sink (_tmp35_);
	relays_btn = _tmp35_;
	gtk_widget_set_tooltip_text ((GtkWidget*) relays_btn, "Manage chatmail relays for this profile");
	g_signal_connect_object (relays_btn, "clicked", (GCallback) _dc_profile_dialog_show_relays_dialog_gtk_button_clicked, self, 0);
	gtk_box_append (relays_box, (GtkWidget*) relays_btn);
	_tmp36_ = (GtkLabel*) gtk_label_new ("Manage transports");
	g_object_ref_sink (_tmp36_);
	relays_label = _tmp36_;
	gtk_widget_add_css_class ((GtkWidget*) relays_label, "dim-label");
	gtk_widget_set_valign ((GtkWidget*) relays_label, GTK_ALIGN_CENTER);
	gtk_label_set_wrap (relays_label, TRUE);
	gtk_label_set_xalign (relays_label, (gfloat) 0);
	gtk_widget_set_hexpand ((GtkWidget*) relays_label, TRUE);
	gtk_box_append (relays_box, (GtkWidget*) relays_label);
	gtk_box_append (content, (GtkWidget*) relays_box);
	_tmp37_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp37_);
	second_device_box = _tmp37_;
	gtk_widget_set_margin_top ((GtkWidget*) second_device_box, 4);
	_tmp38_ = (GtkButton*) gtk_button_new_with_label ("Add Second Device");
	g_object_ref_sink (_tmp38_);
	second_device_btn = _tmp38_;
	gtk_widget_set_tooltip_text ((GtkWidget*) second_device_btn, "Show a setup QR code for another device");
	g_signal_connect_object (second_device_btn, "clicked", (GCallback) _dc_profile_dialog_show_second_device_dialog_gtk_button_clicked, self, 0);
	gtk_box_append (second_device_box, (GtkWidget*) second_device_btn);
	_tmp39_ = (GtkLabel*) gtk_label_new ("Transfer to another device");
	g_object_ref_sink (_tmp39_);
	second_device_label = _tmp39_;
	gtk_widget_add_css_class ((GtkWidget*) second_device_label, "dim-label");
	gtk_widget_set_valign ((GtkWidget*) second_device_label, GTK_ALIGN_CENTER);
	gtk_label_set_wrap (second_device_label, TRUE);
	gtk_label_set_xalign (second_device_label, (gfloat) 0);
	gtk_widget_set_hexpand ((GtkWidget*) second_device_label, TRUE);
	gtk_box_append (second_device_box, (GtkWidget*) second_device_label);
	gtk_box_append (content, (GtkWidget*) second_device_box);
	_tmp40_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp40_);
	delete_box = _tmp40_;
	gtk_widget_set_margin_top ((GtkWidget*) delete_box, 4);
	_tmp41_ = (GtkButton*) gtk_button_new_with_label ("Delete Profile");
	g_object_ref_sink (_tmp41_);
	delete_btn = _tmp41_;
	gtk_widget_add_css_class ((GtkWidget*) delete_btn, "destructive-action");
	gtk_widget_set_tooltip_text ((GtkWidget*) delete_btn, "Delete local profile data");
	g_signal_connect_object (delete_btn, "clicked", (GCallback) _dc_profile_dialog_confirm_delete_account_gtk_button_clicked, self, 0);
	gtk_box_append (delete_box, (GtkWidget*) delete_btn);
	_tmp42_ = (GtkLabel*) gtk_label_new ("Delete local profile data");
	g_object_ref_sink (_tmp42_);
	delete_label = _tmp42_;
	gtk_widget_add_css_class ((GtkWidget*) delete_label, "dim-label");
	gtk_widget_set_valign ((GtkWidget*) delete_label, GTK_ALIGN_CENTER);
	gtk_label_set_wrap (delete_label, TRUE);
	gtk_label_set_xalign (delete_label, (gfloat) 0);
	gtk_widget_set_hexpand ((GtkWidget*) delete_label, TRUE);
	gtk_box_append (delete_box, (GtkWidget*) delete_label);
	gtk_box_append (content, (GtkWidget*) delete_box);
	_tmp43_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp43_);
	scroll = _tmp43_;
	gtk_widget_set_vexpand ((GtkWidget*) scroll, TRUE);
	g_object_set (scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_child (scroll, (GtkWidget*) content);
	gtk_box_append (box, (GtkWidget*) scroll);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) box);
	dc_profile_dialog_load_profile (self, NULL, NULL);
	_g_object_unref0 (scroll);
	_g_object_unref0 (delete_label);
	_g_object_unref0 (delete_btn);
	_g_object_unref0 (delete_box);
	_g_object_unref0 (second_device_label);
	_g_object_unref0 (second_device_btn);
	_g_object_unref0 (second_device_box);
	_g_object_unref0 (relays_label);
	_g_object_unref0 (relays_btn);
	_g_object_unref0 (relays_box);
	_g_object_unref0 (invite_code_label);
	_g_object_unref0 (invite_code_btn);
	_g_object_unref0 (invite_code_box);
	_g_object_unref0 (email_lbl);
	_g_object_unref0 (status_lbl);
	_g_object_unref0 (name_lbl);
	_g_object_unref0 (avatar_btn);
	_g_object_unref0 (content);
	_g_object_unref0 (save_btn);
	_g_object_unref0 (header);
	_g_object_unref0 (box);
	return self;
}

DcProfileDialog*
dc_profile_dialog_new (DcRpcClient* rpc,
                       gint acct_id)
{
	return dc_profile_dialog_construct (DC_TYPE_PROFILE_DIALOG, rpc, acct_id);
}

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

static void
dc_profile_dialog_load_profile (DcProfileDialog* self,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	DcProfileDialogLoadProfileData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogLoadProfileData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_profile_dialog_load_profile_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_load_profile_co (_data_);
}

static void
dc_profile_dialog_load_profile_finish (DcProfileDialog* self,
                                       GAsyncResult* _res_)
{
	DcProfileDialogLoadProfileData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_profile_dialog_load_profile_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	DcProfileDialogLoadProfileData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_load_profile_co (_data_);
}

static gboolean
dc_profile_dialog_load_profile_co (DcProfileDialogLoadProfileData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_config (_data_->_tmp0_, "displayname", _data_->self->priv->account_id, dc_profile_dialog_load_profile_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = dc_rpc_client_get_config_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		_data_->name = _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->self->priv->rpc;
		_data_->_state_ = 2;
		dc_rpc_client_get_config (_data_->_tmp2_, "selfstatus", _data_->self->priv->account_id, dc_profile_dialog_load_profile_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp3_ = dc_rpc_client_get_config_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->status = _data_->_tmp3_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->name);
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = _data_->self->priv->rpc;
		_data_->_state_ = 3;
		dc_rpc_client_get_config (_data_->_tmp4_, "addr", _data_->self->priv->account_id, dc_profile_dialog_load_profile_ready, _data_);
		return FALSE;
		_state_3:
		_data_->_tmp5_ = dc_rpc_client_get_config_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		_data_->email = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->status);
			_g_free0 (_data_->name);
			goto __catch0_g_error;
		}
		_data_->_tmp6_ = _data_->self->priv->rpc;
		_data_->_state_ = 4;
		dc_rpc_client_get_config (_data_->_tmp6_, "selfavatar", _data_->self->priv->account_id, dc_profile_dialog_load_profile_ready, _data_);
		return FALSE;
		_state_4:
		_data_->_tmp7_ = dc_rpc_client_get_config_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		_data_->avatar = _data_->_tmp7_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->email);
			_g_free0 (_data_->status);
			_g_free0 (_data_->name);
			goto __catch0_g_error;
		}
		_data_->_tmp8_ = _data_->name;
		if (_data_->_tmp8_ != NULL) {
			_data_->_tmp9_ = _data_->self->priv->name_entry;
			_data_->_tmp10_ = _data_->name;
			gtk_editable_set_text ((GtkEditable*) _data_->_tmp9_, _data_->_tmp10_);
			_data_->_tmp11_ = _data_->self->priv->avatar_widget;
			_data_->_tmp12_ = _data_->name;
			adw_avatar_set_text (_data_->_tmp11_, _data_->_tmp12_);
		}
		_data_->_tmp13_ = _data_->status;
		if (_data_->_tmp13_ != NULL) {
			_data_->_tmp14_ = _data_->self->priv->status_entry;
			_data_->_tmp15_ = _data_->status;
			gtk_editable_set_text ((GtkEditable*) _data_->_tmp14_, _data_->_tmp15_);
		}
		_data_->_tmp16_ = _data_->email;
		if (_data_->_tmp16_ != NULL) {
			_data_->_tmp17_ = _data_->self->priv->email_label;
			_data_->_tmp18_ = _data_->email;
			gtk_label_set_label (_data_->_tmp17_, _data_->_tmp18_);
		}
		_data_->_tmp21_ = _data_->avatar;
		if (_data_->_tmp21_ != NULL) {
			_data_->_tmp22_ = _data_->avatar;
			_data_->_tmp23_ = strlen (_data_->_tmp22_);
			_data_->_tmp24_ = _data_->_tmp23_;
			_data_->_tmp20_ = _data_->_tmp24_ > 0;
		} else {
			_data_->_tmp20_ = FALSE;
		}
		if (_data_->_tmp20_) {
			_data_->_tmp25_ = _data_->avatar;
			_data_->_tmp19_ = g_file_test (_data_->_tmp25_, G_FILE_TEST_EXISTS);
		} else {
			_data_->_tmp19_ = FALSE;
		}
		if (_data_->_tmp19_) {
			_data_->_tmp26_ = _data_->avatar;
			_data_->_tmp27_ = g_strdup (_data_->_tmp26_);
			_g_free0 (_data_->self->priv->avatar_path);
			_data_->self->priv->avatar_path = _data_->_tmp27_;
		}
		_data_->_tmp28_ = _data_->self->priv->avatar_widget;
		_data_->_tmp29_ = _data_->avatar;
		_data_->_tmp30_ = dc_load_avatar (_data_->_tmp29_);
		_data_->_tmp31_ = _data_->_tmp30_;
		adw_avatar_set_custom_image (_data_->_tmp28_, (GdkPaintable*) _data_->_tmp31_);
		_g_object_unref0 (_data_->_tmp31_);
		_g_free0 (_data_->avatar);
		_g_free0 (_data_->email);
		_g_free0 (_data_->status);
		_g_free0 (_data_->name);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_profile_dialog_do_save (DcProfileDialog* self,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_)
{
	DcProfileDialogDoSaveData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogDoSaveData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_profile_dialog_do_save_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_do_save_co (_data_);
}

static void
dc_profile_dialog_do_save_finish (DcProfileDialog* self,
                                  GAsyncResult* _res_)
{
	DcProfileDialogDoSaveData* _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_profile_dialog_do_save_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_)
{
	DcProfileDialogDoSaveData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_do_save_co (_data_);
}

static gboolean
dc_profile_dialog_do_save_co (DcProfileDialogDoSaveData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_tmp1_ = _data_->self->priv->name_entry;
		_data_->_tmp2_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp1_);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = string_strip (_data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_state_ = 1;
		dc_rpc_client_batch_set_config (_data_->_tmp0_, "displayname", _data_->_tmp5_, _data_->self->priv->account_id, dc_profile_dialog_do_save_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_batch_set_config_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		_g_free0 (_data_->_tmp5_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp6_ = _data_->self->priv->rpc;
		_data_->_tmp7_ = _data_->self->priv->status_entry;
		_data_->_tmp8_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = string_strip (_data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_state_ = 2;
		dc_rpc_client_batch_set_config (_data_->_tmp6_, "selfstatus", _data_->_tmp11_, _data_->self->priv->account_id, dc_profile_dialog_do_save_ready, _data_);
		return FALSE;
		_state_2:
		dc_rpc_client_batch_set_config_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		_g_free0 (_data_->_tmp11_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (_data_->self->priv->avatar_changed) {
			_data_->_tmp13_ = _data_->self->priv->avatar_path;
			_data_->_tmp12_ = _data_->_tmp13_ != NULL;
		} else {
			_data_->_tmp12_ = FALSE;
		}
		if (_data_->_tmp12_) {
			_data_->_tmp14_ = _data_->self->priv->rpc;
			_data_->_tmp15_ = _data_->self->priv->avatar_path;
			_data_->_state_ = 3;
			dc_rpc_client_batch_set_config (_data_->_tmp14_, "selfavatar", _data_->_tmp15_, _data_->self->priv->account_id, dc_profile_dialog_do_save_ready, _data_);
			return FALSE;
			_state_3:
			dc_rpc_client_batch_set_config_finish (_data_->_tmp14_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		g_signal_emit (_data_->self, dc_profile_dialog_signals[DC_PROFILE_DIALOG_PROFILE_UPDATED_SIGNAL], 0);
		adw_dialog_close ((AdwDialog*) _data_->self);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp16_ = _data_->e;
		_data_->_tmp17_ = _data_->_tmp16_->message;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp17_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_profile_dialog_show_invite_code_dialog (DcProfileDialog* self)
{
	DcInviteCodeDialog* dialog = NULL;
	DcRpcClient* _tmp0_;
	DcInviteCodeDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_invite_code_dialog_new (_tmp0_, self->priv->account_id);
	g_object_ref_sink (_tmp1_);
	dialog = _tmp1_;
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

static void
dc_profile_dialog_show_second_device_dialog (DcProfileDialog* self)
{
	DcSecondDeviceDialog* dialog = NULL;
	DcRpcClient* _tmp0_;
	DcSecondDeviceDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_second_device_dialog_new (_tmp0_, self->priv->account_id);
	g_object_ref_sink (_tmp1_);
	dialog = _tmp1_;
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

static void
dc_profile_dialog_show_relays_dialog (DcProfileDialog* self)
{
	DcRelaysDialog* dialog = NULL;
	DcRpcClient* _tmp0_;
	DcRelaysDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_relays_dialog_new (_tmp0_, self->priv->account_id);
	g_object_ref_sink (_tmp1_);
	dialog = _tmp1_;
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

static void
__lambda101_ (DcProfileDialog* self)
{
	dc_profile_dialog_do_delete_account (self, NULL, NULL);
}

static void
___lambda101__dc_void_func (gpointer self)
{
	__lambda101_ ((DcProfileDialog*) self);
}

static void
dc_profile_dialog_confirm_delete_account (DcProfileDialog* self)
{
	gchar* label = NULL;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	const gchar* _tmp11_;
	gint _tmp12_;
	gint _tmp13_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->email_label;
	_tmp1_ = gtk_label_get_label (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_strip (_tmp2_);
	label = _tmp3_;
	_tmp4_ = label;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ == 0) {
		GtkEntry* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp7_ = self->priv->name_entry;
		_tmp8_ = gtk_editable_get_text ((GtkEditable*) _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = string_strip (_tmp9_);
		_g_free0 (label);
		label = _tmp10_;
	}
	_tmp11_ = label;
	_tmp12_ = strlen (_tmp11_);
	_tmp13_ = _tmp12_;
	if (_tmp13_ == 0) {
		gchar* _tmp14_;
		_tmp14_ = g_strdup ("this account");
		_g_free0 (label);
		label = _tmp14_;
	}
	_tmp15_ = label;
	_tmp16_ = g_strdup_printf ("Delete \"%s\"? This will remove all local data for this profile.", _tmp15_);
	_tmp17_ = _tmp16_;
	dc_confirm_action ((GtkWidget*) self, "Delete Profile", _tmp17_, "delete", "Delete Profile", ___lambda101__dc_void_func, g_object_ref (self), g_object_unref);
	_g_free0 (_tmp17_);
	_g_free0 (label);
}

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

static void
dc_profile_dialog_do_delete_account (DcProfileDialog* self,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	DcProfileDialogDoDeleteAccountData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogDoDeleteAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_profile_dialog_do_delete_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_do_delete_account_co (_data_);
}

static void
dc_profile_dialog_do_delete_account_finish (DcProfileDialog* self,
                                            GAsyncResult* _res_)
{
	DcProfileDialogDoDeleteAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_profile_dialog_do_delete_account_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	DcProfileDialogDoDeleteAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_do_delete_account_co (_data_);
}

static gboolean
dc_profile_dialog_do_delete_account_co (DcProfileDialogDoDeleteAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_remove_account (_data_->_tmp0_, _data_->self->priv->account_id, dc_profile_dialog_do_delete_account_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_remove_account_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp1_ = _data_->self->priv->rpc;
		_data_->_tmp2_ = dc_rpc_client_get_account_id (_data_->_tmp1_);
		_data_->_tmp3_ = _data_->_tmp2_;
		if (_data_->_tmp3_ == _data_->self->priv->account_id) {
			_data_->_tmp4_ = _data_->self->priv->rpc;
			dc_rpc_client_set_account_id (_data_->_tmp4_, 0);
		}
		g_signal_emit (_data_->self, dc_profile_dialog_signals[DC_PROFILE_DIALOG_ACCOUNT_DELETED_SIGNAL], 0, _data_->self->priv->account_id);
		adw_dialog_close ((AdwDialog*) _data_->self);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp5_ = _data_->e;
		_data_->_tmp6_ = _data_->_tmp5_->message;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp6_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_profile_dialog_pick_avatar (DcProfileDialog* self,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DcProfileDialogPickAvatarData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogPickAvatarData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_profile_dialog_pick_avatar_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_pick_avatar_co (_data_);
}

static void
dc_profile_dialog_pick_avatar_finish (DcProfileDialog* self,
                                      GAsyncResult* _res_)
{
	DcProfileDialogPickAvatarData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_profile_dialog_pick_avatar_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DcProfileDialogPickAvatarData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_pick_avatar_co (_data_);
}

static gboolean
dc_profile_dialog_pick_avatar_co (DcProfileDialogPickAvatarData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gtk_widget_get_root ((GtkWidget*) _data_->self);
	_data_->_state_ = 1;
	dc_pick_image_file (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, gtk_window_get_type (), GtkWindow), "Select Avatar", dc_profile_dialog_pick_avatar_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = dc_pick_image_file_finish (_data_->_res_);
	_data_->path = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->path;
	if (_data_->_tmp2_ != NULL) {
		_data_->_tmp3_ = _data_->path;
		_data_->_tmp4_ = g_strdup (_data_->_tmp3_);
		_g_free0 (_data_->self->priv->avatar_path);
		_data_->self->priv->avatar_path = _data_->_tmp4_;
		_data_->self->priv->avatar_changed = TRUE;
		_data_->_tmp5_ = _data_->self->priv->avatar_widget;
		_data_->_tmp6_ = _data_->path;
		_data_->_tmp7_ = dc_load_avatar (_data_->_tmp6_);
		_data_->_tmp8_ = _data_->_tmp7_;
		adw_avatar_set_custom_image (_data_->_tmp5_, (GdkPaintable*) _data_->_tmp8_);
		_g_object_unref0 (_data_->_tmp8_);
	}
	_g_free0 (_data_->path);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_profile_dialog_class_init (DcProfileDialogClass * klass,
                              gpointer klass_data)
{
	dc_profile_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcProfileDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_profile_dialog_finalize;
	dc_profile_dialog_signals[DC_PROFILE_DIALOG_PROFILE_UPDATED_SIGNAL] = g_signal_new ("profile-updated", DC_TYPE_PROFILE_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	dc_profile_dialog_signals[DC_PROFILE_DIALOG_ACCOUNT_DELETED_SIGNAL] = g_signal_new ("account-deleted", DC_TYPE_PROFILE_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
dc_profile_dialog_instance_init (DcProfileDialog * self,
                                 gpointer klass)
{
	self->priv = dc_profile_dialog_get_instance_private (self);
	self->priv->avatar_path = NULL;
	self->priv->avatar_changed = FALSE;
}

static void
dc_profile_dialog_finalize (GObject * obj)
{
	DcProfileDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_PROFILE_DIALOG, DcProfileDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->avatar_widget);
	_g_object_unref0 (self->priv->name_entry);
	_g_object_unref0 (self->priv->status_entry);
	_g_object_unref0 (self->priv->email_label);
	_g_free0 (self->priv->avatar_path);
	G_OBJECT_CLASS (dc_profile_dialog_parent_class)->finalize (obj);
}

static GType
dc_profile_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcProfileDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_profile_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcProfileDialog), 0, (GInstanceInitFunc) dc_profile_dialog_instance_init, NULL };
	GType dc_profile_dialog_type_id;
	dc_profile_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcProfileDialog", &g_define_type_info, 0);
	DcProfileDialog_private_offset = g_type_add_instance_private (dc_profile_dialog_type_id, sizeof (DcProfileDialogPrivate));
	return dc_profile_dialog_type_id;
}

GType
dc_profile_dialog_get_type (void)
{
	static volatile gsize dc_profile_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_profile_dialog_type_id__once)) {
		GType dc_profile_dialog_type_id;
		dc_profile_dialog_type_id = dc_profile_dialog_get_type_once ();
		g_once_init_leave (&dc_profile_dialog_type_id__once, dc_profile_dialog_type_id);
	}
	return dc_profile_dialog_type_id__once;
}

static inline gpointer
dc_invite_code_dialog_get_instance_private (DcInviteCodeDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcInviteCodeDialog_private_offset);
}

static void
_dc_invite_code_dialog_copy_invite_text_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	dc_invite_code_dialog_copy_invite_text ((DcInviteCodeDialog*) self);
}

static void
__lambda90_ (DcInviteCodeDialog* self)
{
	adw_dialog_close ((AdwDialog*) self);
}

static void
___lambda90__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda90_ ((DcInviteCodeDialog*) self);
}

static void
__lambda91_ (DcInviteCodeDialog* self)
{
	self->priv->closing = TRUE;
}

static void
___lambda91__adw_dialog_closed (AdwDialog* _sender,
                                gpointer self)
{
	__lambda91_ ((DcInviteCodeDialog*) self);
}

DcInviteCodeDialog*
dc_invite_code_dialog_construct (GType object_type,
                                 DcRpcClient* rpc,
                                 gint acct_id)
{
	DcInviteCodeDialog * self = NULL;
	DcRpcClient* _tmp0_;
	GtkBox* box = NULL;
	GtkBox* _tmp1_;
	AdwHeaderBar* _tmp2_;
	AdwHeaderBar* _tmp3_;
	GtkBox* content = NULL;
	GtkBox* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkPicture* _tmp9_;
	GtkPicture* _tmp10_;
	GtkPicture* _tmp11_;
	GtkPicture* _tmp12_;
	GtkPicture* _tmp13_;
	GtkPicture* _tmp14_;
	GtkPicture* _tmp15_;
	GtkTextView* _tmp16_;
	GtkTextView* _tmp17_;
	GtkTextView* _tmp18_;
	GtkTextView* _tmp19_;
	GtkTextView* _tmp20_;
	GtkScrolledWindow* _tmp21_;
	GtkScrolledWindow* _tmp22_;
	GtkScrolledWindow* _tmp23_;
	GtkScrolledWindow* _tmp24_;
	GtkTextView* _tmp25_;
	GtkScrolledWindow* _tmp26_;
	GtkScrolledWindow* _tmp27_;
	GtkBox* actions = NULL;
	GtkBox* _tmp28_;
	GtkButton* _tmp29_;
	GtkButton* _tmp30_;
	GtkButton* _tmp31_;
	GtkButton* _tmp32_;
	GtkButton* close_btn = NULL;
	GtkButton* _tmp33_;
	g_return_val_if_fail (rpc != NULL, NULL);
	self = (DcInviteCodeDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	self->priv->account_id = acct_id;
	adw_dialog_set_title ((AdwDialog*) self, "Invite Code");
	adw_dialog_set_content_width ((AdwDialog*) self, 480);
	adw_dialog_set_content_height ((AdwDialog*) self, 560);
	adw_dialog_set_can_close ((AdwDialog*) self, TRUE);
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	_tmp2_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	gtk_box_append (box, (GtkWidget*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp4_);
	content = _tmp4_;
	gtk_widget_set_margin_start ((GtkWidget*) content, 18);
	gtk_widget_set_margin_end ((GtkWidget*) content, 18);
	gtk_widget_set_margin_top ((GtkWidget*) content, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) content, 18);
	_tmp5_ = (GtkLabel*) gtk_label_new ("Preparing invite code…");
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->status_label);
	self->priv->status_label = _tmp5_;
	_tmp6_ = self->priv->status_label;
	gtk_label_set_wrap (_tmp6_, TRUE);
	_tmp7_ = self->priv->status_label;
	gtk_label_set_xalign (_tmp7_, (gfloat) 0);
	_tmp8_ = self->priv->status_label;
	gtk_box_append (content, (GtkWidget*) _tmp8_);
	_tmp9_ = (GtkPicture*) gtk_picture_new ();
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->qr_picture);
	self->priv->qr_picture = _tmp9_;
	_tmp10_ = self->priv->qr_picture;
	gtk_picture_set_content_fit (_tmp10_, GTK_CONTENT_FIT_CONTAIN);
	_tmp11_ = self->priv->qr_picture;
	gtk_picture_set_can_shrink (_tmp11_, TRUE);
	_tmp12_ = self->priv->qr_picture;
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_CENTER);
	_tmp13_ = self->priv->qr_picture;
	gtk_widget_set_size_request ((GtkWidget*) _tmp13_, 280, 280);
	_tmp14_ = self->priv->qr_picture;
	gtk_widget_set_visible ((GtkWidget*) _tmp14_, FALSE);
	_tmp15_ = self->priv->qr_picture;
	gtk_box_append (content, (GtkWidget*) _tmp15_);
	_tmp16_ = (GtkTextView*) gtk_text_view_new ();
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->qr_text_view);
	self->priv->qr_text_view = _tmp16_;
	_tmp17_ = self->priv->qr_text_view;
	gtk_text_view_set_editable (_tmp17_, FALSE);
	_tmp18_ = self->priv->qr_text_view;
	gtk_text_view_set_cursor_visible (_tmp18_, FALSE);
	_tmp19_ = self->priv->qr_text_view;
	gtk_text_view_set_monospace (_tmp19_, TRUE);
	_tmp20_ = self->priv->qr_text_view;
	gtk_text_view_set_wrap_mode (_tmp20_, GTK_WRAP_CHAR);
	_tmp21_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->qr_text_scroll);
	self->priv->qr_text_scroll = _tmp21_;
	_tmp22_ = self->priv->qr_text_scroll;
	g_object_set (_tmp22_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp23_ = self->priv->qr_text_scroll;
	gtk_scrolled_window_set_min_content_height (_tmp23_, 96);
	_tmp24_ = self->priv->qr_text_scroll;
	_tmp25_ = self->priv->qr_text_view;
	gtk_scrolled_window_set_child (_tmp24_, (GtkWidget*) _tmp25_);
	_tmp26_ = self->priv->qr_text_scroll;
	gtk_widget_set_visible ((GtkWidget*) _tmp26_, FALSE);
	_tmp27_ = self->priv->qr_text_scroll;
	gtk_box_append (content, (GtkWidget*) _tmp27_);
	_tmp28_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp28_);
	actions = _tmp28_;
	gtk_widget_set_halign ((GtkWidget*) actions, GTK_ALIGN_END);
	gtk_widget_set_margin_top ((GtkWidget*) actions, 6);
	_tmp29_ = (GtkButton*) gtk_button_new_with_label ("Copy Link");
	g_object_ref_sink (_tmp29_);
	_g_object_unref0 (self->priv->copy_btn);
	self->priv->copy_btn = _tmp29_;
	_tmp30_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp30_, FALSE);
	_tmp31_ = self->priv->copy_btn;
	g_signal_connect_object (_tmp31_, "clicked", (GCallback) _dc_invite_code_dialog_copy_invite_text_gtk_button_clicked, self, 0);
	_tmp32_ = self->priv->copy_btn;
	gtk_box_append (actions, (GtkWidget*) _tmp32_);
	_tmp33_ = (GtkButton*) gtk_button_new_with_label ("Close");
	g_object_ref_sink (_tmp33_);
	close_btn = _tmp33_;
	g_signal_connect_object (close_btn, "clicked", (GCallback) ___lambda90__gtk_button_clicked, self, 0);
	gtk_box_append (actions, (GtkWidget*) close_btn);
	gtk_box_append (content, (GtkWidget*) actions);
	gtk_box_append (box, (GtkWidget*) content);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) box);
	dc_install_escape_close ((AdwDialog*) self);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) ___lambda91__adw_dialog_closed, self, 0);
	dc_invite_code_dialog_load_invite_code (self, NULL, NULL);
	_g_object_unref0 (close_btn);
	_g_object_unref0 (actions);
	_g_object_unref0 (content);
	_g_object_unref0 (box);
	return self;
}

DcInviteCodeDialog*
dc_invite_code_dialog_new (DcRpcClient* rpc,
                           gint acct_id)
{
	return dc_invite_code_dialog_construct (DC_TYPE_INVITE_CODE_DIALOG, rpc, acct_id);
}

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

static void
dc_invite_code_dialog_load_invite_code (DcInviteCodeDialog* self,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	DcInviteCodeDialogLoadInviteCodeData* _data_;
	DcInviteCodeDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcInviteCodeDialogLoadInviteCodeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_invite_code_dialog_load_invite_code_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_invite_code_dialog_load_invite_code_co (_data_);
}

static void
dc_invite_code_dialog_load_invite_code_finish (DcInviteCodeDialog* self,
                                               GAsyncResult* _res_)
{
	DcInviteCodeDialogLoadInviteCodeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_invite_code_dialog_load_invite_code_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	DcInviteCodeDialogLoadInviteCodeData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_invite_code_dialog_load_invite_code_co (_data_);
}

static gboolean
dc_invite_code_dialog_load_invite_code_co (DcInviteCodeDialogLoadInviteCodeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_chat_securejoin_qr_code (_data_->_tmp0_, _data_->self->priv->account_id, 0, dc_invite_code_dialog_load_invite_code_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = dc_rpc_client_get_chat_securejoin_qr_code_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		_data_->text = _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->self->priv->rpc;
		_data_->_tmp3_ = _data_->text;
		_data_->_state_ = 2;
		dc_rpc_client_create_qr_svg (_data_->_tmp2_, _data_->_tmp3_, dc_invite_code_dialog_load_invite_code_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp4_ = dc_rpc_client_create_qr_svg_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->svg = _data_->_tmp4_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->text);
			goto __catch0_g_error;
		}
		if (!_data_->self->priv->closing) {
			_data_->_tmp5_ = _data_->text;
			_data_->_tmp6_ = _data_->svg;
			dc_invite_code_dialog_show_qr (_data_->self, _data_->_tmp5_, _data_->_tmp6_);
		}
		_g_free0 (_data_->svg);
		_g_free0 (_data_->text);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		if (!_data_->self->priv->closing) {
			_data_->_tmp7_ = _data_->e;
			_data_->_tmp8_ = _data_->_tmp7_->message;
			dc_invite_code_dialog_show_invite_error (_data_->self, _data_->_tmp8_);
		}
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static void
dc_invite_code_dialog_show_qr (DcInviteCodeDialog* self,
                               const gchar* text,
                               const gchar* svg)
{
	gchar* _tmp0_;
	GtkLabel* _tmp1_;
	GtkTextView* _tmp2_;
	GtkTextBuffer* _tmp3_;
	GtkTextBuffer* _tmp4_;
	GtkScrolledWindow* _tmp5_;
	GtkButton* _tmp6_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	g_return_if_fail (svg != NULL);
	_tmp0_ = g_strdup (text);
	_g_free0 (self->priv->invite_text);
	self->priv->invite_text = _tmp0_;
	_tmp1_ = self->priv->status_label;
	gtk_label_set_label (_tmp1_, "Share this QR code with another user, or copy the invite link below.");
	_tmp2_ = self->priv->qr_text_view;
	_tmp3_ = gtk_text_view_get_buffer (_tmp2_);
	_tmp4_ = _tmp3_;
	g_object_set (_tmp4_, "text", text, NULL);
	_tmp5_ = self->priv->qr_text_scroll;
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, TRUE);
	_tmp6_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp6_, TRUE);
	{
		GBytes* bytes = NULL;
		guint8* _tmp7_;
		gint _tmp7__length1;
		gint _tmp8_ = 0;
		guint8* _tmp9_;
		gint _tmp9__length1;
		GBytes* _tmp10_;
		GdkTexture* _tmp11_ = NULL;
		GdkTexture* _tmp12_;
		GtkPicture* _tmp13_;
		GtkPicture* _tmp14_;
		_tmp7_ = string_get_data (svg, &_tmp8_);
		_tmp7__length1 = _tmp8_;
		_tmp9_ = _tmp7_;
		_tmp9__length1 = _tmp7__length1;
		_tmp10_ = g_bytes_new (_tmp9_, _tmp9__length1);
		bytes = _tmp10_;
		_tmp12_ = gdk_texture_new_from_bytes (bytes, &_inner_error0_);
		_tmp11_ = _tmp12_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_bytes_unref0 (bytes);
			goto __catch0_g_error;
		}
		_tmp13_ = self->priv->qr_picture;
		gtk_picture_set_paintable (_tmp13_, (GdkPaintable*) _tmp11_);
		_tmp14_ = self->priv->qr_picture;
		gtk_widget_set_visible ((GtkWidget*) _tmp14_, TRUE);
		_g_object_unref0 (_tmp11_);
		_g_bytes_unref0 (bytes);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GtkLabel* _tmp15_;
		GError* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp15_ = self->priv->status_label;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		_tmp18_ = g_strconcat ("Invite link is ready, but the QR image could not be rendered: ", _tmp17_, NULL);
		_tmp19_ = _tmp18_;
		gtk_label_set_label (_tmp15_, _tmp19_);
		_g_free0 (_tmp19_);
		_g_error_free0 (e);
	}
	__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
dc_invite_code_dialog_show_invite_error (DcInviteCodeDialog* self,
                                         const gchar* message)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkButton* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->status_label;
	_tmp1_ = g_strconcat ("Invite code creation failed: ", message, NULL);
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, FALSE);
}

static void
dc_invite_code_dialog_copy_invite_text (DcInviteCodeDialog* self)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	GdkDisplay* _tmp5_;
	GdkClipboard* _tmp6_;
	const gchar* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->invite_text;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = self->priv->invite_text;
		_tmp3_ = strlen (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == 0;
	}
	if (_tmp0_) {
		return;
	}
	_tmp5_ = gtk_widget_get_display ((GtkWidget*) self);
	_tmp6_ = gdk_display_get_clipboard (_tmp5_);
	_tmp7_ = self->priv->invite_text;
	gdk_clipboard_set_text (_tmp6_, _tmp7_);
}

static void
dc_invite_code_dialog_class_init (DcInviteCodeDialogClass * klass,
                                  gpointer klass_data)
{
	dc_invite_code_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcInviteCodeDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_invite_code_dialog_finalize;
}

static void
dc_invite_code_dialog_instance_init (DcInviteCodeDialog * self,
                                     gpointer klass)
{
	self->priv = dc_invite_code_dialog_get_instance_private (self);
	self->priv->invite_text = NULL;
	self->priv->closing = FALSE;
}

static void
dc_invite_code_dialog_finalize (GObject * obj)
{
	DcInviteCodeDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_INVITE_CODE_DIALOG, DcInviteCodeDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->status_label);
	_g_object_unref0 (self->priv->qr_picture);
	_g_object_unref0 (self->priv->qr_text_view);
	_g_object_unref0 (self->priv->qr_text_scroll);
	_g_object_unref0 (self->priv->copy_btn);
	_g_free0 (self->priv->invite_text);
	G_OBJECT_CLASS (dc_invite_code_dialog_parent_class)->finalize (obj);
}

static GType
dc_invite_code_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcInviteCodeDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_invite_code_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcInviteCodeDialog), 0, (GInstanceInitFunc) dc_invite_code_dialog_instance_init, NULL };
	GType dc_invite_code_dialog_type_id;
	dc_invite_code_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcInviteCodeDialog", &g_define_type_info, 0);
	DcInviteCodeDialog_private_offset = g_type_add_instance_private (dc_invite_code_dialog_type_id, sizeof (DcInviteCodeDialogPrivate));
	return dc_invite_code_dialog_type_id;
}

GType
dc_invite_code_dialog_get_type (void)
{
	static volatile gsize dc_invite_code_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_invite_code_dialog_type_id__once)) {
		GType dc_invite_code_dialog_type_id;
		dc_invite_code_dialog_type_id = dc_invite_code_dialog_get_type_once ();
		g_once_init_leave (&dc_invite_code_dialog_type_id__once, dc_invite_code_dialog_type_id);
	}
	return dc_invite_code_dialog_type_id__once;
}

static inline gpointer
dc_second_device_dialog_get_instance_private (DcSecondDeviceDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcSecondDeviceDialog_private_offset);
}

static void
_dc_second_device_dialog_copy_qr_text_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self)
{
	dc_second_device_dialog_copy_qr_text ((DcSecondDeviceDialog*) self);
}

static void
__lambda98_ (DcSecondDeviceDialog* self)
{
	adw_dialog_close ((AdwDialog*) self);
}

static void
___lambda98__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda98_ ((DcSecondDeviceDialog*) self);
}

static void
_dc_second_device_dialog_on_closed_adw_dialog_closed (AdwDialog* _sender,
                                                      gpointer self)
{
	dc_second_device_dialog_on_closed ((DcSecondDeviceDialog*) self);
}

DcSecondDeviceDialog*
dc_second_device_dialog_construct (GType object_type,
                                   DcRpcClient* rpc,
                                   gint acct_id)
{
	DcSecondDeviceDialog * self = NULL;
	DcRpcClient* _tmp0_;
	GtkBox* box = NULL;
	GtkBox* _tmp1_;
	AdwHeaderBar* _tmp2_;
	AdwHeaderBar* _tmp3_;
	GtkBox* content = NULL;
	GtkBox* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkPicture* _tmp9_;
	GtkPicture* _tmp10_;
	GtkPicture* _tmp11_;
	GtkPicture* _tmp12_;
	GtkPicture* _tmp13_;
	GtkPicture* _tmp14_;
	GtkPicture* _tmp15_;
	GtkTextView* _tmp16_;
	GtkTextView* _tmp17_;
	GtkTextView* _tmp18_;
	GtkTextView* _tmp19_;
	GtkTextView* _tmp20_;
	GtkScrolledWindow* _tmp21_;
	GtkScrolledWindow* _tmp22_;
	GtkScrolledWindow* _tmp23_;
	GtkScrolledWindow* _tmp24_;
	GtkTextView* _tmp25_;
	GtkScrolledWindow* _tmp26_;
	GtkScrolledWindow* _tmp27_;
	GtkBox* actions = NULL;
	GtkBox* _tmp28_;
	GtkButton* _tmp29_;
	GtkButton* _tmp30_;
	GtkButton* _tmp31_;
	GtkButton* _tmp32_;
	GtkButton* close_btn = NULL;
	GtkButton* _tmp33_;
	g_return_val_if_fail (rpc != NULL, NULL);
	self = (DcSecondDeviceDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	self->priv->account_id = acct_id;
	adw_dialog_set_title ((AdwDialog*) self, "Add Second Device");
	adw_dialog_set_content_width ((AdwDialog*) self, 480);
	adw_dialog_set_content_height ((AdwDialog*) self, 560);
	adw_dialog_set_can_close ((AdwDialog*) self, TRUE);
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	_tmp2_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp2_);
	_tmp3_ = _tmp2_;
	gtk_box_append (box, (GtkWidget*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp4_);
	content = _tmp4_;
	gtk_widget_set_margin_start ((GtkWidget*) content, 18);
	gtk_widget_set_margin_end ((GtkWidget*) content, 18);
	gtk_widget_set_margin_top ((GtkWidget*) content, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) content, 18);
	_tmp5_ = (GtkLabel*) gtk_label_new ("Preparing account…");
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->status_label);
	self->priv->status_label = _tmp5_;
	_tmp6_ = self->priv->status_label;
	gtk_label_set_wrap (_tmp6_, TRUE);
	_tmp7_ = self->priv->status_label;
	gtk_label_set_xalign (_tmp7_, (gfloat) 0);
	_tmp8_ = self->priv->status_label;
	gtk_box_append (content, (GtkWidget*) _tmp8_);
	_tmp9_ = (GtkPicture*) gtk_picture_new ();
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->qr_picture);
	self->priv->qr_picture = _tmp9_;
	_tmp10_ = self->priv->qr_picture;
	gtk_picture_set_content_fit (_tmp10_, GTK_CONTENT_FIT_CONTAIN);
	_tmp11_ = self->priv->qr_picture;
	gtk_picture_set_can_shrink (_tmp11_, TRUE);
	_tmp12_ = self->priv->qr_picture;
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_CENTER);
	_tmp13_ = self->priv->qr_picture;
	gtk_widget_set_size_request ((GtkWidget*) _tmp13_, 280, 280);
	_tmp14_ = self->priv->qr_picture;
	gtk_widget_set_visible ((GtkWidget*) _tmp14_, FALSE);
	_tmp15_ = self->priv->qr_picture;
	gtk_box_append (content, (GtkWidget*) _tmp15_);
	_tmp16_ = (GtkTextView*) gtk_text_view_new ();
	g_object_ref_sink (_tmp16_);
	_g_object_unref0 (self->priv->qr_text_view);
	self->priv->qr_text_view = _tmp16_;
	_tmp17_ = self->priv->qr_text_view;
	gtk_text_view_set_editable (_tmp17_, FALSE);
	_tmp18_ = self->priv->qr_text_view;
	gtk_text_view_set_cursor_visible (_tmp18_, FALSE);
	_tmp19_ = self->priv->qr_text_view;
	gtk_text_view_set_monospace (_tmp19_, TRUE);
	_tmp20_ = self->priv->qr_text_view;
	gtk_text_view_set_wrap_mode (_tmp20_, GTK_WRAP_CHAR);
	_tmp21_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->qr_text_scroll);
	self->priv->qr_text_scroll = _tmp21_;
	_tmp22_ = self->priv->qr_text_scroll;
	g_object_set (_tmp22_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	_tmp23_ = self->priv->qr_text_scroll;
	gtk_scrolled_window_set_min_content_height (_tmp23_, 96);
	_tmp24_ = self->priv->qr_text_scroll;
	_tmp25_ = self->priv->qr_text_view;
	gtk_scrolled_window_set_child (_tmp24_, (GtkWidget*) _tmp25_);
	_tmp26_ = self->priv->qr_text_scroll;
	gtk_widget_set_visible ((GtkWidget*) _tmp26_, FALSE);
	_tmp27_ = self->priv->qr_text_scroll;
	gtk_box_append (content, (GtkWidget*) _tmp27_);
	_tmp28_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp28_);
	actions = _tmp28_;
	gtk_widget_set_halign ((GtkWidget*) actions, GTK_ALIGN_END);
	gtk_widget_set_margin_top ((GtkWidget*) actions, 6);
	_tmp29_ = (GtkButton*) gtk_button_new_with_label ("Copy Text");
	g_object_ref_sink (_tmp29_);
	_g_object_unref0 (self->priv->copy_btn);
	self->priv->copy_btn = _tmp29_;
	_tmp30_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp30_, FALSE);
	_tmp31_ = self->priv->copy_btn;
	g_signal_connect_object (_tmp31_, "clicked", (GCallback) _dc_second_device_dialog_copy_qr_text_gtk_button_clicked, self, 0);
	_tmp32_ = self->priv->copy_btn;
	gtk_box_append (actions, (GtkWidget*) _tmp32_);
	_tmp33_ = (GtkButton*) gtk_button_new_with_label ("Close");
	g_object_ref_sink (_tmp33_);
	close_btn = _tmp33_;
	g_signal_connect_object (close_btn, "clicked", (GCallback) ___lambda98__gtk_button_clicked, self, 0);
	gtk_box_append (actions, (GtkWidget*) close_btn);
	gtk_box_append (content, (GtkWidget*) actions);
	gtk_box_append (box, (GtkWidget*) content);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) box);
	dc_install_escape_close ((AdwDialog*) self);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) _dc_second_device_dialog_on_closed_adw_dialog_closed, self, 0);
	dc_second_device_dialog_start_transfer (self, NULL, NULL);
	_g_object_unref0 (close_btn);
	_g_object_unref0 (actions);
	_g_object_unref0 (content);
	_g_object_unref0 (box);
	return self;
}

DcSecondDeviceDialog*
dc_second_device_dialog_new (DcRpcClient* rpc,
                             gint acct_id)
{
	return dc_second_device_dialog_construct (DC_TYPE_SECOND_DEVICE_DIALOG, rpc, acct_id);
}

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

static void
dc_second_device_dialog_start_transfer (DcSecondDeviceDialog* self,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	DcSecondDeviceDialogStartTransferData* _data_;
	DcSecondDeviceDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcSecondDeviceDialogStartTransferData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_second_device_dialog_start_transfer_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_second_device_dialog_start_transfer_co (_data_);
}

static void
dc_second_device_dialog_start_transfer_finish (DcSecondDeviceDialog* self,
                                               GAsyncResult* _res_)
{
	DcSecondDeviceDialogStartTransferData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
__lambda100_ (DcSecondDeviceDialog* self,
              GObject* obj,
              GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	self->priv->provider_running = FALSE;
	{
		DcRpcClient* _tmp0_;
		_tmp0_ = self->priv->rpc;
		dc_rpc_client_provide_backup_finish (_tmp0_, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (!self->priv->closing) {
			adw_dialog_close ((AdwDialog*) self);
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		if (!self->priv->closing) {
			GError* _tmp1_;
			const gchar* _tmp2_;
			_tmp1_ = e;
			_tmp2_ = _tmp1_->message;
			dc_second_device_dialog_show_transfer_error (self, _tmp2_);
		}
		_g_error_free0 (e);
	}
	__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
___lambda100__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda100_ ((DcSecondDeviceDialog*) self, source_object, res);
	g_object_unref (self);
}

static void
dc_second_device_dialog_start_transfer_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	DcSecondDeviceDialogStartTransferData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_second_device_dialog_start_transfer_co (_data_);
}

static gboolean
dc_second_device_dialog_start_transfer_co (DcSecondDeviceDialogStartTransferData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->self->priv->provider_running = TRUE;
	_data_->_tmp0_ = _data_->self->priv->rpc;
	dc_rpc_client_provide_backup (_data_->_tmp0_, _data_->self->priv->account_id, ___lambda100__gasync_ready_callback, g_object_ref (_data_->self));
	{
		_data_->_tmp1_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_backup_qr (_data_->_tmp1_, _data_->self->priv->account_id, dc_second_device_dialog_start_transfer_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = dc_rpc_client_get_backup_qr_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		_data_->text = _data_->_tmp2_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp3_ = _data_->self->priv->rpc;
		_data_->_tmp4_ = _data_->text;
		_data_->_state_ = 2;
		dc_rpc_client_create_qr_svg (_data_->_tmp3_, _data_->_tmp4_, dc_second_device_dialog_start_transfer_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp5_ = dc_rpc_client_create_qr_svg_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		_data_->svg = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->text);
			goto __catch0_g_error;
		}
		if (!_data_->self->priv->closing) {
			_data_->_tmp6_ = _data_->text;
			_data_->_tmp7_ = _data_->svg;
			dc_second_device_dialog_show_qr (_data_->self, _data_->_tmp6_, _data_->_tmp7_);
		}
		_g_free0 (_data_->svg);
		_g_free0 (_data_->text);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		if (!_data_->self->priv->closing) {
			_data_->_tmp8_ = _data_->e;
			_data_->_tmp9_ = _data_->_tmp8_->message;
			dc_second_device_dialog_show_transfer_error (_data_->self, _data_->_tmp9_);
			dc_second_device_dialog_stop_provider (_data_->self);
		}
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_second_device_dialog_show_qr (DcSecondDeviceDialog* self,
                                 const gchar* text,
                                 const gchar* svg)
{
	gchar* _tmp0_;
	GtkLabel* _tmp1_;
	GtkTextView* _tmp2_;
	GtkTextBuffer* _tmp3_;
	GtkTextBuffer* _tmp4_;
	GtkScrolledWindow* _tmp5_;
	GtkButton* _tmp6_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	g_return_if_fail (svg != NULL);
	_tmp0_ = g_strdup (text);
	_g_free0 (self->priv->qr_text);
	self->priv->qr_text = _tmp0_;
	_tmp1_ = self->priv->status_label;
	gtk_label_set_label (_tmp1_, "Scan this QR code with the second device, or copy the text below.");
	_tmp2_ = self->priv->qr_text_view;
	_tmp3_ = gtk_text_view_get_buffer (_tmp2_);
	_tmp4_ = _tmp3_;
	g_object_set (_tmp4_, "text", text, NULL);
	_tmp5_ = self->priv->qr_text_scroll;
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, TRUE);
	_tmp6_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp6_, TRUE);
	{
		GBytes* bytes = NULL;
		guint8* _tmp7_;
		gint _tmp7__length1;
		gint _tmp8_ = 0;
		guint8* _tmp9_;
		gint _tmp9__length1;
		GBytes* _tmp10_;
		GdkTexture* _tmp11_ = NULL;
		GdkTexture* _tmp12_;
		GtkPicture* _tmp13_;
		GtkPicture* _tmp14_;
		_tmp7_ = string_get_data (svg, &_tmp8_);
		_tmp7__length1 = _tmp8_;
		_tmp9_ = _tmp7_;
		_tmp9__length1 = _tmp7__length1;
		_tmp10_ = g_bytes_new (_tmp9_, _tmp9__length1);
		bytes = _tmp10_;
		_tmp12_ = gdk_texture_new_from_bytes (bytes, &_inner_error0_);
		_tmp11_ = _tmp12_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_bytes_unref0 (bytes);
			goto __catch0_g_error;
		}
		_tmp13_ = self->priv->qr_picture;
		gtk_picture_set_paintable (_tmp13_, (GdkPaintable*) _tmp11_);
		_tmp14_ = self->priv->qr_picture;
		gtk_widget_set_visible ((GtkWidget*) _tmp14_, TRUE);
		_g_object_unref0 (_tmp11_);
		_g_bytes_unref0 (bytes);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GtkLabel* _tmp15_;
		GError* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp15_ = self->priv->status_label;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		_tmp18_ = g_strconcat ("QR text is ready, but the image could not be rendered: ", _tmp17_, NULL);
		_tmp19_ = _tmp18_;
		gtk_label_set_label (_tmp15_, _tmp19_);
		_g_free0 (_tmp19_);
		_g_error_free0 (e);
	}
	__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
dc_second_device_dialog_show_transfer_error (DcSecondDeviceDialog* self,
                                             const gchar* message)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkButton* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->status_label;
	_tmp1_ = g_strconcat ("Second-device setup failed: ", message, NULL);
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, FALSE);
}

static void
dc_second_device_dialog_copy_qr_text (DcSecondDeviceDialog* self)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	GdkDisplay* _tmp5_;
	GdkClipboard* _tmp6_;
	const gchar* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->qr_text;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = self->priv->qr_text;
		_tmp3_ = strlen (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == 0;
	}
	if (_tmp0_) {
		return;
	}
	_tmp5_ = gtk_widget_get_display ((GtkWidget*) self);
	_tmp6_ = gdk_display_get_clipboard (_tmp5_);
	_tmp7_ = self->priv->qr_text;
	gdk_clipboard_set_text (_tmp6_, _tmp7_);
}

static void
dc_second_device_dialog_on_closed (DcSecondDeviceDialog* self)
{
	g_return_if_fail (self != NULL);
	self->priv->closing = TRUE;
	dc_second_device_dialog_stop_provider (self);
}

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

static void
____lambda99__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	___lambda99_ ((DcSecondDeviceDialog*) self, source_object, res);
	g_object_unref (self);
}

static void
dc_second_device_dialog_stop_provider (DcSecondDeviceDialog* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->provider_running) {
		DcRpcClient* _tmp0_;
		_tmp0_ = self->priv->rpc;
		dc_rpc_client_stop_ongoing_process (_tmp0_, self->priv->account_id, ____lambda99__gasync_ready_callback, g_object_ref (self));
	}
}

static void
dc_second_device_dialog_class_init (DcSecondDeviceDialogClass * klass,
                                    gpointer klass_data)
{
	dc_second_device_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcSecondDeviceDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_second_device_dialog_finalize;
}

static void
dc_second_device_dialog_instance_init (DcSecondDeviceDialog * self,
                                       gpointer klass)
{
	self->priv = dc_second_device_dialog_get_instance_private (self);
	self->priv->qr_text = NULL;
	self->priv->closing = FALSE;
	self->priv->provider_running = FALSE;
}

static void
dc_second_device_dialog_finalize (GObject * obj)
{
	DcSecondDeviceDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_SECOND_DEVICE_DIALOG, DcSecondDeviceDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->status_label);
	_g_object_unref0 (self->priv->qr_picture);
	_g_object_unref0 (self->priv->qr_text_view);
	_g_object_unref0 (self->priv->qr_text_scroll);
	_g_object_unref0 (self->priv->copy_btn);
	_g_free0 (self->priv->qr_text);
	G_OBJECT_CLASS (dc_second_device_dialog_parent_class)->finalize (obj);
}

static GType
dc_second_device_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcSecondDeviceDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_second_device_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcSecondDeviceDialog), 0, (GInstanceInitFunc) dc_second_device_dialog_instance_init, NULL };
	GType dc_second_device_dialog_type_id;
	dc_second_device_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcSecondDeviceDialog", &g_define_type_info, 0);
	DcSecondDeviceDialog_private_offset = g_type_add_instance_private (dc_second_device_dialog_type_id, sizeof (DcSecondDeviceDialogPrivate));
	return dc_second_device_dialog_type_id;
}

GType
dc_second_device_dialog_get_type (void)
{
	static volatile gsize dc_second_device_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_second_device_dialog_type_id__once)) {
		GType dc_second_device_dialog_type_id;
		dc_second_device_dialog_type_id = dc_second_device_dialog_get_type_once ();
		g_once_init_leave (&dc_second_device_dialog_type_id__once, dc_second_device_dialog_type_id);
	}
	return dc_second_device_dialog_type_id__once;
}

