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

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <json-glib/json-glib.h>
#include <adwaita.h>
#include <float.h>
#include <math.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_CHATMAIL_RELAY (dc_chatmail_relay_get_type ())
typedef struct _DcChatmailRelay DcChatmailRelay;

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

typedef struct _DcRelayPicker DcRelayPicker;
typedef struct _DcRelayPickerClass DcRelayPickerClass;
typedef struct _DcRelayPickerPrivate DcRelayPickerPrivate;

#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_RELAY_PICKER_0_PROPERTY,
	DC_RELAY_PICKER_NUM_PROPERTIES
};
static GParamSpec* dc_relay_picker_properties[DC_RELAY_PICKER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DcRelayPickerRunDiscoverData DcRelayPickerRunDiscoverData;
typedef struct _Block122Data Block122Data;
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
typedef struct _DcRelayPickerDiscoverFromContactsData DcRelayPickerDiscoverFromContactsData;
typedef struct _DcRelayPickerCollectContactDomainsData DcRelayPickerCollectContactDomainsData;

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

typedef struct _DcRelaysDialog DcRelaysDialog;
typedef struct _DcRelaysDialogClass DcRelaysDialogClass;
typedef struct _DcRelaysDialogPrivate DcRelaysDialogPrivate;

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

typedef struct _DcEventHandler DcEventHandler;
typedef struct _DcEventHandlerClass DcEventHandlerClass;
enum  {
	DC_RELAYS_DIALOG_0_PROPERTY,
	DC_RELAYS_DIALOG_NUM_PROPERTIES
};
static GParamSpec* dc_relays_dialog_properties[DC_RELAYS_DIALOG_NUM_PROPERTIES];

#define DC_TYPE_ENTERED_LOGIN_PARAMS (dc_entered_login_params_get_type ())
#define DC_ENTERED_LOGIN_PARAMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_ENTERED_LOGIN_PARAMS, DcEnteredLoginParams))
#define DC_ENTERED_LOGIN_PARAMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_ENTERED_LOGIN_PARAMS, DcEnteredLoginParamsClass))
#define DC_IS_ENTERED_LOGIN_PARAMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_ENTERED_LOGIN_PARAMS))
#define DC_IS_ENTERED_LOGIN_PARAMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_ENTERED_LOGIN_PARAMS))
#define DC_ENTERED_LOGIN_PARAMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_ENTERED_LOGIN_PARAMS, DcEnteredLoginParamsClass))

typedef struct _DcEnteredLoginParams DcEnteredLoginParams;
typedef struct _DcEnteredLoginParamsClass DcEnteredLoginParamsClass;
typedef struct _DcRelaysDialogRefreshListData DcRelaysDialogRefreshListData;
typedef struct _Block123Data Block123Data;

#define DC_TYPE_CLASSIC_EMAIL_DIALOG (dc_classic_email_dialog_get_type ())
#define DC_CLASSIC_EMAIL_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CLASSIC_EMAIL_DIALOG, DcClassicEmailDialog))
#define DC_CLASSIC_EMAIL_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CLASSIC_EMAIL_DIALOG, DcClassicEmailDialogClass))
#define DC_IS_CLASSIC_EMAIL_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CLASSIC_EMAIL_DIALOG))
#define DC_IS_CLASSIC_EMAIL_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CLASSIC_EMAIL_DIALOG))
#define DC_CLASSIC_EMAIL_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CLASSIC_EMAIL_DIALOG, DcClassicEmailDialogClass))

typedef struct _DcClassicEmailDialog DcClassicEmailDialog;
typedef struct _DcClassicEmailDialogClass DcClassicEmailDialogClass;
typedef struct _DcRelaysDialogConfirmDeleteRelayData DcRelaysDialogConfirmDeleteRelayData;
typedef struct _DcRelaysDialogDoDeleteRelayData DcRelaysDialogDoDeleteRelayData;
typedef struct _DcRelaysDialogDoAddRelayData DcRelaysDialogDoAddRelayData;

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

struct _DcRelayPicker {
	GtkBox parent_instance;
	DcRelayPickerPrivate * priv;
};

struct _DcRelayPickerClass {
	GtkBoxClass parent_class;
};

struct _DcRelayPickerPrivate {
	GtkDropDown* dropdown;
	GtkStringList* model;
	GtkEntry* custom_entry;
	GPtrArray* domains;
	DcRpcClient* rpc;
	GtkButton* discover_btn;
	gboolean discovered;
};

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

struct _Block122Data {
	int _ref_count_;
	DcRelayPicker* self;
	gint added;
	gpointer _async_data_;
};

struct _DcRelayPickerDiscoverFromContactsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcRelayPicker* self;
	DcRpcClient* rpc;
	gint result;
	Block122Data* _data122_;
	GHashTable* counts;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	JsonNode* accounts_node;
	JsonNode* _tmp3_;
	gboolean _tmp4_;
	JsonNode* _tmp5_;
	JsonNode* _tmp6_;
	JsonArray* accounts;
	JsonNode* _tmp7_;
	JsonArray* _tmp8_;
	JsonArray* _tmp9_;
	guint a;
	gboolean _tmp10_;
	guint _tmp11_;
	JsonArray* _tmp12_;
	JsonObject* acct;
	JsonArray* _tmp13_;
	JsonObject* _tmp14_;
	JsonObject* _tmp15_;
	JsonObject* _tmp16_;
	gint aid;
	JsonObject* _tmp17_;
	GHashTable* _tmp18_;
	GHashTable* _tmp19_;
	GError* _inner_error0_;
};

struct _DcRelayPickerCollectContactDomainsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcRelayPicker* self;
	DcRpcClient* rpc;
	gint aid;
	GHashTable* counts;
	JsonArray* ids;
	JsonArray* _tmp0_;
	JsonArray* _tmp1_;
	guint i;
	gboolean _tmp2_;
	guint _tmp3_;
	JsonArray* _tmp4_;
	gint cid;
	JsonArray* _tmp5_;
	JsonObject* obj;
	JsonObject* _tmp6_;
	JsonObject* _tmp7_;
	gchar* _tmp8_;
	JsonObject* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* addr;
	gchar* _tmp12_;
	gint at;
	const gchar* _tmp13_;
	gboolean _tmp14_;
	const gchar* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	gchar* domain;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	const gchar* _tmp25_;
	gint _tmp26_;
	gint _tmp27_;
	gint prev;
	const gchar* _tmp28_;
	gconstpointer _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_;
	GError* _inner_error0_;
};

struct _DcRelaysDialog {
	AdwDialog parent_instance;
	DcRelaysDialogPrivate * priv;
};

struct _DcRelaysDialogClass {
	AdwDialogClass parent_class;
};

struct _DcRelaysDialogPrivate {
	DcRpcClient* rpc;
	DcEventHandler* events;
	gint account_id;
	GtkListBox* list_box;
	GtkStack* list_stack;
	GtkLabel* empty_label;
	DcRelayPicker* picker;
	GtkButton* add_btn;
	gboolean busy;
};

struct _DcRelaysDialogRefreshListData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcRelaysDialog* self;
	GtkListBox* _tmp0_;
	JsonNode* _result_;
	JsonNode* _tmp1_;
	DcRpcClient* _tmp2_;
	JsonNode* _tmp3_;
	JsonNode* _tmp4_;
	GError* e;
	GError* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkStack* _tmp9_;
	gboolean _tmp10_;
	JsonNode* _tmp11_;
	JsonNode* _tmp12_;
	GtkStack* _tmp13_;
	JsonArray* arr;
	JsonNode* _tmp14_;
	JsonArray* _tmp15_;
	JsonArray* _tmp16_;
	JsonArray* _tmp17_;
	GtkStack* _tmp18_;
	guint i;
	gboolean _tmp19_;
	guint _tmp20_;
	JsonArray* _tmp21_;
	JsonNode* node;
	JsonArray* _tmp22_;
	JsonNode* _tmp23_;
	JsonNode* _tmp24_;
	gboolean _tmp25_;
	JsonNode* _tmp26_;
	JsonNode* _tmp27_;
	JsonObject* obj;
	JsonNode* _tmp28_;
	JsonObject* _tmp29_;
	JsonObject* _tmp30_;
	gchar* _tmp31_;
	JsonObject* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* addr;
	gchar* _tmp35_;
	const gchar* _tmp36_;
	gint _tmp37_;
	gint _tmp38_;
	GtkListBox* _tmp39_;
	const gchar* _tmp40_;
	JsonObject* _tmp41_;
	DcEnteredLoginParams* _tmp42_;
	DcEnteredLoginParams* _tmp43_;
	GtkWidget* _tmp44_;
	GtkWidget* _tmp45_;
	GtkStack* _tmp46_;
	GError* _inner_error0_;
};

struct _Block123Data {
	int _ref_count_;
	DcRelaysDialog* self;
	gchar* addr;
	DcEnteredLoginParams* params;
};

struct _DcRelaysDialogConfirmDeleteRelayData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcRelaysDialog* self;
	gchar* addr;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
};

struct _DcRelaysDialogDoDeleteRelayData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcRelaysDialog* self;
	gchar* addr;
	DcRpcClient* _tmp0_;
	GError* e;
	GError* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GError* _inner_error0_;
};

struct _DcRelaysDialogDoAddRelayData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcRelaysDialog* self;
	GtkButton* _tmp0_;
	gchar* qr;
	DcRelayPicker* _tmp1_;
	gchar* _tmp2_;
	DcRpcClient* _tmp3_;
	const gchar* _tmp4_;
	GError* e;
	GError* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkButton* _tmp9_;
	GtkButton* _tmp10_;
	GError* _inner_error0_;
};

static gint DcRelayPicker_private_offset;
static gpointer dc_relay_picker_parent_class = NULL;
static gint DcRelaysDialog_private_offset;
static gpointer dc_relays_dialog_parent_class = NULL;

VALA_EXTERN GType dc_chatmail_relay_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DcChatmailRelay* dc_chatmail_relay_dup (const DcChatmailRelay* self);
VALA_EXTERN void dc_chatmail_relay_free (DcChatmailRelay* self);
VALA_EXTERN gchar* dc_build_chatmail_qr (const gchar* domain);
VALA_EXTERN GType dc_relay_picker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRelayPicker, 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 DcRelayPicker* dc_relay_picker_new (DcRpcClient* rpc);
VALA_EXTERN DcRelayPicker* dc_relay_picker_construct (GType object_type,
                                          DcRpcClient* rpc);
static void _g_free0_ (gpointer var);
static void __lambda142_ (DcRelayPicker* self);
static void ___lambda142__gtk_editable_changed (GtkEditable* _sender,
                                         gpointer self);
static void ___lambda143_ (DcRelayPicker* self);
static void dc_relay_picker_run_discover (DcRelayPicker* self,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
static void dc_relay_picker_run_discover_finish (DcRelayPicker* self,
                                          GAsyncResult* _res_);
static void ____lambda143__gtk_button_clicked (GtkButton* _sender,
                                        gpointer self);
static void dc_relay_picker_run_discover_data_free (gpointer _data);
static gboolean dc_relay_picker_run_discover_co (DcRelayPickerRunDiscoverData* _data_);
VALA_EXTERN void dc_relay_picker_discover_from_contacts (DcRelayPicker* self,
                                             DcRpcClient* rpc,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN gint dc_relay_picker_discover_from_contacts_finish (DcRelayPicker* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
static void dc_relay_picker_run_discover_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
VALA_EXTERN void dc_show_error (GtkWidget* parent,
                    const gchar* message);
VALA_EXTERN gchar* dc_relay_picker_get_selected_domain (DcRelayPicker* self);
VALA_EXTERN gchar* dc_relay_picker_get_chatmail_qr (DcRelayPicker* self);
VALA_EXTERN gboolean dc_relay_picker_add_domain (DcRelayPicker* self,
                                     const gchar* domain,
                                     const gchar* note);
static void dc_relay_picker_discover_from_contacts_data_free (gpointer _data);
static gboolean dc_relay_picker_discover_from_contacts_co (DcRelayPickerDiscoverFromContactsData* _data_);
static Block122Data* block122_data_ref (Block122Data* _data122_);
static void block122_data_unref (void * _userdata_);
VALA_EXTERN void dc_rpc_client_get_all_accounts (DcRpcClient* self,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN JsonNode* dc_rpc_client_get_all_accounts_finish (DcRpcClient* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
static void dc_relay_picker_discover_from_contacts_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void dc_relay_picker_collect_contact_domains (DcRelayPicker* self,
                                              DcRpcClient* rpc,
                                              gint aid,
                                              GHashTable* counts,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
static void dc_relay_picker_collect_contact_domains_finish (DcRelayPicker* self,
                                                     GAsyncResult* _res_,
                                                     GError** error);
static void _vala_JsonNode_free (JsonNode* self);
static void __lambda144_ (Block122Data* _data122_,
                   const gchar* domain,
                   gint count);
static void ___lambda144__gh_func (gconstpointer key,
                            gconstpointer value,
                            gpointer self);
static void dc_relay_picker_collect_contact_domains_data_free (gpointer _data);
static gboolean dc_relay_picker_collect_contact_domains_co (DcRelayPickerCollectContactDomainsData* _data_);
VALA_EXTERN void dc_rpc_client_get_contact_ids_for (DcRpcClient* self,
                                        gint acct_id,
                                        const gchar* query,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
VALA_EXTERN JsonArray* dc_rpc_client_get_contact_ids_for_finish (DcRpcClient* self,
                                                     GAsyncResult* _res_,
                                                     GError** error);
static void dc_relay_picker_collect_contact_domains_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_get_contact_for (DcRpcClient* self,
                                    gint acct_id,
                                    gint contact_id,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
VALA_EXTERN JsonObject* dc_rpc_client_get_contact_for_finish (DcRpcClient* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
VALA_EXTERN gchar* dc_json_str (JsonObject* obj,
                    const gchar* key);
static void dc_relay_picker_finalize (GObject * obj);
static GType dc_relay_picker_get_type_once (void);
VALA_EXTERN GType dc_relays_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRelaysDialog, g_object_unref)
VALA_EXTERN GType dc_event_handler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcEventHandler, g_object_unref)
VALA_EXTERN DcRelaysDialog* dc_relays_dialog_new (DcRpcClient* rpc,
                                      DcEventHandler* events,
                                      gint acct_id);
VALA_EXTERN DcRelaysDialog* dc_relays_dialog_construct (GType object_type,
                                            DcRpcClient* rpc,
                                            DcEventHandler* events,
                                            gint acct_id);
static void __lambda145_ (DcRelaysDialog* self);
static void dc_relays_dialog_do_add_relay (DcRelaysDialog* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void dc_relays_dialog_do_add_relay_finish (DcRelaysDialog* self,
                                           GAsyncResult* _res_);
static void ___lambda145__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN void dc_install_escape_close (AdwDialog* dialog);
static void dc_relays_dialog_refresh_list (DcRelaysDialog* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void dc_relays_dialog_refresh_list_finish (DcRelaysDialog* self,
                                           GAsyncResult* _res_);
static void dc_relays_dialog_refresh_list_data_free (gpointer _data);
static gboolean dc_relays_dialog_refresh_list_co (DcRelaysDialogRefreshListData* _data_);
VALA_EXTERN void dc_clear_listbox (GtkListBox* lb);
VALA_EXTERN void dc_rpc_client_list_transports (DcRpcClient* self,
                                    gint acct_id,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
VALA_EXTERN JsonNode* dc_rpc_client_list_transports_finish (DcRpcClient* self,
                                                GAsyncResult* _res_,
                                                GError** error);
static void dc_relays_dialog_refresh_list_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
VALA_EXTERN GType dc_entered_login_params_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcEnteredLoginParams, g_object_unref)
static GtkWidget* dc_relays_dialog_build_relay_row (DcRelaysDialog* self,
                                             const gchar* addr,
                                             DcEnteredLoginParams* params);
VALA_EXTERN DcEnteredLoginParams* dc_entered_login_params_from_json (JsonObject* obj);
static Block123Data* block123_data_ref (Block123Data* _data123_);
static void block123_data_unref (void * _userdata_);
static void __lambda146_ (Block123Data* _data123_);
static void dc_relays_dialog_show_edit_transport_dialog (DcRelaysDialog* self,
                                                  DcEnteredLoginParams* params);
static void ___lambda146__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void __lambda152_ (Block123Data* _data123_);
static void dc_relays_dialog_confirm_delete_relay (DcRelaysDialog* self,
                                            const gchar* addr,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
static void dc_relays_dialog_confirm_delete_relay_finish (DcRelaysDialog* self,
                                                   GAsyncResult* _res_);
static void ___lambda152__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
VALA_EXTERN GType dc_classic_email_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcClassicEmailDialog, g_object_unref)
VALA_EXTERN DcClassicEmailDialog* dc_classic_email_dialog_new_for_edit (DcRpcClient* rpc,
                                                            DcEventHandler* events,
                                                            gint account_id,
                                                            DcEnteredLoginParams* current);
VALA_EXTERN DcClassicEmailDialog* dc_classic_email_dialog_construct_for_edit (GType object_type,
                                                                  DcRpcClient* rpc,
                                                                  DcEventHandler* events,
                                                                  gint account_id,
                                                                  DcEnteredLoginParams* current);
static void __lambda151_ (DcRelaysDialog* self);
static void ___lambda151__dc_classic_email_dialog_transport_updated (DcClassicEmailDialog* _sender,
                                                              gpointer self);
static void dc_relays_dialog_confirm_delete_relay_data_free (gpointer _data);
static gboolean dc_relays_dialog_confirm_delete_relay_co (DcRelaysDialogConfirmDeleteRelayData* _data_);
VALA_EXTERN void dc_confirm_action (GtkWidget* parent,
                        const gchar* title,
                        const gchar* body,
                        const gchar* action_id,
                        const gchar* action_label,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_);
VALA_EXTERN gboolean dc_confirm_action_finish (GAsyncResult* _res_);
static void dc_relays_dialog_confirm_delete_relay_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void dc_relays_dialog_do_delete_relay (DcRelaysDialog* self,
                                       const gchar* addr,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static void dc_relays_dialog_do_delete_relay_finish (DcRelaysDialog* self,
                                              GAsyncResult* _res_);
static void dc_relays_dialog_do_delete_relay_data_free (gpointer _data);
static gboolean dc_relays_dialog_do_delete_relay_co (DcRelaysDialogDoDeleteRelayData* _data_);
VALA_EXTERN void dc_rpc_client_delete_transport (DcRpcClient* self,
                                     gint acct_id,
                                     const gchar* addr,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_delete_transport_finish (DcRpcClient* self,
                                            GAsyncResult* _res_,
                                            GError** error);
static void dc_relays_dialog_do_delete_relay_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_);
static void dc_relays_dialog_do_add_relay_data_free (gpointer _data);
static gboolean dc_relays_dialog_do_add_relay_co (DcRelaysDialogDoAddRelayData* _data_);
VALA_EXTERN void dc_rpc_client_add_transport_from_qr (DcRpcClient* self,
                                          gint acct_id,
                                          const gchar* qr_text,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN void dc_rpc_client_add_transport_from_qr_finish (DcRpcClient* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
static void dc_relays_dialog_do_add_relay_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void dc_relays_dialog_finalize (GObject * obj);
static GType dc_relays_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

const DcChatmailRelay DC_CHATMAIL_RELAYS[26] = {{"nine.testrun.org", "Default"}, {"mehl.cloud", "German"}, {"mailchat.pl", "Poland"}, {"chatmail.woodpeckersnest.space", "Italy"}, {"chatmail.culturanerd.it", "Italy"}, {"chat.adminforge.de", "Falkenstein, Germany"}, {"chika.aangat.lahat.computer", "Santa Clara, USA"}, {"tarpit.fun", "Nuremberg, Germany"}, {"d.gaufr.es", "Roubaix, France"}, {"chtml.ca", "Quebec, Canada"}, {"chatmail.au", "Melbourne, Australia"}, {"e2ee.wang", "Johannesburg, South Africa"}, {"chat.privittytech.com", "Bangalore, India"}, {"e2ee.im", "Orastie, Romania"}, {"chatmail.email", "Warsaw, Poland"}, {"danneskjold.de", "Helsinki, Finland"}, {"chat.in-the.eu", "Falkenstein, Germany"}, {"chat.nuvon.app", "Prague, Czechia"}, {"nibblehole.com", "Zug, Switzerland"}, {"chat.zashm.org", "Lviv, Ukraine"}, {"chat.sus.fr", "Iceland/Japan/Kenya/South Africa"}, {"delta.thelab.uno", "Gravelines, France"}, {"chat.vim.wtf", "Frankfurt, Germany"}, {"uninterest.ing", "Elk Grove Village, USA"}, {"sweetfern.net", "Ashburn, USA"}, {"delta.disobey.net", "Roon, Netherlands"}};

DcChatmailRelay*
dc_chatmail_relay_dup (const DcChatmailRelay* self)
{
	DcChatmailRelay* dup;
	dup = g_new0 (DcChatmailRelay, 1);
	memcpy (dup, self, sizeof (DcChatmailRelay));
	return dup;
}

void
dc_chatmail_relay_free (DcChatmailRelay* self)
{
	g_free (self);
}

static GType
dc_chatmail_relay_get_type_once (void)
{
	GType dc_chatmail_relay_type_id;
	dc_chatmail_relay_type_id = g_boxed_type_register_static ("DcChatmailRelay", (GBoxedCopyFunc) dc_chatmail_relay_dup, (GBoxedFreeFunc) dc_chatmail_relay_free);
	return dc_chatmail_relay_type_id;
}

GType
dc_chatmail_relay_get_type (void)
{
	static volatile gsize dc_chatmail_relay_type_id__once = 0;
	if (g_once_init_enter (&dc_chatmail_relay_type_id__once)) {
		GType dc_chatmail_relay_type_id;
		dc_chatmail_relay_type_id = dc_chatmail_relay_get_type_once ();
		g_once_init_leave (&dc_chatmail_relay_type_id__once, dc_chatmail_relay_type_id);
	}
	return dc_chatmail_relay_type_id__once;
}

/**
     * Builds the canonical chatmail account QR link for a relay domain.
     * The DCACCOUNT scheme expects an HTTPS URL pointing at the relay's
     * /new endpoint.
     */
gchar*
dc_build_chatmail_qr (const gchar* domain)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (domain != NULL, NULL);
	_tmp0_ = g_strdup_printf ("DCACCOUNT:https://%s/new", domain);
	result = _tmp0_;
	return result;
}

static inline gpointer
dc_relay_picker_get_instance_private (DcRelayPicker* self)
{
	return G_STRUCT_MEMBER_P (self, DcRelayPicker_private_offset);
}

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

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), 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
__lambda142_ (DcRelayPicker* self)
{
	GtkDropDown* _tmp0_;
	GtkEntry* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	_tmp0_ = self->priv->dropdown;
	_tmp1_ = self->priv->custom_entry;
	_tmp2_ = gtk_editable_get_text ((GtkEditable*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_strip (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = strlen (_tmp5_);
	_tmp7_ = _tmp6_;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, _tmp7_ == 0);
	_g_free0 (_tmp5_);
}

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

static void
___lambda143_ (DcRelayPicker* self)
{
	dc_relay_picker_run_discover (self, NULL, NULL);
}

static void
____lambda143__gtk_button_clicked (GtkButton* _sender,
                                   gpointer self)
{
	___lambda143_ ((DcRelayPicker*) self);
}

DcRelayPicker*
dc_relay_picker_construct (GType object_type,
                           DcRpcClient* rpc)
{
	DcRelayPicker * self = NULL;
	DcRpcClient* _tmp0_;
	GPtrArray* _tmp1_;
	GtkStringList* _tmp2_;
	GtkStringList* _tmp16_;
	GListModel* _tmp17_;
	GtkDropDown* _tmp18_;
	GtkDropDown* _tmp19_;
	GtkDropDown* _tmp20_;
	GtkEntry* _tmp21_;
	GtkEntry* _tmp22_;
	GtkEntry* _tmp23_;
	GtkEntry* _tmp24_;
	GtkEntry* _tmp25_;
	GtkBox* row = NULL;
	GtkBox* _tmp26_;
	GtkBox* _tmp27_;
	GtkDropDown* _tmp28_;
	GtkBox* _tmp29_;
	GtkEntry* _tmp30_;
	GtkBox* _tmp31_;
	self = (DcRelayPicker*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 8, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	_tmp1_ = g_ptr_array_new_full ((guint) 0, _g_free0_);
	_g_ptr_array_unref0 (self->priv->domains);
	self->priv->domains = _tmp1_;
	_tmp2_ = gtk_string_list_new (NULL);
	_g_object_unref0 (self->priv->model);
	self->priv->model = _tmp2_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				GtkStringList* _tmp5_;
				DcChatmailRelay _tmp6_;
				const gchar* _tmp7_;
				DcChatmailRelay _tmp8_;
				const gchar* _tmp9_;
				gchar* _tmp10_;
				gchar* _tmp11_;
				GPtrArray* _tmp12_;
				DcChatmailRelay _tmp13_;
				const gchar* _tmp14_;
				gchar* _tmp15_;
				if (!_tmp3_) {
					gint _tmp4_;
					_tmp4_ = i;
					i = _tmp4_ + 1;
				}
				_tmp3_ = FALSE;
				if (!(i < G_N_ELEMENTS (DC_CHATMAIL_RELAYS))) {
					break;
				}
				_tmp5_ = self->priv->model;
				_tmp6_ = DC_CHATMAIL_RELAYS[i];
				_tmp7_ = _tmp6_.domain;
				_tmp8_ = DC_CHATMAIL_RELAYS[i];
				_tmp9_ = _tmp8_.location;
				_tmp10_ = g_strdup_printf ("%s (%s)", _tmp7_, _tmp9_);
				_tmp11_ = _tmp10_;
				gtk_string_list_append (_tmp5_, _tmp11_);
				_g_free0 (_tmp11_);
				_tmp12_ = self->priv->domains;
				_tmp13_ = DC_CHATMAIL_RELAYS[i];
				_tmp14_ = _tmp13_.domain;
				_tmp15_ = g_strdup (_tmp14_);
				g_ptr_array_add (_tmp12_, _tmp15_);
			}
		}
	}
	_tmp16_ = self->priv->model;
	_tmp17_ = _g_object_ref0 ((GListModel*) _tmp16_);
	_tmp18_ = (GtkDropDown*) gtk_drop_down_new (_tmp17_, NULL);
	g_object_ref_sink (_tmp18_);
	_g_object_unref0 (self->priv->dropdown);
	self->priv->dropdown = _tmp18_;
	_tmp19_ = self->priv->dropdown;
	gtk_drop_down_set_selected (_tmp19_, (guint) 0);
	_tmp20_ = self->priv->dropdown;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp20_, TRUE);
	_tmp21_ = (GtkEntry*) gtk_entry_new ();
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->custom_entry);
	self->priv->custom_entry = _tmp21_;
	_tmp22_ = self->priv->custom_entry;
	gtk_entry_set_placeholder_text (_tmp22_, "Custom server name");
	_tmp23_ = self->priv->custom_entry;
	gtk_entry_set_activates_default (_tmp23_, TRUE);
	_tmp24_ = self->priv->custom_entry;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp24_, TRUE);
	_tmp25_ = self->priv->custom_entry;
	g_signal_connect_object ((GtkEditable*) _tmp25_, "changed", (GCallback) ___lambda142__gtk_editable_changed, self, 0);
	_tmp26_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp26_);
	row = _tmp26_;
	_tmp27_ = row;
	_tmp28_ = self->priv->dropdown;
	gtk_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = row;
	_tmp30_ = self->priv->custom_entry;
	gtk_box_append (_tmp29_, (GtkWidget*) _tmp30_);
	_tmp31_ = row;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp31_);
	if (rpc != NULL) {
		GtkButton* _tmp32_;
		GtkButton* _tmp33_;
		GtkButton* _tmp34_;
		GtkButton* _tmp35_;
		GtkButton* _tmp36_;
		GtkButton* _tmp37_;
		_tmp32_ = (GtkButton*) gtk_button_new_with_label ("Discover from Contacts");
		g_object_ref_sink (_tmp32_);
		_g_object_unref0 (self->priv->discover_btn);
		self->priv->discover_btn = _tmp32_;
		_tmp33_ = self->priv->discover_btn;
		gtk_widget_set_halign ((GtkWidget*) _tmp33_, GTK_ALIGN_START);
		_tmp34_ = self->priv->discover_btn;
		gtk_widget_add_css_class ((GtkWidget*) _tmp34_, "flat");
		_tmp35_ = self->priv->discover_btn;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp35_, "Scan contacts on your other profiles and add the relays they use.");
		_tmp36_ = self->priv->discover_btn;
		g_signal_connect_object (_tmp36_, "clicked", (GCallback) ____lambda143__gtk_button_clicked, self, 0);
		_tmp37_ = self->priv->discover_btn;
		gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp37_);
	}
	_g_object_unref0 (row);
	return self;
}

DcRelayPicker*
dc_relay_picker_new (DcRpcClient* rpc)
{
	return dc_relay_picker_construct (DC_TYPE_RELAY_PICKER, rpc);
}

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

static void
dc_relay_picker_run_discover (DcRelayPicker* self,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	DcRelayPickerRunDiscoverData* _data_;
	DcRelayPicker* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcRelayPickerRunDiscoverData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_relay_picker_run_discover_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_relay_picker_run_discover_co (_data_);
}

static void
dc_relay_picker_run_discover_finish (DcRelayPicker* self,
                                     GAsyncResult* _res_)
{
	DcRelayPickerRunDiscoverData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_relay_picker_run_discover_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	DcRelayPickerRunDiscoverData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_relay_picker_run_discover_co (_data_);
}

static gboolean
dc_relay_picker_run_discover_co (DcRelayPickerRunDiscoverData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->rpc;
	if (_data_->_tmp1_ == NULL) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp0_ = _data_->self->priv->discovered;
	}
	if (_data_->_tmp0_) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = _data_->self->priv->discover_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp2_, FALSE);
	_data_->_tmp3_ = _data_->self->priv->discover_btn;
	_data_->_tmp4_ = gtk_button_get_label (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = g_strdup (_data_->_tmp5_);
	_data_->original = _data_->_tmp6_;
	_data_->_tmp7_ = _data_->self->priv->discover_btn;
	gtk_button_set_label (_data_->_tmp7_, "Scanning…");
	_data_->added = 0;
	{
		_data_->_tmp9_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_relay_picker_discover_from_contacts (_data_->self, _data_->_tmp9_, dc_relay_picker_run_discover_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp8_ = dc_relay_picker_discover_from_contacts_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->added = _data_->_tmp8_;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp10_ = _data_->self->priv->discover_btn;
		_data_->_tmp11_ = _data_->original;
		gtk_button_set_label (_data_->_tmp10_, _data_->_tmp11_);
		_data_->_tmp12_ = _data_->self->priv->discover_btn;
		gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp12_, TRUE);
		_data_->_tmp13_ = _data_->e;
		_data_->_tmp14_ = _data_->_tmp13_->message;
		_data_->_tmp15_ = g_strconcat ("Failed to scan contacts: ", _data_->_tmp14_, NULL);
		_data_->_tmp16_ = _data_->_tmp15_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp16_);
		_g_free0 (_data_->_tmp16_);
		_g_error_free0 (_data_->e);
		_g_free0 (_data_->original);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->original);
		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_->self->priv->discovered = TRUE;
	if (_data_->added > 0) {
		_data_->_tmp18_ = g_strdup_printf ("Found %d new", _data_->added);
		_g_free0 (_data_->_tmp17_);
		_data_->_tmp17_ = _data_->_tmp18_;
	} else {
		_data_->_tmp19_ = g_strdup ("No new relays");
		_g_free0 (_data_->_tmp17_);
		_data_->_tmp17_ = _data_->_tmp19_;
	}
	_data_->_tmp20_ = _data_->self->priv->discover_btn;
	gtk_button_set_label (_data_->_tmp20_, _data_->_tmp17_);
	_g_free0 (_data_->_tmp17_);
	_g_free0 (_data_->original);
	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 gint
vala_g_ptr_array_get_length (GPtrArray* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = (gint) self->len;
	return result;
}

gchar*
dc_relay_picker_get_selected_domain (DcRelayPicker* self)
{
	gchar* custom = NULL;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gint idx = 0;
	GtkDropDown* _tmp7_;
	guint _tmp8_;
	guint _tmp9_;
	gboolean _tmp10_ = FALSE;
	GPtrArray* _tmp14_;
	gconstpointer _tmp15_;
	gchar* _tmp16_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->custom_entry;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_strip (_tmp2_);
	custom = _tmp3_;
	_tmp4_ = custom;
	_tmp5_ = strlen (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ > 0) {
		result = custom;
		return result;
	}
	_tmp7_ = self->priv->dropdown;
	_tmp8_ = gtk_drop_down_get_selected (_tmp7_);
	_tmp9_ = _tmp8_;
	idx = (gint) _tmp9_;
	if (idx < 0) {
		_tmp10_ = TRUE;
	} else {
		GPtrArray* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		_tmp11_ = self->priv->domains;
		_tmp12_ = vala_g_ptr_array_get_length (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp10_ = idx >= ((gint) _tmp13_);
	}
	if (_tmp10_) {
		idx = 0;
	}
	_tmp14_ = self->priv->domains;
	_tmp15_ = g_ptr_array_index (_tmp14_, (guint) idx);
	_tmp16_ = g_strdup ((const gchar*) _tmp15_);
	result = _tmp16_;
	_g_free0 (custom);
	return result;
}

gchar*
dc_relay_picker_get_chatmail_qr (DcRelayPicker* self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dc_relay_picker_get_selected_domain (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = dc_build_chatmail_qr (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	result = _tmp3_;
	return result;
}

/**
         * Append a domain entry to the dropdown if it isn't already present.
         * `note` is shown in parentheses after the domain.
         * Returns true when a new entry was added.
         */
gboolean
dc_relay_picker_add_domain (DcRelayPicker* self,
                            const gchar* domain,
                            const gchar* note)
{
	gint _tmp0_;
	gint _tmp1_;
	GtkStringList* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GPtrArray* _tmp12_;
	gchar* _tmp13_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (domain != NULL, FALSE);
	g_return_val_if_fail (note != NULL, FALSE);
	_tmp0_ = strlen (domain);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == 0) {
		result = FALSE;
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				GPtrArray* _tmp4_;
				gint _tmp5_;
				gint _tmp6_;
				GPtrArray* _tmp7_;
				gconstpointer _tmp8_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = self->priv->domains;
				_tmp5_ = vala_g_ptr_array_get_length (_tmp4_);
				_tmp6_ = _tmp5_;
				if (!(i < ((gint) _tmp6_))) {
					break;
				}
				_tmp7_ = self->priv->domains;
				_tmp8_ = g_ptr_array_index (_tmp7_, (guint) i);
				if (g_strcmp0 ((const gchar*) _tmp8_, domain) == 0) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	_tmp9_ = self->priv->model;
	_tmp10_ = g_strdup_printf ("%s (%s)", domain, note);
	_tmp11_ = _tmp10_;
	gtk_string_list_append (_tmp9_, _tmp11_);
	_g_free0 (_tmp11_);
	_tmp12_ = self->priv->domains;
	_tmp13_ = g_strdup (domain);
	g_ptr_array_add (_tmp12_, _tmp13_);
	result = TRUE;
	return result;
}

static void
dc_relay_picker_discover_from_contacts_data_free (gpointer _data)
{
	DcRelayPickerDiscoverFromContactsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->rpc);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcRelayPickerDiscoverFromContactsData, _data_);
}

void
dc_relay_picker_discover_from_contacts (DcRelayPicker* self,
                                        DcRpcClient* rpc,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	DcRelayPickerDiscoverFromContactsData* _data_;
	DcRelayPicker* _tmp0_;
	DcRpcClient* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (rpc != NULL);
	_data_ = g_slice_new0 (DcRelayPickerDiscoverFromContactsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_relay_picker_discover_from_contacts_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (rpc);
	_g_object_unref0 (_data_->rpc);
	_data_->rpc = _tmp1_;
	dc_relay_picker_discover_from_contacts_co (_data_);
}

gint
dc_relay_picker_discover_from_contacts_finish (DcRelayPicker* self,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	gint result;
	DcRelayPickerDiscoverFromContactsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gint _tmp0_ = 0;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

/**
         * Scan known contacts across every configured account (purely local,
         * no network round-trips), pull the domain out of each address, and
         * append the unique ones to the dropdown. Returns how many new
         * domains were added.
         */
static Block122Data*
block122_data_ref (Block122Data* _data122_)
{
	g_atomic_int_inc (&_data122_->_ref_count_);
	return _data122_;
}

static void
block122_data_unref (void * _userdata_)
{
	Block122Data* _data122_;
	_data122_ = (Block122Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data122_->_ref_count_)) {
		DcRelayPicker* self;
		self = _data122_->self;
		_g_object_unref0 (self);
		g_slice_free (Block122Data, _data122_);
	}
}

static void
dc_relay_picker_discover_from_contacts_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	DcRelayPickerDiscoverFromContactsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_relay_picker_discover_from_contacts_co (_data_);
}

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

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

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

static void
__lambda144_ (Block122Data* _data122_,
              const gchar* domain,
              gint count)
{
	DcRelayPicker* self;
	gchar* _tmp0_ = NULL;
	gchar* note = NULL;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	self = _data122_->self;
	g_return_if_fail (domain != NULL);
	if (count == 1) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("1 contact");
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp1_;
	} else {
		gchar* _tmp2_;
		_tmp2_ = g_strdup_printf ("%d contacts", count);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp2_;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	note = _tmp3_;
	_tmp4_ = note;
	if (dc_relay_picker_add_domain (self, domain, _tmp4_)) {
		gint _tmp5_;
		_tmp5_ = _data122_->added;
		_data122_->added = _tmp5_ + 1;
	}
	_g_free0 (note);
	_g_free0 (_tmp0_);
}

static void
___lambda144__gh_func (gconstpointer key,
                       gconstpointer value,
                       gpointer self)
{
	__lambda144_ (self, (const gchar*) key, (gint) ((gintptr) value));
}

static gboolean
dc_relay_picker_discover_from_contacts_co (DcRelayPickerDiscoverFromContactsData* _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_->_data122_ = g_slice_new0 (Block122Data);
	_data_->_data122_->_ref_count_ = 1;
	_data_->_data122_->self = g_object_ref (_data_->self);
	_data_->_data122_->_async_data_ = _data_;
	_data_->_tmp0_ = g_str_hash;
	_data_->_tmp1_ = g_str_equal;
	_data_->_tmp2_ = g_hash_table_new_full (_data_->_tmp0_, _data_->_tmp1_, _g_free0_, NULL);
	_data_->counts = _data_->_tmp2_;
	_data_->_state_ = 1;
	dc_rpc_client_get_all_accounts (_data_->rpc, dc_relay_picker_discover_from_contacts_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp3_ = dc_rpc_client_get_all_accounts_finish (_data_->rpc, _data_->_res_, &_data_->_inner_error0_);
	_data_->accounts_node = _data_->_tmp3_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_hash_table_unref0 (_data_->counts);
		block122_data_unref (_data_->_data122_);
		_data_->_data122_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->accounts_node;
	if (_data_->_tmp5_ != NULL) {
		_data_->_tmp6_ = _data_->accounts_node;
		_data_->_tmp4_ = json_node_get_node_type (_data_->_tmp6_) == JSON_NODE_ARRAY;
	} else {
		_data_->_tmp4_ = FALSE;
	}
	if (_data_->_tmp4_) {
		_data_->_tmp7_ = _data_->accounts_node;
		_data_->_tmp8_ = json_node_get_array (_data_->_tmp7_);
		_data_->_tmp9_ = _json_array_ref0 (_data_->_tmp8_);
		_data_->accounts = _data_->_tmp9_;
		{
			_data_->a = (guint) 0;
			{
				_data_->_tmp10_ = TRUE;
				while (TRUE) {
					if (!_data_->_tmp10_) {
						_data_->_tmp11_ = _data_->a;
						_data_->a = _data_->_tmp11_ + 1;
					}
					_data_->_tmp10_ = FALSE;
					_data_->_tmp12_ = _data_->accounts;
					if (!(_data_->a < json_array_get_length (_data_->_tmp12_))) {
						break;
					}
					_data_->_tmp13_ = _data_->accounts;
					_data_->_tmp14_ = json_array_get_object_element (_data_->_tmp13_, _data_->a);
					_data_->_tmp15_ = _json_object_ref0 (_data_->_tmp14_);
					_data_->acct = _data_->_tmp15_;
					_data_->_tmp16_ = _data_->acct;
					if (_data_->_tmp16_ == NULL) {
						_json_object_unref0 (_data_->acct);
						continue;
					}
					_data_->_tmp17_ = _data_->acct;
					_data_->aid = (gint) json_object_get_int_member (_data_->_tmp17_, "id");
					if (_data_->aid <= 0) {
						_json_object_unref0 (_data_->acct);
						continue;
					}
					_data_->_tmp18_ = _data_->counts;
					_data_->_state_ = 2;
					dc_relay_picker_collect_contact_domains (_data_->self, _data_->rpc, _data_->aid, _data_->_tmp18_, dc_relay_picker_discover_from_contacts_ready, _data_);
					return FALSE;
					_state_2:
					dc_relay_picker_collect_contact_domains_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
						_json_object_unref0 (_data_->acct);
						_json_array_unref0 (_data_->accounts);
						__vala_JsonNode_free0 (_data_->accounts_node);
						_g_hash_table_unref0 (_data_->counts);
						block122_data_unref (_data_->_data122_);
						_data_->_data122_ = NULL;
						g_object_unref (_data_->_async_result);
						return FALSE;
					}
					_json_object_unref0 (_data_->acct);
				}
			}
		}
		_json_array_unref0 (_data_->accounts);
	}
	_data_->_data122_->added = 0;
	_data_->_tmp19_ = _data_->counts;
	g_hash_table_foreach (_data_->_tmp19_, ___lambda144__gh_func, _data_->_data122_);
	_data_->result = _data_->_data122_->added;
	__vala_JsonNode_free0 (_data_->accounts_node);
	_g_hash_table_unref0 (_data_->counts);
	block122_data_unref (_data_->_data122_);
	_data_->_data122_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_relay_picker_collect_contact_domains_data_free (gpointer _data)
{
	DcRelayPickerCollectContactDomainsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->rpc);
	_g_hash_table_unref0 (_data_->counts);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcRelayPickerCollectContactDomainsData, _data_);
}

static gpointer
_g_hash_table_ref0 (gpointer self)
{
	return self ? g_hash_table_ref (self) : NULL;
}

static void
dc_relay_picker_collect_contact_domains (DcRelayPicker* self,
                                         DcRpcClient* rpc,
                                         gint aid,
                                         GHashTable* counts,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_)
{
	DcRelayPickerCollectContactDomainsData* _data_;
	DcRelayPicker* _tmp0_;
	DcRpcClient* _tmp1_;
	GHashTable* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (rpc != NULL);
	g_return_if_fail (counts != NULL);
	_data_ = g_slice_new0 (DcRelayPickerCollectContactDomainsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_relay_picker_collect_contact_domains_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (rpc);
	_g_object_unref0 (_data_->rpc);
	_data_->rpc = _tmp1_;
	_data_->aid = aid;
	_tmp2_ = _g_hash_table_ref0 (counts);
	_g_hash_table_unref0 (_data_->counts);
	_data_->counts = _tmp2_;
	dc_relay_picker_collect_contact_domains_co (_data_);
}

static void
dc_relay_picker_collect_contact_domains_finish (DcRelayPicker* self,
                                                GAsyncResult* _res_,
                                                GError** error)
{
	DcRelayPickerCollectContactDomainsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
dc_relay_picker_collect_contact_domains_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_)
{
	DcRelayPickerCollectContactDomainsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_relay_picker_collect_contact_domains_co (_data_);
}

static gint
string_index_of_char (const gchar* self,
                      gunichar c,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_strchr (((gchar*) self) + start_index, (gssize) -1, c);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

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 gboolean
dc_relay_picker_collect_contact_domains_co (DcRelayPickerCollectContactDomainsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	dc_rpc_client_get_contact_ids_for (_data_->rpc, _data_->aid, NULL, dc_relay_picker_collect_contact_domains_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = dc_rpc_client_get_contact_ids_for_finish (_data_->rpc, _data_->_res_, &_data_->_inner_error0_);
	_data_->ids = _data_->_tmp0_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp1_ = _data_->ids;
	if (_data_->_tmp1_ == NULL) {
		_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_->i = (guint) 0;
		{
			_data_->_tmp2_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp2_) {
					_data_->_tmp3_ = _data_->i;
					_data_->i = _data_->_tmp3_ + 1;
				}
				_data_->_tmp2_ = FALSE;
				_data_->_tmp4_ = _data_->ids;
				if (!(_data_->i < json_array_get_length (_data_->_tmp4_))) {
					break;
				}
				_data_->_tmp5_ = _data_->ids;
				_data_->cid = (gint) json_array_get_int_element (_data_->_tmp5_, _data_->i);
				if (_data_->cid <= 1) {
					continue;
				}
				_data_->_state_ = 2;
				dc_rpc_client_get_contact_for (_data_->rpc, _data_->aid, _data_->cid, dc_relay_picker_collect_contact_domains_ready, _data_);
				return FALSE;
				_state_2:
				_data_->_tmp6_ = dc_rpc_client_get_contact_for_finish (_data_->rpc, _data_->_res_, &_data_->_inner_error0_);
				_data_->obj = _data_->_tmp6_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
					_json_array_unref0 (_data_->ids);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->_tmp7_ = _data_->obj;
				if (_data_->_tmp7_ == NULL) {
					_json_object_unref0 (_data_->obj);
					continue;
				}
				_data_->_tmp9_ = _data_->obj;
				_data_->_tmp10_ = dc_json_str (_data_->_tmp9_, "address");
				_data_->_tmp8_ = _data_->_tmp10_;
				if (_data_->_tmp8_ == NULL) {
					_data_->_tmp11_ = g_strdup ("");
					_g_free0 (_data_->_tmp8_);
					_data_->_tmp8_ = _data_->_tmp11_;
				}
				_data_->_tmp12_ = _data_->_tmp8_;
				_data_->_tmp8_ = NULL;
				_data_->addr = _data_->_tmp12_;
				_data_->_tmp13_ = _data_->addr;
				_data_->at = string_index_of_char (_data_->_tmp13_, (gunichar) '@', 0);
				if (_data_->at <= 0) {
					_data_->_tmp14_ = TRUE;
				} else {
					_data_->_tmp15_ = _data_->addr;
					_data_->_tmp16_ = strlen (_data_->_tmp15_);
					_data_->_tmp17_ = _data_->_tmp16_;
					_data_->_tmp14_ = _data_->at >= (_data_->_tmp17_ - 1);
				}
				if (_data_->_tmp14_) {
					_g_free0 (_data_->addr);
					_g_free0 (_data_->_tmp8_);
					_json_object_unref0 (_data_->obj);
					continue;
				}
				_data_->_tmp18_ = _data_->addr;
				_data_->_tmp19_ = string_substring (_data_->_tmp18_, (glong) (_data_->at + 1), (glong) -1);
				_data_->_tmp20_ = _data_->_tmp19_;
				_data_->_tmp21_ = g_utf8_strdown (_data_->_tmp20_, (gssize) -1);
				_data_->_tmp22_ = _data_->_tmp21_;
				_data_->_tmp23_ = string_strip (_data_->_tmp22_);
				_data_->_tmp24_ = _data_->_tmp23_;
				_g_free0 (_data_->_tmp22_);
				_g_free0 (_data_->_tmp20_);
				_data_->domain = _data_->_tmp24_;
				_data_->_tmp25_ = _data_->domain;
				_data_->_tmp26_ = strlen (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				if (_data_->_tmp27_ == 0) {
					_g_free0 (_data_->domain);
					_g_free0 (_data_->addr);
					_g_free0 (_data_->_tmp8_);
					_json_object_unref0 (_data_->obj);
					continue;
				}
				_data_->_tmp28_ = _data_->domain;
				_data_->_tmp29_ = g_hash_table_lookup (_data_->counts, _data_->_tmp28_);
				_data_->prev = (gint) ((gintptr) _data_->_tmp29_);
				_data_->_tmp30_ = _data_->domain;
				_data_->_tmp31_ = g_strdup (_data_->_tmp30_);
				g_hash_table_insert (_data_->counts, _data_->_tmp31_, (gpointer) ((gintptr) (_data_->prev + 1)));
				_g_free0 (_data_->domain);
				_g_free0 (_data_->addr);
				_g_free0 (_data_->_tmp8_);
				_json_object_unref0 (_data_->obj);
			}
		}
	}
	_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_relay_picker_class_init (DcRelayPickerClass * klass,
                            gpointer klass_data)
{
	dc_relay_picker_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcRelayPicker_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_relay_picker_finalize;
}

static void
dc_relay_picker_instance_init (DcRelayPicker * self,
                               gpointer klass)
{
	self->priv = dc_relay_picker_get_instance_private (self);
	self->priv->rpc = NULL;
	self->priv->discover_btn = NULL;
	self->priv->discovered = FALSE;
}

static void
dc_relay_picker_finalize (GObject * obj)
{
	DcRelayPicker * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_RELAY_PICKER, DcRelayPicker);
	_g_object_unref0 (self->priv->dropdown);
	_g_object_unref0 (self->priv->model);
	_g_object_unref0 (self->priv->custom_entry);
	_g_ptr_array_unref0 (self->priv->domains);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->discover_btn);
	G_OBJECT_CLASS (dc_relay_picker_parent_class)->finalize (obj);
}

/**
     * Reusable widget that lets the user pick a chatmail relay from the
     * curated list or type a custom server name. Used both during account
     * creation and when adding extra transports to an existing profile.
     */
static GType
dc_relay_picker_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcRelayPickerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_relay_picker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcRelayPicker), 0, (GInstanceInitFunc) dc_relay_picker_instance_init, NULL };
	GType dc_relay_picker_type_id;
	dc_relay_picker_type_id = g_type_register_static (gtk_box_get_type (), "DcRelayPicker", &g_define_type_info, 0);
	DcRelayPicker_private_offset = g_type_add_instance_private (dc_relay_picker_type_id, sizeof (DcRelayPickerPrivate));
	return dc_relay_picker_type_id;
}

GType
dc_relay_picker_get_type (void)
{
	static volatile gsize dc_relay_picker_type_id__once = 0;
	if (g_once_init_enter (&dc_relay_picker_type_id__once)) {
		GType dc_relay_picker_type_id;
		dc_relay_picker_type_id = dc_relay_picker_get_type_once ();
		g_once_init_leave (&dc_relay_picker_type_id__once, dc_relay_picker_type_id);
	}
	return dc_relay_picker_type_id__once;
}

static inline gpointer
dc_relays_dialog_get_instance_private (DcRelaysDialog* self)
{
	return G_STRUCT_MEMBER_P (self, DcRelaysDialog_private_offset);
}

static void
__lambda145_ (DcRelaysDialog* self)
{
	dc_relays_dialog_do_add_relay (self, NULL, NULL);
}

static void
___lambda145__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda145_ ((DcRelaysDialog*) self);
}

DcRelaysDialog*
dc_relays_dialog_construct (GType object_type,
                            DcRpcClient* rpc,
                            DcEventHandler* events,
                            gint acct_id)
{
	DcRelaysDialog * self = NULL;
	DcRpcClient* _tmp0_;
	DcEventHandler* _tmp1_;
	GtkBox* box = NULL;
	GtkBox* _tmp2_;
	AdwHeaderBar* _tmp3_;
	AdwHeaderBar* _tmp4_;
	GtkBox* content = NULL;
	GtkBox* _tmp5_;
	GtkLabel* intro = NULL;
	GtkLabel* _tmp6_;
	GtkListBox* _tmp7_;
	GtkListBox* _tmp8_;
	GtkListBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	GtkStack* _tmp14_;
	GtkStack* _tmp15_;
	GtkListBox* _tmp16_;
	GtkStack* _tmp17_;
	GtkLabel* _tmp18_;
	GtkScrolledWindow* scroll = NULL;
	GtkScrolledWindow* _tmp19_;
	GtkStack* _tmp20_;
	GtkLabel* add_label = NULL;
	GtkLabel* _tmp21_;
	DcRelayPicker* _tmp22_;
	DcRelayPicker* _tmp23_;
	GtkBox* add_row = NULL;
	GtkBox* _tmp24_;
	GtkButton* _tmp25_;
	GtkButton* _tmp26_;
	GtkButton* _tmp27_;
	GtkButton* _tmp28_;
	g_return_val_if_fail (rpc != NULL, NULL);
	g_return_val_if_fail (events != NULL, NULL);
	self = (DcRelaysDialog*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (rpc);
	_g_object_unref0 (self->priv->rpc);
	self->priv->rpc = _tmp0_;
	_tmp1_ = _g_object_ref0 (events);
	_g_object_unref0 (self->priv->events);
	self->priv->events = _tmp1_;
	self->priv->account_id = acct_id;
	adw_dialog_set_title ((AdwDialog*) self, "Relays");
	adw_dialog_set_content_width ((AdwDialog*) self, 480);
	adw_dialog_set_content_height ((AdwDialog*) self, 520);
	adw_dialog_set_can_close ((AdwDialog*) self, TRUE);
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp2_);
	box = _tmp2_;
	_tmp3_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	gtk_box_append (box, (GtkWidget*) _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	g_object_ref_sink (_tmp5_);
	content = _tmp5_;
	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);
	gtk_widget_set_vexpand ((GtkWidget*) content, TRUE);
	_tmp6_ = (GtkLabel*) gtk_label_new ("Transports configured for this profile. " "Add more relays to receive messages on additional addresses.");
	g_object_ref_sink (_tmp6_);
	intro = _tmp6_;
	gtk_label_set_wrap (intro, TRUE);
	gtk_label_set_xalign (intro, (gfloat) 0);
	gtk_widget_add_css_class ((GtkWidget*) intro, "dim-label");
	gtk_box_append (content, (GtkWidget*) intro);
	_tmp7_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->list_box);
	self->priv->list_box = _tmp7_;
	_tmp8_ = self->priv->list_box;
	gtk_list_box_set_selection_mode (_tmp8_, GTK_SELECTION_NONE);
	_tmp9_ = self->priv->list_box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp9_, "boxed-list");
	_tmp10_ = (GtkLabel*) gtk_label_new ("No transports configured.");
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->empty_label);
	self->priv->empty_label = _tmp10_;
	_tmp11_ = self->priv->empty_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp11_, "dim-label");
	_tmp12_ = self->priv->empty_label;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp12_, 24);
	_tmp13_ = self->priv->empty_label;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp13_, 24);
	_tmp14_ = (GtkStack*) gtk_stack_new ();
	g_object_ref_sink (_tmp14_);
	_g_object_unref0 (self->priv->list_stack);
	self->priv->list_stack = _tmp14_;
	_tmp15_ = self->priv->list_stack;
	_tmp16_ = self->priv->list_box;
	gtk_stack_add_named (_tmp15_, (GtkWidget*) _tmp16_, "list");
	_tmp17_ = self->priv->list_stack;
	_tmp18_ = self->priv->empty_label;
	gtk_stack_add_named (_tmp17_, (GtkWidget*) _tmp18_, "empty");
	_tmp19_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp19_);
	scroll = _tmp19_;
	g_object_set (scroll, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_widget_set_vexpand ((GtkWidget*) scroll, TRUE);
	_tmp20_ = self->priv->list_stack;
	gtk_scrolled_window_set_child (scroll, (GtkWidget*) _tmp20_);
	gtk_box_append (content, (GtkWidget*) scroll);
	_tmp21_ = (GtkLabel*) gtk_label_new ("Add Relay");
	g_object_ref_sink (_tmp21_);
	add_label = _tmp21_;
	gtk_widget_add_css_class ((GtkWidget*) add_label, "heading");
	gtk_label_set_xalign (add_label, (gfloat) 0);
	gtk_box_append (content, (GtkWidget*) add_label);
	_tmp22_ = dc_relay_picker_new (rpc);
	g_object_ref_sink (_tmp22_);
	_g_object_unref0 (self->priv->picker);
	self->priv->picker = _tmp22_;
	_tmp23_ = self->priv->picker;
	gtk_box_append (content, (GtkWidget*) _tmp23_);
	_tmp24_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp24_);
	add_row = _tmp24_;
	gtk_widget_set_halign ((GtkWidget*) add_row, GTK_ALIGN_END);
	_tmp25_ = (GtkButton*) gtk_button_new_with_label ("Add Relay");
	g_object_ref_sink (_tmp25_);
	_g_object_unref0 (self->priv->add_btn);
	self->priv->add_btn = _tmp25_;
	_tmp26_ = self->priv->add_btn;
	gtk_widget_add_css_class ((GtkWidget*) _tmp26_, "suggested-action");
	_tmp27_ = self->priv->add_btn;
	g_signal_connect_object (_tmp27_, "clicked", (GCallback) ___lambda145__gtk_button_clicked, self, 0);
	_tmp28_ = self->priv->add_btn;
	gtk_box_append (add_row, (GtkWidget*) _tmp28_);
	gtk_box_append (content, (GtkWidget*) add_row);
	gtk_box_append (box, (GtkWidget*) content);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) box);
	dc_install_escape_close ((AdwDialog*) self);
	dc_relays_dialog_refresh_list (self, NULL, NULL);
	_g_object_unref0 (add_row);
	_g_object_unref0 (add_label);
	_g_object_unref0 (scroll);
	_g_object_unref0 (intro);
	_g_object_unref0 (content);
	_g_object_unref0 (box);
	return self;
}

DcRelaysDialog*
dc_relays_dialog_new (DcRpcClient* rpc,
                      DcEventHandler* events,
                      gint acct_id)
{
	return dc_relays_dialog_construct (DC_TYPE_RELAYS_DIALOG, rpc, events, acct_id);
}

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

static void
dc_relays_dialog_refresh_list (DcRelaysDialog* self,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DcRelaysDialogRefreshListData* _data_;
	DcRelaysDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcRelaysDialogRefreshListData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_relays_dialog_refresh_list_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_relays_dialog_refresh_list_co (_data_);
}

static void
dc_relays_dialog_refresh_list_finish (DcRelaysDialog* self,
                                      GAsyncResult* _res_)
{
	DcRelaysDialogRefreshListData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_relays_dialog_refresh_list_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DcRelaysDialogRefreshListData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_relays_dialog_refresh_list_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 gboolean
dc_relays_dialog_refresh_list_co (DcRelaysDialogRefreshListData* _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->list_box;
	dc_clear_listbox (_data_->_tmp0_);
	_data_->_result_ = NULL;
	{
		_data_->_tmp2_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_list_transports (_data_->_tmp2_, _data_->self->priv->account_id, dc_relays_dialog_refresh_list_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp3_ = dc_rpc_client_list_transports_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp3_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		__vala_JsonNode_free0 (_data_->_result_);
		_data_->_result_ = _data_->_tmp4_;
		__vala_JsonNode_free0 (_data_->_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp5_ = _data_->e;
		_data_->_tmp6_ = _data_->_tmp5_->message;
		_data_->_tmp7_ = g_strconcat ("Failed to load transports: ", _data_->_tmp6_, NULL);
		_data_->_tmp8_ = _data_->_tmp7_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp8_);
		_g_free0 (_data_->_tmp8_);
		_data_->_tmp9_ = _data_->self->priv->list_stack;
		gtk_stack_set_visible_child_name (_data_->_tmp9_, "empty");
		_g_error_free0 (_data_->e);
		__vala_JsonNode_free0 (_data_->_result_);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		__vala_JsonNode_free0 (_data_->_result_);
		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_->_tmp11_ = _data_->_result_;
	if (_data_->_tmp11_ == NULL) {
		_data_->_tmp10_ = TRUE;
	} else {
		_data_->_tmp12_ = _data_->_result_;
		_data_->_tmp10_ = json_node_get_node_type (_data_->_tmp12_) != JSON_NODE_ARRAY;
	}
	if (_data_->_tmp10_) {
		_data_->_tmp13_ = _data_->self->priv->list_stack;
		gtk_stack_set_visible_child_name (_data_->_tmp13_, "empty");
		__vala_JsonNode_free0 (_data_->_result_);
		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_->_tmp14_ = _data_->_result_;
	_data_->_tmp15_ = json_node_get_array (_data_->_tmp14_);
	_data_->_tmp16_ = _json_array_ref0 (_data_->_tmp15_);
	_data_->arr = _data_->_tmp16_;
	_data_->_tmp17_ = _data_->arr;
	if (json_array_get_length (_data_->_tmp17_) == ((guint) 0)) {
		_data_->_tmp18_ = _data_->self->priv->list_stack;
		gtk_stack_set_visible_child_name (_data_->_tmp18_, "empty");
		_json_array_unref0 (_data_->arr);
		__vala_JsonNode_free0 (_data_->_result_);
		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_->i = (guint) 0;
		{
			_data_->_tmp19_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp19_) {
					_data_->_tmp20_ = _data_->i;
					_data_->i = _data_->_tmp20_ + 1;
				}
				_data_->_tmp19_ = FALSE;
				_data_->_tmp21_ = _data_->arr;
				if (!(_data_->i < json_array_get_length (_data_->_tmp21_))) {
					break;
				}
				_data_->_tmp22_ = _data_->arr;
				_data_->_tmp23_ = json_array_get_element (_data_->_tmp22_, _data_->i);
				_data_->_tmp24_ = __vala_JsonNode_copy0 (_data_->_tmp23_);
				_data_->node = _data_->_tmp24_;
				_data_->_tmp26_ = _data_->node;
				if (_data_->_tmp26_ == NULL) {
					_data_->_tmp25_ = TRUE;
				} else {
					_data_->_tmp27_ = _data_->node;
					_data_->_tmp25_ = json_node_get_node_type (_data_->_tmp27_) != JSON_NODE_OBJECT;
				}
				if (_data_->_tmp25_) {
					__vala_JsonNode_free0 (_data_->node);
					continue;
				}
				_data_->_tmp28_ = _data_->node;
				_data_->_tmp29_ = json_node_get_object (_data_->_tmp28_);
				_data_->_tmp30_ = _json_object_ref0 (_data_->_tmp29_);
				_data_->obj = _data_->_tmp30_;
				_data_->_tmp32_ = _data_->obj;
				_data_->_tmp33_ = dc_json_str (_data_->_tmp32_, "addr");
				_data_->_tmp31_ = _data_->_tmp33_;
				if (_data_->_tmp31_ == NULL) {
					_data_->_tmp34_ = g_strdup ("");
					_g_free0 (_data_->_tmp31_);
					_data_->_tmp31_ = _data_->_tmp34_;
				}
				_data_->_tmp35_ = _data_->_tmp31_;
				_data_->_tmp31_ = NULL;
				_data_->addr = _data_->_tmp35_;
				_data_->_tmp36_ = _data_->addr;
				_data_->_tmp37_ = strlen (_data_->_tmp36_);
				_data_->_tmp38_ = _data_->_tmp37_;
				if (_data_->_tmp38_ == 0) {
					_g_free0 (_data_->addr);
					_g_free0 (_data_->_tmp31_);
					_json_object_unref0 (_data_->obj);
					__vala_JsonNode_free0 (_data_->node);
					continue;
				}
				_data_->_tmp39_ = _data_->self->priv->list_box;
				_data_->_tmp40_ = _data_->addr;
				_data_->_tmp41_ = _data_->obj;
				_data_->_tmp42_ = dc_entered_login_params_from_json (_data_->_tmp41_);
				_data_->_tmp43_ = _data_->_tmp42_;
				_data_->_tmp44_ = dc_relays_dialog_build_relay_row (_data_->self, _data_->_tmp40_, _data_->_tmp43_);
				_data_->_tmp45_ = _data_->_tmp44_;
				gtk_list_box_append (_data_->_tmp39_, _data_->_tmp45_);
				_g_object_unref0 (_data_->_tmp45_);
				_g_object_unref0 (_data_->_tmp43_);
				_g_free0 (_data_->addr);
				_g_free0 (_data_->_tmp31_);
				_json_object_unref0 (_data_->obj);
				__vala_JsonNode_free0 (_data_->node);
			}
		}
	}
	_data_->_tmp46_ = _data_->self->priv->list_stack;
	gtk_stack_set_visible_child_name (_data_->_tmp46_, "list");
	_json_array_unref0 (_data_->arr);
	__vala_JsonNode_free0 (_data_->_result_);
	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 Block123Data*
block123_data_ref (Block123Data* _data123_)
{
	g_atomic_int_inc (&_data123_->_ref_count_);
	return _data123_;
}

static void
block123_data_unref (void * _userdata_)
{
	Block123Data* _data123_;
	_data123_ = (Block123Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data123_->_ref_count_)) {
		DcRelaysDialog* self;
		self = _data123_->self;
		_g_free0 (_data123_->addr);
		_g_object_unref0 (_data123_->params);
		_g_object_unref0 (self);
		g_slice_free (Block123Data, _data123_);
	}
}

static void
__lambda146_ (Block123Data* _data123_)
{
	DcRelaysDialog* self;
	self = _data123_->self;
	dc_relays_dialog_show_edit_transport_dialog (self, _data123_->params);
}

static void
___lambda146__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda146_ (self);
}

static void
__lambda152_ (Block123Data* _data123_)
{
	DcRelaysDialog* self;
	self = _data123_->self;
	dc_relays_dialog_confirm_delete_relay (self, _data123_->addr, NULL, NULL);
}

static void
___lambda152__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda152_ (self);
}

static GtkWidget*
dc_relays_dialog_build_relay_row (DcRelaysDialog* self,
                                  const gchar* addr,
                                  DcEnteredLoginParams* params)
{
	Block123Data* _data123_;
	gchar* _tmp0_;
	DcEnteredLoginParams* _tmp1_;
	AdwActionRow* row = NULL;
	AdwActionRow* _tmp2_;
	GtkButton* edit_btn = NULL;
	GtkButton* _tmp3_;
	GtkButton* trash_btn = NULL;
	GtkButton* _tmp4_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (addr != NULL, NULL);
	g_return_val_if_fail (params != NULL, NULL);
	_data123_ = g_slice_new0 (Block123Data);
	_data123_->_ref_count_ = 1;
	_data123_->self = g_object_ref (self);
	_tmp0_ = g_strdup (addr);
	_g_free0 (_data123_->addr);
	_data123_->addr = _tmp0_;
	_tmp1_ = _g_object_ref0 (params);
	_g_object_unref0 (_data123_->params);
	_data123_->params = _tmp1_;
	_tmp2_ = (AdwActionRow*) adw_action_row_new ();
	g_object_ref_sink (_tmp2_);
	row = _tmp2_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) row, _data123_->addr);
	_tmp3_ = (GtkButton*) gtk_button_new_from_icon_name ("document-edit-symbolic");
	g_object_ref_sink (_tmp3_);
	edit_btn = _tmp3_;
	gtk_widget_add_css_class ((GtkWidget*) edit_btn, "flat");
	gtk_widget_set_valign ((GtkWidget*) edit_btn, GTK_ALIGN_CENTER);
	gtk_widget_set_tooltip_text ((GtkWidget*) edit_btn, "Edit password and server settings");
	g_signal_connect_data (edit_btn, "clicked", (GCallback) ___lambda146__gtk_button_clicked, block123_data_ref (_data123_), (GClosureNotify) block123_data_unref, 0);
	adw_action_row_add_suffix (row, (GtkWidget*) edit_btn);
	_tmp4_ = (GtkButton*) gtk_button_new_from_icon_name ("user-trash-symbolic");
	g_object_ref_sink (_tmp4_);
	trash_btn = _tmp4_;
	gtk_widget_add_css_class ((GtkWidget*) trash_btn, "flat");
	gtk_widget_set_valign ((GtkWidget*) trash_btn, GTK_ALIGN_CENTER);
	gtk_widget_set_tooltip_text ((GtkWidget*) trash_btn, "Remove this relay");
	g_signal_connect_data (trash_btn, "clicked", (GCallback) ___lambda152__gtk_button_clicked, block123_data_ref (_data123_), (GClosureNotify) block123_data_unref, 0);
	adw_action_row_add_suffix (row, (GtkWidget*) trash_btn);
	result = (GtkWidget*) row;
	_g_object_unref0 (trash_btn);
	_g_object_unref0 (edit_btn);
	block123_data_unref (_data123_);
	_data123_ = NULL;
	return result;
}

static void
__lambda151_ (DcRelaysDialog* self)
{
	dc_relays_dialog_refresh_list (self, NULL, NULL);
}

static void
___lambda151__dc_classic_email_dialog_transport_updated (DcClassicEmailDialog* _sender,
                                                         gpointer self)
{
	__lambda151_ ((DcRelaysDialog*) self);
}

static void
dc_relays_dialog_show_edit_transport_dialog (DcRelaysDialog* self,
                                             DcEnteredLoginParams* params)
{
	DcClassicEmailDialog* dialog = NULL;
	DcRpcClient* _tmp0_;
	DcEventHandler* _tmp1_;
	DcClassicEmailDialog* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (params != NULL);
	_tmp0_ = self->priv->rpc;
	_tmp1_ = self->priv->events;
	_tmp2_ = dc_classic_email_dialog_new_for_edit (_tmp0_, _tmp1_, self->priv->account_id, params);
	g_object_ref_sink (_tmp2_);
	dialog = _tmp2_;
	g_signal_connect_object (dialog, "transport-updated", (GCallback) ___lambda151__dc_classic_email_dialog_transport_updated, self, 0);
	adw_dialog_present ((AdwDialog*) dialog, (GtkWidget*) self);
	_g_object_unref0 (dialog);
}

static void
dc_relays_dialog_confirm_delete_relay_data_free (gpointer _data)
{
	DcRelaysDialogConfirmDeleteRelayData* _data_;
	_data_ = _data;
	_g_free0 (_data_->addr);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcRelaysDialogConfirmDeleteRelayData, _data_);
}

static void
dc_relays_dialog_confirm_delete_relay (DcRelaysDialog* self,
                                       const gchar* addr,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	DcRelaysDialogConfirmDeleteRelayData* _data_;
	DcRelaysDialog* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (addr != NULL);
	_data_ = g_slice_new0 (DcRelaysDialogConfirmDeleteRelayData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_relays_dialog_confirm_delete_relay_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (addr);
	_g_free0 (_data_->addr);
	_data_->addr = _tmp1_;
	dc_relays_dialog_confirm_delete_relay_co (_data_);
}

static void
dc_relays_dialog_confirm_delete_relay_finish (DcRelaysDialog* self,
                                              GAsyncResult* _res_)
{
	DcRelaysDialogConfirmDeleteRelayData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_relays_dialog_confirm_delete_relay_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	DcRelaysDialogConfirmDeleteRelayData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_relays_dialog_confirm_delete_relay_co (_data_);
}

static gboolean
dc_relays_dialog_confirm_delete_relay_co (DcRelaysDialogConfirmDeleteRelayData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_strdup_printf ("Remove transport \"%s\"? The profile will no longer receive messages o" \
"n this address.", _data_->addr);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_state_ = 1;
	dc_confirm_action ((GtkWidget*) _data_->self, "Remove Relay", _data_->_tmp1_, "remove", "Remove", dc_relays_dialog_confirm_delete_relay_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = dc_confirm_action_finish (_data_->_res_);
	_g_free0 (_data_->_tmp1_);
	if (_data_->_tmp2_) {
		dc_relays_dialog_do_delete_relay (_data_->self, _data_->addr, NULL, NULL);
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_relays_dialog_do_delete_relay_data_free (gpointer _data)
{
	DcRelaysDialogDoDeleteRelayData* _data_;
	_data_ = _data;
	_g_free0 (_data_->addr);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcRelaysDialogDoDeleteRelayData, _data_);
}

static void
dc_relays_dialog_do_delete_relay (DcRelaysDialog* self,
                                  const gchar* addr,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	DcRelaysDialogDoDeleteRelayData* _data_;
	DcRelaysDialog* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (addr != NULL);
	_data_ = g_slice_new0 (DcRelaysDialogDoDeleteRelayData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_relays_dialog_do_delete_relay_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (addr);
	_g_free0 (_data_->addr);
	_data_->addr = _tmp1_;
	dc_relays_dialog_do_delete_relay_co (_data_);
}

static void
dc_relays_dialog_do_delete_relay_finish (DcRelaysDialog* self,
                                         GAsyncResult* _res_)
{
	DcRelaysDialogDoDeleteRelayData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_relays_dialog_do_delete_relay_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_)
{
	DcRelaysDialogDoDeleteRelayData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_relays_dialog_do_delete_relay_co (_data_);
}

static gboolean
dc_relays_dialog_do_delete_relay_co (DcRelaysDialogDoDeleteRelayData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->busy) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->busy = TRUE;
	{
		_data_->_tmp0_ = _data_->self->priv->rpc;
		_data_->_state_ = 1;
		dc_rpc_client_delete_transport (_data_->_tmp0_, _data_->self->priv->account_id, _data_->addr, dc_relays_dialog_do_delete_relay_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_delete_transport_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp1_ = _data_->e;
		_data_->_tmp2_ = _data_->_tmp1_->message;
		_data_->_tmp3_ = g_strconcat ("Failed to remove relay: ", _data_->_tmp2_, NULL);
		_data_->_tmp4_ = _data_->_tmp3_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp4_);
		_g_free0 (_data_->_tmp4_);
		_data_->self->priv->busy = FALSE;
		_g_error_free0 (_data_->e);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	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_->self->priv->busy = FALSE;
	_data_->_state_ = 2;
	dc_relays_dialog_refresh_list (_data_->self, dc_relays_dialog_do_delete_relay_ready, _data_);
	return FALSE;
	_state_2:
	dc_relays_dialog_refresh_list_finish (_data_->self, _data_->_res_);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
dc_relays_dialog_do_add_relay (DcRelaysDialog* self,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DcRelaysDialogDoAddRelayData* _data_;
	DcRelaysDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DcRelaysDialogDoAddRelayData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_relays_dialog_do_add_relay_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	dc_relays_dialog_do_add_relay_co (_data_);
}

static void
dc_relays_dialog_do_add_relay_finish (DcRelaysDialog* self,
                                      GAsyncResult* _res_)
{
	DcRelaysDialogDoAddRelayData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_relays_dialog_do_add_relay_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DcRelaysDialogDoAddRelayData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_relays_dialog_do_add_relay_co (_data_);
}

static gboolean
dc_relays_dialog_do_add_relay_co (DcRelaysDialogDoAddRelayData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->busy) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->busy = TRUE;
	_data_->_tmp0_ = _data_->self->priv->add_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp0_, FALSE);
	_data_->_tmp1_ = _data_->self->priv->picker;
	_data_->_tmp2_ = dc_relay_picker_get_chatmail_qr (_data_->_tmp1_);
	_data_->qr = _data_->_tmp2_;
	{
		_data_->_tmp3_ = _data_->self->priv->rpc;
		_data_->_tmp4_ = _data_->qr;
		_data_->_state_ = 1;
		dc_rpc_client_add_transport_from_qr (_data_->_tmp3_, _data_->self->priv->account_id, _data_->_tmp4_, dc_relays_dialog_do_add_relay_ready, _data_);
		return FALSE;
		_state_1:
		dc_rpc_client_add_transport_from_qr_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp5_ = _data_->e;
		_data_->_tmp6_ = _data_->_tmp5_->message;
		_data_->_tmp7_ = g_strconcat ("Failed to add relay: ", _data_->_tmp6_, NULL);
		_data_->_tmp8_ = _data_->_tmp7_;
		dc_show_error ((GtkWidget*) _data_->self, _data_->_tmp8_);
		_g_free0 (_data_->_tmp8_);
		_data_->_tmp9_ = _data_->self->priv->add_btn;
		gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp9_, TRUE);
		_data_->self->priv->busy = FALSE;
		_g_error_free0 (_data_->e);
		_g_free0 (_data_->qr);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->qr);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp10_ = _data_->self->priv->add_btn;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp10_, TRUE);
	_data_->self->priv->busy = FALSE;
	_data_->_state_ = 2;
	dc_relays_dialog_refresh_list (_data_->self, dc_relays_dialog_do_add_relay_ready, _data_);
	return FALSE;
	_state_2:
	dc_relays_dialog_refresh_list_finish (_data_->self, _data_->_res_);
	_g_free0 (_data_->qr);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dc_relays_dialog_class_init (DcRelaysDialogClass * klass,
                             gpointer klass_data)
{
	dc_relays_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcRelaysDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dc_relays_dialog_finalize;
}

static void
dc_relays_dialog_instance_init (DcRelaysDialog * self,
                                gpointer klass)
{
	self->priv = dc_relays_dialog_get_instance_private (self);
	self->priv->busy = FALSE;
}

static void
dc_relays_dialog_finalize (GObject * obj)
{
	DcRelaysDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_RELAYS_DIALOG, DcRelaysDialog);
	_g_object_unref0 (self->priv->rpc);
	_g_object_unref0 (self->priv->events);
	_g_object_unref0 (self->priv->list_box);
	_g_object_unref0 (self->priv->list_stack);
	_g_object_unref0 (self->priv->empty_label);
	_g_object_unref0 (self->priv->picker);
	_g_object_unref0 (self->priv->add_btn);
	G_OBJECT_CLASS (dc_relays_dialog_parent_class)->finalize (obj);
}

/**
     * Lists all transports configured for an account and lets the user
     * remove existing ones (with a confirmation prompt) or add a new one
     * by picking a relay from the curated list.
     */
static GType
dc_relays_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcRelaysDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_relays_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcRelaysDialog), 0, (GInstanceInitFunc) dc_relays_dialog_instance_init, NULL };
	GType dc_relays_dialog_type_id;
	dc_relays_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "DcRelaysDialog", &g_define_type_info, 0);
	DcRelaysDialog_private_offset = g_type_add_instance_private (dc_relays_dialog_type_id, sizeof (DcRelaysDialogPrivate));
	return dc_relays_dialog_type_id;
}

GType
dc_relays_dialog_get_type (void)
{
	static volatile gsize dc_relays_dialog_type_id__once = 0;
	if (g_once_init_enter (&dc_relays_dialog_type_id__once)) {
		GType dc_relays_dialog_type_id;
		dc_relays_dialog_type_id = dc_relays_dialog_get_type_once ();
		g_once_init_leave (&dc_relays_dialog_type_id__once, dc_relays_dialog_type_id);
	}
	return dc_relays_dialog_type_id__once;
}

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

