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

#include <adwaita.h>
#include <glib-object.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <glib/gstdio.h>
#include <gdk/gdk.h>
#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_PROFILE_DIALOG (dc_profile_dialog_get_type ())
#define DC_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_PROFILE_DIALOG, DcProfileDialog))
#define DC_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_PROFILE_DIALOG, DcProfileDialogClass))
#define DC_IS_PROFILE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_PROFILE_DIALOG))
#define DC_IS_PROFILE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_PROFILE_DIALOG))
#define DC_PROFILE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_PROFILE_DIALOG, DcProfileDialogClass))

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

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

typedef struct _DcRpcClient DcRpcClient;
typedef struct _DcRpcClientClass DcRpcClientClass;
enum  {
	DC_PROFILE_DIALOG_0_PROPERTY,
	DC_PROFILE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_profile_dialog_properties[DC_PROFILE_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#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;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
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 void (*DcVoidFunc) (gpointer user_data);
typedef struct _DcProfileDialogDoDeleteAccountData DcProfileDialogDoDeleteAccountData;
typedef struct _DcProfileDialogPickAvatarData DcProfileDialogPickAvatarData;
enum  {
	DC_PROFILE_DIALOG_PROFILE_UPDATED_SIGNAL,
	DC_PROFILE_DIALOG_ACCOUNT_DELETED_SIGNAL,
	DC_PROFILE_DIALOG_NUM_SIGNALS
};
static guint dc_profile_dialog_signals[DC_PROFILE_DIALOG_NUM_SIGNALS] = {0};
typedef struct _DcStorageQuotaPrivate DcStorageQuotaPrivate;
enum  {
	DC_STORAGE_QUOTA_0_PROPERTY,
	DC_STORAGE_QUOTA_AVAILABLE_PROPERTY,
	DC_STORAGE_QUOTA_USED_BYTES_PROPERTY,
	DC_STORAGE_QUOTA_LIMIT_BYTES_PROPERTY,
	DC_STORAGE_QUOTA_NUM_PROPERTIES
};
static GParamSpec* dc_storage_quota_properties[DC_STORAGE_QUOTA_NUM_PROPERTIES];
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

#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;
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
typedef struct _DcSecondDeviceDialogPrivate DcSecondDeviceDialogPrivate;
enum  {
	DC_SECOND_DEVICE_DIALOG_0_PROPERTY,
	DC_SECOND_DEVICE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_second_device_dialog_properties[DC_SECOND_DEVICE_DIALOG_NUM_PROPERTIES];
typedef struct _DcSecondDeviceDialogStartTransferData DcSecondDeviceDialogStartTransferData;

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

struct _DcProfileDialogClass {
	AdwDialogClass parent_class;
};

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

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

struct _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_;
	DcStorageQuota* _tmp8_;
	GError* e;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GError* _tmp11_;
	const gchar* _tmp12_;
	GtkProgressBar* _tmp13_;
	GError* _inner_error0_;
};

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

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

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

struct _DcStorageQuota {
	GObject parent_instance;
	DcStorageQuotaPrivate * priv;
};

struct _DcStorageQuotaClass {
	GObjectClass parent_class;
};

struct _DcStorageQuotaPrivate {
	gboolean _available;
	gint64 _used_bytes;
	gint64 _limit_bytes;
};

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* _tmp13_;
	DcStorageQuota* _tmp14_;
	GError* e;
	GtkProgressBar* _tmp15_;
	GtkLabel* _tmp16_;
	GError* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	DcChatStorageUsage** usages;
	gint _tmp21_;
	DcChatStorageUsage** _tmp22_;
	gint usages_length1;
	gint _usages_size_;
	GtkLabel* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	GtkLabel* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	GtkLabel* _tmp42_;
	GError* _vala1_e;
	GtkLabel* _tmp43_;
	GError* _tmp44_;
	const gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	GtkButton* _tmp48_;
	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_;
	DcChatStorageUsage* _tmp4_;
	JsonArray* _tmp5_;
	gint len;
	JsonArray* _tmp6_;
	gint start;
	gboolean _tmp7_;
	gint end;
	gint count;
	gint* batch;
	gint* _tmp8_;
	gint batch_length1;
	gint _batch_size_;
	gint i;
	gboolean _tmp9_;
	gint _tmp10_;
	gint* _tmp11_;
	gint _tmp11__length1;
	JsonArray* _tmp12_;
	JsonObject* messages;
	DcRpcClient* _tmp13_;
	gint* _tmp14_;
	gint _tmp14__length1;
	JsonObject* _tmp15_;
	JsonObject* _tmp16_;
	gint _vala1_i;
	gboolean _tmp17_;
	gint _tmp18_;
	gchar* key;
	gint* _tmp19_;
	gint _tmp19__length1;
	gint _tmp20_;
	gchar* _tmp21_;
	JsonObject* _tmp22_;
	const gchar* _tmp23_;
	JsonNode* node;
	JsonObject* _tmp24_;
	const gchar* _tmp25_;
	JsonNode* _tmp26_;
	JsonNode* _tmp27_;
	gboolean _tmp28_;
	JsonNode* _tmp29_;
	JsonNode* _tmp30_;
	DcMessage* msg;
	JsonNode* _tmp31_;
	JsonObject* _tmp32_;
	DcMessage* _tmp33_;
	DcChatStorageUsage* _tmp34_;
	DcMessage* _tmp35_;
	GError* _inner_error0_;
};

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

struct _DcInviteCodeDialogClass {
	AdwDialogClass parent_class;
};

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

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

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

struct _DcSecondDeviceDialogClass {
	AdwDialogClass parent_class;
};

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

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

static gint DcProfileDialog_private_offset;
static gpointer dc_profile_dialog_parent_class = NULL;
static gint DcStorageQuota_private_offset;
static gpointer dc_storage_quota_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 GType dc_profile_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcProfileDialog, g_object_unref)
VALA_EXTERN GType dc_rpc_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcClient, g_object_unref)
VALA_EXTERN DcProfileDialog* dc_profile_dialog_new (DcRpcClient* rpc,
                                        gint acct_id);
VALA_EXTERN DcProfileDialog* dc_profile_dialog_construct (GType object_type,
                                              DcRpcClient* rpc,
                                              gint acct_id);
VALA_EXTERN gint dc_rpc_client_get_account_id (DcRpcClient* self);
static void __lambda88_ (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 ___lambda88__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda89_ (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 ___lambda89__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda90_ (DcProfileDialog* self);
static void ___lambda90__gtk_editable_changed (GtkEditable* _sender,
                                        gpointer self);
static GtkWidget* dc_profile_dialog_build_connectivity_storage_section (DcProfileDialog* self);
static void dc_profile_dialog_show_invite_code_dialog (DcProfileDialog* self);
static void _dc_profile_dialog_show_invite_code_dialog_gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self);
static void dc_profile_dialog_show_relays_dialog (DcProfileDialog* self);
static void _dc_profile_dialog_show_relays_dialog_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
static void dc_profile_dialog_show_second_device_dialog (DcProfileDialog* self);
static void _dc_profile_dialog_show_second_device_dialog_gtk_button_clicked (GtkButton* _sender,
                                                                      gpointer self);
static void dc_profile_dialog_confirm_delete_account (DcProfileDialog* self);
static void _dc_profile_dialog_confirm_delete_account_gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self);
static void dc_profile_dialog_load_profile (DcProfileDialog* self,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void dc_profile_dialog_load_profile_finish (DcProfileDialog* self,
                                            GAsyncResult* _res_);
static void dc_profile_dialog_load_connectivity_summary (DcProfileDialog* self,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static void dc_profile_dialog_load_connectivity_summary_finish (DcProfileDialog* self,
                                                         GAsyncResult* _res_);
static void __lambda91_ (DcProfileDialog* self);
static void ___lambda91__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda92_ (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 ___lambda92__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_);
VALA_EXTERN void dc_rpc_client_get_config (DcRpcClient* self,
                               const gchar* key,
                               gint acct_id,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_config_finish (DcRpcClient* self,
                                        GAsyncResult* _res_,
                                        GError** error);
static void dc_profile_dialog_load_profile_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
VALA_EXTERN GdkTexture* dc_load_avatar (const gchar* path);
static void dc_profile_dialog_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_from_connectivity_html (const gchar* html);
static void dc_profile_dialog_set_storage_quota_summary (DcProfileDialog* self,
                                                  DcStorageQuota* quota);
VALA_EXTERN gboolean dc_storage_quota_get_available (DcStorageQuota* self);
VALA_EXTERN gint64 dc_storage_quota_get_limit_bytes (DcStorageQuota* self);
VALA_EXTERN gint64 dc_storage_quota_get_used_bytes (DcStorageQuota* self);
VALA_EXTERN gchar* dc_format_mb (gint64 bytes);
static void dc_profile_dialog_do_save_data_free (gpointer _data);
static gboolean dc_profile_dialog_do_save_co (DcProfileDialogDoSaveData* _data_);
VALA_EXTERN void dc_rpc_client_batch_set_config (DcRpcClient* self,
                                     const gchar* key,
                                     const gchar* val,
                                     gint acct_id,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_batch_set_config_finish (DcRpcClient* self,
                                            GAsyncResult* _res_,
                                            GError** error);
static void dc_profile_dialog_do_save_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
VALA_EXTERN GType dc_invite_code_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcInviteCodeDialog, g_object_unref)
VALA_EXTERN DcInviteCodeDialog* dc_invite_code_dialog_new (DcRpcClient* rpc,
                                               gint acct_id);
VALA_EXTERN DcInviteCodeDialog* dc_invite_code_dialog_construct (GType object_type,
                                                     DcRpcClient* rpc,
                                                     gint acct_id);
VALA_EXTERN GType dc_second_device_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcSecondDeviceDialog, g_object_unref)
VALA_EXTERN DcSecondDeviceDialog* dc_second_device_dialog_new (DcRpcClient* rpc,
                                                   gint acct_id);
VALA_EXTERN DcSecondDeviceDialog* dc_second_device_dialog_construct (GType object_type,
                                                         DcRpcClient* rpc,
                                                         gint acct_id);
VALA_EXTERN GType dc_relays_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRelaysDialog, g_object_unref)
VALA_EXTERN DcRelaysDialog* dc_relays_dialog_new (DcRpcClient* rpc,
                                      gint acct_id);
VALA_EXTERN DcRelaysDialog* dc_relays_dialog_construct (GType object_type,
                                            DcRpcClient* rpc,
                                            gint acct_id);
VALA_EXTERN void dc_confirm_action (GtkWidget* parent,
                        const gchar* title,
                        const gchar* body,
                        const gchar* action_id,
                        const gchar* action_label,
                        DcVoidFunc on_confirm,
                        gpointer on_confirm_target,
                        GDestroyNotify on_confirm_target_destroy_notify);
static void __lambda105_ (DcProfileDialog* self);
static void dc_profile_dialog_do_delete_account (DcProfileDialog* self,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void dc_profile_dialog_do_delete_account_finish (DcProfileDialog* self,
                                                 GAsyncResult* _res_);
static void ___lambda105__dc_void_func (gpointer self);
static void dc_profile_dialog_do_delete_account_data_free (gpointer _data);
static gboolean dc_profile_dialog_do_delete_account_co (DcProfileDialogDoDeleteAccountData* _data_);
VALA_EXTERN void dc_rpc_client_remove_account (DcRpcClient* self,
                                   gint acct_id,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_remove_account_finish (DcRpcClient* self,
                                          GAsyncResult* _res_,
                                          GError** error);
static void dc_profile_dialog_do_delete_account_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_set_account_id (DcRpcClient* self,
                                   gint value);
static void dc_profile_dialog_pick_avatar_data_free (gpointer _data);
static gboolean dc_profile_dialog_pick_avatar_co (DcProfileDialogPickAvatarData* _data_);
VALA_EXTERN void dc_pick_image_file (GtkWindow* parent,
                         const gchar* title,
                         GAsyncReadyCallback _callback_,
                         gpointer _user_data_);
VALA_EXTERN gchar* dc_pick_image_file_finish (GAsyncResult* _res_);
static void dc_profile_dialog_pick_avatar_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void dc_profile_dialog_finalize (GObject * obj);
static GType dc_profile_dialog_get_type_once (void);
VALA_EXTERN DcStorageQuota* dc_storage_quota_new (void);
VALA_EXTERN DcStorageQuota* dc_storage_quota_construct (GType object_type);
static gchar* dc_storage_quota_strip_html (const gchar* html);
static gdouble dc_storage_quota_parse_number (const gchar* s);
static gint64 dc_storage_quota_unit_to_bytes (gdouble value,
                                       const gchar* unit);
VALA_EXTERN void dc_storage_quota_set_used_bytes (DcStorageQuota* self,
                                      gint64 value);
VALA_EXTERN void dc_storage_quota_set_limit_bytes (DcStorageQuota* self,
                                       gint64 value);
VALA_EXTERN void dc_storage_quota_set_available (DcStorageQuota* self,
                                     gboolean value);
static void dc_storage_quota_finalize (GObject * obj);
static GType dc_storage_quota_get_type_once (void);
static void _vala_dc_storage_quota_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_dc_storage_quota_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
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 __lambda93_ (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 ___lambda93__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_set_quota (DcStorageDetailsDialog* self,
                                          DcStorageQuota* quota);
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);
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,
                                             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_add4 (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_client_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_client_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);
static void dc_invite_code_dialog_copy_invite_text (DcInviteCodeDialog* self);
static void _dc_invite_code_dialog_copy_invite_text_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
static void __lambda94_ (DcInviteCodeDialog* self);
static void ___lambda94__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda95_ (DcInviteCodeDialog* self);
static void ___lambda95__adw_dialog_closed (AdwDialog* _sender,
                                     gpointer self);
static void dc_invite_code_dialog_load_invite_code (DcInviteCodeDialog* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void dc_invite_code_dialog_load_invite_code_finish (DcInviteCodeDialog* self,
                                                    GAsyncResult* _res_);
static void dc_invite_code_dialog_load_invite_code_data_free (gpointer _data);
static gboolean dc_invite_code_dialog_load_invite_code_co (DcInviteCodeDialogLoadInviteCodeData* _data_);
VALA_EXTERN void dc_rpc_client_get_chat_securejoin_qr_code (DcRpcClient* self,
                                                gint acct_id,
                                                gint chat_id,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_get_chat_securejoin_qr_code_finish (DcRpcClient* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
static void dc_invite_code_dialog_load_invite_code_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_create_qr_svg (DcRpcClient* self,
                                  const gchar* text,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
VALA_EXTERN gchar* dc_rpc_client_create_qr_svg_finish (DcRpcClient* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static void dc_invite_code_dialog_show_qr (DcInviteCodeDialog* self,
                                    const gchar* text,
                                    const gchar* svg);
static void dc_invite_code_dialog_show_invite_error (DcInviteCodeDialog* self,
                                              const gchar* message);
static void dc_invite_code_dialog_finalize (GObject * obj);
static GType dc_invite_code_dialog_get_type_once (void);
static void dc_second_device_dialog_copy_qr_text (DcSecondDeviceDialog* self);
static void _dc_second_device_dialog_copy_qr_text_gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self);
static void __lambda102_ (DcSecondDeviceDialog* self);
static void ___lambda102__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void dc_second_device_dialog_on_closed (DcSecondDeviceDialog* self);
static void _dc_second_device_dialog_on_closed_adw_dialog_closed (AdwDialog* _sender,
                                                           gpointer self);
static void dc_second_device_dialog_start_transfer (DcSecondDeviceDialog* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void dc_second_device_dialog_start_transfer_finish (DcSecondDeviceDialog* self,
                                                    GAsyncResult* _res_);
static void dc_second_device_dialog_start_transfer_data_free (gpointer _data);
static gboolean dc_second_device_dialog_start_transfer_co (DcSecondDeviceDialogStartTransferData* _data_);
VALA_EXTERN void dc_rpc_client_provide_backup (DcRpcClient* self,
                                   gint acct_id,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_provide_backup_finish (DcRpcClient* self,
                                          GAsyncResult* _res_,
                                          GError** error);
static void __lambda104_ (DcSecondDeviceDialog* self,
                   GObject* obj,
                   GAsyncResult* res);
static void dc_second_device_dialog_show_transfer_error (DcSecondDeviceDialog* self,
                                                  const gchar* message);
static void ___lambda104__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 ___lambda103_ (DcSecondDeviceDialog* self,
                    GObject* obj,
                    GAsyncResult* res);
static void ____lambda103__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
dc_profile_dialog_get_instance_private (DcProfileDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcProfileDialog_private_offset);
}

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

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

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

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

static void
___lambda89__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda89_ ((DcProfileDialog*) self);
}

static void
__lambda90_ (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
___lambda90__gtk_editable_changed (GtkEditable* _sender,
                                   gpointer self)
{
	__lambda90_ ((DcProfileDialog*) self);
}

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

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

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

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

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

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

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

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

static void
__lambda92_ (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
___lambda92__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda92_ ((DcProfileDialog*) self);
}

static GtkWidget*
dc_profile_dialog_build_connectivity_storage_section (DcProfileDialog* self)
{
	GtkBox* section = NULL;
	GtkBox* _tmp0_;
	GtkLabel* title = NULL;
	GtkLabel* _tmp1_;
	GtkBox* conn_row = NULL;
	GtkBox* _tmp2_;
	GtkImage* conn_icon = NULL;
	GtkImage* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkProgressBar* _tmp11_;
	GtkProgressBar* _tmp12_;
	GtkProgressBar* _tmp13_;
	GtkProgressBar* _tmp14_;
	GtkLabel* _tmp15_;
	GtkLabel* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkBox* actions = NULL;
	GtkBox* _tmp21_;
	GtkButton* refresh_btn = NULL;
	GtkButton* _tmp22_;
	GtkButton* details_btn = NULL;
	GtkButton* _tmp23_;
	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_ = (GtkLabel*) gtk_label_new ("Storage & Connectivity");
	g_object_ref_sink (_tmp1_);
	title = _tmp1_;
	gtk_widget_add_css_class ((GtkWidget*) title, "heading");
	gtk_widget_set_halign ((GtkWidget*) title, GTK_ALIGN_START);
	gtk_box_append (section, (GtkWidget*) title);
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp2_);
	conn_row = _tmp2_;
	_tmp3_ = (GtkImage*) gtk_image_new_from_icon_name ("network-transmit-receive-symbolic");
	g_object_ref_sink (_tmp3_);
	conn_icon = _tmp3_;
	gtk_widget_set_valign ((GtkWidget*) conn_icon, GTK_ALIGN_CENTER);
	gtk_box_append (conn_row, (GtkWidget*) conn_icon);
	_tmp4_ = (GtkLabel*) gtk_label_new ("Checking connection…");
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->connectivity_status_label);
	self->priv->connectivity_status_label = _tmp4_;
	_tmp5_ = self->priv->connectivity_status_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
	_tmp6_ = self->priv->connectivity_status_label;
	gtk_label_set_xalign (_tmp6_, (gfloat) 0);
	_tmp7_ = self->priv->connectivity_status_label;
	gtk_label_set_wrap (_tmp7_, TRUE);
	_tmp8_ = self->priv->connectivity_status_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp8_, TRUE);
	_tmp9_ = self->priv->connectivity_status_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp9_, "dim-label");
	_tmp10_ = self->priv->connectivity_status_label;
	gtk_box_append (conn_row, (GtkWidget*) _tmp10_);
	gtk_box_append (section, (GtkWidget*) conn_row);
	_tmp11_ = (GtkProgressBar*) gtk_progress_bar_new ();
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->storage_progress);
	self->priv->storage_progress = _tmp11_;
	_tmp12_ = self->priv->storage_progress;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "storage-quota-bar");
	_tmp13_ = self->priv->storage_progress;
	gtk_progress_bar_set_fraction (_tmp13_, 0.0);
	_tmp14_ = self->priv->storage_progress;
	gtk_box_append (section, (GtkWidget*) _tmp14_);
	_tmp15_ = (GtkLabel*) gtk_label_new ("Loading server quota…");
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->storage_summary_label);
	self->priv->storage_summary_label = _tmp15_;
	_tmp16_ = self->priv->storage_summary_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp16_, GTK_ALIGN_START);
	_tmp17_ = self->priv->storage_summary_label;
	gtk_label_set_xalign (_tmp17_, (gfloat) 0);
	_tmp18_ = self->priv->storage_summary_label;
	gtk_label_set_wrap (_tmp18_, TRUE);
	_tmp19_ = self->priv->storage_summary_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp19_, "dim-label");
	_tmp20_ = self->priv->storage_summary_label;
	gtk_box_append (section, (GtkWidget*) _tmp20_);
	_tmp21_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp21_);
	actions = _tmp21_;
	gtk_widget_set_halign ((GtkWidget*) actions, GTK_ALIGN_END);
	_tmp22_ = (GtkButton*) gtk_button_new_from_icon_name ("view-refresh-symbolic");
	g_object_ref_sink (_tmp22_);
	refresh_btn = _tmp22_;
	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) ___lambda91__gtk_button_clicked, self, 0);
	gtk_box_append (actions, (GtkWidget*) refresh_btn);
	_tmp23_ = (GtkButton*) gtk_button_new_with_label ("Details…");
	g_object_ref_sink (_tmp23_);
	details_btn = _tmp23_;
	gtk_widget_set_tooltip_text ((GtkWidget*) details_btn, "Show storage by conversation");
	g_signal_connect_object (details_btn, "clicked", (GCallback) ___lambda92__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);
	_g_object_unref0 (title);
	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_->_tmp21_ = _data_->avatar;
		if (_data_->_tmp21_ != NULL) {
			_data_->_tmp22_ = _data_->avatar;
			_data_->_tmp23_ = strlen (_data_->_tmp22_);
			_data_->_tmp24_ = _data_->_tmp23_;
			_data_->_tmp20_ = _data_->_tmp24_ > 0;
		} else {
			_data_->_tmp20_ = FALSE;
		}
		if (_data_->_tmp20_) {
			_data_->_tmp25_ = _data_->avatar;
			_data_->_tmp19_ = g_file_test (_data_->_tmp25_, G_FILE_TEST_EXISTS);
		} else {
			_data_->_tmp19_ = FALSE;
		}
		if (_data_->_tmp19_) {
			_data_->_tmp26_ = _data_->avatar;
			_data_->_tmp27_ = g_strdup (_data_->_tmp26_);
			_g_free0 (_data_->self->priv->avatar_path);
			_data_->self->priv->avatar_path = _data_->_tmp27_;
		}
		_data_->_tmp28_ = _data_->self->priv->avatar_widget;
		_data_->_tmp29_ = _data_->avatar;
		_data_->_tmp30_ = dc_load_avatar (_data_->_tmp29_);
		_data_->_tmp31_ = _data_->_tmp30_;
		adw_avatar_set_custom_image (_data_->_tmp28_, (GdkPaintable*) _data_->_tmp31_);
		_g_object_unref0 (_data_->_tmp31_);
		_g_free0 (_data_->avatar);
		_g_free0 (_data_->email);
		_g_free0 (_data_->status);
		_g_free0 (_data_->name);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_profile_dialog_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_from_connectivity_html (_data_->_tmp6_);
		_data_->quota = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->quota;
		dc_profile_dialog_set_storage_quota_summary (_data_->self, _data_->_tmp8_);
		_g_object_unref0 (_data_->quota);
		_g_free0 (_data_->html);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp9_ = _data_->self->priv->connectivity_status_label;
		gtk_label_set_label (_data_->_tmp9_, "Connection details unavailable");
		_data_->_tmp10_ = _data_->self->priv->storage_summary_label;
		_data_->_tmp11_ = _data_->e;
		_data_->_tmp12_ = _data_->_tmp11_->message;
		gtk_label_set_label (_data_->_tmp10_, _data_->_tmp12_);
		_data_->_tmp13_ = _data_->self->priv->storage_progress;
		gtk_progress_bar_set_fraction (_data_->_tmp13_, 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 void
dc_profile_dialog_set_storage_quota_summary (DcProfileDialog* self,
                                             DcStorageQuota* quota)
{
	GtkProgressBar* _tmp0_;
	GtkProgressBar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_;
	gboolean _tmp4_;
	gdouble fraction = 0.0;
	gint64 _tmp9_;
	gint64 _tmp10_;
	gint64 _tmp11_;
	gint64 _tmp12_;
	GtkProgressBar* _tmp13_;
	gint64 left = 0LL;
	gint64 _tmp16_;
	gint64 _tmp17_;
	gint64 _tmp18_;
	gint64 _tmp19_;
	GtkLabel* _tmp20_;
	gint64 _tmp21_;
	gint64 _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gint64 _tmp27_;
	gint64 _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (quota != NULL);
	_tmp0_ = self->priv->storage_progress;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp0_, "storage-quota-warning");
	_tmp1_ = self->priv->storage_progress;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp1_, "storage-quota-error");
	_tmp3_ = dc_storage_quota_get_available (quota);
	_tmp4_ = _tmp3_;
	if (!_tmp4_) {
		_tmp2_ = TRUE;
	} else {
		gint64 _tmp5_;
		gint64 _tmp6_;
		_tmp5_ = dc_storage_quota_get_limit_bytes (quota);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_ <= ((gint64) 0);
	}
	if (_tmp2_) {
		GtkProgressBar* _tmp7_;
		GtkLabel* _tmp8_;
		_tmp7_ = self->priv->storage_progress;
		gtk_progress_bar_set_fraction (_tmp7_, 0.0);
		_tmp8_ = self->priv->storage_summary_label;
		gtk_label_set_label (_tmp8_, "Server quota has not been reported yet.");
		return;
	}
	_tmp9_ = dc_storage_quota_get_used_bytes (quota);
	_tmp10_ = _tmp9_;
	_tmp11_ = dc_storage_quota_get_limit_bytes (quota);
	_tmp12_ = _tmp11_;
	fraction = ((gdouble) _tmp10_) / ((gdouble) _tmp12_);
	if (fraction < 0.0) {
		fraction = 0.0;
	}
	if (fraction > 1.0) {
		fraction = 1.0;
	}
	_tmp13_ = self->priv->storage_progress;
	gtk_progress_bar_set_fraction (_tmp13_, fraction);
	if (fraction >= 0.95) {
		GtkProgressBar* _tmp14_;
		_tmp14_ = self->priv->storage_progress;
		gtk_widget_add_css_class ((GtkWidget*) _tmp14_, "storage-quota-error");
	} else {
		if (fraction >= 0.75) {
			GtkProgressBar* _tmp15_;
			_tmp15_ = self->priv->storage_progress;
			gtk_widget_add_css_class ((GtkWidget*) _tmp15_, "storage-quota-warning");
		}
	}
	_tmp16_ = dc_storage_quota_get_limit_bytes (quota);
	_tmp17_ = _tmp16_;
	_tmp18_ = dc_storage_quota_get_used_bytes (quota);
	_tmp19_ = _tmp18_;
	left = _tmp17_ - _tmp19_;
	if (left < ((gint64) 0)) {
		left = (gint64) 0;
	}
	_tmp20_ = self->priv->storage_summary_label;
	_tmp21_ = dc_storage_quota_get_used_bytes (quota);
	_tmp22_ = _tmp21_;
	_tmp23_ = dc_format_mb (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = dc_format_mb (left);
	_tmp26_ = _tmp25_;
	_tmp27_ = dc_storage_quota_get_limit_bytes (quota);
	_tmp28_ = _tmp27_;
	_tmp29_ = dc_format_mb (_tmp28_);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strdup_printf ("%s used · %s left of %s", _tmp24_, _tmp26_, _tmp30_);
	_tmp32_ = _tmp31_;
	gtk_label_set_label (_tmp20_, _tmp32_);
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
}

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 gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static void
dc_profile_dialog_do_save_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_)
{
	DcProfileDialogDoSaveData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_profile_dialog_do_save_co (_data_);
}

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

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

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

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

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

static void
___lambda105__dc_void_func (gpointer self)
{
	__lambda105_ ((DcProfileDialog*) self);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

static void
dc_profile_dialog_finalize (GObject * obj)
{
	DcProfileDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_PROFILE_DIALOG, DcProfileDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->avatar_widget);
	_g_object_unref0 (self->priv->name_entry);
	_g_object_unref0 (self->priv->status_entry);
	_g_object_unref0 (self->priv->email_label);
	_g_object_unref0 (self->priv->connectivity_status_label);
	_g_object_unref0 (self->priv->storage_summary_label);
	_g_object_unref0 (self->priv->storage_progress);
	_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_storage_quota_get_instance_private (DcStorageQuota* self)
{
	return G_STRUCT_MEMBER_P (self, DcStorageQuota_private_offset);
}

DcStorageQuota*
dc_storage_quota_from_connectivity_html (const gchar* html)
{
	DcStorageQuota* quota = NULL;
	DcStorageQuota* _tmp0_;
	gchar* text = NULL;
	gchar* _tmp1_;
	GError* _inner_error0_ = NULL;
	DcStorageQuota* result;
	g_return_val_if_fail (html != NULL, NULL);
	_tmp0_ = dc_storage_quota_new ();
	quota = _tmp0_;
	_tmp1_ = dc_storage_quota_strip_html (html);
	text = _tmp1_;
	{
		GRegex* rx = NULL;
		GRegex* _tmp2_;
		GMatchInfo* match = NULL;
		GMatchInfo* _tmp3_ = NULL;
		gboolean _tmp4_;
		_tmp2_ = g_regex_new ("([0-9]+(?:[\\.,][0-9]+)?)\\s*([KMGT]?i?B)\\s+of\\s+" "([0-9]+(?:[\\.,][0-9]+)?)\\s*([KMGT]?i?B)\\s+used", G_REGEX_CASELESS, 0, &_inner_error0_);
		rx = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp4_ = g_regex_match (rx, text, 0, &_tmp3_);
		_g_match_info_unref0 (match);
		match = _tmp3_;
		if (_tmp4_) {
			gdouble used = 0.0;
			GMatchInfo* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gdouble _tmp8_;
			gchar* used_unit = NULL;
			GMatchInfo* _tmp9_;
			gchar* _tmp10_;
			gdouble limit = 0.0;
			GMatchInfo* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			gdouble _tmp14_;
			gchar* limit_unit = NULL;
			GMatchInfo* _tmp15_;
			gchar* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			gint64 _tmp19_;
			_tmp5_ = match;
			_tmp6_ = g_match_info_fetch (_tmp5_, 1);
			_tmp7_ = _tmp6_;
			_tmp8_ = dc_storage_quota_parse_number (_tmp7_);
			_g_free0 (_tmp7_);
			used = _tmp8_;
			_tmp9_ = match;
			_tmp10_ = g_match_info_fetch (_tmp9_, 2);
			used_unit = _tmp10_;
			_tmp11_ = match;
			_tmp12_ = g_match_info_fetch (_tmp11_, 3);
			_tmp13_ = _tmp12_;
			_tmp14_ = dc_storage_quota_parse_number (_tmp13_);
			_g_free0 (_tmp13_);
			limit = _tmp14_;
			_tmp15_ = match;
			_tmp16_ = g_match_info_fetch (_tmp15_, 4);
			limit_unit = _tmp16_;
			_tmp17_ = used_unit;
			dc_storage_quota_set_used_bytes (quota, dc_storage_quota_unit_to_bytes (used, _tmp17_));
			_tmp18_ = limit_unit;
			dc_storage_quota_set_limit_bytes (quota, dc_storage_quota_unit_to_bytes (limit, _tmp18_));
			_tmp19_ = quota->priv->_limit_bytes;
			dc_storage_quota_set_available (quota, _tmp19_ > ((gint64) 0));
			_g_free0 (limit_unit);
			_g_free0 (used_unit);
		}
		_g_match_info_unref0 (match);
		_g_regex_unref0 (rx);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (text);
		_g_object_unref0 (quota);
		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 NULL;
	}
	result = quota;
	_g_free0 (text);
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__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 NULL;
}

static gchar*
dc_storage_quota_strip_html (const gchar* html)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (html != NULL, NULL);
	_tmp0_ = g_strdup (html);
	text = _tmp0_;
	{
		GRegex* tags = NULL;
		GRegex* _tmp1_;
		gchar* _tmp2_ = NULL;
		GRegex* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp1_ = g_regex_new ("<[^>]+>", 0, 0, &_inner_error0_);
		tags = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = tags;
		_tmp4_ = text;
		_tmp5_ = g_regex_replace (_tmp3_, _tmp4_, (gssize) -1, 0, " ", 0, &_inner_error0_);
		_tmp2_ = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (tags);
			goto __catch0_g_error;
		}
		_tmp6_ = _tmp2_;
		_tmp2_ = NULL;
		_g_free0 (text);
		text = _tmp6_;
		_g_free0 (_tmp2_);
		_g_regex_unref0 (tags);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (text);
		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 NULL;
	}
	_tmp7_ = text;
	_tmp8_ = string_replace (_tmp7_, "&nbsp;", " ");
	_g_free0 (text);
	text = _tmp8_;
	_tmp9_ = text;
	_tmp10_ = string_replace (_tmp9_, "&amp;", "&");
	_g_free0 (text);
	text = _tmp10_;
	_tmp11_ = text;
	_tmp12_ = string_replace (_tmp11_, "&lt;", "<");
	_g_free0 (text);
	text = _tmp12_;
	_tmp13_ = text;
	_tmp14_ = string_replace (_tmp13_, "&gt;", ">");
	_g_free0 (text);
	text = _tmp14_;
	_tmp15_ = text;
	_tmp16_ = string_replace (_tmp15_, "&quot;", "\"");
	_g_free0 (text);
	text = _tmp16_;
	{
		GRegex* spaces = NULL;
		GRegex* _tmp17_;
		gchar* _tmp18_ = NULL;
		GRegex* _tmp19_;
		const gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		_tmp17_ = g_regex_new ("\\s+", 0, 0, &_inner_error0_);
		spaces = _tmp17_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp19_ = spaces;
		_tmp20_ = text;
		_tmp21_ = g_regex_replace (_tmp19_, _tmp20_, (gssize) -1, 0, " ", 0, &_inner_error0_);
		_tmp18_ = _tmp21_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (spaces);
			goto __catch1_g_error;
		}
		_tmp22_ = _tmp18_;
		_tmp18_ = NULL;
		_g_free0 (text);
		text = _tmp22_;
		_g_free0 (_tmp18_);
		_g_regex_unref0 (spaces);
	}
	goto __finally1;
	__catch1_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (text);
		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 NULL;
	}
	_tmp23_ = text;
	_tmp24_ = string_strip (_tmp23_);
	result = _tmp24_;
	_g_free0 (text);
	return result;
}

static gdouble
double_parse (const gchar* str)
{
	gdouble result;
	g_return_val_if_fail (str != NULL, -1.0);
	result = g_ascii_strtod (str, NULL);
	return result;
}

static gdouble
dc_storage_quota_parse_number (const gchar* s)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gdouble _tmp2_;
	gdouble result;
	g_return_val_if_fail (s != NULL, -1.0);
	_tmp0_ = string_replace (s, ",", ".");
	_tmp1_ = _tmp0_;
	_tmp2_ = double_parse (_tmp1_);
	_g_free0 (_tmp1_);
	result = _tmp2_;
	return result;
}

static gint64
dc_storage_quota_unit_to_bytes (gdouble value,
                                const gchar* unit)
{
	gchar* u = NULL;
	gchar* _tmp0_;
	gdouble mult = 0.0;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gint64 result;
	g_return_val_if_fail (unit != NULL, -1LL);
	_tmp0_ = g_utf8_strup (unit, (gssize) -1);
	u = _tmp0_;
	mult = 1.0;
	_tmp2_ = u;
	if (g_strcmp0 (_tmp2_, "KB") == 0) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp3_;
		_tmp3_ = u;
		_tmp1_ = g_strcmp0 (_tmp3_, "KIB") == 0;
	}
	if (_tmp1_) {
		mult = 1024.0;
	} else {
		gboolean _tmp4_ = FALSE;
		const gchar* _tmp5_;
		_tmp5_ = u;
		if (g_strcmp0 (_tmp5_, "MB") == 0) {
			_tmp4_ = TRUE;
		} else {
			const gchar* _tmp6_;
			_tmp6_ = u;
			_tmp4_ = g_strcmp0 (_tmp6_, "MIB") == 0;
		}
		if (_tmp4_) {
			mult = 1024.0 * 1024.0;
		} else {
			gboolean _tmp7_ = FALSE;
			const gchar* _tmp8_;
			_tmp8_ = u;
			if (g_strcmp0 (_tmp8_, "GB") == 0) {
				_tmp7_ = TRUE;
			} else {
				const gchar* _tmp9_;
				_tmp9_ = u;
				_tmp7_ = g_strcmp0 (_tmp9_, "GIB") == 0;
			}
			if (_tmp7_) {
				mult = (1024.0 * 1024.0) * 1024.0;
			} else {
				gboolean _tmp10_ = FALSE;
				const gchar* _tmp11_;
				_tmp11_ = u;
				if (g_strcmp0 (_tmp11_, "TB") == 0) {
					_tmp10_ = TRUE;
				} else {
					const gchar* _tmp12_;
					_tmp12_ = u;
					_tmp10_ = g_strcmp0 (_tmp12_, "TIB") == 0;
				}
				if (_tmp10_) {
					mult = ((1024.0 * 1024.0) * 1024.0) * 1024.0;
				}
			}
		}
	}
	result = (gint64) (value * mult);
	_g_free0 (u);
	return result;
}

DcStorageQuota*
dc_storage_quota_construct (GType object_type)
{
	DcStorageQuota * self = NULL;
	self = (DcStorageQuota*) g_object_new (object_type, NULL);
	return self;
}

DcStorageQuota*
dc_storage_quota_new (void)
{
	return dc_storage_quota_construct (DC_TYPE_STORAGE_QUOTA);
}

gboolean
dc_storage_quota_get_available (DcStorageQuota* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_available;
	return result;
}

void
dc_storage_quota_set_available (DcStorageQuota* self,
                                gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_storage_quota_get_available (self);
	if (old_value != value) {
		self->priv->_available = value;
		g_object_notify_by_pspec ((GObject *) self, dc_storage_quota_properties[DC_STORAGE_QUOTA_AVAILABLE_PROPERTY]);
	}
}

gint64
dc_storage_quota_get_used_bytes (DcStorageQuota* self)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = self->priv->_used_bytes;
	return result;
}

void
dc_storage_quota_set_used_bytes (DcStorageQuota* self,
                                 gint64 value)
{
	gint64 old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_storage_quota_get_used_bytes (self);
	if (old_value != value) {
		self->priv->_used_bytes = value;
		g_object_notify_by_pspec ((GObject *) self, dc_storage_quota_properties[DC_STORAGE_QUOTA_USED_BYTES_PROPERTY]);
	}
}

gint64
dc_storage_quota_get_limit_bytes (DcStorageQuota* self)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = self->priv->_limit_bytes;
	return result;
}

void
dc_storage_quota_set_limit_bytes (DcStorageQuota* self,
                                  gint64 value)
{
	gint64 old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_storage_quota_get_limit_bytes (self);
	if (old_value != value) {
		self->priv->_limit_bytes = value;
		g_object_notify_by_pspec ((GObject *) self, dc_storage_quota_properties[DC_STORAGE_QUOTA_LIMIT_BYTES_PROPERTY]);
	}
}

static void
dc_storage_quota_class_init (DcStorageQuotaClass * klass,
                             gpointer klass_data)
{
	dc_storage_quota_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcStorageQuota_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_storage_quota_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_storage_quota_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_storage_quota_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_STORAGE_QUOTA_AVAILABLE_PROPERTY, dc_storage_quota_properties[DC_STORAGE_QUOTA_AVAILABLE_PROPERTY] = g_param_spec_boolean ("available", "available", "available", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_STORAGE_QUOTA_USED_BYTES_PROPERTY, dc_storage_quota_properties[DC_STORAGE_QUOTA_USED_BYTES_PROPERTY] = g_param_spec_int64 ("used-bytes", "used-bytes", "used-bytes", G_MININT64, G_MAXINT64, (gint64) 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_STORAGE_QUOTA_LIMIT_BYTES_PROPERTY, dc_storage_quota_properties[DC_STORAGE_QUOTA_LIMIT_BYTES_PROPERTY] = g_param_spec_int64 ("limit-bytes", "limit-bytes", "limit-bytes", G_MININT64, G_MAXINT64, (gint64) 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dc_storage_quota_instance_init (DcStorageQuota * self,
                                gpointer klass)
{
	self->priv = dc_storage_quota_get_instance_private (self);
	self->priv->_available = FALSE;
	self->priv->_used_bytes = (gint64) 0;
	self->priv->_limit_bytes = (gint64) 0;
}

static void
dc_storage_quota_finalize (GObject * obj)
{
	DcStorageQuota * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_STORAGE_QUOTA, DcStorageQuota);
	G_OBJECT_CLASS (dc_storage_quota_parent_class)->finalize (obj);
}

static GType
dc_storage_quota_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcStorageQuotaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_storage_quota_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcStorageQuota), 0, (GInstanceInitFunc) dc_storage_quota_instance_init, NULL };
	GType dc_storage_quota_type_id;
	dc_storage_quota_type_id = g_type_register_static (G_TYPE_OBJECT, "DcStorageQuota", &g_define_type_info, 0);
	DcStorageQuota_private_offset = g_type_add_instance_private (dc_storage_quota_type_id, sizeof (DcStorageQuotaPrivate));
	return dc_storage_quota_type_id;
}

GType
dc_storage_quota_get_type (void)
{
	static volatile gsize dc_storage_quota_type_id__once = 0;
	if (g_once_init_enter (&dc_storage_quota_type_id__once)) {
		GType dc_storage_quota_type_id;
		dc_storage_quota_type_id = dc_storage_quota_get_type_once ();
		g_once_init_leave (&dc_storage_quota_type_id__once, dc_storage_quota_type_id);
	}
	return dc_storage_quota_type_id__once;
}

static void
_vala_dc_storage_quota_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	DcStorageQuota * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_STORAGE_QUOTA, DcStorageQuota);
	switch (property_id) {
		case DC_STORAGE_QUOTA_AVAILABLE_PROPERTY:
		g_value_set_boolean (value, dc_storage_quota_get_available (self));
		break;
		case DC_STORAGE_QUOTA_USED_BYTES_PROPERTY:
		g_value_set_int64 (value, dc_storage_quota_get_used_bytes (self));
		break;
		case DC_STORAGE_QUOTA_LIMIT_BYTES_PROPERTY:
		g_value_set_int64 (value, dc_storage_quota_get_limit_bytes (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_storage_quota_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	DcStorageQuota * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_STORAGE_QUOTA, DcStorageQuota);
	switch (property_id) {
		case DC_STORAGE_QUOTA_AVAILABLE_PROPERTY:
		dc_storage_quota_set_available (self, g_value_get_boolean (value));
		break;
		case DC_STORAGE_QUOTA_USED_BYTES_PROPERTY:
		dc_storage_quota_set_used_bytes (self, g_value_get_int64 (value));
		break;
		case DC_STORAGE_QUOTA_LIMIT_BYTES_PROPERTY:
		dc_storage_quota_set_limit_bytes (self, g_value_get_int64 (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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
__lambda93_ (DcStorageDetailsDialog* self)
{
	dc_storage_details_dialog_load_details (self, NULL, NULL);
}

static void
___lambda93__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda93_ ((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* quota_title = NULL;
	GtkLabel* _tmp8_;
	GtkProgressBar* _tmp9_;
	GtkProgressBar* _tmp10_;
	GtkProgressBar* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkLabel* _tmp14_;
	GtkLabel* _tmp15_;
	GtkLabel* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* local_title = NULL;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkLabel* _tmp20_;
	GtkLabel* _tmp21_;
	GtkLabel* _tmp22_;
	GtkLabel* _tmp23_;
	GtkLabel* _tmp24_;
	GtkButton* _tmp25_;
	GtkButton* _tmp26_;
	GtkButton* _tmp27_;
	GtkButton* _tmp28_;
	GtkButton* _tmp29_;
	GtkSeparator* _tmp30_;
	GtkSeparator* _tmp31_;
	GtkLabel* chats_title = NULL;
	GtkLabel* _tmp32_;
	GtkLabel* _tmp33_;
	GtkLabel* _tmp34_;
	GtkLabel* _tmp35_;
	GtkLabel* _tmp36_;
	GtkLabel* _tmp37_;
	GtkLabel* _tmp38_;
	GtkListBox* _tmp39_;
	GtkListBox* _tmp40_;
	GtkListBox* _tmp41_;
	GtkListBox* _tmp42_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp43_;
	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) ___lambda93__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_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp7_);
	content = _tmp7_;
	gtk_widget_set_margin_start ((GtkWidget*) content, 16);
	gtk_widget_set_margin_end ((GtkWidget*) content, 16);
	gtk_widget_set_margin_top ((GtkWidget*) content, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) content, 16);
	_tmp8_ = (GtkLabel*) gtk_label_new ("Server Quota");
	g_object_ref_sink (_tmp8_);
	quota_title = _tmp8_;
	gtk_widget_add_css_class ((GtkWidget*) quota_title, "heading");
	gtk_widget_set_halign ((GtkWidget*) quota_title, GTK_ALIGN_START);
	gtk_box_append (content, (GtkWidget*) quota_title);
	_tmp9_ = (GtkProgressBar*) gtk_progress_bar_new ();
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->quota_progress);
	self->priv->quota_progress = _tmp9_;
	_tmp10_ = self->priv->quota_progress;
	gtk_widget_add_css_class ((GtkWidget*) _tmp10_, "storage-quota-bar");
	_tmp11_ = self->priv->quota_progress;
	gtk_box_append (content, (GtkWidget*) _tmp11_);
	_tmp12_ = (GtkLabel*) gtk_label_new ("Loading quota…");
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->quota_label);
	self->priv->quota_label = _tmp12_;
	_tmp13_ = self->priv->quota_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp13_, GTK_ALIGN_START);
	_tmp14_ = self->priv->quota_label;
	gtk_label_set_xalign (_tmp14_, (gfloat) 0);
	_tmp15_ = self->priv->quota_label;
	gtk_label_set_wrap (_tmp15_, TRUE);
	_tmp16_ = self->priv->quota_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp16_, "dim-label");
	_tmp17_ = self->priv->quota_label;
	gtk_box_append (content, (GtkWidget*) _tmp17_);
	_tmp18_ = (GtkLabel*) gtk_label_new ("Local Copies");
	g_object_ref_sink (_tmp18_);
	local_title = _tmp18_;
	gtk_widget_add_css_class ((GtkWidget*) local_title, "heading");
	gtk_widget_set_halign ((GtkWidget*) local_title, GTK_ALIGN_START);
	gtk_box_append (content, (GtkWidget*) local_title);
	_tmp19_ = (GtkLabel*) gtk_label_new ("Scanning local files…");
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->local_total_label);
	self->priv->local_total_label = _tmp19_;
	_tmp20_ = self->priv->local_total_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp20_, GTK_ALIGN_START);
	_tmp21_ = self->priv->local_total_label;
	gtk_label_set_xalign (_tmp21_, (gfloat) 0);
	_tmp22_ = self->priv->local_total_label;
	gtk_label_set_wrap (_tmp22_, TRUE);
	_tmp23_ = self->priv->local_total_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp23_, "dim-label");
	_tmp24_ = self->priv->local_total_label;
	gtk_box_append (content, (GtkWidget*) _tmp24_);
	_tmp25_ = (GtkButton*) gtk_button_new_with_label ("Clear Local Cache…");
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (self->priv->clear_cache_btn);
	self->priv->clear_cache_btn = _tmp25_;
	_tmp26_ = self->priv->clear_cache_btn;
	gtk_widget_set_halign ((GtkWidget*) _tmp26_, GTK_ALIGN_START);
	_tmp27_ = self->priv->clear_cache_btn;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp27_, "Explain what can be safely cleared");
	_tmp28_ = self->priv->clear_cache_btn;
	g_signal_connect_object (_tmp28_, "clicked", (GCallback) _dc_storage_details_dialog_show_clear_cache_info_gtk_button_clicked, self, 0);
	_tmp29_ = self->priv->clear_cache_btn;
	gtk_box_append (content, (GtkWidget*) _tmp29_);
	_tmp30_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	g_object_ref_sink (_tmp30_);
	_tmp31_ = _tmp30_;
	gtk_box_append (content, (GtkWidget*) _tmp31_);
	_g_object_unref0 (_tmp31_);
	_tmp32_ = (GtkLabel*) gtk_label_new ("Conversations by Storage Size");
	g_object_ref_sink (_tmp32_);
	chats_title = _tmp32_;
	gtk_widget_add_css_class ((GtkWidget*) chats_title, "heading");
	gtk_widget_set_halign ((GtkWidget*) chats_title, GTK_ALIGN_START);
	gtk_box_append (content, (GtkWidget*) chats_title);
	_tmp33_ = (GtkLabel*) gtk_label_new ("Preparing scan…");
	g_object_ref_sink (_tmp33_);
	_g_object_unref0 (self->priv->scan_status_label);
	self->priv->scan_status_label = _tmp33_;
	_tmp34_ = self->priv->scan_status_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp34_, GTK_ALIGN_START);
	_tmp35_ = self->priv->scan_status_label;
	gtk_label_set_xalign (_tmp35_, (gfloat) 0);
	_tmp36_ = self->priv->scan_status_label;
	gtk_label_set_wrap (_tmp36_, TRUE);
	_tmp37_ = self->priv->scan_status_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp37_, "dim-label");
	_tmp38_ = self->priv->scan_status_label;
	gtk_box_append (content, (GtkWidget*) _tmp38_);
	_tmp39_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp39_);
	_g_object_unref0 (self->priv->chat_usage_list);
	self->priv->chat_usage_list = _tmp39_;
	_tmp40_ = self->priv->chat_usage_list;
	gtk_list_box_set_selection_mode (_tmp40_, GTK_SELECTION_NONE);
	_tmp41_ = self->priv->chat_usage_list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp41_, "boxed-list");
	_tmp42_ = self->priv->chat_usage_list;
	gtk_box_append (content, (GtkWidget*) _tmp42_);
	_tmp43_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp43_);
	scroll = _tmp43_;
	gtk_widget_set_vexpand ((GtkWidget*) scroll, TRUE);
	g_object_set (scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_child (scroll, (GtkWidget*) content);
	gtk_box_append (box, (GtkWidget*) scroll);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) box);
	dc_install_escape_close ((AdwDialog*) self);
	dc_storage_details_dialog_load_details (self, NULL, NULL);
	_g_object_unref0 (scroll);
	_g_object_unref0 (chats_title);
	_g_object_unref0 (local_title);
	_g_object_unref0 (quota_title);
	_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_from_connectivity_html (_data_->html);
			_data_->_tmp14_ = _data_->_tmp13_;
			dc_storage_details_dialog_set_quota (_data_->self, _data_->_tmp14_);
			_g_object_unref0 (_data_->_tmp14_);
			_g_free0 (_data_->html);
		}
		goto __finally3;
		__catch3_g_error:
		{
			_data_->e = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp15_ = _data_->self->priv->quota_progress;
			gtk_progress_bar_set_fraction (_data_->_tmp15_, 0.0);
			_data_->_tmp16_ = _data_->self->priv->quota_label;
			_data_->_tmp17_ = _data_->e;
			_data_->_tmp18_ = _data_->_tmp17_->message;
			_data_->_tmp19_ = g_strconcat ("Server quota unavailable: ", _data_->_tmp18_, NULL);
			_data_->_tmp20_ = _data_->_tmp19_;
			gtk_label_set_label (_data_->_tmp16_, _data_->_tmp20_);
			_g_free0 (_data_->_tmp20_);
			_g_error_free0 (_data_->e);
		}
		__finally3:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp21_ = 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_->_tmp22_ = dc_storage_details_dialog_scan_all_chats_finish (_data_->self, _data_->_res_, &_data_->_tmp21_, &_data_->_inner_error0_);
		_data_->usages = _data_->_tmp22_;
		_data_->usages_length1 = _data_->_tmp21_;
		_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);
		if (_data_->account_bytes > ((gint64) 0)) {
			_data_->_tmp23_ = _data_->self->priv->local_total_label;
			_data_->_tmp24_ = dc_format_mb (_data_->account_bytes);
			_data_->_tmp25_ = _data_->_tmp24_;
			_data_->_tmp26_ = dc_format_mb (_data_->self->priv->unique_local_file_bytes);
			_data_->_tmp27_ = _data_->_tmp26_;
			_data_->_tmp28_ = dc_format_mb (_data_->self->priv->known_attachment_bytes);
			_data_->_tmp29_ = _data_->_tmp28_;
			_data_->_tmp30_ = g_strdup_printf ("%s local account data · %s downloaded message files · %s known attachm" \
"ent payload", _data_->_tmp25_, _data_->_tmp27_, _data_->_tmp29_);
			_data_->_tmp31_ = _data_->_tmp30_;
			gtk_label_set_label (_data_->_tmp23_, _data_->_tmp31_);
			_g_free0 (_data_->_tmp31_);
			_g_free0 (_data_->_tmp29_);
			_g_free0 (_data_->_tmp27_);
			_g_free0 (_data_->_tmp25_);
		} else {
			_data_->_tmp32_ = _data_->self->priv->local_total_label;
			_data_->_tmp33_ = dc_format_mb (_data_->self->priv->unique_local_file_bytes);
			_data_->_tmp34_ = _data_->_tmp33_;
			_data_->_tmp35_ = dc_format_mb (_data_->self->priv->known_attachment_bytes);
			_data_->_tmp36_ = _data_->_tmp35_;
			_data_->_tmp37_ = g_strdup_printf ("%s downloaded message files · %s known attachment payload", _data_->_tmp34_, _data_->_tmp36_);
			_data_->_tmp38_ = _data_->_tmp37_;
			gtk_label_set_label (_data_->_tmp32_, _data_->_tmp38_);
			_g_free0 (_data_->_tmp38_);
			_g_free0 (_data_->_tmp36_);
			_g_free0 (_data_->_tmp34_);
		}
		if (_data_->usages_length1 == 0) {
			_data_->_tmp40_ = g_strdup ("No downloaded message files found in conversations.");
			_g_free0 (_data_->_tmp39_);
			_data_->_tmp39_ = _data_->_tmp40_;
		} else {
			_data_->_tmp41_ = g_strdup_printf ("%d conversations with local or attached files.", _data_->usages_length1);
			_g_free0 (_data_->_tmp39_);
			_data_->_tmp39_ = _data_->_tmp41_;
		}
		_data_->_tmp42_ = _data_->self->priv->scan_status_label;
		gtk_label_set_label (_data_->_tmp42_, _data_->_tmp39_);
		_g_free0 (_data_->_tmp39_);
		_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_->_tmp43_ = _data_->self->priv->scan_status_label;
		_data_->_tmp44_ = _data_->_vala1_e;
		_data_->_tmp45_ = _data_->_tmp44_->message;
		_data_->_tmp46_ = g_strconcat ("Storage scan failed: ", _data_->_tmp45_, NULL);
		_data_->_tmp47_ = _data_->_tmp46_;
		gtk_label_set_label (_data_->_tmp43_, _data_->_tmp47_);
		_g_free0 (_data_->_tmp47_);
		_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_->_tmp48_ = _data_->self->priv->refresh_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp48_, 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_set_quota (DcStorageDetailsDialog* self,
                                     DcStorageQuota* quota)
{
	GtkProgressBar* _tmp0_;
	GtkProgressBar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_;
	gboolean _tmp4_;
	gdouble fraction = 0.0;
	gint64 _tmp9_;
	gint64 _tmp10_;
	gint64 _tmp11_;
	gint64 _tmp12_;
	GtkProgressBar* _tmp13_;
	gint64 left = 0LL;
	gint64 _tmp16_;
	gint64 _tmp17_;
	gint64 _tmp18_;
	gint64 _tmp19_;
	GtkLabel* _tmp20_;
	gint64 _tmp21_;
	gint64 _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gint64 _tmp27_;
	gint64 _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (quota != NULL);
	_tmp0_ = self->priv->quota_progress;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp0_, "storage-quota-warning");
	_tmp1_ = self->priv->quota_progress;
	gtk_widget_remove_css_class ((GtkWidget*) _tmp1_, "storage-quota-error");
	_tmp3_ = dc_storage_quota_get_available (quota);
	_tmp4_ = _tmp3_;
	if (!_tmp4_) {
		_tmp2_ = TRUE;
	} else {
		gint64 _tmp5_;
		gint64 _tmp6_;
		_tmp5_ = dc_storage_quota_get_limit_bytes (quota);
		_tmp6_ = _tmp5_;
		_tmp2_ = _tmp6_ <= ((gint64) 0);
	}
	if (_tmp2_) {
		GtkProgressBar* _tmp7_;
		GtkLabel* _tmp8_;
		_tmp7_ = self->priv->quota_progress;
		gtk_progress_bar_set_fraction (_tmp7_, 0.0);
		_tmp8_ = self->priv->quota_label;
		gtk_label_set_label (_tmp8_, "Server quota has not been reported yet.");
		return;
	}
	_tmp9_ = dc_storage_quota_get_used_bytes (quota);
	_tmp10_ = _tmp9_;
	_tmp11_ = dc_storage_quota_get_limit_bytes (quota);
	_tmp12_ = _tmp11_;
	fraction = ((gdouble) _tmp10_) / ((gdouble) _tmp12_);
	if (fraction < 0.0) {
		fraction = 0.0;
	}
	if (fraction > 1.0) {
		fraction = 1.0;
	}
	_tmp13_ = self->priv->quota_progress;
	gtk_progress_bar_set_fraction (_tmp13_, fraction);
	if (fraction >= 0.95) {
		GtkProgressBar* _tmp14_;
		_tmp14_ = self->priv->quota_progress;
		gtk_widget_add_css_class ((GtkWidget*) _tmp14_, "storage-quota-error");
	} else {
		if (fraction >= 0.75) {
			GtkProgressBar* _tmp15_;
			_tmp15_ = self->priv->quota_progress;
			gtk_widget_add_css_class ((GtkWidget*) _tmp15_, "storage-quota-warning");
		}
	}
	_tmp16_ = dc_storage_quota_get_limit_bytes (quota);
	_tmp17_ = _tmp16_;
	_tmp18_ = dc_storage_quota_get_used_bytes (quota);
	_tmp19_ = _tmp18_;
	left = _tmp17_ - _tmp19_;
	if (left < ((gint64) 0)) {
		left = (gint64) 0;
	}
	_tmp20_ = self->priv->quota_label;
	_tmp21_ = dc_storage_quota_get_used_bytes (quota);
	_tmp22_ = _tmp21_;
	_tmp23_ = dc_format_mb (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = dc_format_mb (left);
	_tmp26_ = _tmp25_;
	_tmp27_ = dc_storage_quota_get_limit_bytes (quota);
	_tmp28_ = _tmp27_;
	_tmp29_ = dc_format_mb (_tmp28_);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strdup_printf ("%s used · %s left of %s", _tmp24_, _tmp26_, _tmp30_);
	_tmp32_ = _tmp31_;
	gtk_label_set_label (_tmp20_, _tmp32_);
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
}

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_add4 (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, 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_add4 (&_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_client_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_->usage;
	_data_->_tmp5_ = _data_->ids;
	_data_->_tmp4_->message_count = (gint) json_array_get_length (_data_->_tmp5_);
	_data_->_tmp6_ = _data_->ids;
	_data_->len = (gint) json_array_get_length (_data_->_tmp6_);
	{
		_data_->start = 0;
		{
			_data_->_tmp7_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp7_) {
					_data_->start += 200;
				}
				_data_->_tmp7_ = 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_->_tmp8_ = g_new0 (gint, _data_->count);
				_data_->batch = _data_->_tmp8_;
				_data_->batch_length1 = _data_->count;
				_data_->_batch_size_ = _data_->batch_length1;
				{
					_data_->i = 0;
					{
						_data_->_tmp9_ = TRUE;
						while (TRUE) {
							if (!_data_->_tmp9_) {
								_data_->_tmp10_ = _data_->i;
								_data_->i = _data_->_tmp10_ + 1;
							}
							_data_->_tmp9_ = FALSE;
							if (!(_data_->i < _data_->count)) {
								break;
							}
							_data_->_tmp11_ = _data_->batch;
							_data_->_tmp11__length1 = _data_->batch_length1;
							_data_->_tmp12_ = _data_->ids;
							_data_->_tmp11_[_data_->i] = (gint) json_array_get_int_element (_data_->_tmp12_, (guint) (_data_->start + _data_->i));
						}
					}
				}
				_data_->_tmp13_ = _data_->self->priv->rpc;
				_data_->_tmp14_ = _data_->batch;
				_data_->_tmp14__length1 = _data_->batch_length1;
				_data_->_state_ = 2;
				dc_rpc_client_get_messages_for (_data_->_tmp13_, _data_->self->priv->account_id, _data_->_tmp14_, (gint) _data_->_tmp14__length1, dc_storage_details_dialog_scan_chat_ready, _data_);
				return FALSE;
				_state_2:
				_data_->_tmp15_ = dc_rpc_client_get_messages_for_finish (_data_->_tmp13_, _data_->_res_, &_data_->_inner_error0_);
				_data_->messages = _data_->_tmp15_;
				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_->_tmp16_ = _data_->messages;
				if (_data_->_tmp16_ == NULL) {
					_json_object_unref0 (_data_->messages);
					_data_->batch = (g_free (_data_->batch), NULL);
					continue;
				}
				{
					_data_->_vala1_i = 0;
					{
						_data_->_tmp17_ = TRUE;
						while (TRUE) {
							if (!_data_->_tmp17_) {
								_data_->_tmp18_ = _data_->_vala1_i;
								_data_->_vala1_i = _data_->_tmp18_ + 1;
							}
							_data_->_tmp17_ = FALSE;
							if (!(_data_->_vala1_i < _data_->count)) {
								break;
							}
							_data_->_tmp19_ = _data_->batch;
							_data_->_tmp19__length1 = _data_->batch_length1;
							_data_->_tmp20_ = _data_->_tmp19_[_data_->_vala1_i];
							_data_->_tmp21_ = g_strdup_printf ("%i", _data_->_tmp20_);
							_data_->key = _data_->_tmp21_;
							_data_->_tmp22_ = _data_->messages;
							_data_->_tmp23_ = _data_->key;
							if (!json_object_has_member (_data_->_tmp22_, _data_->_tmp23_)) {
								_g_free0 (_data_->key);
								continue;
							}
							_data_->_tmp24_ = _data_->messages;
							_data_->_tmp25_ = _data_->key;
							_data_->_tmp26_ = json_object_get_member (_data_->_tmp24_, _data_->_tmp25_);
							_data_->_tmp27_ = __vala_JsonNode_copy0 (_data_->_tmp26_);
							_data_->node = _data_->_tmp27_;
							_data_->_tmp29_ = _data_->node;
							if (_data_->_tmp29_ == NULL) {
								_data_->_tmp28_ = TRUE;
							} else {
								_data_->_tmp30_ = _data_->node;
								_data_->_tmp28_ = json_node_get_node_type (_data_->_tmp30_) != JSON_NODE_OBJECT;
							}
							if (_data_->_tmp28_) {
								__vala_JsonNode_free0 (_data_->node);
								_g_free0 (_data_->key);
								continue;
							}
							_data_->_tmp31_ = _data_->node;
							_data_->_tmp32_ = json_node_get_object (_data_->_tmp31_);
							_data_->_tmp33_ = dc_rpc_client_parse_message (_data_->_tmp32_, NULL);
							_data_->msg = _data_->_tmp33_;
							_data_->_tmp34_ = _data_->usage;
							_data_->_tmp35_ = _data_->msg;
							dc_storage_details_dialog_add_message_usage (_data_->self, _data_->_tmp34_, _data_->_tmp35_);
							_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_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_format_mb (usage->local_bytes);
	_tmp10_ = _tmp9_;
	_tmp11_ = dc_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_ = (GtkLabel*) gtk_label_new (_tmp14_);
	g_object_ref_sink (_tmp15_);
	_tmp16_ = _tmp15_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp10_);
	subtitle = _tmp16_;
	gtk_widget_set_halign ((GtkWidget*) subtitle, GTK_ALIGN_START);
	gtk_label_set_xalign (subtitle, (gfloat) 0);
	gtk_label_set_wrap (subtitle, TRUE);
	gtk_widget_add_css_class ((GtkWidget*) subtitle, "dim-label");
	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;
}

gchar*
dc_format_mb (gint64 bytes)
{
	gdouble mb = 0.0;
	gchar* _tmp0_;
	gchar* result;
	mb = ((gdouble) bytes) / (1024.0 * 1024.0);
	_tmp0_ = g_strdup_printf ("%.1f MB", mb);
	result = _tmp0_;
	return result;
}

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

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

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

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

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

static void
___lambda95__adw_dialog_closed (AdwDialog* _sender,
                                gpointer self)
{
	__lambda95_ ((DcInviteCodeDialog*) self);
}

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

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

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

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

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

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

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

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

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

static void
dc_invite_code_dialog_show_invite_error (DcInviteCodeDialog* self,
                                         const gchar* message)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkButton* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->status_label;
	_tmp1_ = g_strconcat ("Invite code creation failed: ", message, NULL);
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, FALSE);
}

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

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

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

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

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

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

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

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

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

static void
___lambda102__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda102_ ((DcSecondDeviceDialog*) self);
}

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

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

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

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

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

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

static void
__lambda104_ (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
___lambda104__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda104_ ((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, ___lambda104__gasync_ready_callback, g_object_ref (_data_->self));
	{
		_data_->_tmp1_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_get_backup_qr (_data_->_tmp1_, _data_->self->priv->account_id, dc_second_device_dialog_start_transfer_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = dc_rpc_client_get_backup_qr_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		_data_->text = _data_->_tmp2_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp3_ = _data_->self->priv->rpc;
		_data_->_tmp4_ = _data_->text;
		_data_->_state_ = 2;
		dc_rpc_client_create_qr_svg (_data_->_tmp3_, _data_->_tmp4_, dc_second_device_dialog_start_transfer_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp5_ = dc_rpc_client_create_qr_svg_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		_data_->svg = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_free0 (_data_->text);
			goto __catch0_g_error;
		}
		if (!_data_->self->priv->closing) {
			_data_->_tmp6_ = _data_->text;
			_data_->_tmp7_ = _data_->svg;
			dc_second_device_dialog_show_qr (_data_->self, _data_->_tmp6_, _data_->_tmp7_);
		}
		_g_free0 (_data_->svg);
		_g_free0 (_data_->text);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		if (!_data_->self->priv->closing) {
			_data_->_tmp8_ = _data_->e;
			_data_->_tmp9_ = _data_->_tmp8_->message;
			dc_second_device_dialog_show_transfer_error (_data_->self, _data_->_tmp9_);
			dc_second_device_dialog_stop_provider (_data_->self);
		}
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_second_device_dialog_show_transfer_error (DcSecondDeviceDialog* self,
                                             const gchar* message)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkButton* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	_tmp0_ = self->priv->status_label;
	_tmp1_ = g_strconcat ("Second-device setup failed: ", message, NULL);
	_tmp2_ = _tmp1_;
	gtk_label_set_label (_tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->copy_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, FALSE);
}

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

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

static void
___lambda103_ (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
____lambda103__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	___lambda103_ ((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, ____lambda103__gasync_ready_callback, g_object_ref (self));
	}
}

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

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

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

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

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

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);
}

