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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <float.h>
#include <math.h>
#include <adwaita.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
#include <gdk/gdk.h>
#include <json-glib/json-glib.h>
#include <pango/pango.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_QR_CODE_VIEW (dc_qr_code_view_get_type ())
#define DC_QR_CODE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_QR_CODE_VIEW, DcQrCodeView))
#define DC_QR_CODE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_QR_CODE_VIEW, DcQrCodeViewClass))
#define DC_IS_QR_CODE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_QR_CODE_VIEW))
#define DC_IS_QR_CODE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_QR_CODE_VIEW))
#define DC_QR_CODE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_QR_CODE_VIEW, DcQrCodeViewClass))

typedef struct _DcQrCodeView DcQrCodeView;
typedef struct _DcQrCodeViewClass DcQrCodeViewClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block76Data Block76Data;

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

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

typedef struct _DcSettingsManager DcSettingsManager;
typedef struct _DcSettingsManagerClass DcSettingsManagerClass;

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

typedef struct _DcEventHandler DcEventHandler;
typedef struct _DcEventHandlerClass DcEventHandlerClass;
enum  {
	DC_PROFILE_DIALOG_0_PROPERTY,
	DC_PROFILE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_profile_dialog_properties[DC_PROFILE_DIALOG_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcProfileDialogLoadReadReceiptSettingsData DcProfileDialogLoadReadReceiptSettingsData;
typedef struct _DcProfileDialogSaveReadReceiptSettingsData DcProfileDialogSaveReadReceiptSettingsData;

#define DC_TYPE_STORAGE_DETAILS_DIALOG (dc_storage_details_dialog_get_type ())
#define DC_STORAGE_DETAILS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_STORAGE_DETAILS_DIALOG, DcStorageDetailsDialog))
#define DC_STORAGE_DETAILS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_STORAGE_DETAILS_DIALOG, DcStorageDetailsDialogClass))
#define DC_IS_STORAGE_DETAILS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_STORAGE_DETAILS_DIALOG))
#define DC_IS_STORAGE_DETAILS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_STORAGE_DETAILS_DIALOG))
#define DC_STORAGE_DETAILS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_STORAGE_DETAILS_DIALOG, DcStorageDetailsDialogClass))

typedef struct _DcStorageDetailsDialog DcStorageDetailsDialog;
typedef struct _DcStorageDetailsDialogClass DcStorageDetailsDialogClass;
typedef struct _DcProfileDialogLoadProfileData DcProfileDialogLoadProfileData;

#define DC_TYPE_STORAGE_QUOTA (dc_storage_quota_get_type ())
#define DC_STORAGE_QUOTA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_STORAGE_QUOTA, DcStorageQuota))
#define DC_STORAGE_QUOTA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_STORAGE_QUOTA, DcStorageQuotaClass))
#define DC_IS_STORAGE_QUOTA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_STORAGE_QUOTA))
#define DC_IS_STORAGE_QUOTA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_STORAGE_QUOTA))
#define DC_STORAGE_QUOTA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_STORAGE_QUOTA, DcStorageQuotaClass))

typedef struct _DcStorageQuota DcStorageQuota;
typedef struct _DcStorageQuotaClass DcStorageQuotaClass;
typedef struct _DcProfileDialogLoadConnectivitySummaryData DcProfileDialogLoadConnectivitySummaryData;
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 struct _DcProfileDialogConfirmDeleteAccountData DcProfileDialogConfirmDeleteAccountData;
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};

#define DC_TYPE_CHAT_STORAGE_USAGE (dc_chat_storage_usage_get_type ())
#define DC_CHAT_STORAGE_USAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CHAT_STORAGE_USAGE, DcChatStorageUsage))
#define DC_CHAT_STORAGE_USAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CHAT_STORAGE_USAGE, DcChatStorageUsageClass))
#define DC_IS_CHAT_STORAGE_USAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CHAT_STORAGE_USAGE))
#define DC_IS_CHAT_STORAGE_USAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CHAT_STORAGE_USAGE))
#define DC_CHAT_STORAGE_USAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CHAT_STORAGE_USAGE, DcChatStorageUsageClass))

typedef struct _DcChatStorageUsage DcChatStorageUsage;
typedef struct _DcChatStorageUsageClass DcChatStorageUsageClass;
typedef struct _DcChatStorageUsagePrivate DcChatStorageUsagePrivate;
enum  {
	DC_CHAT_STORAGE_USAGE_0_PROPERTY,
	DC_CHAT_STORAGE_USAGE_NUM_PROPERTIES
};
static GParamSpec* dc_chat_storage_usage_properties[DC_CHAT_STORAGE_USAGE_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _DcStorageDetailsDialogPrivate DcStorageDetailsDialogPrivate;
enum  {
	DC_STORAGE_DETAILS_DIALOG_0_PROPERTY,
	DC_STORAGE_DETAILS_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_storage_details_dialog_properties[DC_STORAGE_DETAILS_DIALOG_NUM_PROPERTIES];
typedef struct _DcStorageDetailsDialogLoadDetailsData DcStorageDetailsDialogLoadDetailsData;
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
typedef struct _DcStorageDetailsDialogScanAllChatsData DcStorageDetailsDialogScanAllChatsData;

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

typedef struct _DcChatEntry DcChatEntry;
typedef struct _DcChatEntryClass DcChatEntryClass;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))

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

typedef struct _DcMessage DcMessage;
typedef struct _DcMessageClass DcMessageClass;
typedef struct _DcStorageDetailsDialogScanChatData DcStorageDetailsDialogScanChatData;
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;
typedef struct _DcInviteCodeDialogRefreshLinkStateData DcInviteCodeDialogRefreshLinkStateData;
typedef struct _DcInviteCodeDialogToggleLinkData DcInviteCodeDialogToggleLinkData;
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 _Block76Data {
	int _ref_count_;
	AdwDialog* dialog;
};

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

struct _DcProfileDialogClass {
	AdwDialogClass parent_class;
};

struct _DcProfileDialogPrivate {
	DcRpcClient* rpc;
	DcSettingsManager* settings;
	DcEventHandler* events;
	gint account_id;
	AdwAvatar* avatar_widget;
	GtkEntry* name_entry;
	GtkEntry* status_entry;
	GtkLabel* email_label;
	GtkLabel* default_caption_label;
	GtkButton* default_make_button;
	gchar* account_addr;
	GtkLabel* connectivity_status_label;
	GtkLabel* storage_summary_label;
	GtkProgressBar* storage_progress;
	GtkSwitch* read_receipts_switch;
	GtkLabel* read_receipts_caption_label;
	gchar* avatar_path;
	gboolean avatar_changed;
	gboolean loading_read_receipts;
	gboolean saving_read_receipts;
	gboolean saved_read_receipts_enabled;
};

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

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

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_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	gint _tmp25_;
	gint _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	AdwAvatar* _tmp30_;
	const gchar* _tmp31_;
	GdkTexture* _tmp32_;
	GdkTexture* _tmp33_;
	GError* _inner_error0_;
};

struct _DcProfileDialogLoadConnectivitySummaryData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcProfileDialog* self;
	gint connectivity;
	DcRpcClient* _tmp0_;
	GtkLabel* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* html;
	DcRpcClient* _tmp4_;
	gchar* _tmp5_;
	DcStorageQuota* quota;
	const gchar* _tmp6_;
	DcStorageQuota* _tmp7_;
	GtkProgressBar* _tmp8_;
	DcStorageQuota* _tmp9_;
	GtkLabel* _tmp10_;
	DcStorageQuota* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GError* e;
	GtkLabel* _tmp14_;
	GtkLabel* _tmp15_;
	GError* _tmp16_;
	const gchar* _tmp17_;
	GtkProgressBar* _tmp18_;
	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 _DcProfileDialogConfirmDeleteAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcProfileDialog* self;
	gchar* label;
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	GtkEntry* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	gint _tmp12_;
	gint _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gboolean _tmp18_;
};

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 _DcChatStorageUsage {
	GObject parent_instance;
	DcChatStorageUsagePrivate * priv;
	gint chat_id;
	gchar* name;
	gint message_count;
	gint local_file_count;
	gint64 remote_bytes;
	gint64 local_bytes;
};

struct _DcChatStorageUsageClass {
	GObjectClass parent_class;
};

struct _DcChatStorageUsagePrivate {
	GHashTable* local_paths;
};

struct _DcStorageDetailsDialog {
	AdwDialog parent_instance;
	DcStorageDetailsDialogPrivate * priv;
};

struct _DcStorageDetailsDialogClass {
	AdwDialogClass parent_class;
};

struct _DcStorageDetailsDialogPrivate {
	DcRpcClient* rpc;
	gint account_id;
	GtkProgressBar* quota_progress;
	GtkLabel* quota_label;
	GtkLabel* local_total_label;
	GtkLabel* scan_status_label;
	GtkListBox* chat_usage_list;
	GtkButton* refresh_btn;
	GtkButton* clear_cache_btn;
	gchar* blob_dir;
	gint64 known_attachment_bytes;
	gint64 unique_local_file_bytes;
	GHashTable* global_local_paths;
};

struct _DcStorageDetailsDialogLoadDetailsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcStorageDetailsDialog* self;
	GtkButton* _tmp0_;
	GtkListBox* _tmp1_;
	GHashTable* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	gint64 account_bytes;
	gint64 _tmp5_;
	DcRpcClient* _tmp6_;
	gchar* _tmp7_;
	DcRpcClient* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* html;
	DcRpcClient* _tmp11_;
	gchar* _tmp12_;
	DcStorageQuota* quota;
	DcStorageQuota* _tmp13_;
	GtkProgressBar* _tmp14_;
	DcStorageQuota* _tmp15_;
	GtkLabel* _tmp16_;
	DcStorageQuota* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	GError* e;
	GtkProgressBar* _tmp20_;
	GtkLabel* _tmp21_;
	GError* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	DcChatStorageUsage** usages;
	gint _tmp26_;
	DcChatStorageUsage** _tmp27_;
	gint usages_length1;
	gint _usages_size_;
	gchar* file_summary;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	const gchar* _tmp39_;
	gchar* _tmp40_;
	GtkLabel* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	GtkLabel* _tmp45_;
	GError* _vala1_e;
	GtkLabel* _tmp46_;
	GError* _tmp47_;
	const gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	GtkButton* _tmp51_;
	GError* _inner_error0_;
};

struct _DcStorageDetailsDialogScanAllChatsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcStorageDetailsDialog* self;
	DcChatStorageUsage** result;
	gint result_length1;
	DcChatStorageUsage** usages;
	DcChatStorageUsage** _tmp0_;
	gint usages_length1;
	gint _usages_size_;
	JsonArray* entries;
	DcRpcClient* _tmp1_;
	JsonArray* _tmp2_;
	JsonArray* _tmp3_;
	DcChatStorageUsage** _tmp4_;
	gint _tmp4__length1;
	JsonObject* items;
	JsonObject* _tmp5_;
	DcRpcClient* _tmp6_;
	JsonArray* _tmp7_;
	JsonObject* _tmp8_;
	JsonObject* _tmp9_;
	guint i;
	gboolean _tmp10_;
	guint _tmp11_;
	JsonArray* _tmp12_;
	gint chat_id;
	JsonArray* _tmp13_;
	gchar* name;
	JsonObject* _tmp14_;
	gchar* _tmp15_;
	GtkLabel* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	DcChatStorageUsage* usage;
	const gchar* _tmp20_;
	DcChatStorageUsage* _tmp21_;
	gboolean _tmp22_;
	DcChatStorageUsage* _tmp23_;
	DcChatStorageUsage* _tmp24_;
	DcChatStorageUsage* _tmp25_;
	DcChatStorageUsage* _tmp26_;
	DcChatStorageUsage** _tmp27_;
	gint _tmp27__length1;
	GError* _inner_error0_;
};

struct _DcStorageDetailsDialogScanChatData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcStorageDetailsDialog* self;
	gint chat_id;
	gchar* name;
	DcChatStorageUsage* result;
	DcChatStorageUsage* usage;
	DcChatStorageUsage* _tmp0_;
	JsonArray* ids;
	DcRpcClient* _tmp1_;
	JsonArray* _tmp2_;
	JsonArray* _tmp3_;
	gint len;
	JsonArray* _tmp4_;
	DcChatStorageUsage* _tmp5_;
	gint start;
	gboolean _tmp6_;
	gint end;
	gint count;
	gint* batch;
	gint* _tmp7_;
	gint batch_length1;
	gint _batch_size_;
	gint i;
	gboolean _tmp8_;
	gint _tmp9_;
	gint* _tmp10_;
	gint _tmp10__length1;
	JsonArray* _tmp11_;
	JsonObject* messages;
	DcRpcClient* _tmp12_;
	gint* _tmp13_;
	gint _tmp13__length1;
	JsonObject* _tmp14_;
	JsonObject* _tmp15_;
	gint _vala1_i;
	gboolean _tmp16_;
	gint _tmp17_;
	gchar* key;
	gint* _tmp18_;
	gint _tmp18__length1;
	gint _tmp19_;
	gchar* _tmp20_;
	JsonObject* _tmp21_;
	const gchar* _tmp22_;
	JsonNode* node;
	JsonObject* _tmp23_;
	const gchar* _tmp24_;
	JsonNode* _tmp25_;
	JsonNode* _tmp26_;
	gboolean _tmp27_;
	JsonNode* _tmp28_;
	JsonNode* _tmp29_;
	DcMessage* msg;
	JsonNode* _tmp30_;
	JsonObject* _tmp31_;
	DcMessage* _tmp32_;
	DcChatStorageUsage* _tmp33_;
	DcMessage* _tmp34_;
	GError* _inner_error0_;
};

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

struct _DcInviteCodeDialogClass {
	AdwDialogClass parent_class;
};

struct _DcInviteCodeDialogPrivate {
	DcRpcClient* rpc;
	gint account_id;
	gint chat_id;
	DcQrCodeView* qr_view;
	GtkButton* toggle_btn;
	gboolean closing;
	gboolean link_active;
	gboolean toggle_busy;
};

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 _DcInviteCodeDialogRefreshLinkStateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcInviteCodeDialog* self;
	const gchar* _tmp0_;
	DcQrCodeView* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* text;
	gchar* _tmp4_;
	gboolean _tmp5_;
	const gchar* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	GtkButton* _tmp9_;
	JsonObject* qr;
	DcRpcClient* _tmp10_;
	const gchar* _tmp11_;
	JsonObject* _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
	JsonObject* _tmp15_;
	JsonObject* _tmp16_;
	gchar* kind;
	JsonObject* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gboolean _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	GtkButton* _tmp24_;
	GError* _inner_error0_;
};

struct _DcInviteCodeDialogToggleLinkData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcInviteCodeDialog* self;
	const gchar* _tmp0_;
	DcQrCodeView* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* text;
	gchar* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	const gchar* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	GtkButton* _tmp10_;
	GtkButton* _tmp11_;
	const gchar* _tmp12_;
	GtkButton* _tmp13_;
	DcRpcClient* _tmp14_;
	const gchar* _tmp15_;
	GError* e;
	DcQrCodeView* _tmp16_;
	GError* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	GError* _inner_error1_;
	GError* _inner_error0_;
};

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

struct _DcSecondDeviceDialogClass {
	AdwDialogClass parent_class;
};

struct _DcSecondDeviceDialogPrivate {
	DcRpcClient* rpc;
	gint account_id;
	DcQrCodeView* qr_view;
	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 DcChatStorageUsage_private_offset;
static gpointer dc_chat_storage_usage_parent_class = NULL;
static gint DcStorageDetailsDialog_private_offset;
static gpointer dc_storage_details_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 GtkLabel* dc_heading_label (const gchar* text);
VALA_EXTERN GtkLabel* dc_dim_label (const gchar* text,
                        gboolean hexpand);
VALA_EXTERN GtkBox* dc_content_box (gint side_margin);
VALA_EXTERN GtkBox* dc_end_actions_box (void);
VALA_EXTERN GType dc_qr_code_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcQrCodeView, g_object_unref)
VALA_EXTERN GtkBox* dc_setup_qr_dialog (AdwDialog* dialog,
                            DcQrCodeView* qr_view);
VALA_EXTERN GtkButton* dc_close_button (AdwDialog* dialog);
static Block76Data* block76_data_ref (Block76Data* _data76_);
static void block76_data_unref (void * _userdata_);
static void __lambda136_ (Block76Data* _data76_);
static void ___lambda136__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
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 GType dc_settings_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSettingsManager, g_object_unref)
VALA_EXTERN GType dc_event_handler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcEventHandler, g_object_unref)
VALA_EXTERN DcProfileDialog* dc_profile_dialog_new (DcRpcClient* rpc,
                                        DcSettingsManager* settings,
                                        DcEventHandler* events,
                                        gint acct_id);
VALA_EXTERN DcProfileDialog* dc_profile_dialog_construct (GType object_type,
                                              DcRpcClient* rpc,
                                              DcSettingsManager* settings,
                                              DcEventHandler* events,
                                              gint acct_id);
VALA_EXTERN gint dc_rpc_client_get_account_id (DcRpcClient* self);
static void __lambda132_ (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 ___lambda132__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda133_ (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 ___lambda133__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda134_ (DcProfileDialog* self);
static void ___lambda134__gtk_editable_changed (GtkEditable* _sender,
                                         gpointer self);
static GtkButton* dc_profile_dialog_append_profile_action_row (DcProfileDialog* self,
                                                        GtkBox* content,
                                                        const gchar* button_label,
                                                        const gchar* tooltip,
                                                        const gchar* caption_text,
                                                        const gchar* css_class);
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 GtkWidget* dc_profile_dialog_build_read_receipts_row (DcProfileDialog* self);
static GtkWidget* dc_profile_dialog_build_connectivity_storage_section (DcProfileDialog* 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 GtkWidget* dc_profile_dialog_build_default_account_row (DcProfileDialog* self);
static void __lambda156_ (DcProfileDialog* self);
static void dc_profile_dialog_confirm_delete_account (DcProfileDialog* self,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static void dc_profile_dialog_confirm_delete_account_finish (DcProfileDialog* self,
                                                      GAsyncResult* _res_);
static void ___lambda156__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_read_receipt_settings (DcProfileDialog* self,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void dc_profile_dialog_load_read_receipt_settings_finish (DcProfileDialog* self,
                                                          GAsyncResult* _res_);
static void dc_profile_dialog_load_connectivity_summary (DcProfileDialog* self,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static void dc_profile_dialog_load_connectivity_summary_finish (DcProfileDialog* self,
                                                         GAsyncResult* _res_);
static void dc_profile_dialog_make_account_default (DcProfileDialog* self);
static void _dc_profile_dialog_make_account_default_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
static void dc_profile_dialog_update_default_account_row (DcProfileDialog* self);
static void __lambda138_ (DcProfileDialog* self);
static void dc_profile_dialog_save_read_receipt_settings (DcProfileDialog* self,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void dc_profile_dialog_save_read_receipt_settings_finish (DcProfileDialog* self,
                                                          GAsyncResult* _res_);
static void ___lambda138__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void dc_profile_dialog_load_read_receipt_settings_data_free (gpointer _data);
static gboolean dc_profile_dialog_load_read_receipt_settings_co (DcProfileDialogLoadReadReceiptSettingsData* _data_);
VALA_EXTERN gboolean dc_rpc_client_get_is_connected (DcRpcClient* self);
static void dc_profile_dialog_set_read_receipt_controls_sensitive (DcProfileDialog* self,
                                                            gboolean sensitive);
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_read_receipt_settings_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void dc_profile_dialog_update_read_receipts_caption (DcProfileDialog* self,
                                                     gboolean enabled);
static void dc_profile_dialog_save_read_receipt_settings_data_free (gpointer _data);
static gboolean dc_profile_dialog_save_read_receipt_settings_co (DcProfileDialogSaveReadReceiptSettingsData* _data_);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
VALA_EXTERN void dc_rpc_client_batch_set_config (DcRpcClient* self,
                                     const gchar* key,
                                     const gchar* val,
                                     gint acct_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_batch_set_config_finish (DcRpcClient* self,
                                            GAsyncResult* _res_,
                                            GError** error);
static void dc_profile_dialog_save_read_receipt_settings_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
VALA_EXTERN void dc_settings_manager_save_default_account_addr (DcSettingsManager* self,
                                                    const gchar* v);
VALA_EXTERN const gchar* dc_settings_manager_get_default_account_addr (DcSettingsManager* self);
static void __lambda139_ (DcProfileDialog* self);
static void ___lambda139__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda140_ (DcProfileDialog* self);
VALA_EXTERN GType dc_storage_details_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcStorageDetailsDialog, g_object_unref)
VALA_EXTERN DcStorageDetailsDialog* dc_storage_details_dialog_new (DcRpcClient* rpc,
                                                       gint acct_id);
VALA_EXTERN DcStorageDetailsDialog* dc_storage_details_dialog_construct (GType object_type,
                                                             DcRpcClient* rpc,
                                                             gint acct_id);
static void ___lambda140__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_profile_dialog_load_profile_data_free (gpointer _data);
static gboolean dc_profile_dialog_load_profile_co (DcProfileDialogLoadProfileData* _data_);
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_load_connectivity_summary_data_free (gpointer _data);
static gboolean dc_profile_dialog_load_connectivity_summary_co (DcProfileDialogLoadConnectivitySummaryData* _data_);
VALA_EXTERN void dc_rpc_client_get_connectivity (DcRpcClient* self,
                                     gint acct_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN gint dc_rpc_client_get_connectivity_finish (DcRpcClient* self,
                                            GAsyncResult* _res_,
                                            GError** error);
static void dc_profile_dialog_load_connectivity_summary_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_);
static gchar* dc_profile_dialog_connection_label_for_state (gint state);
VALA_EXTERN void dc_rpc_client_get_connectivity_html (DcRpcClient* self,
                                          gint acct_id,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_connectivity_html_finish (DcRpcClient* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
VALA_EXTERN GType dc_storage_quota_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcStorageQuota, g_object_unref)
VALA_EXTERN DcStorageQuota* dc_storage_quota_parse_connectivity_report (const gchar* report);
VALA_EXTERN void dc_apply_quota_progress (GtkProgressBar* progress,
                              DcStorageQuota* quota);
VALA_EXTERN gchar* dc_storage_quota_summary_text (DcStorageQuota* self);
static void dc_profile_dialog_do_save_data_free (gpointer _data);
static gboolean dc_profile_dialog_do_save_co (DcProfileDialogDoSaveData* _data_);
static void dc_profile_dialog_do_save_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_);
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,
                                               gint chat_id);
VALA_EXTERN DcInviteCodeDialog* dc_invite_code_dialog_construct (GType object_type,
                                                     DcRpcClient* rpc,
                                                     gint acct_id,
                                                     gint chat_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,
                                      DcEventHandler* events,
                                      gint acct_id);
VALA_EXTERN DcRelaysDialog* dc_relays_dialog_construct (GType object_type,
                                            DcRpcClient* rpc,
                                            DcEventHandler* events,
                                            gint acct_id);
static void dc_profile_dialog_confirm_delete_account_data_free (gpointer _data);
static gboolean dc_profile_dialog_confirm_delete_account_co (DcProfileDialogConfirmDeleteAccountData* _data_);
VALA_EXTERN void dc_confirm_action (GtkWidget* parent,
                        const gchar* title,
                        const gchar* body,
                        const gchar* action_id,
                        const gchar* action_label,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_);
VALA_EXTERN gboolean dc_confirm_action_finish (GAsyncResult* _res_);
static void dc_profile_dialog_confirm_delete_account_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
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 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);
VALA_EXTERN GType dc_chat_storage_usage_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatStorageUsage, g_object_unref)
static void _g_free0_ (gpointer var);
VALA_EXTERN DcChatStorageUsage* dc_chat_storage_usage_new (gint chat_id,
                                               const gchar* name);
VALA_EXTERN DcChatStorageUsage* dc_chat_storage_usage_construct (GType object_type,
                                                     gint chat_id,
                                                     const gchar* name);
VALA_EXTERN gboolean dc_chat_storage_usage_add_local_file (DcChatStorageUsage* self,
                                               const gchar* path,
                                               gint64 bytes);
VALA_EXTERN gint64 dc_chat_storage_usage_total_bytes (DcChatStorageUsage* self);
static void dc_chat_storage_usage_finalize (GObject * obj);
static GType dc_chat_storage_usage_get_type_once (void);
static void __lambda141_ (DcStorageDetailsDialog* self);
static void dc_storage_details_dialog_load_details (DcStorageDetailsDialog* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void dc_storage_details_dialog_load_details_finish (DcStorageDetailsDialog* self,
                                                    GAsyncResult* _res_);
static void ___lambda141__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_storage_details_dialog_show_clear_cache_info (DcStorageDetailsDialog* self);
static void _dc_storage_details_dialog_show_clear_cache_info_gtk_button_clicked (GtkButton* _sender,
                                                                          gpointer self);
VALA_EXTERN void dc_install_escape_close (AdwDialog* dialog);
static void dc_storage_details_dialog_load_details_data_free (gpointer _data);
static gboolean dc_storage_details_dialog_load_details_co (DcStorageDetailsDialogLoadDetailsData* _data_);
VALA_EXTERN void dc_clear_listbox (GtkListBox* lb);
VALA_EXTERN void dc_rpc_client_get_account_file_size (DcRpcClient* self,
                                          gint acct_id,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN gint64 dc_rpc_client_get_account_file_size_finish (DcRpcClient* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
static void dc_storage_details_dialog_load_details_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_get_blob_dir (DcRpcClient* self,
                                 gint acct_id,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_blob_dir_finish (DcRpcClient* self,
                                          GAsyncResult* _res_,
                                          GError** error);
static void dc_storage_details_dialog_scan_all_chats (DcStorageDetailsDialog* self,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static DcChatStorageUsage** dc_storage_details_dialog_scan_all_chats_finish (DcStorageDetailsDialog* self,
                                                                      GAsyncResult* _res_,
                                                                      gint* result_length1,
                                                                      GError** error);
static void dc_storage_details_dialog_sort_usages (DcStorageDetailsDialog* self,
                                            DcChatStorageUsage** usages,
                                            gint usages_length1);
static void dc_storage_details_dialog_populate_chat_usage_list (DcStorageDetailsDialog* self,
                                                         DcChatStorageUsage** usages,
                                                         gint usages_length1);
VALA_EXTERN gchar* dc_storage_quota_format_mb (gint64 bytes);
static void dc_storage_details_dialog_scan_all_chats_data_free (gpointer _data);
static gboolean dc_storage_details_dialog_scan_all_chats_co (DcStorageDetailsDialogScanAllChatsData* _data_);
VALA_EXTERN void dc_rpc_client_get_chatlist_entries_for (DcRpcClient* self,
                                             gint acct_id,
                                             const gchar* query,
                                             gint list_flags,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN JsonArray* dc_rpc_client_get_chatlist_entries_for_finish (DcRpcClient* self,
                                                          GAsyncResult* _res_,
                                                          GError** error);
static void dc_storage_details_dialog_scan_all_chats_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_get_chatlist_items_by_entries_for (DcRpcClient* self,
                                                      gint acct_id,
                                                      JsonArray* entries,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
VALA_EXTERN JsonObject* dc_rpc_client_get_chatlist_items_by_entries_for_finish (DcRpcClient* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error);
static gchar* dc_storage_details_dialog_get_chat_name (DcStorageDetailsDialog* self,
                                                JsonObject* items,
                                                gint chat_id);
static void dc_storage_details_dialog_scan_chat (DcStorageDetailsDialog* self,
                                          gint chat_id,
                                          const gchar* name,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static DcChatStorageUsage* dc_storage_details_dialog_scan_chat_finish (DcStorageDetailsDialog* self,
                                                                GAsyncResult* _res_,
                                                                GError** error);
static void _vala_array_add49 (DcChatStorageUsage** * array,
                        gint* length,
                        gint* size,
                        DcChatStorageUsage* value);
VALA_EXTERN GType dc_chat_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatEntry, g_object_unref)
VALA_EXTERN DcChatEntry* dc_rpc_parsers_parse_chat_item (gint chat_id,
                                             JsonObject* obj);
VALA_EXTERN const gchar* dc_chat_entry_get_name (DcChatEntry* self);
static void dc_storage_details_dialog_scan_chat_data_free (gpointer _data);
static gboolean dc_storage_details_dialog_scan_chat_co (DcStorageDetailsDialogScanChatData* _data_);
VALA_EXTERN void dc_rpc_client_get_message_ids_for (DcRpcClient* self,
                                        gint acct_id,
                                        gint chat_id,
                                        gboolean info_only,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
VALA_EXTERN JsonArray* dc_rpc_client_get_message_ids_for_finish (DcRpcClient* self,
                                                     GAsyncResult* _res_,
                                                     GError** error);
static void dc_storage_details_dialog_scan_chat_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_get_messages_for (DcRpcClient* self,
                                     gint acct_id,
                                     gint* msg_ids,
                                     gint msg_ids_length1,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN JsonObject* dc_rpc_client_get_messages_for_finish (DcRpcClient* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
VALA_EXTERN GType dc_message_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessage, g_object_unref)
VALA_EXTERN DcMessage* dc_rpc_parsers_parse_message (JsonObject* obj,
                                         const gchar* self_email);
static void dc_storage_details_dialog_add_message_usage (DcStorageDetailsDialog* self,
                                                  DcChatStorageUsage* usage,
                                                  DcMessage* msg);
VALA_EXTERN gint dc_message_get_file_bytes (DcMessage* self);
static gchar* dc_storage_details_dialog_resolve_local_path (DcStorageDetailsDialog* self,
                                                     const gchar* path);
VALA_EXTERN const gchar* dc_message_get_file_path (DcMessage* self);
static gint64 dc_storage_details_dialog_file_size (const gchar* path);
static GtkWidget* dc_storage_details_dialog_build_chat_usage_row (DcStorageDetailsDialog* self,
                                                           DcChatStorageUsage* usage,
                                                           gint64 max_bytes);
static void dc_storage_details_dialog_finalize (GObject * obj);
static GType dc_storage_details_dialog_get_type_once (void);
VALA_EXTERN gdouble dc_storage_quota_used_fraction (DcStorageQuota* self);
VALA_EXTERN gboolean dc_storage_quota_is_error (DcStorageQuota* self);
VALA_EXTERN gboolean dc_storage_quota_is_warning (DcStorageQuota* self);
VALA_EXTERN DcQrCodeView* dc_qr_code_view_new (const gchar* initial_status);
VALA_EXTERN DcQrCodeView* dc_qr_code_view_construct (GType object_type,
                                         const gchar* initial_status);
static void ___lambda135_ (DcInviteCodeDialog* self);
static void dc_invite_code_dialog_toggle_link (DcInviteCodeDialog* self,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
static void dc_invite_code_dialog_toggle_link_finish (DcInviteCodeDialog* self,
                                               GAsyncResult* _res_);
static void ____lambda135__gtk_button_clicked (GtkButton* _sender,
                                        gpointer self);
VALA_EXTERN GtkButton* dc_qr_code_view_make_copy_button (DcQrCodeView* self,
                                             const gchar* label);
static void __lambda137_ (DcInviteCodeDialog* self);
static void ___lambda137__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);
VALA_EXTERN void dc_qr_code_view_show_code (DcQrCodeView* self,
                                const gchar* text,
                                const gchar* svg,
                                const gchar* ready_status,
                                const gchar* render_error_status);
static void dc_invite_code_dialog_refresh_link_state (DcInviteCodeDialog* self,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static void dc_invite_code_dialog_refresh_link_state_finish (DcInviteCodeDialog* self,
                                                      GAsyncResult* _res_);
static void dc_invite_code_dialog_refresh_link_state_data_free (gpointer _data);
static gboolean dc_invite_code_dialog_refresh_link_state_co (DcInviteCodeDialogRefreshLinkStateData* _data_);
VALA_EXTERN const gchar* dc_qr_code_view_get_code_text (DcQrCodeView* self);
VALA_EXTERN void dc_rpc_client_check_qr (DcRpcClient* self,
                             gint acct_id,
                             const gchar* qr_text,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_);
VALA_EXTERN JsonObject* dc_rpc_client_check_qr_finish (DcRpcClient* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static void dc_invite_code_dialog_refresh_link_state_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
static void dc_invite_code_dialog_apply_link_state (DcInviteCodeDialog* self);
VALA_EXTERN void dc_qr_code_view_set_qr_opacity (DcQrCodeView* self,
                                     gdouble opacity);
VALA_EXTERN void dc_qr_code_view_set_status (DcQrCodeView* self,
                                 const gchar* message);
static void dc_invite_code_dialog_toggle_link_data_free (gpointer _data);
static gboolean dc_invite_code_dialog_toggle_link_co (DcInviteCodeDialogToggleLinkData* _data_);
VALA_EXTERN void dc_rpc_client_set_config_from_qr (DcRpcClient* self,
                                       gint acct_id,
                                       const gchar* qr_text,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_set_config_from_qr_finish (DcRpcClient* self,
                                              GAsyncResult* _res_,
                                              GError** error);
static void dc_invite_code_dialog_toggle_link_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_);
VALA_EXTERN void dc_qr_code_view_set_copy_sensitive (DcQrCodeView* self,
                                         gboolean sensitive);
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_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 __lambda154_ (DcSecondDeviceDialog* self,
                   GObject* obj,
                   GAsyncResult* res);
static void dc_second_device_dialog_show_transfer_error (DcSecondDeviceDialog* self,
                                                  const gchar* message);
static void ___lambda154__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 ___lambda153_ (DcSecondDeviceDialog* self,
                    GObject* obj,
                    GAsyncResult* res);
static void ____lambda153__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 void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

GtkLabel*
dc_heading_label (const gchar* text)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* result;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (text);
	g_object_ref_sink (_tmp0_);
	label = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) label, "heading");
	gtk_widget_set_halign ((GtkWidget*) label, GTK_ALIGN_START);
	result = label;
	return result;
}

GtkLabel*
dc_dim_label (const gchar* text,
              gboolean hexpand)
{
	GtkLabel* label = NULL;
	GtkLabel* _tmp0_;
	GtkLabel* result;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (text);
	g_object_ref_sink (_tmp0_);
	label = _tmp0_;
	gtk_widget_add_css_class ((GtkWidget*) label, "dim-label");
	gtk_widget_set_halign ((GtkWidget*) label, GTK_ALIGN_START);
	gtk_label_set_xalign (label, (gfloat) 0);
	gtk_label_set_wrap (label, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) label, hexpand);
	result = label;
	return result;
}

GtkBox*
dc_content_box (gint side_margin)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	GtkBox* result;
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	gtk_widget_set_margin_start ((GtkWidget*) box, side_margin);
	gtk_widget_set_margin_end ((GtkWidget*) box, side_margin);
	gtk_widget_set_margin_top ((GtkWidget*) box, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) box, side_margin);
	result = box;
	return result;
}

GtkBox*
dc_end_actions_box (void)
{
	GtkBox* actions = NULL;
	GtkBox* _tmp0_;
	GtkBox* result;
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp0_);
	actions = _tmp0_;
	gtk_widget_set_halign ((GtkWidget*) actions, GTK_ALIGN_END);
	gtk_widget_set_margin_top ((GtkWidget*) actions, 6);
	result = actions;
	return result;
}

GtkBox*
dc_setup_qr_dialog (AdwDialog* dialog,
                    DcQrCodeView* qr_view)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	AdwHeaderBar* _tmp1_;
	AdwHeaderBar* _tmp2_;
	GtkBox* content = NULL;
	GtkBox* _tmp3_;
	GtkBox* actions = NULL;
	GtkBox* _tmp4_;
	GtkBox* result;
	g_return_val_if_fail (dialog != NULL, NULL);
	g_return_val_if_fail (qr_view != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp1_);
	_tmp2_ = _tmp1_;
	gtk_box_append (box, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = dc_content_box (18);
	content = _tmp3_;
	gtk_box_append (content, (GtkWidget*) qr_view);
	_tmp4_ = dc_end_actions_box ();
	actions = _tmp4_;
	gtk_box_append (content, (GtkWidget*) actions);
	gtk_box_append (box, (GtkWidget*) content);
	adw_dialog_set_child (dialog, (GtkWidget*) box);
	result = actions;
	_g_object_unref0 (content);
	_g_object_unref0 (box);
	return result;
}

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

static Block76Data*
block76_data_ref (Block76Data* _data76_)
{
	g_atomic_int_inc (&_data76_->_ref_count_);
	return _data76_;
}

static void
block76_data_unref (void * _userdata_)
{
	Block76Data* _data76_;
	_data76_ = (Block76Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data76_->_ref_count_)) {
		_g_object_unref0 (_data76_->dialog);
		g_slice_free (Block76Data, _data76_);
	}
}

static void
__lambda136_ (Block76Data* _data76_)
{
	adw_dialog_close (_data76_->dialog);
}

static void
___lambda136__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda136_ (self);
}

GtkButton*
dc_close_button (AdwDialog* dialog)
{
	Block76Data* _data76_;
	AdwDialog* _tmp0_;
	GtkButton* button = NULL;
	GtkButton* _tmp1_;
	GtkButton* result;
	g_return_val_if_fail (dialog != NULL, NULL);
	_data76_ = g_slice_new0 (Block76Data);
	_data76_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (dialog);
	_g_object_unref0 (_data76_->dialog);
	_data76_->dialog = _tmp0_;
	_tmp1_ = (GtkButton*) gtk_button_new_with_label ("Close");
	g_object_ref_sink (_tmp1_);
	button = _tmp1_;
	g_signal_connect_data (button, "clicked", (GCallback) ___lambda136__gtk_button_clicked, block76_data_ref (_data76_), (GClosureNotify) block76_data_unref, 0);
	result = button;
	block76_data_unref (_data76_);
	_data76_ = NULL;
	return result;
}

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

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

static void
___lambda132__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda132_ ((DcProfileDialog*) self);
}

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

static void
___lambda133__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda133_ ((DcProfileDialog*) self);
}

static void
__lambda134_ (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
___lambda134__gtk_editable_changed (GtkEditable* _sender,
                                    gpointer self)
{
	__lambda134_ ((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
__lambda156_ (DcProfileDialog* self)
{
	dc_profile_dialog_confirm_delete_account (self, NULL, NULL);
}

static void
___lambda156__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda156_ ((DcProfileDialog*) self);
}

DcProfileDialog*
dc_profile_dialog_construct (GType object_type,
                             DcRpcClient* rpc,
                             DcSettingsManager* settings,
                             DcEventHandler* events,
                             gint acct_id)
{
	DcProfileDialog * self = NULL;
	DcRpcClient* _tmp0_;
	DcSettingsManager* _tmp1_;
	DcEventHandler* _tmp2_;
	gint _tmp3_ = 0;
	GtkBox* box = NULL;
	GtkBox* _tmp6_;
	AdwHeaderBar* header = NULL;
	AdwHeaderBar* _tmp7_;
	GtkButton* save_btn = NULL;
	GtkButton* _tmp8_;
	GtkBox* content = NULL;
	GtkBox* _tmp9_;
	AdwAvatar* _tmp10_;
	AdwAvatar* _tmp11_;
	AdwAvatar* _tmp12_;
	GtkButton* avatar_btn = NULL;
	GtkButton* _tmp13_;
	GtkSeparator* _tmp14_;
	GtkSeparator* _tmp15_;
	GtkGrid* fields_grid = NULL;
	GtkGrid* _tmp16_;
	GtkLabel* name_heading = NULL;
	GtkLabel* _tmp17_;
	GtkEntry* _tmp18_;
	GtkEntry* _tmp19_;
	GtkEntry* _tmp20_;
	GtkEntry* _tmp21_;
	GtkEntry* _tmp22_;
	GtkLabel* status_heading = NULL;
	GtkLabel* _tmp23_;
	GtkEntry* _tmp24_;
	GtkEntry* _tmp25_;
	GtkEntry* _tmp26_;
	GtkEntry* _tmp27_;
	GtkLabel* email_heading = NULL;
	GtkLabel* _tmp28_;
	GtkLabel* _tmp29_;
	GtkLabel* _tmp30_;
	GtkLabel* _tmp31_;
	GtkLabel* _tmp32_;
	GtkLabel* _tmp33_;
	GtkButton* invite_button = NULL;
	GtkButton* _tmp34_;
	GtkSeparator* _tmp35_;
	GtkSeparator* _tmp36_;
	GtkWidget* _tmp37_;
	GtkWidget* _tmp38_;
	GtkSeparator* _tmp39_;
	GtkSeparator* _tmp40_;
	GtkWidget* _tmp41_;
	GtkWidget* _tmp42_;
	GtkSeparator* _tmp43_;
	GtkSeparator* _tmp44_;
	GtkButton* relays_button = NULL;
	GtkButton* _tmp45_;
	GtkButton* second_device_button = NULL;
	GtkButton* _tmp46_;
	GtkWidget* _tmp47_;
	GtkWidget* _tmp48_;
	GtkButton* delete_button = NULL;
	GtkButton* _tmp49_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp50_;
	g_return_val_if_fail (rpc != NULL, NULL);
	g_return_val_if_fail (settings != NULL, NULL);
	g_return_val_if_fail (events != 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_;
	_tmp1_ = _g_object_ref0 (settings);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	_tmp2_ = _g_object_ref0 (events);
	_g_object_unref0 (self->priv->events);
	self->priv->events = _tmp2_;
	if (acct_id > 0) {
		_tmp3_ = acct_id;
	} else {
		gint _tmp4_;
		gint _tmp5_;
		_tmp4_ = dc_rpc_client_get_account_id (rpc);
		_tmp5_ = _tmp4_;
		_tmp3_ = _tmp5_;
	}
	self->priv->account_id = _tmp3_;
	adw_dialog_set_title ((AdwDialog*) self, "My Profile");
	adw_dialog_set_content_width ((AdwDialog*) self, 420);
	adw_dialog_set_content_height ((AdwDialog*) self, 560);
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp6_);
	box = _tmp6_;
	_tmp7_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp7_);
	header = _tmp7_;
	_tmp8_ = (GtkButton*) gtk_button_new_with_label ("Save");
	g_object_ref_sink (_tmp8_);
	save_btn = _tmp8_;
	gtk_widget_add_css_class ((GtkWidget*) save_btn, "suggested-action");
	g_signal_connect_object (save_btn, "clicked", (GCallback) ___lambda132__gtk_button_clicked, self, 0);
	adw_header_bar_pack_end (header, (GtkWidget*) save_btn);
	gtk_box_append (box, (GtkWidget*) header);
	_tmp9_ = dc_content_box (16);
	content = _tmp9_;
	_tmp10_ = (AdwAvatar*) adw_avatar_new (96, "", TRUE);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->avatar_widget);
	self->priv->avatar_widget = _tmp10_;
	_tmp11_ = self->priv->avatar_widget;
	gtk_widget_set_halign ((GtkWidget*) _tmp11_, GTK_ALIGN_CENTER);
	_tmp12_ = self->priv->avatar_widget;
	gtk_box_append (content, (GtkWidget*) _tmp12_);
	_tmp13_ = (GtkButton*) gtk_button_new_with_label ("Change Avatar");
	g_object_ref_sink (_tmp13_);
	avatar_btn = _tmp13_;
	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) ___lambda133__gtk_button_clicked, self, 0);
	gtk_box_append (content, (GtkWidget*) avatar_btn);
	_tmp14_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp14_);
	_tmp15_ = _tmp14_;
	gtk_box_append (content, (GtkWidget*) _tmp15_);
	_g_object_unref0 (_tmp15_);
	_tmp16_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp16_);
	fields_grid = _tmp16_;
	gtk_grid_set_column_spacing (fields_grid, 12);
	gtk_grid_set_row_spacing (fields_grid, 12);
	_tmp17_ = dc_heading_label ("Name");
	name_heading = _tmp17_;
	gtk_widget_set_valign ((GtkWidget*) name_heading, GTK_ALIGN_CENTER);
	gtk_grid_attach (fields_grid, (GtkWidget*) name_heading, 0, 0, 1, 1);
	_tmp18_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->name_entry);
	self->priv->name_entry = _tmp18_;
	_tmp19_ = self->priv->name_entry;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp19_, TRUE);
	_tmp20_ = self->priv->name_entry;
	gtk_entry_set_placeholder_text (_tmp20_, "Your name");
	_tmp21_ = self->priv->name_entry;
	g_signal_connect_object ((GtkEditable*) _tmp21_, "changed", (GCallback) ___lambda134__gtk_editable_changed, self, 0);
	_tmp22_ = self->priv->name_entry;
	gtk_grid_attach (fields_grid, (GtkWidget*) _tmp22_, 1, 0, 1, 1);
	_tmp23_ = dc_heading_label ("Status");
	status_heading = _tmp23_;
	gtk_widget_set_valign ((GtkWidget*) status_heading, GTK_ALIGN_CENTER);
	gtk_grid_attach (fields_grid, (GtkWidget*) status_heading, 0, 1, 1, 1);
	_tmp24_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->status_entry);
	self->priv->status_entry = _tmp24_;
	_tmp25_ = self->priv->status_entry;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp25_, TRUE);
	_tmp26_ = self->priv->status_entry;
	gtk_entry_set_placeholder_text (_tmp26_, "Your status message");
	_tmp27_ = self->priv->status_entry;
	gtk_grid_attach (fields_grid, (GtkWidget*) _tmp27_, 1, 1, 1, 1);
	_tmp28_ = dc_heading_label ("Email");
	email_heading = _tmp28_;
	gtk_widget_set_valign ((GtkWidget*) email_heading, GTK_ALIGN_CENTER);
	gtk_grid_attach (fields_grid, (GtkWidget*) email_heading, 0, 2, 1, 1);
	_tmp29_ = dc_dim_label ("", FALSE);
	_g_object_unref0 (self->priv->email_label);
	self->priv->email_label = _tmp29_;
	_tmp30_ = self->priv->email_label;
	gtk_label_set_selectable (_tmp30_, TRUE);
	_tmp31_ = self->priv->email_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp31_, TRUE);
	_tmp32_ = self->priv->email_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp32_, GTK_ALIGN_CENTER);
	_tmp33_ = self->priv->email_label;
	gtk_grid_attach (fields_grid, (GtkWidget*) _tmp33_, 1, 2, 1, 1);
	gtk_box_append (content, (GtkWidget*) fields_grid);
	_tmp34_ = dc_profile_dialog_append_profile_action_row (self, content, "Invite Code", "Show a contact invite QR code", "Share your contact", NULL);
	invite_button = _tmp34_;
	g_signal_connect_object (invite_button, "clicked", (GCallback) _dc_profile_dialog_show_invite_code_dialog_gtk_button_clicked, self, 0);
	_tmp35_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp35_);
	_tmp36_ = _tmp35_;
	gtk_box_append (content, (GtkWidget*) _tmp36_);
	_g_object_unref0 (_tmp36_);
	_tmp37_ = dc_profile_dialog_build_read_receipts_row (self);
	_tmp38_ = _tmp37_;
	gtk_box_append (content, _tmp38_);
	_g_object_unref0 (_tmp38_);
	_tmp39_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp39_);
	_tmp40_ = _tmp39_;
	gtk_box_append (content, (GtkWidget*) _tmp40_);
	_g_object_unref0 (_tmp40_);
	_tmp41_ = dc_profile_dialog_build_connectivity_storage_section (self);
	_tmp42_ = _tmp41_;
	gtk_box_append (content, _tmp42_);
	_g_object_unref0 (_tmp42_);
	_tmp43_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp43_);
	_tmp44_ = _tmp43_;
	gtk_box_append (content, (GtkWidget*) _tmp44_);
	_g_object_unref0 (_tmp44_);
	_tmp45_ = dc_profile_dialog_append_profile_action_row (self, content, "Relays...", "Manage chatmail relays for this profile", "Manage transports", NULL);
	relays_button = _tmp45_;
	g_signal_connect_object (relays_button, "clicked", (GCallback) _dc_profile_dialog_show_relays_dialog_gtk_button_clicked, self, 0);
	_tmp46_ = dc_profile_dialog_append_profile_action_row (self, content, "Add Second Device", "Show a setup QR code for another device", "Transfer to another device", NULL);
	second_device_button = _tmp46_;
	g_signal_connect_object (second_device_button, "clicked", (GCallback) _dc_profile_dialog_show_second_device_dialog_gtk_button_clicked, self, 0);
	_tmp47_ = dc_profile_dialog_build_default_account_row (self);
	_tmp48_ = _tmp47_;
	gtk_box_append (content, _tmp48_);
	_g_object_unref0 (_tmp48_);
	_tmp49_ = dc_profile_dialog_append_profile_action_row (self, content, "Delete Profile", "Delete local profile data", "Delete local profile data", "destructive-action");
	delete_button = _tmp49_;
	g_signal_connect_object (delete_button, "clicked", (GCallback) ___lambda156__gtk_button_clicked, self, 0);
	_tmp50_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp50_);
	scroll = _tmp50_;
	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);
	dc_profile_dialog_load_read_receipt_settings (self, NULL, NULL);
	dc_profile_dialog_load_connectivity_summary (self, NULL, NULL);
	_g_object_unref0 (scroll);
	_g_object_unref0 (delete_button);
	_g_object_unref0 (second_device_button);
	_g_object_unref0 (relays_button);
	_g_object_unref0 (invite_button);
	_g_object_unref0 (email_heading);
	_g_object_unref0 (status_heading);
	_g_object_unref0 (name_heading);
	_g_object_unref0 (fields_grid);
	_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,
                       DcSettingsManager* settings,
                       DcEventHandler* events,
                       gint acct_id)
{
	return dc_profile_dialog_construct (DC_TYPE_PROFILE_DIALOG, rpc, settings, events, acct_id);
}

static GtkButton*
dc_profile_dialog_append_profile_action_row (DcProfileDialog* self,
                                             GtkBox* content,
                                             const gchar* button_label,
                                             const gchar* tooltip,
                                             const gchar* caption_text,
                                             const gchar* css_class)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkLabel* caption = NULL;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkBox* _tmp4_;
	GtkLabel* _tmp5_;
	GtkButton* button = NULL;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp9_;
	GtkBox* _tmp10_;
	GtkButton* _tmp11_;
	GtkBox* _tmp12_;
	GtkButton* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (content != NULL, NULL);
	g_return_val_if_fail (button_label != NULL, NULL);
	g_return_val_if_fail (tooltip != NULL, NULL);
	g_return_val_if_fail (caption_text != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	_tmp1_ = box;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp1_, 4);
	_tmp2_ = dc_dim_label (caption_text, TRUE);
	caption = _tmp2_;
	_tmp3_ = caption;
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
	_tmp4_ = box;
	_tmp5_ = caption;
	gtk_box_append (_tmp4_, (GtkWidget*) _tmp5_);
	_tmp6_ = (GtkButton*) gtk_button_new_with_label (button_label);
	g_object_ref_sink (_tmp6_);
	button = _tmp6_;
	_tmp7_ = button;
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_END);
	if (css_class != NULL) {
		GtkButton* _tmp8_;
		_tmp8_ = button;
		gtk_widget_add_css_class ((GtkWidget*) _tmp8_, css_class);
	}
	_tmp9_ = button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp9_, tooltip);
	_tmp10_ = box;
	_tmp11_ = button;
	gtk_box_append (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = box;
	gtk_box_append (content, (GtkWidget*) _tmp12_);
	result = button;
	_g_object_unref0 (caption);
	_g_object_unref0 (box);
	return result;
}

static void
_dc_profile_dialog_make_account_default_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	dc_profile_dialog_make_account_default ((DcProfileDialog*) self);
}

static GtkWidget*
dc_profile_dialog_build_default_account_row (DcProfileDialog* self)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	gtk_widget_set_margin_top ((GtkWidget*) box, 4);
	_tmp1_ = dc_dim_label ("", TRUE);
	_g_object_unref0 (self->priv->default_caption_label);
	self->priv->default_caption_label = _tmp1_;
	_tmp2_ = self->priv->default_caption_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp2_, GTK_ALIGN_CENTER);
	_tmp3_ = self->priv->default_caption_label;
	gtk_box_append (box, (GtkWidget*) _tmp3_);
	_tmp4_ = (GtkButton*) gtk_button_new_with_label ("Make Default");
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->default_make_button);
	self->priv->default_make_button = _tmp4_;
	_tmp5_ = self->priv->default_make_button;
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_END);
	_tmp6_ = self->priv->default_make_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp6_, GTK_ALIGN_CENTER);
	_tmp7_ = self->priv->default_make_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp7_, "Open this account when Parla starts");
	_tmp8_ = self->priv->default_make_button;
	g_signal_connect_object (_tmp8_, "clicked", (GCallback) _dc_profile_dialog_make_account_default_gtk_button_clicked, self, 0);
	_tmp9_ = self->priv->default_make_button;
	gtk_box_append (box, (GtkWidget*) _tmp9_);
	dc_profile_dialog_update_default_account_row (self);
	result = (GtkWidget*) box;
	return result;
}

static void
__lambda138_ (DcProfileDialog* self)
{
	if (!self->priv->loading_read_receipts) {
		dc_profile_dialog_save_read_receipt_settings (self, NULL, NULL);
	}
}

static void
___lambda138__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda138_ ((DcProfileDialog*) self);
}

static GtkWidget*
dc_profile_dialog_build_read_receipts_row (DcProfileDialog* self)
{
	GtkBox* box = NULL;
	GtkBox* _tmp0_;
	GtkBox* labels = NULL;
	GtkBox* _tmp1_;
	GtkLabel* title = NULL;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkSwitch* _tmp5_;
	GtkSwitch* _tmp6_;
	GtkSwitch* _tmp7_;
	GtkSwitch* _tmp8_;
	GtkSwitch* _tmp9_;
	GtkSwitch* _tmp10_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp0_);
	box = _tmp0_;
	gtk_widget_set_margin_top ((GtkWidget*) box, 4);
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	g_object_ref_sink (_tmp1_);
	labels = _tmp1_;
	gtk_widget_set_hexpand ((GtkWidget*) labels, TRUE);
	_tmp2_ = dc_heading_label ("Read Receipts");
	title = _tmp2_;
	gtk_box_append (labels, (GtkWidget*) title);
	_tmp3_ = dc_dim_label ("This affects this profile in every Delta Chat client, not only Parla.", TRUE);
	_g_object_unref0 (self->priv->read_receipts_caption_label);
	self->priv->read_receipts_caption_label = _tmp3_;
	_tmp4_ = self->priv->read_receipts_caption_label;
	gtk_box_append (labels, (GtkWidget*) _tmp4_);
	gtk_box_append (box, (GtkWidget*) labels);
	_tmp5_ = (GtkSwitch*) gtk_switch_new ();
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->read_receipts_switch);
	self->priv->read_receipts_switch = _tmp5_;
	_tmp6_ = self->priv->read_receipts_switch;
	gtk_switch_set_active (_tmp6_, TRUE);
	_tmp7_ = self->priv->read_receipts_switch;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp7_, FALSE);
	_tmp8_ = self->priv->read_receipts_switch;
	gtk_widget_set_valign ((GtkWidget*) _tmp8_, GTK_ALIGN_CENTER);
	_tmp9_ = self->priv->read_receipts_switch;
	g_signal_connect_object ((GObject*) _tmp9_, "notify::active", (GCallback) ___lambda138__g_object_notify, self, 0);
	_tmp10_ = self->priv->read_receipts_switch;
	gtk_box_append (box, (GtkWidget*) _tmp10_);
	result = (GtkWidget*) box;
	_g_object_unref0 (title);
	_g_object_unref0 (labels);
	return result;
}

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

static void
dc_profile_dialog_load_read_receipt_settings (DcProfileDialog* self,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	DcProfileDialogLoadReadReceiptSettingsData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogLoadReadReceiptSettingsData);
	_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_read_receipt_settings_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_load_read_receipt_settings_co (_data_);
}

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

static void
dc_profile_dialog_load_read_receipt_settings_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	DcProfileDialogLoadReadReceiptSettingsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_load_read_receipt_settings_co (_data_);
}

static gboolean
dc_profile_dialog_load_read_receipt_settings_co (DcProfileDialogLoadReadReceiptSettingsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->rpc;
	_data_->_tmp2_ = dc_rpc_client_get_is_connected (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	if (!_data_->_tmp3_) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp0_ = _data_->self->priv->account_id <= 0;
	}
	if (_data_->_tmp0_) {
		dc_profile_dialog_set_read_receipt_controls_sensitive (_data_->self, FALSE);
		_data_->_tmp4_ = _data_->self->priv->read_receipts_caption_label;
		gtk_label_set_label (_data_->_tmp4_, "No active profile");
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->loading_read_receipts = TRUE;
	dc_profile_dialog_set_read_receipt_controls_sensitive (_data_->self, FALSE);
	{
		_data_->_tmp5_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_config (_data_->_tmp5_, "mdns_enabled", _data_->self->priv->account_id, dc_profile_dialog_load_read_receipt_settings_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = dc_rpc_client_get_config_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
		_data_->enabled = _data_->_tmp6_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp8_ = _data_->enabled;
		if (_data_->_tmp8_ == NULL) {
			_data_->_tmp7_ = TRUE;
		} else {
			_data_->_tmp9_ = _data_->enabled;
			_data_->_tmp7_ = g_strcmp0 (_data_->_tmp9_, "0") != 0;
		}
		_data_->_tmp10_ = _data_->self->priv->read_receipts_switch;
		gtk_switch_set_active (_data_->_tmp10_, _data_->_tmp7_);
		_data_->_tmp11_ = _data_->self->priv->read_receipts_switch;
		_data_->_tmp12_ = gtk_switch_get_active (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->self->priv->saved_read_receipts_enabled = _data_->_tmp13_;
		_data_->_tmp14_ = _data_->self->priv->read_receipts_switch;
		_data_->_tmp15_ = gtk_switch_get_active (_data_->_tmp14_);
		_data_->_tmp16_ = _data_->_tmp15_;
		dc_profile_dialog_update_read_receipts_caption (_data_->self, _data_->_tmp16_);
		_g_free0 (_data_->enabled);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp17_ = _data_->self->priv->read_receipts_caption_label;
		gtk_label_set_label (_data_->_tmp17_, "Unable to read read receipt setting");
		_data_->_tmp18_ = _data_->self->priv->read_receipts_caption_label;
		_data_->_tmp19_ = _data_->e;
		_data_->_tmp20_ = _data_->_tmp19_->message;
		gtk_widget_set_tooltip_text ((GtkWidget*) _data_->_tmp18_, _data_->_tmp20_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	{
		_data_->self->priv->loading_read_receipts = FALSE;
		dc_profile_dialog_set_read_receipt_controls_sensitive (_data_->self, TRUE);
	}
	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_set_read_receipt_controls_sensitive (DcProfileDialog* self,
                                                       gboolean sensitive)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GtkSwitch* _tmp5_;
	g_return_if_fail (self != NULL);
	if (sensitive) {
		DcRpcClient* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->rpc;
		_tmp3_ = dc_rpc_client_get_is_connected (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp1_ = _tmp4_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = self->priv->account_id > 0;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp5_ = self->priv->read_receipts_switch;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp5_, _tmp0_);
}

static void
dc_profile_dialog_update_read_receipts_caption (DcProfileDialog* self,
                                                gboolean enabled)
{
	const gchar* _tmp0_ = NULL;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	g_return_if_fail (self != NULL);
	if (enabled) {
		_tmp0_ = "Enabled. This affects this profile in every Delta Chat client, not onl" \
"y Parla.";
	} else {
		_tmp0_ = "Disabled. This affects this profile in every Delta Chat client, not on" \
"ly Parla.";
	}
	_tmp1_ = self->priv->read_receipts_caption_label;
	gtk_label_set_label (_tmp1_, _tmp0_);
	_tmp2_ = self->priv->read_receipts_caption_label;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, NULL);
}

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

static void
dc_profile_dialog_save_read_receipt_settings (DcProfileDialog* self,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	DcProfileDialogSaveReadReceiptSettingsData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogSaveReadReceiptSettingsData);
	_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_save_read_receipt_settings_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_save_read_receipt_settings_co (_data_);
}

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

static void
dc_profile_dialog_save_read_receipt_settings_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	DcProfileDialogSaveReadReceiptSettingsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_save_read_receipt_settings_co (_data_);
}

static gboolean
dc_profile_dialog_save_read_receipt_settings_co (DcProfileDialogSaveReadReceiptSettingsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->loading_read_receipts) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp0_ = _data_->self->priv->saving_read_receipts;
	}
	if (_data_->_tmp0_) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = _data_->self->priv->rpc;
	_data_->_tmp3_ = dc_rpc_client_get_is_connected (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	if (!_data_->_tmp4_) {
		_data_->_tmp1_ = TRUE;
	} else {
		_data_->_tmp1_ = _data_->self->priv->account_id <= 0;
	}
	if (_data_->_tmp1_) {
		dc_show_error ((GtkWidget*) _data_->self, "No active profile");
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->self->priv->read_receipts_switch;
	_data_->_tmp6_ = gtk_switch_get_active (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->enabled = _data_->_tmp7_;
	if (_data_->enabled == _data_->self->priv->saved_read_receipts_enabled) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->saving_read_receipts = TRUE;
	dc_profile_dialog_set_read_receipt_controls_sensitive (_data_->self, FALSE);
	{
		if (_data_->enabled) {
			_data_->_tmp8_ = "1";
		} else {
			_data_->_tmp8_ = "0";
		}
		_data_->_tmp9_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_batch_set_config (_data_->_tmp9_, "mdns_enabled", _data_->_tmp8_, _data_->self->priv->account_id, dc_profile_dialog_save_read_receipt_settings_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_batch_set_config_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->self->priv->saved_read_receipts_enabled = _data_->enabled;
		dc_profile_dialog_update_read_receipts_caption (_data_->self, _data_->enabled);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp10_ = _data_->e;
		_data_->_tmp11_ = _data_->_tmp10_->message;
		_data_->_tmp12_ = g_strconcat ("Failed to save read receipt setting: ", _data_->_tmp11_, NULL);
		_data_->_tmp13_ = _data_->_tmp12_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp13_);
		_g_free0 (_data_->_tmp13_);
		_data_->self->priv->loading_read_receipts = TRUE;
		_data_->_tmp14_ = _data_->self->priv->read_receipts_switch;
		gtk_switch_set_active (_data_->_tmp14_, _data_->self->priv->saved_read_receipts_enabled);
		_data_->self->priv->loading_read_receipts = FALSE;
		_g_error_free0 (_data_->e);
	}
	__finally0:
	{
		_data_->self->priv->saving_read_receipts = FALSE;
		dc_profile_dialog_set_read_receipt_controls_sensitive (_data_->self, TRUE);
	}
	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_make_account_default (DcProfileDialog* self)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	DcSettingsManager* _tmp5_;
	const gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->account_addr;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = self->priv->account_addr;
		_tmp3_ = strlen (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == 0;
	}
	if (_tmp0_) {
		return;
	}
	_tmp5_ = self->priv->settings;
	_tmp6_ = self->priv->account_addr;
	dc_settings_manager_save_default_account_addr (_tmp5_, _tmp6_);
	dc_profile_dialog_update_default_account_row (self);
}

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

static void
dc_profile_dialog_update_default_account_row (DcProfileDialog* self)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gboolean loaded = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean is_default = FALSE;
	const gchar* _tmp18_ = NULL;
	GtkLabel* _tmp19_;
	gboolean _tmp20_ = FALSE;
	GtkButton* _tmp21_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->account_addr;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = self->priv->account_addr;
		_tmp3_ = strlen (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ > 0;
	} else {
		_tmp0_ = FALSE;
	}
	loaded = _tmp0_;
	if (loaded) {
		DcSettingsManager* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		_tmp6_ = self->priv->settings;
		_tmp7_ = dc_settings_manager_get_default_account_addr (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_utf8_strdown (_tmp8_, (gssize) -1);
		_tmp10_ = _tmp9_;
		_tmp11_ = string_strip (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = self->priv->account_addr;
		_tmp14_ = g_utf8_strdown (_tmp13_, (gssize) -1);
		_tmp15_ = _tmp14_;
		_tmp16_ = string_strip (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp5_ = g_strcmp0 (_tmp12_, _tmp17_) == 0;
		_g_free0 (_tmp17_);
		_g_free0 (_tmp15_);
		_g_free0 (_tmp12_);
		_g_free0 (_tmp10_);
	} else {
		_tmp5_ = FALSE;
	}
	is_default = _tmp5_;
	if (is_default) {
		_tmp18_ = "This is your default account, opened when Parla starts";
	} else {
		_tmp18_ = "Open this account automatically when Parla starts";
	}
	_tmp19_ = self->priv->default_caption_label;
	gtk_label_set_label (_tmp19_, _tmp18_);
	if (loaded) {
		_tmp20_ = !is_default;
	} else {
		_tmp20_ = FALSE;
	}
	_tmp21_ = self->priv->default_make_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp21_, _tmp20_);
}

static void
__lambda139_ (DcProfileDialog* self)
{
	dc_profile_dialog_load_connectivity_summary (self, NULL, NULL);
}

static void
___lambda139__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda139_ ((DcProfileDialog*) self);
}

static void
__lambda140_ (DcProfileDialog* self)
{
	DcStorageDetailsDialog* dialog = NULL;
	DcRpcClient* _tmp0_;
	DcStorageDetailsDialog* _tmp1_;
	_tmp0_ = self->priv->rpc;
	_tmp1_ = dc_storage_details_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
___lambda140__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda140_ ((DcProfileDialog*) self);
}

static GtkWidget*
dc_profile_dialog_build_connectivity_storage_section (DcProfileDialog* self)
{
	GtkBox* section = NULL;
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkBox* conn_row = NULL;
	GtkBox* _tmp3_;
	GtkImage* conn_icon = NULL;
	GtkImage* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkProgressBar* _tmp7_;
	GtkProgressBar* _tmp8_;
	GtkProgressBar* _tmp9_;
	GtkProgressBar* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkBox* actions = NULL;
	GtkBox* _tmp13_;
	GtkButton* refresh_btn = NULL;
	GtkButton* _tmp14_;
	GtkButton* details_btn = NULL;
	GtkButton* _tmp15_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	g_object_ref_sink (_tmp0_);
	section = _tmp0_;
	_tmp1_ = dc_heading_label ("Storage & Connectivity");
	_tmp2_ = _tmp1_;
	gtk_box_append (section, (GtkWidget*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp3_);
	conn_row = _tmp3_;
	_tmp4_ = (GtkImage*) gtk_image_new_from_icon_name ("network-transmit-receive-symbolic");
	g_object_ref_sink (_tmp4_);
	conn_icon = _tmp4_;
	gtk_widget_set_valign ((GtkWidget*) conn_icon, GTK_ALIGN_CENTER);
	gtk_box_append (conn_row, (GtkWidget*) conn_icon);
	_tmp5_ = dc_dim_label ("Checking connection…", TRUE);
	_g_object_unref0 (self->priv->connectivity_status_label);
	self->priv->connectivity_status_label = _tmp5_;
	_tmp6_ = self->priv->connectivity_status_label;
	gtk_box_append (conn_row, (GtkWidget*) _tmp6_);
	gtk_box_append (section, (GtkWidget*) conn_row);
	_tmp7_ = (GtkProgressBar*) gtk_progress_bar_new ();
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->storage_progress);
	self->priv->storage_progress = _tmp7_;
	_tmp8_ = self->priv->storage_progress;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, "storage-quota-bar");
	_tmp9_ = self->priv->storage_progress;
	gtk_progress_bar_set_fraction (_tmp9_, 0.0);
	_tmp10_ = self->priv->storage_progress;
	gtk_box_append (section, (GtkWidget*) _tmp10_);
	_tmp11_ = dc_dim_label ("Loading server quota…", FALSE);
	_g_object_unref0 (self->priv->storage_summary_label);
	self->priv->storage_summary_label = _tmp11_;
	_tmp12_ = self->priv->storage_summary_label;
	gtk_box_append (section, (GtkWidget*) _tmp12_);
	_tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp13_);
	actions = _tmp13_;
	gtk_widget_set_halign ((GtkWidget*) actions, GTK_ALIGN_END);
	_tmp14_ = (GtkButton*) gtk_button_new_from_icon_name ("view-refresh-symbolic");
	g_object_ref_sink (_tmp14_);
	refresh_btn = _tmp14_;
	gtk_widget_set_tooltip_text ((GtkWidget*) refresh_btn, "Refresh storage and connectivity");
	gtk_widget_add_css_class ((GtkWidget*) refresh_btn, "flat");
	g_signal_connect_object (refresh_btn, "clicked", (GCallback) ___lambda139__gtk_button_clicked, self, 0);
	gtk_box_append (actions, (GtkWidget*) refresh_btn);
	_tmp15_ = (GtkButton*) gtk_button_new_with_label ("Details…");
	g_object_ref_sink (_tmp15_);
	details_btn = _tmp15_;
	gtk_widget_set_tooltip_text ((GtkWidget*) details_btn, "Show storage by conversation");
	g_signal_connect_object (details_btn, "clicked", (GCallback) ___lambda140__gtk_button_clicked, self, 0);
	gtk_box_append (actions, (GtkWidget*) details_btn);
	gtk_box_append (section, (GtkWidget*) actions);
	result = (GtkWidget*) section;
	_g_object_unref0 (details_btn);
	_g_object_unref0 (refresh_btn);
	_g_object_unref0 (actions);
	_g_object_unref0 (conn_icon);
	_g_object_unref0 (conn_row);
	return result;
}

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_->_tmp19_ = _data_->email;
			_data_->_tmp20_ = g_strdup (_data_->_tmp19_);
			_g_free0 (_data_->self->priv->account_addr);
			_data_->self->priv->account_addr = _data_->_tmp20_;
			dc_profile_dialog_update_default_account_row (_data_->self);
		}
		_data_->_tmp23_ = _data_->avatar;
		if (_data_->_tmp23_ != NULL) {
			_data_->_tmp24_ = _data_->avatar;
			_data_->_tmp25_ = strlen (_data_->_tmp24_);
			_data_->_tmp26_ = _data_->_tmp25_;
			_data_->_tmp22_ = _data_->_tmp26_ > 0;
		} else {
			_data_->_tmp22_ = FALSE;
		}
		if (_data_->_tmp22_) {
			_data_->_tmp27_ = _data_->avatar;
			_data_->_tmp21_ = g_file_test (_data_->_tmp27_, G_FILE_TEST_EXISTS);
		} else {
			_data_->_tmp21_ = FALSE;
		}
		if (_data_->_tmp21_) {
			_data_->_tmp28_ = _data_->avatar;
			_data_->_tmp29_ = g_strdup (_data_->_tmp28_);
			_g_free0 (_data_->self->priv->avatar_path);
			_data_->self->priv->avatar_path = _data_->_tmp29_;
		}
		_data_->_tmp30_ = _data_->self->priv->avatar_widget;
		_data_->_tmp31_ = _data_->avatar;
		_data_->_tmp32_ = dc_load_avatar (_data_->_tmp31_);
		_data_->_tmp33_ = _data_->_tmp32_;
		adw_avatar_set_custom_image (_data_->_tmp30_, (GdkPaintable*) _data_->_tmp33_);
		_g_object_unref0 (_data_->_tmp33_);
		_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_load_connectivity_summary_data_free (gpointer _data)
{
	DcProfileDialogLoadConnectivitySummaryData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DcProfileDialogLoadConnectivitySummaryData, _data_);
}

static void
dc_profile_dialog_load_connectivity_summary (DcProfileDialog* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	DcProfileDialogLoadConnectivitySummaryData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogLoadConnectivitySummaryData);
	_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_connectivity_summary_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_load_connectivity_summary_co (_data_);
}

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

static void
dc_profile_dialog_load_connectivity_summary_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_)
{
	DcProfileDialogLoadConnectivitySummaryData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_load_connectivity_summary_co (_data_);
}

static gboolean
dc_profile_dialog_load_connectivity_summary_co (DcProfileDialogLoadConnectivitySummaryData* _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_connectivity (_data_->_tmp0_, _data_->self->priv->account_id, dc_profile_dialog_load_connectivity_summary_ready, _data_);
		return FALSE;
		_state_1:
		_data_->connectivity = dc_rpc_client_get_connectivity_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp1_ = _data_->self->priv->connectivity_status_label;
		_data_->_tmp2_ = dc_profile_dialog_connection_label_for_state (_data_->connectivity);
		_data_->_tmp3_ = _data_->_tmp2_;
		gtk_label_set_label (_data_->_tmp1_, _data_->_tmp3_);
		_g_free0 (_data_->_tmp3_);
		_data_->_tmp4_ = _data_->self->priv->rpc;
		_data_->_state_ = 2;
		dc_rpc_client_get_connectivity_html (_data_->_tmp4_, _data_->self->priv->account_id, dc_profile_dialog_load_connectivity_summary_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp5_ = dc_rpc_client_get_connectivity_html_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		_data_->html = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp6_ = _data_->html;
		_data_->_tmp7_ = dc_storage_quota_parse_connectivity_report (_data_->_tmp6_);
		_data_->quota = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->self->priv->storage_progress;
		_data_->_tmp9_ = _data_->quota;
		dc_apply_quota_progress (_data_->_tmp8_, _data_->_tmp9_);
		_data_->_tmp10_ = _data_->self->priv->storage_summary_label;
		_data_->_tmp11_ = _data_->quota;
		_data_->_tmp12_ = dc_storage_quota_summary_text (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		gtk_label_set_label (_data_->_tmp10_, _data_->_tmp13_);
		_g_free0 (_data_->_tmp13_);
		_g_object_unref0 (_data_->quota);
		_g_free0 (_data_->html);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp14_ = _data_->self->priv->connectivity_status_label;
		gtk_label_set_label (_data_->_tmp14_, "Connection details unavailable");
		_data_->_tmp15_ = _data_->self->priv->storage_summary_label;
		_data_->_tmp16_ = _data_->e;
		_data_->_tmp17_ = _data_->_tmp16_->message;
		gtk_label_set_label (_data_->_tmp15_, _data_->_tmp17_);
		_data_->_tmp18_ = _data_->self->priv->storage_progress;
		gtk_progress_bar_set_fraction (_data_->_tmp18_, 0.0);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gchar*
dc_profile_dialog_connection_label_for_state (gint state)
{
	gchar* _tmp4_;
	gchar* result;
	if (state >= 4000) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("Connected; all background work is done");
		result = _tmp0_;
		return result;
	}
	if (state >= 3000) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("Connected; sending or syncing messages");
		result = _tmp1_;
		return result;
	}
	if (state >= 2000) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup ("Connecting to the server");
		result = _tmp2_;
		return result;
	}
	if (state >= 1000) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup ("Not connected");
		result = _tmp3_;
		return result;
	}
	_tmp4_ = g_strdup ("Connection state unknown");
	result = _tmp4_;
	return result;
}

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 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, 0);
	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_;
	DcEventHandler* _tmp1_;
	DcRelaysDialog* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = self->priv->events;
	_tmp2_ = dc_relays_dialog_new (_tmp0_, _tmp1_, self->priv->account_id);
	g_object_ref_sink (_tmp2_);
	dialog = _tmp2_;
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

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

static void
dc_profile_dialog_confirm_delete_account (DcProfileDialog* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	DcProfileDialogConfirmDeleteAccountData* _data_;
	DcProfileDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcProfileDialogConfirmDeleteAccountData);
	_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_confirm_delete_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_profile_dialog_confirm_delete_account_co (_data_);
}

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

static void
dc_profile_dialog_confirm_delete_account_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	DcProfileDialogConfirmDeleteAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_confirm_delete_account_co (_data_);
}

static gboolean
dc_profile_dialog_confirm_delete_account_co (DcProfileDialogConfirmDeleteAccountData* _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->email_label;
	_data_->_tmp1_ = gtk_label_get_label (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = string_strip (_data_->_tmp2_);
	_data_->label = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->label;
	_data_->_tmp5_ = strlen (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	if (_data_->_tmp6_ == 0) {
		_data_->_tmp7_ = _data_->self->priv->name_entry;
		_data_->_tmp8_ = gtk_editable_get_text ((GtkEditable*) _data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = string_strip (_data_->_tmp9_);
		_g_free0 (_data_->label);
		_data_->label = _data_->_tmp10_;
	}
	_data_->_tmp11_ = _data_->label;
	_data_->_tmp12_ = strlen (_data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	if (_data_->_tmp13_ == 0) {
		_data_->_tmp14_ = g_strdup ("this account");
		_g_free0 (_data_->label);
		_data_->label = _data_->_tmp14_;
	}
	_data_->_tmp15_ = _data_->label;
	_data_->_tmp16_ = g_strdup_printf ("Delete \"%s\"? This will remove all local data for this profile.", _data_->_tmp15_);
	_data_->_tmp17_ = _data_->_tmp16_;
	_data_->_state_ = 1;
	dc_confirm_action ((GtkWidget*) _data_->self, "Delete Profile", _data_->_tmp17_, "delete", "Delete Profile", dc_profile_dialog_confirm_delete_account_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp18_ = dc_confirm_action_finish (_data_->_res_);
	_g_free0 (_data_->_tmp17_);
	if (_data_->_tmp18_) {
		dc_profile_dialog_do_delete_account (_data_->self, NULL, NULL);
	}
	_g_free0 (_data_->label);
	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_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->account_addr = NULL;
	self->priv->avatar_path = NULL;
	self->priv->avatar_changed = FALSE;
	self->priv->loading_read_receipts = FALSE;
	self->priv->saving_read_receipts = FALSE;
	self->priv->saved_read_receipts_enabled = TRUE;
}

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->settings);
	_g_object_unref0 (self->priv->events);
	_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_object_unref0 (self->priv->default_caption_label);
	_g_object_unref0 (self->priv->default_make_button);
	_g_free0 (self->priv->account_addr);
	_g_object_unref0 (self->priv->connectivity_status_label);
	_g_object_unref0 (self->priv->storage_summary_label);
	_g_object_unref0 (self->priv->storage_progress);
	_g_object_unref0 (self->priv->read_receipts_switch);
	_g_object_unref0 (self->priv->read_receipts_caption_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_chat_storage_usage_get_instance_private (DcChatStorageUsage* self)
{
	return G_STRUCT_MEMBER_P (self, DcChatStorageUsage_private_offset);
}

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

DcChatStorageUsage*
dc_chat_storage_usage_construct (GType object_type,
                                 gint chat_id,
                                 const gchar* name)
{
	DcChatStorageUsage * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (name != NULL, NULL);
	self = (DcChatStorageUsage*) g_object_new (object_type, NULL);
	self->chat_id = chat_id;
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	return self;
}

DcChatStorageUsage*
dc_chat_storage_usage_new (gint chat_id,
                           const gchar* name)
{
	return dc_chat_storage_usage_construct (DC_TYPE_CHAT_STORAGE_USAGE, chat_id, name);
}

gboolean
dc_chat_storage_usage_add_local_file (DcChatStorageUsage* self,
                                      const gchar* path,
                                      gint64 bytes)
{
	GHashTable* _tmp0_;
	GHashTable* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gint _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	_tmp0_ = self->priv->local_paths;
	if (g_hash_table_contains (_tmp0_, path)) {
		result = FALSE;
		return result;
	}
	_tmp1_ = self->priv->local_paths;
	_tmp2_ = g_strdup (path);
	_tmp3_ = g_strdup ("1");
	g_hash_table_insert (_tmp1_, _tmp2_, _tmp3_);
	self->local_bytes = self->local_bytes + bytes;
	_tmp4_ = self->local_file_count;
	self->local_file_count = _tmp4_ + 1;
	result = TRUE;
	return result;
}

gint64
dc_chat_storage_usage_total_bytes (DcChatStorageUsage* self)
{
	gint64 _tmp0_ = 0LL;
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	if (self->local_bytes > self->remote_bytes) {
		_tmp0_ = self->local_bytes;
	} else {
		_tmp0_ = self->remote_bytes;
	}
	result = _tmp0_;
	return result;
}

static void
dc_chat_storage_usage_class_init (DcChatStorageUsageClass * klass,
                                  gpointer klass_data)
{
	dc_chat_storage_usage_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcChatStorageUsage_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_chat_storage_usage_finalize;
}

static void
dc_chat_storage_usage_instance_init (DcChatStorageUsage * self,
                                     gpointer klass)
{
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	self->priv = dc_chat_storage_usage_get_instance_private (self);
	self->message_count = 0;
	self->local_file_count = 0;
	self->remote_bytes = (gint64) 0;
	self->local_bytes = (gint64) 0;
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_free0_);
	self->priv->local_paths = _tmp2_;
}

static void
dc_chat_storage_usage_finalize (GObject * obj)
{
	DcChatStorageUsage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_CHAT_STORAGE_USAGE, DcChatStorageUsage);
	_g_free0 (self->name);
	_g_hash_table_unref0 (self->priv->local_paths);
	G_OBJECT_CLASS (dc_chat_storage_usage_parent_class)->finalize (obj);
}

static GType
dc_chat_storage_usage_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcChatStorageUsageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_chat_storage_usage_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcChatStorageUsage), 0, (GInstanceInitFunc) dc_chat_storage_usage_instance_init, NULL };
	GType dc_chat_storage_usage_type_id;
	dc_chat_storage_usage_type_id = g_type_register_static (G_TYPE_OBJECT, "DcChatStorageUsage", &g_define_type_info, 0);
	DcChatStorageUsage_private_offset = g_type_add_instance_private (dc_chat_storage_usage_type_id, sizeof (DcChatStorageUsagePrivate));
	return dc_chat_storage_usage_type_id;
}

GType
dc_chat_storage_usage_get_type (void)
{
	static volatile gsize dc_chat_storage_usage_type_id__once = 0;
	if (g_once_init_enter (&dc_chat_storage_usage_type_id__once)) {
		GType dc_chat_storage_usage_type_id;
		dc_chat_storage_usage_type_id = dc_chat_storage_usage_get_type_once ();
		g_once_init_leave (&dc_chat_storage_usage_type_id__once, dc_chat_storage_usage_type_id);
	}
	return dc_chat_storage_usage_type_id__once;
}

static inline gpointer
dc_storage_details_dialog_get_instance_private (DcStorageDetailsDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcStorageDetailsDialog_private_offset);
}

static void
__lambda141_ (DcStorageDetailsDialog* self)
{
	dc_storage_details_dialog_load_details (self, NULL, NULL);
}

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

static void
_dc_storage_details_dialog_show_clear_cache_info_gtk_button_clicked (GtkButton* _sender,
                                                                     gpointer self)
{
	dc_storage_details_dialog_show_clear_cache_info ((DcStorageDetailsDialog*) self);
}

DcStorageDetailsDialog*
dc_storage_details_dialog_construct (GType object_type,
                                     DcRpcClient* rpc,
                                     gint acct_id)
{
	DcStorageDetailsDialog * self = NULL;
	DcRpcClient* _tmp0_;
	GtkBox* box = NULL;
	GtkBox* _tmp1_;
	AdwHeaderBar* header = NULL;
	AdwHeaderBar* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkButton* _tmp6_;
	GtkBox* content = NULL;
	GtkBox* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkProgressBar* _tmp10_;
	GtkProgressBar* _tmp11_;
	GtkProgressBar* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	GtkLabel* _tmp15_;
	GtkLabel* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	GtkButton* _tmp19_;
	GtkButton* _tmp20_;
	GtkButton* _tmp21_;
	GtkButton* _tmp22_;
	GtkButton* _tmp23_;
	GtkSeparator* _tmp24_;
	GtkSeparator* _tmp25_;
	GtkLabel* _tmp26_;
	GtkLabel* _tmp27_;
	GtkLabel* _tmp28_;
	GtkLabel* _tmp29_;
	GtkListBox* _tmp30_;
	GtkListBox* _tmp31_;
	GtkListBox* _tmp32_;
	GtkListBox* _tmp33_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp34_;
	g_return_val_if_fail (rpc != NULL, NULL);
	self = (DcStorageDetailsDialog*) 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, "Storage Details");
	adw_dialog_set_content_width ((AdwDialog*) self, 560);
	adw_dialog_set_content_height ((AdwDialog*) self, 680);
	_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_);
	header = _tmp2_;
	_tmp3_ = (GtkButton*) gtk_button_new_from_icon_name ("view-refresh-symbolic");
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->refresh_btn);
	self->priv->refresh_btn = _tmp3_;
	_tmp4_ = self->priv->refresh_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp4_, "Rescan storage usage");
	_tmp5_ = self->priv->refresh_btn;
	g_signal_connect_object (_tmp5_, "clicked", (GCallback) ___lambda141__gtk_button_clicked, self, 0);
	_tmp6_ = self->priv->refresh_btn;
	adw_header_bar_pack_end (header, (GtkWidget*) _tmp6_);
	gtk_box_append (box, (GtkWidget*) header);
	_tmp7_ = dc_content_box (16);
	content = _tmp7_;
	_tmp8_ = dc_heading_label ("Server Quota");
	_tmp9_ = _tmp8_;
	gtk_box_append (content, (GtkWidget*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = (GtkProgressBar*) gtk_progress_bar_new ();
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->quota_progress);
	self->priv->quota_progress = _tmp10_;
	_tmp11_ = self->priv->quota_progress;
	gtk_widget_add_css_class ((GtkWidget*) _tmp11_, "storage-quota-bar");
	_tmp12_ = self->priv->quota_progress;
	gtk_box_append (content, (GtkWidget*) _tmp12_);
	_tmp13_ = dc_dim_label ("Loading quota…", FALSE);
	_g_object_unref0 (self->priv->quota_label);
	self->priv->quota_label = _tmp13_;
	_tmp14_ = self->priv->quota_label;
	gtk_box_append (content, (GtkWidget*) _tmp14_);
	_tmp15_ = dc_heading_label ("Local Copies");
	_tmp16_ = _tmp15_;
	gtk_box_append (content, (GtkWidget*) _tmp16_);
	_g_object_unref0 (_tmp16_);
	_tmp17_ = dc_dim_label ("Scanning local files…", FALSE);
	_g_object_unref0 (self->priv->local_total_label);
	self->priv->local_total_label = _tmp17_;
	_tmp18_ = self->priv->local_total_label;
	gtk_box_append (content, (GtkWidget*) _tmp18_);
	_tmp19_ = (GtkButton*) gtk_button_new_with_label ("Clear Local Cache…");
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->clear_cache_btn);
	self->priv->clear_cache_btn = _tmp19_;
	_tmp20_ = self->priv->clear_cache_btn;
	gtk_widget_set_halign ((GtkWidget*) _tmp20_, GTK_ALIGN_START);
	_tmp21_ = self->priv->clear_cache_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp21_, "Explain what can be safely cleared");
	_tmp22_ = self->priv->clear_cache_btn;
	g_signal_connect_object (_tmp22_, "clicked", (GCallback) _dc_storage_details_dialog_show_clear_cache_info_gtk_button_clicked, self, 0);
	_tmp23_ = self->priv->clear_cache_btn;
	gtk_box_append (content, (GtkWidget*) _tmp23_);
	_tmp24_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp24_);
	_tmp25_ = _tmp24_;
	gtk_box_append (content, (GtkWidget*) _tmp25_);
	_g_object_unref0 (_tmp25_);
	_tmp26_ = dc_heading_label ("Conversations by Storage Size");
	_tmp27_ = _tmp26_;
	gtk_box_append (content, (GtkWidget*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	_tmp28_ = dc_dim_label ("Preparing scan…", FALSE);
	_g_object_unref0 (self->priv->scan_status_label);
	self->priv->scan_status_label = _tmp28_;
	_tmp29_ = self->priv->scan_status_label;
	gtk_box_append (content, (GtkWidget*) _tmp29_);
	_tmp30_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp30_);
	_g_object_unref0 (self->priv->chat_usage_list);
	self->priv->chat_usage_list = _tmp30_;
	_tmp31_ = self->priv->chat_usage_list;
	gtk_list_box_set_selection_mode (_tmp31_, GTK_SELECTION_NONE);
	_tmp32_ = self->priv->chat_usage_list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp32_, "boxed-list");
	_tmp33_ = self->priv->chat_usage_list;
	gtk_box_append (content, (GtkWidget*) _tmp33_);
	_tmp34_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp34_);
	scroll = _tmp34_;
	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_install_escape_close ((AdwDialog*) self);
	dc_storage_details_dialog_load_details (self, NULL, NULL);
	_g_object_unref0 (scroll);
	_g_object_unref0 (content);
	_g_object_unref0 (header);
	_g_object_unref0 (box);
	return self;
}

DcStorageDetailsDialog*
dc_storage_details_dialog_new (DcRpcClient* rpc,
                               gint acct_id)
{
	return dc_storage_details_dialog_construct (DC_TYPE_STORAGE_DETAILS_DIALOG, rpc, acct_id);
}

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

static void
dc_storage_details_dialog_load_details (DcStorageDetailsDialog* self,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	DcStorageDetailsDialogLoadDetailsData* _data_;
	DcStorageDetailsDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcStorageDetailsDialogLoadDetailsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_storage_details_dialog_load_details_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_storage_details_dialog_load_details_co (_data_);
}

static void
dc_storage_details_dialog_load_details_finish (DcStorageDetailsDialog* self,
                                               GAsyncResult* _res_)
{
	DcStorageDetailsDialogLoadDetailsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_storage_details_dialog_load_details_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	DcStorageDetailsDialogLoadDetailsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_storage_details_dialog_load_details_co (_data_);
}

static gboolean
dc_storage_details_dialog_load_details_co (DcStorageDetailsDialogLoadDetailsData* _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->refresh_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp0_, FALSE);
	_data_->_tmp1_ = _data_->self->priv->chat_usage_list;
	dc_clear_listbox (_data_->_tmp1_);
	_data_->self->priv->known_attachment_bytes = (gint64) 0;
	_data_->self->priv->unique_local_file_bytes = (gint64) 0;
	_data_->_tmp2_ = _data_->self->priv->global_local_paths;
	g_hash_table_remove_all (_data_->_tmp2_);
	_data_->_tmp3_ = _data_->self->priv->scan_status_label;
	gtk_label_set_label (_data_->_tmp3_, "Scanning conversations…");
	_data_->_tmp4_ = _data_->self->priv->local_total_label;
	gtk_label_set_label (_data_->_tmp4_, "Scanning local files…");
	{
		_data_->account_bytes = (gint64) 0;
		{
			_data_->_tmp6_ = _data_->self->priv->rpc;
			_data_->_state_ = 1;
			dc_rpc_client_get_account_file_size (_data_->_tmp6_, _data_->self->priv->account_id, dc_storage_details_dialog_load_details_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp5_ = dc_rpc_client_get_account_file_size_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_data_->account_bytes = _data_->_tmp5_;
		}
		goto __finally1;
		__catch1_g_error:
		{
			g_clear_error (&_data_->_inner_error0_);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		{
			_data_->_tmp8_ = _data_->self->priv->rpc;
			_data_->_state_ = 2;
			dc_rpc_client_get_blob_dir (_data_->_tmp8_, _data_->self->priv->account_id, dc_storage_details_dialog_load_details_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp9_ = dc_rpc_client_get_blob_dir_finish (_data_->_tmp8_, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp7_ = _data_->_tmp9_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch2_g_error;
			}
			_data_->_tmp10_ = _data_->_tmp7_;
			_data_->_tmp7_ = NULL;
			_g_free0 (_data_->self->priv->blob_dir);
			_data_->self->priv->blob_dir = _data_->_tmp10_;
			_g_free0 (_data_->_tmp7_);
		}
		goto __finally2;
		__catch2_g_error:
		{
			g_clear_error (&_data_->_inner_error0_);
			_g_free0 (_data_->self->priv->blob_dir);
			_data_->self->priv->blob_dir = NULL;
		}
		__finally2:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		{
			_data_->_tmp11_ = _data_->self->priv->rpc;
			_data_->_state_ = 3;
			dc_rpc_client_get_connectivity_html (_data_->_tmp11_, _data_->self->priv->account_id, dc_storage_details_dialog_load_details_ready, _data_);
			return FALSE;
			_state_3:
			_data_->_tmp12_ = dc_rpc_client_get_connectivity_html_finish (_data_->_tmp11_, _data_->_res_, &_data_->_inner_error0_);
			_data_->html = _data_->_tmp12_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch3_g_error;
			}
			_data_->_tmp13_ = dc_storage_quota_parse_connectivity_report (_data_->html);
			_data_->quota = _data_->_tmp13_;
			_data_->_tmp14_ = _data_->self->priv->quota_progress;
			_data_->_tmp15_ = _data_->quota;
			dc_apply_quota_progress (_data_->_tmp14_, _data_->_tmp15_);
			_data_->_tmp16_ = _data_->self->priv->quota_label;
			_data_->_tmp17_ = _data_->quota;
			_data_->_tmp18_ = dc_storage_quota_summary_text (_data_->_tmp17_);
			_data_->_tmp19_ = _data_->_tmp18_;
			gtk_label_set_label (_data_->_tmp16_, _data_->_tmp19_);
			_g_free0 (_data_->_tmp19_);
			_g_object_unref0 (_data_->quota);
			_g_free0 (_data_->html);
		}
		goto __finally3;
		__catch3_g_error:
		{
			_data_->e = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp20_ = _data_->self->priv->quota_progress;
			gtk_progress_bar_set_fraction (_data_->_tmp20_, 0.0);
			_data_->_tmp21_ = _data_->self->priv->quota_label;
			_data_->_tmp22_ = _data_->e;
			_data_->_tmp23_ = _data_->_tmp22_->message;
			_data_->_tmp24_ = g_strconcat ("Server quota unavailable: ", _data_->_tmp23_, NULL);
			_data_->_tmp25_ = _data_->_tmp24_;
			gtk_label_set_label (_data_->_tmp21_, _data_->_tmp25_);
			_g_free0 (_data_->_tmp25_);
			_g_error_free0 (_data_->e);
		}
		__finally3:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp26_ = 0;
		_data_->_state_ = 4;
		dc_storage_details_dialog_scan_all_chats (_data_->self, dc_storage_details_dialog_load_details_ready, _data_);
		return FALSE;
		_state_4:
		_data_->_tmp27_ = dc_storage_details_dialog_scan_all_chats_finish (_data_->self, _data_->_res_, &_data_->_tmp26_, &_data_->_inner_error0_);
		_data_->usages = _data_->_tmp27_;
		_data_->usages_length1 = _data_->_tmp26_;
		_data_->_usages_size_ = _data_->usages_length1;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		dc_storage_details_dialog_sort_usages (_data_->self, _data_->usages, (gint) _data_->usages_length1);
		dc_storage_details_dialog_populate_chat_usage_list (_data_->self, _data_->usages, (gint) _data_->usages_length1);
		_data_->_tmp28_ = dc_storage_quota_format_mb (_data_->self->priv->unique_local_file_bytes);
		_data_->_tmp29_ = _data_->_tmp28_;
		_data_->_tmp30_ = dc_storage_quota_format_mb (_data_->self->priv->known_attachment_bytes);
		_data_->_tmp31_ = _data_->_tmp30_;
		_data_->_tmp32_ = g_strdup_printf ("%s downloaded message files · %s known attachment payload", _data_->_tmp29_, _data_->_tmp31_);
		_data_->_tmp33_ = _data_->_tmp32_;
		_g_free0 (_data_->_tmp31_);
		_g_free0 (_data_->_tmp29_);
		_data_->file_summary = _data_->_tmp33_;
		if (_data_->account_bytes > ((gint64) 0)) {
			_data_->_tmp35_ = dc_storage_quota_format_mb (_data_->account_bytes);
			_data_->_tmp36_ = _data_->_tmp35_;
			_data_->_tmp37_ = _data_->file_summary;
			_data_->_tmp38_ = g_strdup_printf ("%s local account data · %s", _data_->_tmp36_, _data_->_tmp37_);
			_g_free0 (_data_->_tmp34_);
			_data_->_tmp34_ = _data_->_tmp38_;
			_g_free0 (_data_->_tmp36_);
		} else {
			_data_->_tmp39_ = _data_->file_summary;
			_data_->_tmp40_ = g_strdup (_data_->_tmp39_);
			_g_free0 (_data_->_tmp34_);
			_data_->_tmp34_ = _data_->_tmp40_;
		}
		_data_->_tmp41_ = _data_->self->priv->local_total_label;
		gtk_label_set_label (_data_->_tmp41_, _data_->_tmp34_);
		if (_data_->usages_length1 == 0) {
			_data_->_tmp43_ = g_strdup ("No downloaded message files found in conversations.");
			_g_free0 (_data_->_tmp42_);
			_data_->_tmp42_ = _data_->_tmp43_;
		} else {
			_data_->_tmp44_ = g_strdup_printf ("%d conversations with local or attached files.", _data_->usages_length1);
			_g_free0 (_data_->_tmp42_);
			_data_->_tmp42_ = _data_->_tmp44_;
		}
		_data_->_tmp45_ = _data_->self->priv->scan_status_label;
		gtk_label_set_label (_data_->_tmp45_, _data_->_tmp42_);
		_g_free0 (_data_->_tmp42_);
		_g_free0 (_data_->_tmp34_);
		_g_free0 (_data_->file_summary);
		_data_->usages = (_vala_array_free (_data_->usages, _data_->usages_length1, (GDestroyNotify) g_object_unref), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp46_ = _data_->self->priv->scan_status_label;
		_data_->_tmp47_ = _data_->_vala1_e;
		_data_->_tmp48_ = _data_->_tmp47_->message;
		_data_->_tmp49_ = g_strconcat ("Storage scan failed: ", _data_->_tmp48_, NULL);
		_data_->_tmp50_ = _data_->_tmp49_;
		gtk_label_set_label (_data_->_tmp46_, _data_->_tmp50_);
		_g_free0 (_data_->_tmp50_);
		_g_error_free0 (_data_->_vala1_e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp51_ = _data_->self->priv->refresh_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp51_, TRUE);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_storage_details_dialog_scan_all_chats_data_free (gpointer _data)
{
	DcStorageDetailsDialogScanAllChatsData* _data_;
	_data_ = _data;
	_data_->result = (_vala_array_free (_data_->result, _data_->result_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcStorageDetailsDialogScanAllChatsData, _data_);
}

static void
dc_storage_details_dialog_scan_all_chats (DcStorageDetailsDialog* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	DcStorageDetailsDialogScanAllChatsData* _data_;
	DcStorageDetailsDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcStorageDetailsDialogScanAllChatsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_storage_details_dialog_scan_all_chats_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_storage_details_dialog_scan_all_chats_co (_data_);
}

static DcChatStorageUsage**
dc_storage_details_dialog_scan_all_chats_finish (DcStorageDetailsDialog* self,
                                                 GAsyncResult* _res_,
                                                 gint* result_length1,
                                                 GError** error)
{
	DcChatStorageUsage** result;
	DcStorageDetailsDialogScanAllChatsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	*result_length1 = _data_->result_length1;
	_data_->result = NULL;
	return result;
}

static void
dc_storage_details_dialog_scan_all_chats_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	DcStorageDetailsDialogScanAllChatsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_storage_details_dialog_scan_all_chats_co (_data_);
}

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

static gboolean
dc_storage_details_dialog_scan_all_chats_co (DcStorageDetailsDialogScanAllChatsData* _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_ = g_new0 (DcChatStorageUsage*, 0 + 1);
	_data_->usages = _data_->_tmp0_;
	_data_->usages_length1 = 0;
	_data_->_usages_size_ = _data_->usages_length1;
	_data_->_tmp1_ = _data_->self->priv->rpc;
	_data_->_state_ = 1;
	dc_rpc_client_get_chatlist_entries_for (_data_->_tmp1_, _data_->self->priv->account_id, NULL, -1, dc_storage_details_dialog_scan_all_chats_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = dc_rpc_client_get_chatlist_entries_for_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
	_data_->entries = _data_->_tmp2_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_data_->usages = (_vala_array_free (_data_->usages, _data_->usages_length1, (GDestroyNotify) g_object_unref), NULL);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->entries;
	if (_data_->_tmp3_ == NULL) {
		_data_->_tmp4_ = _data_->usages;
		_data_->_tmp4__length1 = _data_->usages_length1;
		_data_->result_length1 = _data_->_tmp4__length1;
		_data_->result = _data_->_tmp4_;
		_json_array_unref0 (_data_->entries);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->items = NULL;
	{
		_data_->_tmp6_ = _data_->self->priv->rpc;
		_data_->_tmp7_ = _data_->entries;
		_data_->_state_ = 2;
		dc_rpc_client_get_chatlist_items_by_entries_for (_data_->_tmp6_, _data_->self->priv->account_id, _data_->_tmp7_, dc_storage_details_dialog_scan_all_chats_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp8_ = dc_rpc_client_get_chatlist_items_by_entries_for_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp5_ = _data_->_tmp8_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp9_ = _data_->_tmp5_;
		_data_->_tmp5_ = NULL;
		_json_object_unref0 (_data_->items);
		_data_->items = _data_->_tmp9_;
		_json_object_unref0 (_data_->_tmp5_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_json_object_unref0 (_data_->items);
		_json_array_unref0 (_data_->entries);
		_data_->usages = (_vala_array_free (_data_->usages, _data_->usages_length1, (GDestroyNotify) g_object_unref), NULL);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->i = (guint) 0;
		{
			_data_->_tmp10_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp10_) {
					_data_->_tmp11_ = _data_->i;
					_data_->i = _data_->_tmp11_ + 1;
				}
				_data_->_tmp10_ = FALSE;
				_data_->_tmp12_ = _data_->entries;
				if (!(_data_->i < json_array_get_length (_data_->_tmp12_))) {
					break;
				}
				_data_->_tmp13_ = _data_->entries;
				_data_->chat_id = (gint) json_array_get_int_element (_data_->_tmp13_, _data_->i);
				_data_->_tmp14_ = _data_->items;
				_data_->_tmp15_ = dc_storage_details_dialog_get_chat_name (_data_->self, _data_->_tmp14_, _data_->chat_id);
				_data_->name = _data_->_tmp15_;
				_data_->_tmp16_ = _data_->self->priv->scan_status_label;
				_data_->_tmp17_ = _data_->name;
				_data_->_tmp18_ = g_strdup_printf ("Scanning %s…", _data_->_tmp17_);
				_data_->_tmp19_ = _data_->_tmp18_;
				gtk_label_set_label (_data_->_tmp16_, _data_->_tmp19_);
				_g_free0 (_data_->_tmp19_);
				_data_->_tmp20_ = _data_->name;
				_data_->_state_ = 3;
				dc_storage_details_dialog_scan_chat (_data_->self, _data_->chat_id, _data_->_tmp20_, dc_storage_details_dialog_scan_all_chats_ready, _data_);
				return FALSE;
				_state_3:
				_data_->_tmp21_ = dc_storage_details_dialog_scan_chat_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
				_data_->usage = _data_->_tmp21_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
					_g_free0 (_data_->name);
					_json_object_unref0 (_data_->items);
					_json_array_unref0 (_data_->entries);
					_data_->usages = (_vala_array_free (_data_->usages, _data_->usages_length1, (GDestroyNotify) g_object_unref), NULL);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->_tmp23_ = _data_->usage;
				if (_data_->_tmp23_->remote_bytes > ((gint64) 0)) {
					_data_->_tmp22_ = TRUE;
				} else {
					_data_->_tmp24_ = _data_->usage;
					_data_->_tmp22_ = _data_->_tmp24_->local_bytes > ((gint64) 0);
				}
				if (_data_->_tmp22_) {
					_data_->_tmp25_ = _data_->usage;
					_data_->_tmp26_ = _g_object_ref0 (_data_->_tmp25_);
					_vala_array_add49 (&_data_->usages, &_data_->usages_length1, &_data_->_usages_size_, _data_->_tmp26_);
				}
				_g_object_unref0 (_data_->usage);
				_g_free0 (_data_->name);
			}
		}
	}
	_data_->_tmp27_ = _data_->usages;
	_data_->_tmp27__length1 = _data_->usages_length1;
	_data_->result_length1 = _data_->_tmp27__length1;
	_data_->result = _data_->_tmp27_;
	_json_object_unref0 (_data_->items);
	_json_array_unref0 (_data_->entries);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gchar*
dc_storage_details_dialog_get_chat_name (DcStorageDetailsDialog* self,
                                         JsonObject* items,
                                         gint chat_id)
{
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (items != NULL) {
		gchar* key = NULL;
		gchar* _tmp0_;
		const gchar* _tmp1_;
		_tmp0_ = g_strdup_printf ("%i", chat_id);
		key = _tmp0_;
		_tmp1_ = key;
		if (json_object_has_member (items, _tmp1_)) {
			DcChatEntry* entry = NULL;
			const gchar* _tmp2_;
			JsonObject* _tmp3_;
			DcChatEntry* _tmp4_;
			DcChatEntry* _tmp5_;
			const gchar* _tmp6_;
			const gchar* _tmp7_;
			gint _tmp8_;
			gint _tmp9_;
			_tmp2_ = key;
			_tmp3_ = json_object_get_object_member (items, _tmp2_);
			_tmp4_ = dc_rpc_parsers_parse_chat_item (chat_id, _tmp3_);
			entry = _tmp4_;
			_tmp5_ = entry;
			_tmp6_ = dc_chat_entry_get_name (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = strlen (_tmp7_);
			_tmp9_ = _tmp8_;
			if (_tmp9_ > 0) {
				DcChatEntry* _tmp10_;
				const gchar* _tmp11_;
				const gchar* _tmp12_;
				gchar* _tmp13_;
				_tmp10_ = entry;
				_tmp11_ = dc_chat_entry_get_name (_tmp10_);
				_tmp12_ = _tmp11_;
				_tmp13_ = g_strdup (_tmp12_);
				result = _tmp13_;
				_g_object_unref0 (entry);
				_g_free0 (key);
				return result;
			}
			_g_object_unref0 (entry);
		}
		_g_free0 (key);
	}
	_tmp14_ = g_strdup_printf ("Chat #%d", chat_id);
	result = _tmp14_;
	return result;
}

static void
dc_storage_details_dialog_scan_chat_data_free (gpointer _data)
{
	DcStorageDetailsDialogScanChatData* _data_;
	_data_ = _data;
	_g_free0 (_data_->name);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcStorageDetailsDialogScanChatData, _data_);
}

static void
dc_storage_details_dialog_scan_chat (DcStorageDetailsDialog* self,
                                     gint chat_id,
                                     const gchar* name,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	DcStorageDetailsDialogScanChatData* _data_;
	DcStorageDetailsDialog* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_data_ = g_slice_new0 (DcStorageDetailsDialogScanChatData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_storage_details_dialog_scan_chat_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->chat_id = chat_id;
	_tmp1_ = g_strdup (name);
	_g_free0 (_data_->name);
	_data_->name = _tmp1_;
	dc_storage_details_dialog_scan_chat_co (_data_);
}

static DcChatStorageUsage*
dc_storage_details_dialog_scan_chat_finish (DcStorageDetailsDialog* self,
                                            GAsyncResult* _res_,
                                            GError** error)
{
	DcChatStorageUsage* result;
	DcStorageDetailsDialogScanChatData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dc_storage_details_dialog_scan_chat_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	DcStorageDetailsDialogScanChatData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_storage_details_dialog_scan_chat_co (_data_);
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

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

static gboolean
dc_storage_details_dialog_scan_chat_co (DcStorageDetailsDialogScanChatData* _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_ = dc_chat_storage_usage_new (_data_->chat_id, _data_->name);
	_data_->usage = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->rpc;
	_data_->_state_ = 1;
	dc_rpc_client_get_message_ids_for (_data_->_tmp1_, _data_->self->priv->account_id, _data_->chat_id, FALSE, dc_storage_details_dialog_scan_chat_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = dc_rpc_client_get_message_ids_for_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
	_data_->ids = _data_->_tmp2_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->usage);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->ids;
	if (_data_->_tmp3_ == NULL) {
		_data_->result = _data_->usage;
		_json_array_unref0 (_data_->ids);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->ids;
	_data_->len = (gint) json_array_get_length (_data_->_tmp4_);
	_data_->_tmp5_ = _data_->usage;
	_data_->_tmp5_->message_count = _data_->len;
	{
		_data_->start = 0;
		{
			_data_->_tmp6_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp6_) {
					_data_->start += 200;
				}
				_data_->_tmp6_ = FALSE;
				if (!(_data_->start < _data_->len)) {
					break;
				}
				_data_->end = _data_->start + 200;
				if (_data_->end > _data_->len) {
					_data_->end = _data_->len;
				}
				_data_->count = _data_->end - _data_->start;
				_data_->_tmp7_ = g_new0 (gint, _data_->count);
				_data_->batch = _data_->_tmp7_;
				_data_->batch_length1 = _data_->count;
				_data_->_batch_size_ = _data_->batch_length1;
				{
					_data_->i = 0;
					{
						_data_->_tmp8_ = TRUE;
						while (TRUE) {
							if (!_data_->_tmp8_) {
								_data_->_tmp9_ = _data_->i;
								_data_->i = _data_->_tmp9_ + 1;
							}
							_data_->_tmp8_ = FALSE;
							if (!(_data_->i < _data_->count)) {
								break;
							}
							_data_->_tmp10_ = _data_->batch;
							_data_->_tmp10__length1 = _data_->batch_length1;
							_data_->_tmp11_ = _data_->ids;
							_data_->_tmp10_[_data_->i] = (gint) json_array_get_int_element (_data_->_tmp11_, (guint) (_data_->start + _data_->i));
						}
					}
				}
				_data_->_tmp12_ = _data_->self->priv->rpc;
				_data_->_tmp13_ = _data_->batch;
				_data_->_tmp13__length1 = _data_->batch_length1;
				_data_->_state_ = 2;
				dc_rpc_client_get_messages_for (_data_->_tmp12_, _data_->self->priv->account_id, _data_->_tmp13_, (gint) _data_->_tmp13__length1, dc_storage_details_dialog_scan_chat_ready, _data_);
				return FALSE;
				_state_2:
				_data_->_tmp14_ = dc_rpc_client_get_messages_for_finish (_data_->_tmp12_, _data_->_res_, &_data_->_inner_error0_);
				_data_->messages = _data_->_tmp14_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
					_data_->batch = (g_free (_data_->batch), NULL);
					_json_array_unref0 (_data_->ids);
					_g_object_unref0 (_data_->usage);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->_tmp15_ = _data_->messages;
				if (_data_->_tmp15_ == NULL) {
					_json_object_unref0 (_data_->messages);
					_data_->batch = (g_free (_data_->batch), NULL);
					continue;
				}
				{
					_data_->_vala1_i = 0;
					{
						_data_->_tmp16_ = TRUE;
						while (TRUE) {
							if (!_data_->_tmp16_) {
								_data_->_tmp17_ = _data_->_vala1_i;
								_data_->_vala1_i = _data_->_tmp17_ + 1;
							}
							_data_->_tmp16_ = FALSE;
							if (!(_data_->_vala1_i < _data_->count)) {
								break;
							}
							_data_->_tmp18_ = _data_->batch;
							_data_->_tmp18__length1 = _data_->batch_length1;
							_data_->_tmp19_ = _data_->_tmp18_[_data_->_vala1_i];
							_data_->_tmp20_ = g_strdup_printf ("%i", _data_->_tmp19_);
							_data_->key = _data_->_tmp20_;
							_data_->_tmp21_ = _data_->messages;
							_data_->_tmp22_ = _data_->key;
							if (!json_object_has_member (_data_->_tmp21_, _data_->_tmp22_)) {
								_g_free0 (_data_->key);
								continue;
							}
							_data_->_tmp23_ = _data_->messages;
							_data_->_tmp24_ = _data_->key;
							_data_->_tmp25_ = json_object_get_member (_data_->_tmp23_, _data_->_tmp24_);
							_data_->_tmp26_ = __vala_JsonNode_copy0 (_data_->_tmp25_);
							_data_->node = _data_->_tmp26_;
							_data_->_tmp28_ = _data_->node;
							if (_data_->_tmp28_ == NULL) {
								_data_->_tmp27_ = TRUE;
							} else {
								_data_->_tmp29_ = _data_->node;
								_data_->_tmp27_ = json_node_get_node_type (_data_->_tmp29_) != JSON_NODE_OBJECT;
							}
							if (_data_->_tmp27_) {
								__vala_JsonNode_free0 (_data_->node);
								_g_free0 (_data_->key);
								continue;
							}
							_data_->_tmp30_ = _data_->node;
							_data_->_tmp31_ = json_node_get_object (_data_->_tmp30_);
							_data_->_tmp32_ = dc_rpc_parsers_parse_message (_data_->_tmp31_, NULL);
							_data_->msg = _data_->_tmp32_;
							_data_->_tmp33_ = _data_->usage;
							_data_->_tmp34_ = _data_->msg;
							dc_storage_details_dialog_add_message_usage (_data_->self, _data_->_tmp33_, _data_->_tmp34_);
							_g_object_unref0 (_data_->msg);
							__vala_JsonNode_free0 (_data_->node);
							_g_free0 (_data_->key);
						}
					}
				}
				_json_object_unref0 (_data_->messages);
				_data_->batch = (g_free (_data_->batch), NULL);
			}
		}
	}
	_data_->result = _data_->usage;
	_json_array_unref0 (_data_->ids);
	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_storage_details_dialog_add_message_usage (DcStorageDetailsDialog* self,
                                             DcChatStorageUsage* usage,
                                             DcMessage* msg)
{
	gint _tmp0_;
	gint _tmp1_;
	gchar* local_path = NULL;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gint64 bytes = 0LL;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	GHashTable* _tmp12_;
	const gchar* _tmp13_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (usage != NULL);
	g_return_if_fail (msg != NULL);
	_tmp0_ = dc_message_get_file_bytes (msg);
	_tmp1_ = _tmp0_;
	if (_tmp1_ > 0) {
		gint _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		_tmp2_ = dc_message_get_file_bytes (msg);
		_tmp3_ = _tmp2_;
		usage->remote_bytes = usage->remote_bytes + _tmp3_;
		_tmp4_ = dc_message_get_file_bytes (msg);
		_tmp5_ = _tmp4_;
		self->priv->known_attachment_bytes = self->priv->known_attachment_bytes + _tmp5_;
	}
	_tmp6_ = dc_message_get_file_path (msg);
	_tmp7_ = _tmp6_;
	_tmp8_ = dc_storage_details_dialog_resolve_local_path (self, _tmp7_);
	local_path = _tmp8_;
	_tmp9_ = local_path;
	if (_tmp9_ == NULL) {
		_g_free0 (local_path);
		return;
	}
	_tmp10_ = local_path;
	bytes = dc_storage_details_dialog_file_size (_tmp10_);
	if (bytes <= ((gint64) 0)) {
		_g_free0 (local_path);
		return;
	}
	_tmp11_ = local_path;
	dc_chat_storage_usage_add_local_file (usage, _tmp11_, bytes);
	_tmp12_ = self->priv->global_local_paths;
	_tmp13_ = local_path;
	if (!g_hash_table_contains (_tmp12_, _tmp13_)) {
		GHashTable* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		_tmp14_ = self->priv->global_local_paths;
		_tmp15_ = local_path;
		_tmp16_ = g_strdup (_tmp15_);
		_tmp17_ = g_strdup ("1");
		g_hash_table_insert (_tmp14_, _tmp16_, _tmp17_);
		self->priv->unique_local_file_bytes = self->priv->unique_local_file_bytes + bytes;
	}
	_g_free0 (local_path);
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
dc_storage_details_dialog_resolve_local_path (DcStorageDetailsDialog* self,
                                              const gchar* path)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (path == NULL) {
		_tmp0_ = TRUE;
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (path);
		_tmp2_ = _tmp1_;
		_tmp0_ = _tmp2_ == 0;
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	if (g_str_has_prefix (path, "$BLOBDIR/")) {
		gboolean _tmp3_ = FALSE;
		const gchar* _tmp4_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp4_ = self->priv->blob_dir;
		if (_tmp4_ == NULL) {
			_tmp3_ = TRUE;
		} else {
			const gchar* _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			_tmp5_ = self->priv->blob_dir;
			_tmp6_ = strlen (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp3_ = _tmp7_ == 0;
		}
		if (_tmp3_) {
			result = NULL;
			return result;
		}
		_tmp8_ = self->priv->blob_dir;
		_tmp9_ = string_substring (path, (glong) 9, (glong) -1);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_build_filename (_tmp8_, _tmp10_, NULL);
		_tmp12_ = _tmp11_;
		_g_free0 (_tmp10_);
		result = _tmp12_;
		return result;
	}
	if (g_path_is_absolute (path)) {
		gchar* _tmp13_;
		_tmp13_ = g_strdup (path);
		result = _tmp13_;
		return result;
	}
	result = NULL;
	return result;
}

static gint64
dc_storage_details_dialog_file_size (const gchar* path)
{
	gint64 _tmp5_ = -1LL;
	GError* _inner_error0_ = NULL;
	gint64 result;
	g_return_val_if_fail (path != NULL, -1LL);
	if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
		result = (gint64) 0;
		return result;
	}
	{
		GFileInfo* info = NULL;
		GFile* _tmp0_;
		GFile* _tmp1_;
		GFileInfo* _tmp2_;
		GFileInfo* _tmp3_;
		GFileInfo* _tmp4_;
		_tmp0_ = g_file_new_for_path (path);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_file_query_info (_tmp1_, "standard::size", G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp1_);
		info = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp4_ = info;
		result = g_file_info_get_size (_tmp4_);
		_g_object_unref0 (info);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = (gint64) 0;
		return result;
	}
	__finally0:
	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 _tmp5_;
}

static void
dc_storage_details_dialog_sort_usages (DcStorageDetailsDialog* self,
                                       DcChatStorageUsage** usages,
                                       gint usages_length1)
{
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(i < usages_length1)) {
					break;
				}
				{
					gint j = 0;
					j = i + 1;
					{
						gboolean _tmp2_ = FALSE;
						_tmp2_ = TRUE;
						while (TRUE) {
							DcChatStorageUsage* _tmp4_;
							DcChatStorageUsage* _tmp5_;
							if (!_tmp2_) {
								gint _tmp3_;
								_tmp3_ = j;
								j = _tmp3_ + 1;
							}
							_tmp2_ = FALSE;
							if (!(j < usages_length1)) {
								break;
							}
							_tmp4_ = usages[j];
							_tmp5_ = usages[i];
							if (dc_chat_storage_usage_total_bytes (_tmp4_) > dc_chat_storage_usage_total_bytes (_tmp5_)) {
								DcChatStorageUsage* tmp = NULL;
								DcChatStorageUsage* _tmp6_;
								DcChatStorageUsage* _tmp7_;
								DcChatStorageUsage* _tmp8_;
								DcChatStorageUsage* _tmp9_;
								DcChatStorageUsage* _tmp10_;
								DcChatStorageUsage* _tmp11_;
								_tmp6_ = usages[i];
								_tmp7_ = _g_object_ref0 (_tmp6_);
								tmp = _tmp7_;
								_tmp8_ = usages[j];
								_tmp9_ = _g_object_ref0 (_tmp8_);
								_g_object_unref0 (usages[i]);
								usages[i] = _tmp9_;
								_tmp10_ = tmp;
								_tmp11_ = _g_object_ref0 (_tmp10_);
								_g_object_unref0 (usages[j]);
								usages[j] = _tmp11_;
								_g_object_unref0 (tmp);
							}
						}
					}
				}
			}
		}
	}
}

static void
dc_storage_details_dialog_populate_chat_usage_list (DcStorageDetailsDialog* self,
                                                    DcChatStorageUsage** usages,
                                                    gint usages_length1)
{
	GtkListBox* _tmp0_;
	gint64 max = 0LL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->chat_usage_list;
	dc_clear_listbox (_tmp0_);
	max = (gint64) 1;
	{
		DcChatStorageUsage** usage_collection = NULL;
		gint usage_collection_length1 = 0;
		gint _usage_collection_size_ = 0;
		gint usage_it = 0;
		usage_collection = usages;
		usage_collection_length1 = usages_length1;
		for (usage_it = 0; usage_it < usage_collection_length1; usage_it = usage_it + 1) {
			DcChatStorageUsage* _tmp1_;
			DcChatStorageUsage* usage = NULL;
			_tmp1_ = _g_object_ref0 (usage_collection[usage_it]);
			usage = _tmp1_;
			{
				DcChatStorageUsage* _tmp2_;
				_tmp2_ = usage;
				if (dc_chat_storage_usage_total_bytes (_tmp2_) > max) {
					DcChatStorageUsage* _tmp3_;
					_tmp3_ = usage;
					max = dc_chat_storage_usage_total_bytes (_tmp3_);
				}
				_g_object_unref0 (usage);
			}
		}
	}
	{
		DcChatStorageUsage** usage_collection = NULL;
		gint usage_collection_length1 = 0;
		gint _usage_collection_size_ = 0;
		gint usage_it = 0;
		usage_collection = usages;
		usage_collection_length1 = usages_length1;
		for (usage_it = 0; usage_it < usage_collection_length1; usage_it = usage_it + 1) {
			DcChatStorageUsage* _tmp4_;
			DcChatStorageUsage* usage = NULL;
			_tmp4_ = _g_object_ref0 (usage_collection[usage_it]);
			usage = _tmp4_;
			{
				GtkListBox* _tmp5_;
				DcChatStorageUsage* _tmp6_;
				GtkWidget* _tmp7_;
				GtkWidget* _tmp8_;
				_tmp5_ = self->priv->chat_usage_list;
				_tmp6_ = usage;
				_tmp7_ = dc_storage_details_dialog_build_chat_usage_row (self, _tmp6_, max);
				_tmp8_ = _tmp7_;
				gtk_list_box_append (_tmp5_, _tmp8_);
				_g_object_unref0 (_tmp8_);
				_g_object_unref0 (usage);
			}
		}
	}
}

static GtkWidget*
dc_storage_details_dialog_build_chat_usage_row (DcStorageDetailsDialog* self,
                                                DcChatStorageUsage* usage,
                                                gint64 max_bytes)
{
	GtkListBoxRow* row = NULL;
	GtkListBoxRow* _tmp0_;
	GtkBox* box = NULL;
	GtkBox* _tmp1_;
	GtkBox* top = NULL;
	GtkBox* _tmp2_;
	GtkLabel* title = NULL;
	const gchar* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* amount = NULL;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* subtitle = NULL;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	GtkLabel* _tmp15_;
	GtkLabel* _tmp16_;
	GtkProgressBar* bar = NULL;
	GtkProgressBar* _tmp17_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (usage != NULL, NULL);
	_tmp0_ = (GtkListBoxRow*) gtk_list_box_row_new ();
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	gtk_list_box_row_set_activatable (row, FALSE);
	_tmp1_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	g_object_ref_sink (_tmp1_);
	box = _tmp1_;
	gtk_widget_set_margin_start ((GtkWidget*) box, 12);
	gtk_widget_set_margin_end ((GtkWidget*) box, 12);
	gtk_widget_set_margin_top ((GtkWidget*) box, 8);
	gtk_widget_set_margin_bottom ((GtkWidget*) box, 8);
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp2_);
	top = _tmp2_;
	_tmp3_ = usage->name;
	_tmp4_ = (GtkLabel*) gtk_label_new (_tmp3_);
	g_object_ref_sink (_tmp4_);
	title = _tmp4_;
	gtk_widget_set_halign ((GtkWidget*) title, GTK_ALIGN_START);
	gtk_label_set_xalign (title, (gfloat) 0);
	gtk_label_set_ellipsize (title, PANGO_ELLIPSIZE_END);
	gtk_widget_set_hexpand ((GtkWidget*) title, TRUE);
	gtk_box_append (top, (GtkWidget*) title);
	_tmp5_ = dc_storage_quota_format_mb (dc_chat_storage_usage_total_bytes (usage));
	_tmp6_ = _tmp5_;
	_tmp7_ = (GtkLabel*) gtk_label_new (_tmp6_);
	g_object_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	amount = _tmp8_;
	gtk_widget_add_css_class ((GtkWidget*) amount, "numeric");
	gtk_widget_set_halign ((GtkWidget*) amount, GTK_ALIGN_END);
	gtk_box_append (top, (GtkWidget*) amount);
	gtk_box_append (box, (GtkWidget*) top);
	_tmp9_ = dc_storage_quota_format_mb (usage->local_bytes);
	_tmp10_ = _tmp9_;
	_tmp11_ = dc_storage_quota_format_mb (usage->remote_bytes);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strdup_printf ("%s local · %s attached · %d files · %d messages", _tmp10_, _tmp12_, usage->local_file_count, usage->message_count);
	_tmp14_ = _tmp13_;
	_tmp15_ = dc_dim_label (_tmp14_, FALSE);
	_tmp16_ = _tmp15_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp10_);
	subtitle = _tmp16_;
	gtk_widget_add_css_class ((GtkWidget*) subtitle, "caption");
	gtk_box_append (box, (GtkWidget*) subtitle);
	_tmp17_ = (GtkProgressBar*) gtk_progress_bar_new ();
	g_object_ref_sink (_tmp17_);
	bar = _tmp17_;
	gtk_widget_add_css_class ((GtkWidget*) bar, "storage-chat-bar");
	gtk_progress_bar_set_fraction (bar, ((gdouble) dc_chat_storage_usage_total_bytes (usage)) / ((gdouble) max_bytes));
	gtk_box_append (box, (GtkWidget*) bar);
	gtk_list_box_row_set_child (row, (GtkWidget*) box);
	result = (GtkWidget*) row;
	_g_object_unref0 (bar);
	_g_object_unref0 (subtitle);
	_g_object_unref0 (amount);
	_g_object_unref0 (title);
	_g_object_unref0 (top);
	_g_object_unref0 (box);
	return result;
}

static void
dc_storage_details_dialog_show_clear_cache_info (DcStorageDetailsDialog* self)
{
	AdwAlertDialog* dialog = NULL;
	AdwAlertDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (AdwAlertDialog*) adw_alert_dialog_new ("Clear Local Cache", "Parla can show downloaded local files, but Delta Chat does not expose " \
"a safe cache-only purge for message blobs through this RPC server. Del" \
"eting those files directly can break attachments and forwarded message" \
"s.\n" \
"\n" \
"Use the conversation list above to decide which chats or messages to r" \
"emove. Delta Chat housekeeping then cleans unused local files.");
	g_object_ref_sink (_tmp0_);
	dialog = _tmp0_;
	adw_alert_dialog_add_response (dialog, "ok", "OK");
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

static void
dc_storage_details_dialog_class_init (DcStorageDetailsDialogClass * klass,
                                      gpointer klass_data)
{
	dc_storage_details_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcStorageDetailsDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_storage_details_dialog_finalize;
}

static void
dc_storage_details_dialog_instance_init (DcStorageDetailsDialog * self,
                                         gpointer klass)
{
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	self->priv = dc_storage_details_dialog_get_instance_private (self);
	self->priv->blob_dir = NULL;
	self->priv->known_attachment_bytes = (gint64) 0;
	self->priv->unique_local_file_bytes = (gint64) 0;
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_free0_);
	self->priv->global_local_paths = _tmp2_;
}

static void
dc_storage_details_dialog_finalize (GObject * obj)
{
	DcStorageDetailsDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_STORAGE_DETAILS_DIALOG, DcStorageDetailsDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->quota_progress);
	_g_object_unref0 (self->priv->quota_label);
	_g_object_unref0 (self->priv->local_total_label);
	_g_object_unref0 (self->priv->scan_status_label);
	_g_object_unref0 (self->priv->chat_usage_list);
	_g_object_unref0 (self->priv->refresh_btn);
	_g_object_unref0 (self->priv->clear_cache_btn);
	_g_free0 (self->priv->blob_dir);
	_g_hash_table_unref0 (self->priv->global_local_paths);
	G_OBJECT_CLASS (dc_storage_details_dialog_parent_class)->finalize (obj);
}

static GType
dc_storage_details_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcStorageDetailsDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_storage_details_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcStorageDetailsDialog), 0, (GInstanceInitFunc) dc_storage_details_dialog_instance_init, NULL };
	GType dc_storage_details_dialog_type_id;
	dc_storage_details_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcStorageDetailsDialog", &g_define_type_info, 0);
	DcStorageDetailsDialog_private_offset = g_type_add_instance_private (dc_storage_details_dialog_type_id, sizeof (DcStorageDetailsDialogPrivate));
	return dc_storage_details_dialog_type_id;
}

GType
dc_storage_details_dialog_get_type (void)
{
	static volatile gsize dc_storage_details_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_storage_details_dialog_type_id__once)) {
		GType dc_storage_details_dialog_type_id;
		dc_storage_details_dialog_type_id = dc_storage_details_dialog_get_type_once ();
		g_once_init_leave (&dc_storage_details_dialog_type_id__once, dc_storage_details_dialog_type_id);
	}
	return dc_storage_details_dialog_type_id__once;
}

void
dc_apply_quota_progress (GtkProgressBar* progress,
                         DcStorageQuota* quota)
{
	g_return_if_fail (progress != NULL);
	g_return_if_fail (quota != NULL);
	gtk_widget_remove_css_class ((GtkWidget*) progress, "storage-quota-warning");
	gtk_widget_remove_css_class ((GtkWidget*) progress, "storage-quota-error");
	gtk_progress_bar_set_fraction (progress, dc_storage_quota_used_fraction (quota));
	if (dc_storage_quota_is_error (quota)) {
		gtk_widget_add_css_class ((GtkWidget*) progress, "storage-quota-error");
	} else {
		if (dc_storage_quota_is_warning (quota)) {
			gtk_widget_add_css_class ((GtkWidget*) progress, "storage-quota-warning");
		}
	}
}

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

static void
___lambda135_ (DcInviteCodeDialog* self)
{
	dc_invite_code_dialog_toggle_link (self, NULL, NULL);
}

static void
____lambda135__gtk_button_clicked (GtkButton* _sender,
                                   gpointer self)
{
	___lambda135_ ((DcInviteCodeDialog*) self);
}

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

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

DcInviteCodeDialog*
dc_invite_code_dialog_construct (GType object_type,
                                 DcRpcClient* rpc,
                                 gint acct_id,
                                 gint chat_id)
{
	DcInviteCodeDialog * self = NULL;
	DcRpcClient* _tmp0_;
	const gchar* _tmp1_ = NULL;
	DcQrCodeView* _tmp2_;
	GtkBox* actions = NULL;
	DcQrCodeView* _tmp3_;
	GtkBox* _tmp4_;
	GtkBox* _tmp10_;
	DcQrCodeView* _tmp11_;
	GtkButton* _tmp12_;
	GtkButton* _tmp13_;
	GtkBox* _tmp14_;
	GtkButton* _tmp15_;
	GtkButton* _tmp16_;
	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;
	self->priv->chat_id = chat_id;
	if (chat_id > 0) {
		_tmp1_ = "Invite Link";
	} else {
		_tmp1_ = "Invite Code";
	}
	adw_dialog_set_title ((AdwDialog*) self, _tmp1_);
	adw_dialog_set_content_width ((AdwDialog*) self, 480);
	adw_dialog_set_content_height ((AdwDialog*) self, 560);
	adw_dialog_set_can_close ((AdwDialog*) self, TRUE);
	_tmp2_ = dc_qr_code_view_new ("Preparing invite code…");
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->qr_view);
	self->priv->qr_view = _tmp2_;
	_tmp3_ = self->priv->qr_view;
	_tmp4_ = dc_setup_qr_dialog ((AdwDialog*) self, _tmp3_);
	actions = _tmp4_;
	if (chat_id > 0) {
		GtkButton* _tmp5_;
		GtkButton* _tmp6_;
		GtkButton* _tmp7_;
		GtkBox* _tmp8_;
		GtkButton* _tmp9_;
		_tmp5_ = (GtkButton*) gtk_button_new_with_label ("Deactivate Link");
		g_object_ref_sink (_tmp5_);
		_g_object_unref0 (self->priv->toggle_btn);
		self->priv->toggle_btn = _tmp5_;
		_tmp6_ = self->priv->toggle_btn;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp6_, FALSE);
		_tmp7_ = self->priv->toggle_btn;
		g_signal_connect_object (_tmp7_, "clicked", (GCallback) ____lambda135__gtk_button_clicked, self, 0);
		_tmp8_ = actions;
		_tmp9_ = self->priv->toggle_btn;
		gtk_box_append (_tmp8_, (GtkWidget*) _tmp9_);
	}
	_tmp10_ = actions;
	_tmp11_ = self->priv->qr_view;
	_tmp12_ = dc_qr_code_view_make_copy_button (_tmp11_, "Copy Link");
	_tmp13_ = _tmp12_;
	gtk_box_append (_tmp10_, (GtkWidget*) _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = actions;
	_tmp15_ = dc_close_button ((AdwDialog*) self);
	_tmp16_ = _tmp15_;
	gtk_box_append (_tmp14_, (GtkWidget*) _tmp16_);
	_g_object_unref0 (_tmp16_);
	dc_install_escape_close ((AdwDialog*) self);
	g_signal_connect_object ((AdwDialog*) self, "closed", (GCallback) ___lambda137__adw_dialog_closed, self, 0);
	dc_invite_code_dialog_load_invite_code (self, NULL, NULL);
	_g_object_unref0 (actions);
	return self;
}

DcInviteCodeDialog*
dc_invite_code_dialog_new (DcRpcClient* rpc,
                           gint acct_id,
                           gint chat_id)
{
	return dc_invite_code_dialog_construct (DC_TYPE_INVITE_CODE_DIALOG, rpc, acct_id, chat_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, _data_->self->priv->chat_id, 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 void
dc_invite_code_dialog_show_qr (DcInviteCodeDialog* self,
                               const gchar* text,
                               const gchar* svg)
{
	const gchar* _tmp0_ = NULL;
	gchar* ready_status = NULL;
	gchar* _tmp1_;
	DcQrCodeView* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	g_return_if_fail (svg != NULL);
	if (self->priv->chat_id > 0) {
		_tmp0_ = "Share this QR code or invite link to let others join.";
	} else {
		_tmp0_ = "Share this QR code with another user, or copy the invite link below.";
	}
	_tmp1_ = g_strdup (_tmp0_);
	ready_status = _tmp1_;
	_tmp2_ = self->priv->qr_view;
	_tmp3_ = ready_status;
	dc_qr_code_view_show_code (_tmp2_, text, svg, _tmp3_, "Invite link is ready, but the QR image could not be rendered: ");
	if (self->priv->chat_id > 0) {
		dc_invite_code_dialog_refresh_link_state (self, NULL, NULL);
	}
	_g_free0 (ready_status);
}

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

static void
dc_invite_code_dialog_refresh_link_state (DcInviteCodeDialog* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	DcInviteCodeDialogRefreshLinkStateData* _data_;
	DcInviteCodeDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcInviteCodeDialogRefreshLinkStateData);
	_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_refresh_link_state_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_invite_code_dialog_refresh_link_state_co (_data_);
}

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

static void
dc_invite_code_dialog_refresh_link_state_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	DcInviteCodeDialogRefreshLinkStateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_invite_code_dialog_refresh_link_state_co (_data_);
}

static gboolean
dc_invite_code_dialog_refresh_link_state_co (DcInviteCodeDialogRefreshLinkStateData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->qr_view;
	_data_->_tmp2_ = dc_qr_code_view_get_code_text (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp0_ = _data_->_tmp3_;
	if (_data_->_tmp0_ == NULL) {
		_data_->_tmp0_ = "";
	}
	_data_->_tmp4_ = g_strdup (_data_->_tmp0_);
	_data_->text = _data_->_tmp4_;
	_data_->_tmp6_ = _data_->text;
	_data_->_tmp7_ = strlen (_data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	if (_data_->_tmp8_ == 0) {
		_data_->_tmp5_ = TRUE;
	} else {
		_data_->_tmp9_ = _data_->self->priv->toggle_btn;
		_data_->_tmp5_ = _data_->_tmp9_ == NULL;
	}
	if (_data_->_tmp5_) {
		_g_free0 (_data_->text);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp10_ = _data_->self->priv->rpc;
		_data_->_tmp11_ = _data_->text;
		_data_->_state_ = 1;
		dc_rpc_client_check_qr (_data_->_tmp10_, _data_->self->priv->account_id, _data_->_tmp11_, dc_invite_code_dialog_refresh_link_state_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp12_ = dc_rpc_client_check_qr_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
		_data_->qr = _data_->_tmp12_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (_data_->self->priv->closing) {
			_data_->_tmp14_ = TRUE;
		} else {
			_data_->_tmp15_ = _data_->qr;
			_data_->_tmp14_ = _data_->_tmp15_ == NULL;
		}
		if (_data_->_tmp14_) {
			_data_->_tmp13_ = TRUE;
		} else {
			_data_->_tmp16_ = _data_->qr;
			_data_->_tmp13_ = !json_object_has_member (_data_->_tmp16_, "kind");
		}
		if (_data_->_tmp13_) {
			_json_object_unref0 (_data_->qr);
			_g_free0 (_data_->text);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp17_ = _data_->qr;
		_data_->_tmp18_ = json_object_get_string_member (_data_->_tmp17_, "kind");
		_data_->_tmp19_ = g_strdup (_data_->_tmp18_);
		_data_->kind = _data_->_tmp19_;
		_data_->_tmp21_ = _data_->kind;
		if (g_str_has_prefix (_data_->_tmp21_, "withdraw")) {
			_data_->_tmp20_ = TRUE;
		} else {
			_data_->_tmp22_ = _data_->kind;
			_data_->_tmp20_ = g_str_has_prefix (_data_->_tmp22_, "revive");
		}
		if (_data_->_tmp20_) {
			_data_->_tmp23_ = _data_->kind;
			_data_->self->priv->link_active = g_str_has_prefix (_data_->_tmp23_, "withdraw");
			dc_invite_code_dialog_apply_link_state (_data_->self);
		} else {
			_data_->_tmp24_ = _data_->self->priv->toggle_btn;
			gtk_widget_set_visible ((GtkWidget*) _data_->_tmp24_, FALSE);
		}
		_g_free0 (_data_->kind);
		_json_object_unref0 (_data_->qr);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->text);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_free0 (_data_->text);
	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_invite_code_dialog_apply_link_state (DcInviteCodeDialog* self)
{
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->toggle_btn;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->toggle_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
	if (self->priv->link_active) {
		GtkButton* _tmp2_;
		GtkButton* _tmp3_;
		DcQrCodeView* _tmp4_;
		DcQrCodeView* _tmp5_;
		_tmp2_ = self->priv->toggle_btn;
		gtk_button_set_label (_tmp2_, "Deactivate Link");
		_tmp3_ = self->priv->toggle_btn;
		gtk_widget_remove_css_class ((GtkWidget*) _tmp3_, "suggested-action");
		_tmp4_ = self->priv->qr_view;
		dc_qr_code_view_set_qr_opacity (_tmp4_, 1.0);
		_tmp5_ = self->priv->qr_view;
		dc_qr_code_view_set_status (_tmp5_, "Share this QR code or invite link to let others join.");
	} else {
		GtkButton* _tmp6_;
		GtkButton* _tmp7_;
		DcQrCodeView* _tmp8_;
		DcQrCodeView* _tmp9_;
		_tmp6_ = self->priv->toggle_btn;
		gtk_button_set_label (_tmp6_, "Activate Link");
		_tmp7_ = self->priv->toggle_btn;
		gtk_widget_add_css_class ((GtkWidget*) _tmp7_, "suggested-action");
		_tmp8_ = self->priv->qr_view;
		dc_qr_code_view_set_qr_opacity (_tmp8_, 0.35);
		_tmp9_ = self->priv->qr_view;
		dc_qr_code_view_set_status (_tmp9_, "This invite link is deactivated — activate it to let others join.");
	}
}

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

static void
dc_invite_code_dialog_toggle_link (DcInviteCodeDialog* self,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_)
{
	DcInviteCodeDialogToggleLinkData* _data_;
	DcInviteCodeDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcInviteCodeDialogToggleLinkData);
	_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_toggle_link_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_invite_code_dialog_toggle_link_co (_data_);
}

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

static void
dc_invite_code_dialog_toggle_link_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_)
{
	DcInviteCodeDialogToggleLinkData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_invite_code_dialog_toggle_link_co (_data_);
}

static gboolean
dc_invite_code_dialog_toggle_link_co (DcInviteCodeDialogToggleLinkData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->qr_view;
	_data_->_tmp2_ = dc_qr_code_view_get_code_text (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp0_ = _data_->_tmp3_;
	if (_data_->_tmp0_ == NULL) {
		_data_->_tmp0_ = "";
	}
	_data_->_tmp4_ = g_strdup (_data_->_tmp0_);
	_data_->text = _data_->_tmp4_;
	_data_->_tmp7_ = _data_->text;
	_data_->_tmp8_ = strlen (_data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	if (_data_->_tmp9_ == 0) {
		_data_->_tmp6_ = TRUE;
	} else {
		_data_->_tmp10_ = _data_->self->priv->toggle_btn;
		_data_->_tmp6_ = _data_->_tmp10_ == NULL;
	}
	if (_data_->_tmp6_) {
		_data_->_tmp5_ = TRUE;
	} else {
		_data_->_tmp5_ = _data_->self->priv->toggle_busy;
	}
	if (_data_->_tmp5_) {
		_g_free0 (_data_->text);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->toggle_busy = TRUE;
	_data_->_tmp11_ = _data_->self->priv->toggle_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp11_, FALSE);
	if (_data_->self->priv->link_active) {
		_data_->_tmp12_ = "Deactivating…";
	} else {
		_data_->_tmp12_ = "Activating…";
	}
	_data_->_tmp13_ = _data_->self->priv->toggle_btn;
	gtk_button_set_label (_data_->_tmp13_, _data_->_tmp12_);
	{
		_data_->_tmp14_ = _data_->self->priv->rpc;
		_data_->_tmp15_ = _data_->text;
		_data_->_state_ = 1;
		dc_rpc_client_set_config_from_qr (_data_->_tmp14_, _data_->self->priv->account_id, _data_->_tmp15_, dc_invite_code_dialog_toggle_link_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_set_config_from_qr_finish (_data_->_tmp14_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_state_ = 2;
		dc_invite_code_dialog_refresh_link_state (_data_->self, dc_invite_code_dialog_toggle_link_ready, _data_);
		return FALSE;
		_state_2:
		dc_invite_code_dialog_refresh_link_state_finish (_data_->self, _data_->_res_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		if (!_data_->self->priv->closing) {
			_data_->_tmp16_ = _data_->self->priv->qr_view;
			_data_->_tmp17_ = _data_->e;
			_data_->_tmp18_ = _data_->_tmp17_->message;
			_data_->_tmp19_ = g_strconcat ("Could not update the invite link: ", _data_->_tmp18_, NULL);
			_data_->_tmp20_ = _data_->_tmp19_;
			dc_qr_code_view_set_status (_data_->_tmp16_, _data_->_tmp20_);
			_g_free0 (_data_->_tmp20_);
			dc_invite_code_dialog_apply_link_state (_data_->self);
		}
		_g_error_free0 (_data_->e);
	}
	__finally0:
	{
		_data_->self->priv->toggle_busy = FALSE;
	}
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->text);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_free0 (_data_->text);
	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_invite_code_dialog_show_invite_error (DcInviteCodeDialog* self,
                                         const gchar* message)
{
	DcQrCodeView* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	DcQrCodeView* _tmp3_;
	GtkButton* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->qr_view;
	_tmp1_ = g_strconcat ("Invite code creation failed: ", message, NULL);
	_tmp2_ = _tmp1_;
	dc_qr_code_view_set_status (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->qr_view;
	dc_qr_code_view_set_copy_sensitive (_tmp3_, FALSE);
	_tmp4_ = self->priv->toggle_btn;
	if (_tmp4_ != NULL) {
		GtkButton* _tmp5_;
		_tmp5_ = self->priv->toggle_btn;
		gtk_widget_set_visible ((GtkWidget*) _tmp5_, FALSE);
	}
}

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->toggle_btn = NULL;
	self->priv->closing = FALSE;
	self->priv->link_active = TRUE;
	self->priv->toggle_busy = 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->qr_view);
	_g_object_unref0 (self->priv->toggle_btn);
	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_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_;
	DcQrCodeView* _tmp1_;
	GtkBox* actions = NULL;
	DcQrCodeView* _tmp2_;
	GtkBox* _tmp3_;
	DcQrCodeView* _tmp4_;
	GtkButton* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
	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_ = dc_qr_code_view_new ("Preparing account…");
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->qr_view);
	self->priv->qr_view = _tmp1_;
	_tmp2_ = self->priv->qr_view;
	_tmp3_ = dc_setup_qr_dialog ((AdwDialog*) self, _tmp2_);
	actions = _tmp3_;
	_tmp4_ = self->priv->qr_view;
	_tmp5_ = dc_qr_code_view_make_copy_button (_tmp4_, "Copy Text");
	_tmp6_ = _tmp5_;
	gtk_box_append (actions, (GtkWidget*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = dc_close_button ((AdwDialog*) self);
	_tmp8_ = _tmp7_;
	gtk_box_append (actions, (GtkWidget*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	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 (actions);
	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
__lambda154_ (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
___lambda154__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda154_ ((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, ___lambda154__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)
{
	DcQrCodeView* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	g_return_if_fail (svg != NULL);
	_tmp0_ = self->priv->qr_view;
	dc_qr_code_view_show_code (_tmp0_, text, svg, "Scan this QR code with the second device, or copy the text below.", "QR text is ready, but the image could not be rendered: ");
}

static void
dc_second_device_dialog_show_transfer_error (DcSecondDeviceDialog* self,
                                             const gchar* message)
{
	DcQrCodeView* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	DcQrCodeView* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->qr_view;
	_tmp1_ = g_strconcat ("Second-device setup failed: ", message, NULL);
	_tmp2_ = _tmp1_;
	dc_qr_code_view_set_status (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->qr_view;
	dc_qr_code_view_set_copy_sensitive (_tmp3_, FALSE);
}

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
___lambda153_ (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
____lambda153__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	___lambda153_ ((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, ____lambda153__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->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->qr_view);
	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;
}

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

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

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

