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

#include <glib-object.h>
#include <glib.h>
#include <json-glib/json-glib.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.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_RPC_PARSERS (dc_rpc_parsers_get_type ())
#define DC_RPC_PARSERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_RPC_PARSERS, DcRpcParsers))
#define DC_RPC_PARSERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_RPC_PARSERS, DcRpcParsersClass))
#define DC_IS_RPC_PARSERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_RPC_PARSERS))
#define DC_IS_RPC_PARSERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_RPC_PARSERS))
#define DC_RPC_PARSERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_RPC_PARSERS, DcRpcParsersClass))

typedef struct _DcRpcParsers DcRpcParsers;
typedef struct _DcRpcParsersClass DcRpcParsersClass;
typedef struct _DcRpcParsersPrivate DcRpcParsersPrivate;

#define DC_TYPE_CONTACT (dc_contact_get_type ())
#define DC_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_CONTACT, DcContact))
#define DC_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_CONTACT, DcContactClass))
#define DC_IS_CONTACT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_CONTACT))
#define DC_IS_CONTACT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_CONTACT))
#define DC_CONTACT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_CONTACT, DcContactClass))

typedef struct _DcContact DcContact;
typedef struct _DcContactClass DcContactClass;
#define _g_free0(var) (var = (g_free (var), NULL))

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

typedef struct _DcMessage DcMessage;
typedef struct _DcMessageClass DcMessageClass;
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))

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

typedef struct _DcChatEntry DcChatEntry;
typedef struct _DcChatEntryClass DcChatEntryClass;
typedef enum  {
	DC_CHAT_KIND_UNKNOWN = 0,
	DC_CHAT_KIND_DIRECT = 1,
	DC_CHAT_KIND_GROUP = 2
} DcChatKind;

#define DC_TYPE_CHAT_KIND (dc_chat_kind_get_type ())

#define DC_TYPE_MESSAGE_REACTION (dc_message_reaction_get_type ())
#define DC_MESSAGE_REACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_MESSAGE_REACTION, DcMessageReaction))
#define DC_MESSAGE_REACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_MESSAGE_REACTION, DcMessageReactionClass))
#define DC_IS_MESSAGE_REACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_MESSAGE_REACTION))
#define DC_IS_MESSAGE_REACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_MESSAGE_REACTION))
#define DC_MESSAGE_REACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_MESSAGE_REACTION, DcMessageReactionClass))

typedef struct _DcMessageReaction DcMessageReaction;
typedef struct _DcMessageReactionClass DcMessageReactionClass;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
typedef struct _DcMessagePrivate DcMessagePrivate;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
typedef struct _DcParamSpecRpcParsers DcParamSpecRpcParsers;

struct _DcRpcParsers {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DcRpcParsersPrivate * priv;
};

struct _DcRpcParsersClass {
	GTypeClass parent_class;
	void (*finalize) (DcRpcParsers *self);
};

struct _DcMessage {
	GObject parent_instance;
	DcMessagePrivate * priv;
	GPtrArray* reaction_details;
};

struct _DcMessageClass {
	GObjectClass parent_class;
};

struct _DcParamSpecRpcParsers {
	GParamSpec parent_instance;
};

static gpointer dc_rpc_parsers_parent_class = NULL;

VALA_EXTERN gpointer dc_rpc_parsers_ref (gpointer instance);
VALA_EXTERN void dc_rpc_parsers_unref (gpointer instance);
VALA_EXTERN GParamSpec* dc_param_spec_rpc_parsers (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void dc_value_set_rpc_parsers (GValue* value,
                               gpointer v_object);
VALA_EXTERN void dc_value_take_rpc_parsers (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer dc_value_get_rpc_parsers (const GValue* value);
VALA_EXTERN GType dc_rpc_parsers_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcRpcParsers, dc_rpc_parsers_unref)
VALA_EXTERN GType dc_contact_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcContact, g_object_unref)
VALA_EXTERN DcContact* dc_rpc_parsers_parse_contact (gint contact_id,
                                         JsonObject* obj);
VALA_EXTERN DcContact* dc_contact_new (void);
VALA_EXTERN DcContact* dc_contact_construct (GType object_type);
VALA_EXTERN void dc_contact_set_id (DcContact* self,
                        gint value);
VALA_EXTERN gchar* dc_json_str (JsonObject* obj,
                    const gchar* key);
VALA_EXTERN void dc_contact_set_display_name (DcContact* self,
                                  const gchar* value);
VALA_EXTERN void dc_contact_set_address (DcContact* self,
                             const gchar* value);
VALA_EXTERN void dc_contact_set_profile_image (DcContact* self,
                                   const gchar* value);
VALA_EXTERN gboolean dc_json_bool (JsonObject* obj,
                       const gchar* key);
VALA_EXTERN void dc_contact_set_is_verified (DcContact* self,
                                 gboolean value);
VALA_EXTERN void dc_contact_set_is_blocked (DcContact* self,
                                gboolean value);
VALA_EXTERN void dc_contact_set_status (DcContact* self,
                            const gchar* value);
VALA_EXTERN void dc_contact_set_was_seen_recently (DcContact* self,
                                       gboolean value);
VALA_EXTERN GType dc_message_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessage, g_object_unref)
VALA_EXTERN DcMessage* dc_rpc_parsers_parse_message (JsonObject* obj,
                                         const gchar* self_email);
VALA_EXTERN DcMessage* dc_message_new (void);
VALA_EXTERN DcMessage* dc_message_construct (GType object_type);
VALA_EXTERN gint64 dc_json_int (JsonObject* obj,
                    const gchar* key,
                    gint64 fallback);
VALA_EXTERN void dc_message_set_id (DcMessage* self,
                        gint value);
VALA_EXTERN void dc_message_set_chat_id (DcMessage* self,
                             gint value);
VALA_EXTERN void dc_message_set_text (DcMessage* self,
                          const gchar* value);
VALA_EXTERN void dc_message_set_timestamp (DcMessage* self,
                               gint64 value);
VALA_EXTERN void dc_message_set_is_info (DcMessage* self,
                             gboolean value);
VALA_EXTERN void dc_message_set_is_forwarded (DcMessage* self,
                                  gboolean value);
VALA_EXTERN void dc_message_set_is_edited (DcMessage* self,
                               gboolean value);
VALA_EXTERN void dc_message_set_is_pinned (DcMessage* self,
                               gboolean value);
VALA_EXTERN void dc_message_set_override_sender_name (DcMessage* self,
                                          const gchar* value);
VALA_EXTERN void dc_message_set_file_path (DcMessage* self,
                               const gchar* value);
VALA_EXTERN void dc_message_set_file_name (DcMessage* self,
                               const gchar* value);
VALA_EXTERN void dc_message_set_file_mime (DcMessage* self,
                               const gchar* value);
VALA_EXTERN void dc_message_set_file_bytes (DcMessage* self,
                                gint value);
VALA_EXTERN void dc_message_set_view_type (DcMessage* self,
                               const gchar* value);
VALA_EXTERN void dc_message_set_state (DcMessage* self,
                           gint value);
VALA_EXTERN void dc_message_set_has_html (DcMessage* self,
                              gboolean value);
VALA_EXTERN void dc_message_set_download_state (DcMessage* self,
                                    const gchar* value);
VALA_EXTERN void dc_message_set_sender_address (DcMessage* self,
                                    const gchar* value);
VALA_EXTERN void dc_message_set_sender_name (DcMessage* self,
                                 const gchar* value);
VALA_EXTERN void dc_message_set_sender_avatar_path (DcMessage* self,
                                        const gchar* value);
VALA_EXTERN void dc_message_set_sender_contact_id (DcMessage* self,
                                       gint value);
VALA_EXTERN void dc_message_set_sender_was_seen_recently (DcMessage* self,
                                              gboolean value);
VALA_EXTERN const gchar* dc_message_get_sender_address (DcMessage* self);
VALA_EXTERN void dc_message_set_is_outgoing (DcMessage* self,
                                 gboolean value);
static void dc_rpc_parsers_parse_reactions (JsonObject* obj,
                                     DcMessage* msg);
static void dc_rpc_parsers_parse_quote (JsonObject* obj,
                                 DcMessage* msg);
VALA_EXTERN GType dc_chat_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcChatEntry, g_object_unref)
VALA_EXTERN DcChatEntry* dc_rpc_parsers_parse_chat_item (gint chat_id,
                                             JsonObject* obj);
VALA_EXTERN DcChatEntry* dc_chat_entry_new (void);
VALA_EXTERN DcChatEntry* dc_chat_entry_construct (GType object_type);
VALA_EXTERN void dc_chat_entry_set_id (DcChatEntry* self,
                           gint value);
VALA_EXTERN void dc_chat_entry_set_name (DcChatEntry* self,
                             const gchar* value);
VALA_EXTERN void dc_chat_entry_set_summary_prefix (DcChatEntry* self,
                                       const gchar* value);
VALA_EXTERN void dc_chat_entry_set_last_message (DcChatEntry* self,
                                     const gchar* value);
VALA_EXTERN void dc_chat_entry_set_last_message_id (DcChatEntry* self,
                                        gint value);
VALA_EXTERN void dc_chat_entry_set_unread_count (DcChatEntry* self,
                                     gint value);
VALA_EXTERN void dc_chat_entry_set_timestamp (DcChatEntry* self,
                                  gint64 value);
VALA_EXTERN void dc_chat_entry_set_avatar_path (DcChatEntry* self,
                                    const gchar* value);
VALA_EXTERN GType dc_chat_kind_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DcChatKind dc_rpc_parsers_parse_chat_kind (JsonObject* obj);
VALA_EXTERN void dc_chat_entry_set_kind (DcChatEntry* self,
                             DcChatKind value);
VALA_EXTERN void dc_chat_entry_set_is_muted (DcChatEntry* self,
                                 gboolean value);
VALA_EXTERN void dc_chat_entry_set_is_contact_request (DcChatEntry* self,
                                           gboolean value);
VALA_EXTERN void dc_chat_entry_set_is_pinned (DcChatEntry* self,
                                  gboolean value);
VALA_EXTERN void dc_chat_entry_set_is_archived (DcChatEntry* self,
                                    gboolean value);
VALA_EXTERN void dc_chat_entry_set_was_seen_recently (DcChatEntry* self,
                                          gboolean value);
VALA_EXTERN gboolean dc_chat_entry_get_was_seen_recently (DcChatEntry* self);
VALA_EXTERN GType dc_message_reaction_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcMessageReaction, g_object_unref)
static void _g_object_unref0_ (gpointer var);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
static void _vala_array_add14 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static DcMessageReaction* dc_rpc_parsers_find_reaction (GPtrArray* reactions,
                                                 const gchar* emoji);
VALA_EXTERN DcMessageReaction* dc_message_reaction_new (const gchar* emoji);
VALA_EXTERN DcMessageReaction* dc_message_reaction_construct (GType object_type,
                                                  const gchar* emoji);
VALA_EXTERN void dc_message_reaction_add_user (DcMessageReaction* self,
                                   gint contact_id);
static void _vala_array_add15 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
static void _vala_array_add16 (gint* * array,
                        gint* length,
                        gint* size,
                        gint value);
VALA_EXTERN void dc_message_set_my_reactions (DcMessage* self,
                                  const gchar* value);
VALA_EXTERN void dc_message_set_reactions (DcMessage* self,
                               const gchar* value);
VALA_EXTERN const gchar* dc_message_reaction_get_emoji (DcMessageReaction* self);
VALA_EXTERN void dc_message_set_quote_text (DcMessage* self,
                                const gchar* value);
VALA_EXTERN void dc_message_set_quote_sender_name (DcMessage* self,
                                       const gchar* value);
VALA_EXTERN void dc_message_set_quote_msg_id (DcMessage* self,
                                  gint value);
VALA_EXTERN DcRpcParsers* dc_rpc_parsers_new (void);
VALA_EXTERN DcRpcParsers* dc_rpc_parsers_construct (GType object_type);
static void dc_rpc_parsers_finalize (DcRpcParsers * obj);
static GType dc_rpc_parsers_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

DcContact*
dc_rpc_parsers_parse_contact (gint contact_id,
                              JsonObject* obj)
{
	DcContact* c = NULL;
	DcContact* _tmp0_;
	DcContact* _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	DcContact* _tmp5_;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_;
	DcContact* _tmp9_;
	DcContact* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	DcContact* _tmp13_;
	DcContact* _tmp14_;
	DcContact* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	DcContact* _tmp18_;
	DcContact* result;
	g_return_val_if_fail (obj != NULL, NULL);
	_tmp0_ = dc_contact_new ();
	c = _tmp0_;
	_tmp1_ = c;
	dc_contact_set_id (_tmp1_, contact_id);
	_tmp3_ = dc_json_str (obj, "displayName");
	_tmp2_ = _tmp3_;
	if (_tmp2_ == NULL) {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("");
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp4_;
	}
	_tmp5_ = c;
	dc_contact_set_display_name (_tmp5_, _tmp2_);
	_tmp7_ = dc_json_str (obj, "address");
	_tmp6_ = _tmp7_;
	if (_tmp6_ == NULL) {
		gchar* _tmp8_;
		_tmp8_ = g_strdup ("");
		_g_free0 (_tmp6_);
		_tmp6_ = _tmp8_;
	}
	_tmp9_ = c;
	dc_contact_set_address (_tmp9_, _tmp6_);
	_tmp10_ = c;
	_tmp11_ = dc_json_str (obj, "profileImage");
	_tmp12_ = _tmp11_;
	dc_contact_set_profile_image (_tmp10_, _tmp12_);
	_g_free0 (_tmp12_);
	_tmp13_ = c;
	dc_contact_set_is_verified (_tmp13_, dc_json_bool (obj, "isVerified"));
	_tmp14_ = c;
	dc_contact_set_is_blocked (_tmp14_, dc_json_bool (obj, "isBlocked"));
	_tmp15_ = c;
	_tmp16_ = dc_json_str (obj, "status");
	_tmp17_ = _tmp16_;
	dc_contact_set_status (_tmp15_, _tmp17_);
	_g_free0 (_tmp17_);
	_tmp18_ = c;
	dc_contact_set_was_seen_recently (_tmp18_, dc_json_bool (obj, "wasSeenRecently"));
	result = c;
	_g_free0 (_tmp6_);
	_g_free0 (_tmp2_);
	return result;
}

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

DcMessage*
dc_rpc_parsers_parse_message (JsonObject* obj,
                              const gchar* self_email)
{
	DcMessage* msg = NULL;
	DcMessage* _tmp0_;
	DcMessage* _tmp1_;
	DcMessage* _tmp2_;
	DcMessage* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	DcMessage* _tmp6_;
	DcMessage* _tmp7_;
	DcMessage* _tmp8_;
	DcMessage* _tmp9_;
	DcMessage* _tmp10_;
	DcMessage* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	DcMessage* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	DcMessage* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	DcMessage* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	DcMessage* _tmp23_;
	DcMessage* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	DcMessage* _tmp27_;
	DcMessage* _tmp28_;
	gchar* _tmp29_ = NULL;
	gchar* _tmp30_;
	DcMessage* _tmp32_;
	gboolean _tmp33_ = FALSE;
	gboolean _tmp58_ = FALSE;
	gboolean _tmp70_ = FALSE;
	DcMessage* _tmp72_;
	DcMessage* _tmp73_;
	DcMessage* result;
	g_return_val_if_fail (obj != NULL, NULL);
	_tmp0_ = dc_message_new ();
	msg = _tmp0_;
	_tmp1_ = msg;
	dc_message_set_id (_tmp1_, (gint) dc_json_int (obj, "id", (gint64) 0));
	_tmp2_ = msg;
	dc_message_set_chat_id (_tmp2_, (gint) dc_json_int (obj, "chatId", (gint64) 0));
	_tmp3_ = msg;
	_tmp4_ = dc_json_str (obj, "text");
	_tmp5_ = _tmp4_;
	dc_message_set_text (_tmp3_, _tmp5_);
	_g_free0 (_tmp5_);
	_tmp6_ = msg;
	dc_message_set_timestamp (_tmp6_, dc_json_int (obj, "timestamp", (gint64) 0));
	_tmp7_ = msg;
	dc_message_set_is_info (_tmp7_, dc_json_bool (obj, "isInfo"));
	_tmp8_ = msg;
	dc_message_set_is_forwarded (_tmp8_, dc_json_bool (obj, "isForwarded"));
	_tmp9_ = msg;
	dc_message_set_is_edited (_tmp9_, dc_json_bool (obj, "isEdited"));
	_tmp10_ = msg;
	dc_message_set_is_pinned (_tmp10_, dc_json_bool (obj, "isPinned"));
	_tmp11_ = msg;
	_tmp12_ = dc_json_str (obj, "overrideSenderName");
	_tmp13_ = _tmp12_;
	dc_message_set_override_sender_name (_tmp11_, _tmp13_);
	_g_free0 (_tmp13_);
	_tmp14_ = msg;
	_tmp15_ = dc_json_str (obj, "file");
	_tmp16_ = _tmp15_;
	dc_message_set_file_path (_tmp14_, _tmp16_);
	_g_free0 (_tmp16_);
	_tmp17_ = msg;
	_tmp18_ = dc_json_str (obj, "fileName");
	_tmp19_ = _tmp18_;
	dc_message_set_file_name (_tmp17_, _tmp19_);
	_g_free0 (_tmp19_);
	_tmp20_ = msg;
	_tmp21_ = dc_json_str (obj, "fileMime");
	_tmp22_ = _tmp21_;
	dc_message_set_file_mime (_tmp20_, _tmp22_);
	_g_free0 (_tmp22_);
	_tmp23_ = msg;
	dc_message_set_file_bytes (_tmp23_, (gint) dc_json_int (obj, "fileBytes", (gint64) 0));
	_tmp24_ = msg;
	_tmp25_ = dc_json_str (obj, "viewType");
	_tmp26_ = _tmp25_;
	dc_message_set_view_type (_tmp24_, _tmp26_);
	_g_free0 (_tmp26_);
	_tmp27_ = msg;
	dc_message_set_state (_tmp27_, (gint) dc_json_int (obj, "state", (gint64) 0));
	_tmp28_ = msg;
	dc_message_set_has_html (_tmp28_, dc_json_bool (obj, "hasHtml"));
	_tmp30_ = dc_json_str (obj, "downloadState");
	_tmp29_ = _tmp30_;
	if (_tmp29_ == NULL) {
		gchar* _tmp31_;
		_tmp31_ = g_strdup ("Done");
		_g_free0 (_tmp29_);
		_tmp29_ = _tmp31_;
	}
	_tmp32_ = msg;
	dc_message_set_download_state (_tmp32_, _tmp29_);
	if (json_object_has_member (obj, "sender")) {
		JsonNode* _tmp34_;
		_tmp34_ = json_object_get_member (obj, "sender");
		_tmp33_ = !json_node_is_null (_tmp34_);
	} else {
		_tmp33_ = FALSE;
	}
	if (_tmp33_) {
		JsonObject* sender = NULL;
		JsonObject* _tmp35_;
		JsonObject* _tmp36_;
		DcMessage* _tmp37_;
		JsonObject* _tmp38_;
		gchar* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_ = NULL;
		JsonObject* _tmp42_;
		gchar* _tmp43_;
		DcMessage* _tmp46_;
		gchar* _tmp47_ = NULL;
		JsonObject* _tmp48_;
		gchar* _tmp49_;
		DcMessage* _tmp52_;
		DcMessage* _tmp53_;
		JsonObject* _tmp54_;
		DcMessage* _tmp55_;
		JsonObject* _tmp56_;
		_tmp35_ = json_object_get_object_member (obj, "sender");
		_tmp36_ = _json_object_ref0 (_tmp35_);
		sender = _tmp36_;
		_tmp37_ = msg;
		_tmp38_ = sender;
		_tmp39_ = dc_json_str (_tmp38_, "address");
		_tmp40_ = _tmp39_;
		dc_message_set_sender_address (_tmp37_, _tmp40_);
		_g_free0 (_tmp40_);
		_tmp42_ = sender;
		_tmp43_ = dc_json_str (_tmp42_, "displayName");
		_tmp41_ = _tmp43_;
		if (_tmp41_ == NULL) {
			JsonObject* _tmp44_;
			gchar* _tmp45_;
			_tmp44_ = sender;
			_tmp45_ = dc_json_str (_tmp44_, "name");
			_g_free0 (_tmp41_);
			_tmp41_ = _tmp45_;
		}
		_tmp46_ = msg;
		dc_message_set_sender_name (_tmp46_, _tmp41_);
		_tmp48_ = sender;
		_tmp49_ = dc_json_str (_tmp48_, "profileImage");
		_tmp47_ = _tmp49_;
		if (_tmp47_ == NULL) {
			JsonObject* _tmp50_;
			gchar* _tmp51_;
			_tmp50_ = sender;
			_tmp51_ = dc_json_str (_tmp50_, "avatarPath");
			_g_free0 (_tmp47_);
			_tmp47_ = _tmp51_;
		}
		_tmp52_ = msg;
		dc_message_set_sender_avatar_path (_tmp52_, _tmp47_);
		_tmp53_ = msg;
		_tmp54_ = sender;
		dc_message_set_sender_contact_id (_tmp53_, (gint) dc_json_int (_tmp54_, "id", (gint64) 0));
		_tmp55_ = msg;
		_tmp56_ = sender;
		dc_message_set_sender_was_seen_recently (_tmp55_, dc_json_bool (_tmp56_, "wasSeenRecently"));
		_g_free0 (_tmp47_);
		_g_free0 (_tmp41_);
		_json_object_unref0 (sender);
	}
	if (json_object_has_member (obj, "fromId")) {
		DcMessage* _tmp57_;
		_tmp57_ = msg;
		dc_message_set_sender_contact_id (_tmp57_, (gint) json_object_get_int_member (obj, "fromId"));
	}
	if (self_email != NULL) {
		DcMessage* _tmp59_;
		const gchar* _tmp60_;
		const gchar* _tmp61_;
		_tmp59_ = msg;
		_tmp60_ = dc_message_get_sender_address (_tmp59_);
		_tmp61_ = _tmp60_;
		_tmp58_ = _tmp61_ != NULL;
	} else {
		_tmp58_ = FALSE;
	}
	if (_tmp58_) {
		DcMessage* _tmp62_;
		DcMessage* _tmp63_;
		const gchar* _tmp64_;
		const gchar* _tmp65_;
		gchar* _tmp66_;
		gchar* _tmp67_;
		gchar* _tmp68_;
		gchar* _tmp69_;
		_tmp62_ = msg;
		_tmp63_ = msg;
		_tmp64_ = dc_message_get_sender_address (_tmp63_);
		_tmp65_ = _tmp64_;
		_tmp66_ = g_utf8_strdown (_tmp65_, (gssize) -1);
		_tmp67_ = _tmp66_;
		_tmp68_ = g_utf8_strdown (self_email, (gssize) -1);
		_tmp69_ = _tmp68_;
		dc_message_set_is_outgoing (_tmp62_, g_strcmp0 (_tmp67_, _tmp69_) == 0);
		_g_free0 (_tmp69_);
		_g_free0 (_tmp67_);
	}
	if (json_object_has_member (obj, "fromId")) {
		_tmp70_ = json_object_get_int_member (obj, "fromId") == ((gint64) 1);
	} else {
		_tmp70_ = FALSE;
	}
	if (_tmp70_) {
		DcMessage* _tmp71_;
		_tmp71_ = msg;
		dc_message_set_is_outgoing (_tmp71_, TRUE);
	}
	_tmp72_ = msg;
	dc_rpc_parsers_parse_reactions (obj, _tmp72_);
	_tmp73_ = msg;
	dc_rpc_parsers_parse_quote (obj, _tmp73_);
	result = msg;
	_g_free0 (_tmp29_);
	return result;
}

DcChatEntry*
dc_rpc_parsers_parse_chat_item (gint chat_id,
                                JsonObject* obj)
{
	DcChatEntry* entry = NULL;
	DcChatEntry* _tmp0_;
	DcChatEntry* _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	DcChatEntry* _tmp5_;
	gchar* s1 = NULL;
	gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	const gchar* _tmp8_;
	gchar* s2 = NULL;
	gchar* _tmp14_;
	gboolean _tmp15_ = FALSE;
	const gchar* _tmp16_;
	DcChatEntry* _tmp22_;
	DcChatEntry* _tmp23_;
	DcChatEntry* _tmp24_;
	DcChatEntry* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	DcChatEntry* _tmp28_;
	DcChatEntry* _tmp29_;
	DcChatEntry* _tmp30_;
	DcChatEntry* _tmp31_;
	DcChatEntry* _tmp32_;
	DcChatEntry* _tmp33_;
	gboolean _tmp34_ = FALSE;
	gboolean _tmp35_ = FALSE;
	DcChatEntry* _tmp36_;
	gboolean _tmp37_;
	gboolean _tmp38_;
	DcChatEntry* result;
	g_return_val_if_fail (obj != NULL, NULL);
	_tmp0_ = dc_chat_entry_new ();
	entry = _tmp0_;
	_tmp1_ = entry;
	dc_chat_entry_set_id (_tmp1_, chat_id);
	_tmp3_ = dc_json_str (obj, "name");
	_tmp2_ = _tmp3_;
	if (_tmp2_ == NULL) {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("");
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp4_;
	}
	_tmp5_ = entry;
	dc_chat_entry_set_name (_tmp5_, _tmp2_);
	_tmp6_ = dc_json_str (obj, "summaryText1");
	s1 = _tmp6_;
	_tmp8_ = s1;
	if (_tmp8_ != NULL) {
		const gchar* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		_tmp9_ = s1;
		_tmp10_ = strlen (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp7_ = _tmp11_ > 0;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		DcChatEntry* _tmp12_;
		const gchar* _tmp13_;
		_tmp12_ = entry;
		_tmp13_ = s1;
		dc_chat_entry_set_summary_prefix (_tmp12_, _tmp13_);
	}
	_tmp14_ = dc_json_str (obj, "summaryText2");
	s2 = _tmp14_;
	_tmp16_ = s2;
	if (_tmp16_ != NULL) {
		const gchar* _tmp17_;
		gint _tmp18_;
		gint _tmp19_;
		_tmp17_ = s2;
		_tmp18_ = strlen (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp15_ = _tmp19_ > 0;
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		DcChatEntry* _tmp20_;
		const gchar* _tmp21_;
		_tmp20_ = entry;
		_tmp21_ = s2;
		dc_chat_entry_set_last_message (_tmp20_, _tmp21_);
	}
	_tmp22_ = entry;
	dc_chat_entry_set_last_message_id (_tmp22_, (gint) dc_json_int (obj, "lastMessageId", (gint64) 0));
	_tmp23_ = entry;
	dc_chat_entry_set_unread_count (_tmp23_, (gint) dc_json_int (obj, "freshMessageCounter", (gint64) 0));
	_tmp24_ = entry;
	dc_chat_entry_set_timestamp (_tmp24_, dc_json_int (obj, "lastMessageTimestamp", (gint64) 0));
	_tmp25_ = entry;
	_tmp26_ = dc_json_str (obj, "avatarPath");
	_tmp27_ = _tmp26_;
	dc_chat_entry_set_avatar_path (_tmp25_, _tmp27_);
	_g_free0 (_tmp27_);
	_tmp28_ = entry;
	dc_chat_entry_set_kind (_tmp28_, dc_rpc_parsers_parse_chat_kind (obj));
	_tmp29_ = entry;
	dc_chat_entry_set_is_muted (_tmp29_, dc_json_bool (obj, "isMuted"));
	_tmp30_ = entry;
	dc_chat_entry_set_is_contact_request (_tmp30_, dc_json_bool (obj, "isContactRequest"));
	_tmp31_ = entry;
	dc_chat_entry_set_is_pinned (_tmp31_, dc_json_bool (obj, "isPinned"));
	_tmp32_ = entry;
	dc_chat_entry_set_is_archived (_tmp32_, dc_json_bool (obj, "isArchived"));
	_tmp33_ = entry;
	dc_chat_entry_set_was_seen_recently (_tmp33_, dc_json_bool (obj, "wasSeenRecently"));
	_tmp36_ = entry;
	_tmp37_ = dc_chat_entry_get_was_seen_recently (_tmp36_);
	_tmp38_ = _tmp37_;
	if (!_tmp38_) {
		_tmp35_ = json_object_has_member (obj, "contact");
	} else {
		_tmp35_ = FALSE;
	}
	if (_tmp35_) {
		JsonNode* _tmp39_;
		_tmp39_ = json_object_get_member (obj, "contact");
		_tmp34_ = !json_node_is_null (_tmp39_);
	} else {
		_tmp34_ = FALSE;
	}
	if (_tmp34_) {
		JsonObject* contact = NULL;
		JsonObject* _tmp40_;
		JsonObject* _tmp41_;
		DcChatEntry* _tmp42_;
		JsonObject* _tmp43_;
		_tmp40_ = json_object_get_object_member (obj, "contact");
		_tmp41_ = _json_object_ref0 (_tmp40_);
		contact = _tmp41_;
		_tmp42_ = entry;
		_tmp43_ = contact;
		dc_chat_entry_set_was_seen_recently (_tmp42_, dc_json_bool (_tmp43_, "wasSeenRecently"));
		_json_object_unref0 (contact);
	}
	result = entry;
	_g_free0 (s2);
	_g_free0 (s1);
	_g_free0 (_tmp2_);
	return result;
}

DcChatKind
dc_rpc_parsers_parse_chat_kind (JsonObject* obj)
{
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* chat_type = NULL;
	gchar* _tmp3_;
	gboolean is_self_talk = FALSE;
	gboolean is_device_chat = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	DcChatKind result;
	g_return_val_if_fail (obj != NULL, 0);
	_tmp1_ = dc_json_str (obj, "chatType");
	_tmp0_ = _tmp1_;
	if (_tmp0_ == NULL) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup ("");
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp2_;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	chat_type = _tmp3_;
	is_self_talk = dc_json_bool (obj, "isSelfTalk");
	is_device_chat = dc_json_bool (obj, "isDeviceChat");
	_tmp6_ = chat_type;
	if (g_strcmp0 (_tmp6_, "Single") == 0) {
		_tmp5_ = !is_self_talk;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		_tmp4_ = !is_device_chat;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		result = DC_CHAT_KIND_DIRECT;
		_g_free0 (chat_type);
		_g_free0 (_tmp0_);
		return result;
	}
	_tmp9_ = chat_type;
	if (g_strcmp0 (_tmp9_, "Group") == 0) {
		_tmp8_ = TRUE;
	} else {
		const gchar* _tmp10_;
		_tmp10_ = chat_type;
		_tmp8_ = g_strcmp0 (_tmp10_, "Broadcast") == 0;
	}
	if (_tmp8_) {
		_tmp7_ = TRUE;
	} else {
		const gchar* _tmp11_;
		_tmp11_ = chat_type;
		_tmp7_ = g_strcmp0 (_tmp11_, "OutBroadcast") == 0;
	}
	if (_tmp7_) {
		result = DC_CHAT_KIND_GROUP;
		_g_free0 (chat_type);
		_g_free0 (_tmp0_);
		return result;
	}
	result = DC_CHAT_KIND_UNKNOWN;
	_g_free0 (chat_type);
	_g_free0 (_tmp0_);
	return result;
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

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

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

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

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

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

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

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

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

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

static gpointer
_g_ptr_array_ref0 (gpointer self)
{
	return self ? g_ptr_array_ref (self) : NULL;
}

static void
dc_rpc_parsers_parse_reactions (JsonObject* obj,
                                DcMessage* msg)
{
	gboolean _tmp0_ = FALSE;
	JsonObject* reactions_obj = NULL;
	JsonObject* _tmp2_;
	JsonObject* _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	JsonObject* _tmp6_;
	JsonObject* by_contact = NULL;
	JsonObject* _tmp10_;
	JsonObject* _tmp11_;
	JsonObject* _tmp12_;
	GPtrArray* reaction_details = NULL;
	GPtrArray* _tmp13_;
	gchar** r_emojis = NULL;
	gchar** _tmp14_;
	gint r_emojis_length1;
	gint _r_emojis_size_;
	gint* r_counts = NULL;
	gint* _tmp15_;
	gint r_counts_length1;
	gint _r_counts_size_;
	gchar** my_emojis = NULL;
	gchar** _tmp16_;
	gint my_emojis_length1;
	gint _my_emojis_size_;
	GList* members = NULL;
	JsonObject* _tmp17_;
	GList* _tmp18_;
	GList* _tmp19_;
	gchar** _tmp59_;
	gint _tmp59__length1;
	gchar** _tmp63_;
	gint _tmp63__length1;
	GPtrArray* _tmp64_;
	GPtrArray* _tmp65_;
	GString* sb = NULL;
	GString* _tmp66_;
	GString* _tmp77_;
	const gchar* _tmp78_;
	g_return_if_fail (obj != NULL);
	g_return_if_fail (msg != NULL);
	if (!json_object_has_member (obj, "reactions")) {
		_tmp0_ = TRUE;
	} else {
		JsonNode* _tmp1_;
		_tmp1_ = json_object_get_member (obj, "reactions");
		_tmp0_ = json_node_is_null (_tmp1_);
	}
	if (_tmp0_) {
		return;
	}
	_tmp2_ = json_object_get_object_member (obj, "reactions");
	_tmp3_ = _json_object_ref0 (_tmp2_);
	reactions_obj = _tmp3_;
	_tmp6_ = reactions_obj;
	if (_tmp6_ == NULL) {
		_tmp5_ = TRUE;
	} else {
		JsonObject* _tmp7_;
		_tmp7_ = reactions_obj;
		_tmp5_ = !json_object_has_member (_tmp7_, "reactionsByContact");
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		JsonObject* _tmp8_;
		JsonNode* _tmp9_;
		_tmp8_ = reactions_obj;
		_tmp9_ = json_object_get_member (_tmp8_, "reactionsByContact");
		_tmp4_ = json_node_is_null (_tmp9_);
	}
	if (_tmp4_) {
		_json_object_unref0 (reactions_obj);
		return;
	}
	_tmp10_ = reactions_obj;
	_tmp11_ = json_object_get_object_member (_tmp10_, "reactionsByContact");
	_tmp12_ = _json_object_ref0 (_tmp11_);
	by_contact = _tmp12_;
	_tmp13_ = g_ptr_array_new_full ((guint) 0, _g_object_unref0_);
	reaction_details = _tmp13_;
	_tmp14_ = g_new0 (gchar*, 0 + 1);
	r_emojis = _tmp14_;
	r_emojis_length1 = 0;
	_r_emojis_size_ = r_emojis_length1;
	_tmp15_ = g_new0 (gint, 0);
	r_counts = _tmp15_;
	r_counts_length1 = 0;
	_r_counts_size_ = r_counts_length1;
	_tmp16_ = g_new0 (gchar*, 0 + 1);
	my_emojis = _tmp16_;
	my_emojis_length1 = 0;
	_my_emojis_size_ = my_emojis_length1;
	_tmp17_ = by_contact;
	_tmp18_ = json_object_get_members (_tmp17_);
	members = _tmp18_;
	_tmp19_ = members;
	{
		GList* cid_collection = NULL;
		GList* cid_it = NULL;
		cid_collection = _tmp19_;
		for (cid_it = cid_collection; cid_it != NULL; cid_it = cid_it->next) {
			const gchar* cid = NULL;
			cid = (const gchar*) cid_it->data;
			{
				JsonNode* node = NULL;
				JsonObject* _tmp20_;
				const gchar* _tmp21_;
				JsonNode* _tmp22_;
				JsonNode* _tmp23_;
				JsonNode* _tmp24_;
				JsonArray* arr = NULL;
				JsonNode* _tmp25_;
				JsonArray* _tmp26_;
				JsonArray* _tmp27_;
				gboolean is_self = FALSE;
				const gchar* _tmp28_;
				gint contact_id = 0;
				const gchar* _tmp29_;
				_tmp20_ = by_contact;
				_tmp21_ = cid;
				_tmp22_ = json_object_get_member (_tmp20_, _tmp21_);
				_tmp23_ = __vala_JsonNode_copy0 (_tmp22_);
				node = _tmp23_;
				_tmp24_ = node;
				if (json_node_get_node_type (_tmp24_) != JSON_NODE_ARRAY) {
					__vala_JsonNode_free0 (node);
					continue;
				}
				_tmp25_ = node;
				_tmp26_ = json_node_get_array (_tmp25_);
				_tmp27_ = _json_array_ref0 (_tmp26_);
				arr = _tmp27_;
				_tmp28_ = cid;
				is_self = g_strcmp0 (_tmp28_, "1") == 0;
				_tmp29_ = cid;
				contact_id = atoi (_tmp29_);
				{
					guint j = 0U;
					j = (guint) 0;
					{
						gboolean _tmp30_ = FALSE;
						_tmp30_ = TRUE;
						while (TRUE) {
							JsonArray* _tmp32_;
							gchar* emoji = NULL;
							JsonArray* _tmp33_;
							const gchar* _tmp34_;
							gchar* _tmp35_;
							DcMessageReaction* reaction = NULL;
							GPtrArray* _tmp38_;
							const gchar* _tmp39_;
							DcMessageReaction* _tmp40_;
							DcMessageReaction* _tmp41_;
							DcMessageReaction* _tmp47_;
							gint found = 0;
							if (!_tmp30_) {
								guint _tmp31_;
								_tmp31_ = j;
								j = _tmp31_ + 1;
							}
							_tmp30_ = FALSE;
							_tmp32_ = arr;
							if (!(j < json_array_get_length (_tmp32_))) {
								break;
							}
							_tmp33_ = arr;
							_tmp34_ = json_array_get_string_element (_tmp33_, j);
							_tmp35_ = g_strdup (_tmp34_);
							emoji = _tmp35_;
							if (is_self) {
								const gchar* _tmp36_;
								gchar* _tmp37_;
								_tmp36_ = emoji;
								_tmp37_ = g_strdup (_tmp36_);
								_vala_array_add14 (&my_emojis, &my_emojis_length1, &_my_emojis_size_, _tmp37_);
							}
							_tmp38_ = reaction_details;
							_tmp39_ = emoji;
							_tmp40_ = dc_rpc_parsers_find_reaction (_tmp38_, _tmp39_);
							reaction = _tmp40_;
							_tmp41_ = reaction;
							if (_tmp41_ == NULL) {
								const gchar* _tmp42_;
								DcMessageReaction* _tmp43_;
								GPtrArray* _tmp44_;
								DcMessageReaction* _tmp45_;
								DcMessageReaction* _tmp46_;
								_tmp42_ = emoji;
								_tmp43_ = dc_message_reaction_new (_tmp42_);
								_g_object_unref0 (reaction);
								reaction = _tmp43_;
								_tmp44_ = reaction_details;
								_tmp45_ = reaction;
								_tmp46_ = _g_object_ref0 (_tmp45_);
								g_ptr_array_add (_tmp44_, _tmp46_);
							}
							_tmp47_ = reaction;
							dc_message_reaction_add_user (_tmp47_, contact_id);
							found = -1;
							{
								gint k = 0;
								k = 0;
								{
									gboolean _tmp48_ = FALSE;
									_tmp48_ = TRUE;
									while (TRUE) {
										gchar** _tmp50_;
										gint _tmp50__length1;
										gchar** _tmp51_;
										gint _tmp51__length1;
										const gchar* _tmp52_;
										const gchar* _tmp53_;
										if (!_tmp48_) {
											gint _tmp49_;
											_tmp49_ = k;
											k = _tmp49_ + 1;
										}
										_tmp48_ = FALSE;
										_tmp50_ = r_emojis;
										_tmp50__length1 = r_emojis_length1;
										if (!(k < _tmp50__length1)) {
											break;
										}
										_tmp51_ = r_emojis;
										_tmp51__length1 = r_emojis_length1;
										_tmp52_ = _tmp51_[k];
										_tmp53_ = emoji;
										if (g_strcmp0 (_tmp52_, _tmp53_) == 0) {
											found = k;
											break;
										}
									}
								}
							}
							if (found >= 0) {
								gint* _tmp54_;
								gint _tmp54__length1;
								gint* _tmp55_;
								gint _tmp55__length1;
								gint _tmp56_;
								_tmp54_ = r_counts;
								_tmp54__length1 = r_counts_length1;
								_tmp55_ = r_counts;
								_tmp55__length1 = r_counts_length1;
								_tmp56_ = _tmp55_[found];
								_tmp54_[found] = _tmp56_ + 1;
							} else {
								const gchar* _tmp57_;
								gchar* _tmp58_;
								_tmp57_ = emoji;
								_tmp58_ = g_strdup (_tmp57_);
								_vala_array_add15 (&r_emojis, &r_emojis_length1, &_r_emojis_size_, _tmp58_);
								_vala_array_add16 (&r_counts, &r_counts_length1, &_r_counts_size_, 1);
							}
							_g_object_unref0 (reaction);
							_g_free0 (emoji);
						}
					}
				}
				_json_array_unref0 (arr);
				__vala_JsonNode_free0 (node);
			}
		}
	}
	_tmp59_ = my_emojis;
	_tmp59__length1 = my_emojis_length1;
	if (_tmp59__length1 > 0) {
		gchar** _tmp60_;
		gint _tmp60__length1;
		gchar* _tmp61_;
		gchar* _tmp62_;
		_tmp60_ = my_emojis;
		_tmp60__length1 = my_emojis_length1;
		_tmp61_ = _vala_g_strjoinv (",", _tmp60_, (gint) _tmp60__length1);
		_tmp62_ = _tmp61_;
		dc_message_set_my_reactions (msg, _tmp62_);
		_g_free0 (_tmp62_);
	}
	_tmp63_ = r_emojis;
	_tmp63__length1 = r_emojis_length1;
	if (_tmp63__length1 == 0) {
		(members == NULL) ? NULL : (members = (g_list_free (members), NULL));
		my_emojis = (_vala_array_free (my_emojis, my_emojis_length1, (GDestroyNotify) g_free), NULL);
		r_counts = (g_free (r_counts), NULL);
		r_emojis = (_vala_array_free (r_emojis, r_emojis_length1, (GDestroyNotify) g_free), NULL);
		_g_ptr_array_unref0 (reaction_details);
		_json_object_unref0 (by_contact);
		_json_object_unref0 (reactions_obj);
		return;
	}
	_tmp64_ = reaction_details;
	_tmp65_ = _g_ptr_array_ref0 (_tmp64_);
	_g_ptr_array_unref0 (msg->reaction_details);
	msg->reaction_details = _tmp65_;
	_tmp66_ = g_string_new ("");
	sb = _tmp66_;
	{
		gint k = 0;
		k = 0;
		{
			gboolean _tmp67_ = FALSE;
			_tmp67_ = TRUE;
			while (TRUE) {
				gchar** _tmp69_;
				gint _tmp69__length1;
				GString* _tmp70_;
				GString* _tmp72_;
				gchar** _tmp73_;
				gint _tmp73__length1;
				const gchar* _tmp74_;
				gint* _tmp75_;
				gint _tmp75__length1;
				gint _tmp76_;
				if (!_tmp67_) {
					gint _tmp68_;
					_tmp68_ = k;
					k = _tmp68_ + 1;
				}
				_tmp67_ = FALSE;
				_tmp69_ = r_emojis;
				_tmp69__length1 = r_emojis_length1;
				if (!(k < _tmp69__length1)) {
					break;
				}
				_tmp70_ = sb;
				if (_tmp70_->len > ((gssize) 0)) {
					GString* _tmp71_;
					_tmp71_ = sb;
					g_string_append (_tmp71_, ",");
				}
				_tmp72_ = sb;
				_tmp73_ = r_emojis;
				_tmp73__length1 = r_emojis_length1;
				_tmp74_ = _tmp73_[k];
				_tmp75_ = r_counts;
				_tmp75__length1 = r_counts_length1;
				_tmp76_ = _tmp75_[k];
				g_string_append_printf (_tmp72_, "%s:%d", _tmp74_, _tmp76_);
			}
		}
	}
	_tmp77_ = sb;
	_tmp78_ = _tmp77_->str;
	dc_message_set_reactions (msg, _tmp78_);
	_g_string_free0 (sb);
	(members == NULL) ? NULL : (members = (g_list_free (members), NULL));
	my_emojis = (_vala_array_free (my_emojis, my_emojis_length1, (GDestroyNotify) g_free), NULL);
	r_counts = (g_free (r_counts), NULL);
	r_emojis = (_vala_array_free (r_emojis, r_emojis_length1, (GDestroyNotify) g_free), NULL);
	_g_ptr_array_unref0 (reaction_details);
	_json_object_unref0 (by_contact);
	_json_object_unref0 (reactions_obj);
}

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

static DcMessageReaction*
dc_rpc_parsers_find_reaction (GPtrArray* reactions,
                              const gchar* emoji)
{
	DcMessageReaction* result;
	g_return_val_if_fail (reactions != NULL, NULL);
	g_return_val_if_fail (emoji != NULL, NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_;
				gint _tmp3_;
				gconstpointer _tmp4_;
				const gchar* _tmp5_;
				const gchar* _tmp6_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = vala_g_ptr_array_get_length (reactions);
				_tmp3_ = _tmp2_;
				if (!(i < _tmp3_)) {
					break;
				}
				_tmp4_ = g_ptr_array_index (reactions, (guint) i);
				_tmp5_ = dc_message_reaction_get_emoji ((DcMessageReaction*) _tmp4_);
				_tmp6_ = _tmp5_;
				if (g_strcmp0 (_tmp6_, emoji) == 0) {
					gconstpointer _tmp7_;
					DcMessageReaction* _tmp8_;
					_tmp7_ = g_ptr_array_index (reactions, (guint) i);
					_tmp8_ = _g_object_ref0 ((DcMessageReaction*) _tmp7_);
					result = _tmp8_;
					return result;
				}
			}
		}
	}
	result = NULL;
	return result;
}

static void
dc_rpc_parsers_parse_quote (JsonObject* obj,
                            DcMessage* msg)
{
	gboolean _tmp0_ = FALSE;
	JsonObject* quote = NULL;
	JsonObject* _tmp2_;
	JsonObject* _tmp3_;
	JsonObject* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	JsonObject* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	JsonObject* _tmp10_;
	g_return_if_fail (obj != NULL);
	g_return_if_fail (msg != NULL);
	if (!json_object_has_member (obj, "quote")) {
		_tmp0_ = TRUE;
	} else {
		JsonNode* _tmp1_;
		_tmp1_ = json_object_get_member (obj, "quote");
		_tmp0_ = json_node_is_null (_tmp1_);
	}
	if (_tmp0_) {
		return;
	}
	_tmp2_ = json_object_get_object_member (obj, "quote");
	_tmp3_ = _json_object_ref0 (_tmp2_);
	quote = _tmp3_;
	_tmp4_ = quote;
	_tmp5_ = dc_json_str (_tmp4_, "text");
	_tmp6_ = _tmp5_;
	dc_message_set_quote_text (msg, _tmp6_);
	_g_free0 (_tmp6_);
	_tmp7_ = quote;
	_tmp8_ = dc_json_str (_tmp7_, "authorDisplayName");
	_tmp9_ = _tmp8_;
	dc_message_set_quote_sender_name (msg, _tmp9_);
	_g_free0 (_tmp9_);
	_tmp10_ = quote;
	dc_message_set_quote_msg_id (msg, (gint) dc_json_int (_tmp10_, "messageId", (gint64) 0));
	_json_object_unref0 (quote);
}

DcRpcParsers*
dc_rpc_parsers_construct (GType object_type)
{
	DcRpcParsers* self = NULL;
	self = (DcRpcParsers*) g_type_create_instance (object_type);
	return self;
}

DcRpcParsers*
dc_rpc_parsers_new (void)
{
	return dc_rpc_parsers_construct (DC_TYPE_RPC_PARSERS);
}

static void
dc_value_rpc_parsers_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dc_value_rpc_parsers_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dc_rpc_parsers_unref (value->data[0].v_pointer);
	}
}

static void
dc_value_rpc_parsers_copy_value (const GValue* src_value,
                                 GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dc_rpc_parsers_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dc_value_rpc_parsers_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dc_value_rpc_parsers_collect_value (GValue* value,
                                    guint n_collect_values,
                                    GTypeCValue* collect_values,
                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DcRpcParsers * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dc_rpc_parsers_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dc_value_rpc_parsers_lcopy_value (const GValue* value,
                                  guint n_collect_values,
                                  GTypeCValue* collect_values,
                                  guint collect_flags)
{
	DcRpcParsers ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dc_rpc_parsers_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
dc_param_spec_rpc_parsers (const gchar* name,
                           const gchar* nick,
                           const gchar* blurb,
                           GType object_type,
                           GParamFlags flags)
{
	DcParamSpecRpcParsers* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DC_TYPE_RPC_PARSERS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
dc_value_get_rpc_parsers (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_TYPE_RPC_PARSERS), NULL);
	return value->data[0].v_pointer;
}

void
dc_value_set_rpc_parsers (GValue* value,
                          gpointer v_object)
{
	DcRpcParsers * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_TYPE_RPC_PARSERS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_TYPE_RPC_PARSERS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dc_rpc_parsers_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_rpc_parsers_unref (old);
	}
}

void
dc_value_take_rpc_parsers (GValue* value,
                           gpointer v_object)
{
	DcRpcParsers * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DC_TYPE_RPC_PARSERS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DC_TYPE_RPC_PARSERS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dc_rpc_parsers_unref (old);
	}
}

static void
dc_rpc_parsers_class_init (DcRpcParsersClass * klass,
                           gpointer klass_data)
{
	dc_rpc_parsers_parent_class = g_type_class_peek_parent (klass);
	((DcRpcParsersClass *) klass)->finalize = dc_rpc_parsers_finalize;
}

static void
dc_rpc_parsers_instance_init (DcRpcParsers * self,
                              gpointer klass)
{
	self->ref_count = 1;
}

static void
dc_rpc_parsers_finalize (DcRpcParsers * obj)
{
	DcRpcParsers * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_RPC_PARSERS, DcRpcParsers);
	g_signal_handlers_destroy (self);
}

static GType
dc_rpc_parsers_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dc_value_rpc_parsers_init, dc_value_rpc_parsers_free_value, dc_value_rpc_parsers_copy_value, dc_value_rpc_parsers_peek_pointer, "p", dc_value_rpc_parsers_collect_value, "p", dc_value_rpc_parsers_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DcRpcParsersClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_rpc_parsers_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcRpcParsers), 0, (GInstanceInitFunc) dc_rpc_parsers_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dc_rpc_parsers_type_id;
	dc_rpc_parsers_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DcRpcParsers", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dc_rpc_parsers_type_id;
}

GType
dc_rpc_parsers_get_type (void)
{
	static volatile gsize dc_rpc_parsers_type_id__once = 0;
	if (g_once_init_enter (&dc_rpc_parsers_type_id__once)) {
		GType dc_rpc_parsers_type_id;
		dc_rpc_parsers_type_id = dc_rpc_parsers_get_type_once ();
		g_once_init_leave (&dc_rpc_parsers_type_id__once, dc_rpc_parsers_type_id);
	}
	return dc_rpc_parsers_type_id__once;
}

gpointer
dc_rpc_parsers_ref (gpointer instance)
{
	DcRpcParsers * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
dc_rpc_parsers_unref (gpointer instance)
{
	DcRpcParsers * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DC_RPC_PARSERS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

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

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

