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

#include "omemo.h"
#include <glib-object.h>
#include <glib.h>
#include "libdino.h"
#include <stdlib.h>
#include <string.h>
#include "qlite.h"
#include <gio/gio.h>
#include "xmpp-vala.h"
#include <gee.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

enum  {
	DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_0_PROPERTY,
	DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_ENCRYPTION_PROPERTY,
	DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_NAME_PROPERTY,
	DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_NUM_PROPERTIES
};
static GParamSpec* dino_plugins_omemo_encryption_list_entry_properties[DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _qlite_database_unref0(var) ((var == NULL) ? NULL : (var = (qlite_database_unref (var), NULL)))
#define _qlite_statement_builder_unref0(var) ((var == NULL) ? NULL : (var = (qlite_statement_builder_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _qlite_row_option_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_option_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
typedef struct _DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData;

struct _DinoPluginsOmemoEncryptionListEntryPrivate {
	DinoPluginsOmemoPlugin* plugin;
	DinoPluginsOmemoDatabase* db;
};

struct _DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOmemoEncryptionListEntry* self;
	DinoEntitiesConversation* conversation;
	DinoPluginsSetInputFieldStatus input_status_callback;
	gpointer input_status_callback_target;
	DinoEntitiesConversationType _tmp0_;
	DinoEntitiesConversationType _tmp1_;
	DinoPluginsInputFieldStatus* _tmp2_;
	DinoPluginsInputFieldStatus* _tmp3_;
	DinoMucManager* muc_manager;
	DinoPluginsOmemoPlugin* _tmp4_;
	DinoApplication* _tmp5_;
	DinoStreamInteractor* _tmp6_;
	DinoStreamInteractor* _tmp7_;
	DinoModuleIdentity* _tmp8_;
	gpointer _tmp9_;
	DinoPluginsOmemoManager* omemo_manager;
	DinoPluginsOmemoPlugin* _tmp10_;
	DinoApplication* _tmp11_;
	DinoStreamInteractor* _tmp12_;
	DinoStreamInteractor* _tmp13_;
	DinoModuleIdentity* _tmp14_;
	gpointer _tmp15_;
	DinoMucManager* _tmp16_;
	DinoEntitiesAccount* _tmp17_;
	DinoEntitiesAccount* _tmp18_;
	XmppJid* _tmp19_;
	XmppJid* _tmp20_;
	GeeList* offline_members;
	DinoMucManager* _tmp21_;
	XmppJid* _tmp22_;
	XmppJid* _tmp23_;
	DinoEntitiesAccount* _tmp24_;
	DinoEntitiesAccount* _tmp25_;
	GeeList* _tmp26_;
	GeeList* _tmp27_;
	GeeList* _offline_member_list;
	GeeList* _tmp28_;
	gint _offline_member_size;
	GeeList* _tmp29_;
	gint _tmp30_;
	gint _tmp31_;
	gint _offline_member_index;
	gint _tmp32_;
	gint _tmp33_;
	XmppJid* offline_member;
	GeeList* _tmp34_;
	gpointer _tmp35_;
	gboolean ok;
	DinoPluginsOmemoManager* _tmp36_;
	DinoEntitiesAccount* _tmp37_;
	DinoEntitiesAccount* _tmp38_;
	XmppJid* _tmp39_;
	XmppJid* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	DinoPluginsInputFieldStatus* _tmp45_;
	DinoPluginsInputFieldStatus* _tmp46_;
	DinoPluginsOmemoManager* _tmp47_;
	DinoEntitiesAccount* _tmp48_;
	DinoEntitiesAccount* _tmp49_;
	XmppJid* _tmp50_;
	XmppJid* _tmp51_;
	XmppJid* _tmp52_;
	XmppJid* _tmp53_;
	XmppJid* _tmp54_;
	gboolean _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	DinoPluginsInputFieldStatus* _tmp58_;
	DinoPluginsInputFieldStatus* _tmp59_;
};

static gint DinoPluginsOmemoEncryptionListEntry_private_offset;
static gpointer dino_plugins_omemo_encryption_list_entry_parent_class = NULL;
static DinoPluginsEncryptionListEntryIface * dino_plugins_omemo_encryption_list_entry_dino_plugins_encryption_list_entry_parent_iface = NULL;

static GObject* dino_plugins_omemo_encryption_list_entry_real_get_encryption_icon (DinoPluginsEncryptionListEntry* base,
                                                                            DinoEntitiesConversation* conversation,
                                                                            DinoContentItem* content_item);
static gchar* dino_plugins_omemo_encryption_list_entry_real_get_encryption_icon_name (DinoPluginsEncryptionListEntry* base,
                                                                               DinoEntitiesConversation* conversation,
                                                                               DinoContentItem* content_item);
static void dino_plugins_omemo_encryption_list_entry_real_encryption_activated (DinoPluginsEncryptionListEntry* base,
                                                                         DinoEntitiesConversation* conversation,
                                                                         DinoPluginsSetInputFieldStatus input_status_callback,
                                                                         gpointer input_status_callback_target);
static void dino_plugins_omemo_encryption_list_entry_encryption_activated_async_data_free (gpointer _data);
static gboolean dino_plugins_omemo_encryption_list_entry_encryption_activated_async_co (DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData* _data_);
static void dino_plugins_omemo_encryption_list_entry_encryption_activated_async_ready (GObject* source_object,
                                                                                GAsyncResult* _res_,
                                                                                gpointer _user_data_);
static void dino_plugins_omemo_encryption_list_entry_finalize (GObject * obj);
static GType dino_plugins_omemo_encryption_list_entry_get_type_once (void);
static void _vala_dino_plugins_omemo_encryption_list_entry_get_property (GObject * object,
                                                                  guint property_id,
                                                                  GValue * value,
                                                                  GParamSpec * pspec);
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);

static inline gpointer
dino_plugins_omemo_encryption_list_entry_get_instance_private (DinoPluginsOmemoEncryptionListEntry* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOmemoEncryptionListEntry_private_offset);
}

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

static gpointer
_qlite_database_ref0 (gpointer self)
{
	return self ? qlite_database_ref (self) : NULL;
}

DinoPluginsOmemoEncryptionListEntry*
dino_plugins_omemo_encryption_list_entry_construct (GType object_type,
                                                    DinoPluginsOmemoPlugin* plugin)
{
	DinoPluginsOmemoEncryptionListEntry * self = NULL;
	DinoPluginsOmemoPlugin* _tmp0_;
	DinoPluginsOmemoDatabase* _tmp1_;
	DinoPluginsOmemoDatabase* _tmp2_;
	g_return_val_if_fail (plugin != NULL, NULL);
	self = (DinoPluginsOmemoEncryptionListEntry*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (plugin);
	_g_object_unref0 (self->priv->plugin);
	self->priv->plugin = _tmp0_;
	_tmp1_ = plugin->db;
	_tmp2_ = _qlite_database_ref0 (_tmp1_);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp2_;
	return self;
}

DinoPluginsOmemoEncryptionListEntry*
dino_plugins_omemo_encryption_list_entry_new (DinoPluginsOmemoPlugin* plugin)
{
	return dino_plugins_omemo_encryption_list_entry_construct (DINO_PLUGINS_OMEMO_TYPE_ENCRYPTION_LIST_ENTRY, plugin);
}

static GObject*
dino_plugins_omemo_encryption_list_entry_real_get_encryption_icon (DinoPluginsEncryptionListEntry* base,
                                                                   DinoEntitiesConversation* conversation,
                                                                   DinoContentItem* content_item)
{
	DinoPluginsOmemoEncryptionListEntry * self;
	GObject* result;
	self = (DinoPluginsOmemoEncryptionListEntry*) base;
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (content_item != NULL, NULL);
	result = NULL;
	return result;
}

static gpointer
_qlite_column_ref0 (gpointer self)
{
	return self ? qlite_column_ref (self) : NULL;
}

static gchar*
dino_plugins_omemo_encryption_list_entry_real_get_encryption_icon_name (DinoPluginsEncryptionListEntry* base,
                                                                        DinoEntitiesConversation* conversation,
                                                                        DinoContentItem* content_item)
{
	DinoPluginsOmemoEncryptionListEntry * self;
	DinoEntitiesEncryption _tmp0_;
	DinoEntitiesEncryption _tmp1_;
	DinoEntitiesEncryption _tmp2_;
	DinoEntitiesEncryption _tmp3_;
	QliteRowOption* row = NULL;
	DinoPluginsOmemoDatabase* _tmp4_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp5_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp6_;
	DinoPluginsOmemoDatabase* _tmp7_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp8_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp9_;
	QliteColumn* _tmp10_;
	QliteColumn* _tmp11_;
	QliteColumn** _tmp12_;
	QliteColumn** _tmp13_;
	gint _tmp13__length1;
	QliteQueryBuilder* _tmp14_;
	QliteQueryBuilder* _tmp15_;
	DinoPluginsOmemoDatabase* _tmp16_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp17_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp18_;
	QliteColumn* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	QliteQueryBuilder* _tmp22_;
	QliteQueryBuilder* _tmp23_;
	DinoPluginsOmemoDatabase* _tmp24_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp25_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp26_;
	DinoPluginsOmemoDatabase* _tmp27_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp28_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp29_;
	QliteColumn* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	DinoPluginsOmemoDatabase* _tmp33_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp34_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp35_;
	QliteColumn* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	DinoPluginsOmemoDatabase* _tmp39_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp40_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp41_;
	QliteColumn* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	DinoPluginsOmemoDatabase* _tmp45_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp46_;
	DinoPluginsOmemoDatabaseContentItemMetaTable* _tmp47_;
	QliteColumn* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	QliteQueryBuilder* _tmp53_;
	QliteQueryBuilder* _tmp54_;
	QliteQueryBuilder* _tmp55_;
	QliteQueryBuilder* _tmp56_;
	QliteRowOption* _tmp57_;
	QliteRowOption* _tmp58_;
	gboolean _tmp59_ = FALSE;
	QliteRowOption* _tmp60_;
	gchar* result;
	self = (DinoPluginsOmemoEncryptionListEntry*) base;
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (content_item != NULL, NULL);
	_tmp0_ = dino_content_item_get_encryption (content_item);
	_tmp1_ = _tmp0_;
	_tmp2_ = dino_plugins_encryption_list_entry_get_encryption ((DinoPluginsEncryptionListEntry*) self);
	_tmp3_ = _tmp2_;
	if (_tmp1_ != _tmp3_) {
		result = NULL;
		return result;
	}
	_tmp4_ = self->priv->db;
	_tmp5_ = dino_plugins_omemo_database_get_content_item_meta (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->db;
	_tmp8_ = dino_plugins_omemo_database_get_identity_meta (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_->trust_level;
	_tmp11_ = _qlite_column_ref0 (_tmp10_);
	_tmp12_ = g_new0 (QliteColumn*, 1 + 1);
	_tmp12_[0] = _tmp11_;
	_tmp13_ = _tmp12_;
	_tmp13__length1 = 1;
	_tmp14_ = qlite_table_select ((QliteTable*) _tmp6_, _tmp13_, (gint) 1);
	_tmp15_ = _tmp14_;
	_tmp16_ = self->priv->db;
	_tmp17_ = dino_plugins_omemo_database_get_content_item_meta (_tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = _tmp18_->content_item_id;
	_tmp20_ = dino_content_item_get_id (content_item);
	_tmp21_ = _tmp20_;
	_tmp22_ = qlite_query_builder_with (_tmp15_, G_TYPE_INT, NULL, NULL, _tmp19_, "=", (gpointer) ((gintptr) _tmp21_));
	_tmp23_ = _tmp22_;
	_tmp24_ = self->priv->db;
	_tmp25_ = dino_plugins_omemo_database_get_identity_meta (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = self->priv->db;
	_tmp28_ = dino_plugins_omemo_database_get_identity_meta (_tmp27_);
	_tmp29_ = _tmp28_;
	_tmp30_ = _tmp29_->address_name;
	_tmp31_ = qlite_column_to_string (_tmp30_);
	_tmp32_ = _tmp31_;
	_tmp33_ = self->priv->db;
	_tmp34_ = dino_plugins_omemo_database_get_content_item_meta (_tmp33_);
	_tmp35_ = _tmp34_;
	_tmp36_ = _tmp35_->address_name;
	_tmp37_ = qlite_column_to_string (_tmp36_);
	_tmp38_ = _tmp37_;
	_tmp39_ = self->priv->db;
	_tmp40_ = dino_plugins_omemo_database_get_identity_meta (_tmp39_);
	_tmp41_ = _tmp40_;
	_tmp42_ = _tmp41_->device_id;
	_tmp43_ = qlite_column_to_string (_tmp42_);
	_tmp44_ = _tmp43_;
	_tmp45_ = self->priv->db;
	_tmp46_ = dino_plugins_omemo_database_get_content_item_meta (_tmp45_);
	_tmp47_ = _tmp46_;
	_tmp48_ = _tmp47_->device_id;
	_tmp49_ = qlite_column_to_string (_tmp48_);
	_tmp50_ = _tmp49_;
	_tmp51_ = g_strconcat (_tmp32_, "=", _tmp38_, " AND ", _tmp44_, "=", _tmp50_, NULL);
	_tmp52_ = _tmp51_;
	_tmp53_ = qlite_query_builder_join_on (_tmp23_, (QliteTable*) _tmp26_, _tmp52_, NULL);
	_tmp54_ = _tmp53_;
	_tmp55_ = qlite_query_builder_single (_tmp54_);
	_tmp56_ = _tmp55_;
	_tmp57_ = qlite_query_builder_row (_tmp56_);
	_tmp58_ = _tmp57_;
	_qlite_statement_builder_unref0 (_tmp56_);
	_qlite_statement_builder_unref0 (_tmp54_);
	_g_free0 (_tmp52_);
	_g_free0 (_tmp50_);
	_g_free0 (_tmp44_);
	_g_free0 (_tmp38_);
	_g_free0 (_tmp32_);
	_qlite_statement_builder_unref0 (_tmp23_);
	_qlite_statement_builder_unref0 (_tmp15_);
	_tmp13_ = (_vala_array_free (_tmp13_, _tmp13__length1, (GDestroyNotify) qlite_column_unref), NULL);
	row = _tmp58_;
	_tmp60_ = row;
	if (qlite_row_option_is_present (_tmp60_)) {
		QliteRowOption* _tmp61_;
		DinoPluginsOmemoDatabase* _tmp62_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp63_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp64_;
		QliteColumn* _tmp65_;
		gpointer _tmp66_;
		_tmp61_ = row;
		_tmp62_ = self->priv->db;
		_tmp63_ = dino_plugins_omemo_database_get_identity_meta (_tmp62_);
		_tmp64_ = _tmp63_;
		_tmp65_ = _tmp64_->trust_level;
		_tmp66_ = qlite_row_option_get (_tmp61_, G_TYPE_INT, NULL, NULL, _tmp65_, NULL);
		_tmp59_ = ((DinoPluginsOmemoTrustLevel) ((gint) ((gintptr) _tmp66_))) == DINO_PLUGINS_OMEMO_TRUST_LEVEL_VERIFIED;
	} else {
		_tmp59_ = FALSE;
	}
	if (_tmp59_) {
		gchar* _tmp67_;
		_tmp67_ = g_strdup ("dino-security-high-symbolic");
		result = _tmp67_;
		_qlite_row_option_unref0 (row);
		return result;
	}
	result = NULL;
	_qlite_row_option_unref0 (row);
	return result;
}

static void
dino_plugins_omemo_encryption_list_entry_real_encryption_activated (DinoPluginsEncryptionListEntry* base,
                                                                    DinoEntitiesConversation* conversation,
                                                                    DinoPluginsSetInputFieldStatus input_status_callback,
                                                                    gpointer input_status_callback_target)
{
	DinoPluginsOmemoEncryptionListEntry * self;
	self = (DinoPluginsOmemoEncryptionListEntry*) base;
	g_return_if_fail (conversation != NULL);
	dino_plugins_omemo_encryption_list_entry_encryption_activated_async (self, conversation, input_status_callback, input_status_callback_target, NULL, NULL);
}

static void
dino_plugins_omemo_encryption_list_entry_encryption_activated_async_data_free (gpointer _data)
{
	DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData, _data_);
}

void
dino_plugins_omemo_encryption_list_entry_encryption_activated_async (DinoPluginsOmemoEncryptionListEntry* self,
                                                                     DinoEntitiesConversation* conversation,
                                                                     DinoPluginsSetInputFieldStatus input_status_callback,
                                                                     gpointer input_status_callback_target,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_)
{
	DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData* _data_;
	DinoPluginsOmemoEncryptionListEntry* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_data_ = g_slice_new0 (DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_omemo_encryption_list_entry_encryption_activated_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	_data_->input_status_callback = input_status_callback;
	_data_->input_status_callback_target = input_status_callback_target;
	dino_plugins_omemo_encryption_list_entry_encryption_activated_async_co (_data_);
}

void
dino_plugins_omemo_encryption_list_entry_encryption_activated_finish (DinoPluginsOmemoEncryptionListEntry* self,
                                                                      GAsyncResult* _res_)
{
	DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dino_plugins_omemo_encryption_list_entry_encryption_activated_async_ready (GObject* source_object,
                                                                           GAsyncResult* _res_,
                                                                           gpointer _user_data_)
{
	DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_omemo_encryption_list_entry_encryption_activated_async_co (_data_);
}

static gboolean
dino_plugins_omemo_encryption_list_entry_encryption_activated_async_co (DinoPluginsOmemoEncryptionListEntryEncryptionActivatedAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = dino_entities_conversation_get_type_ (_data_->conversation);
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT_PM) {
		_data_->_tmp2_ = dino_plugins_input_field_status_new ("Can't use encryption in a groupchat private message.", DINO_PLUGINS_INPUT_FIELD_STATUS_MESSAGE_TYPE_ERROR, DINO_PLUGINS_INPUT_FIELD_STATUS_INPUT_STATE_NO_SEND, FALSE);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->input_status_callback (_data_->_tmp3_, _data_->input_status_callback_target);
		_g_object_unref0 (_data_->_tmp3_);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->self->priv->plugin;
	_data_->_tmp5_ = _data_->_tmp4_->app;
	_data_->_tmp6_ = dino_application_get_stream_interactor (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = dino_muc_manager_IDENTITY;
	_data_->_tmp9_ = dino_stream_interactor_get_module (_data_->_tmp7_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp8_);
	_data_->muc_manager = (DinoMucManager*) _data_->_tmp9_;
	_data_->_tmp10_ = _data_->self->priv->plugin;
	_data_->_tmp11_ = _data_->_tmp10_->app;
	_data_->_tmp12_ = dino_application_get_stream_interactor (_data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = dino_plugins_omemo_manager_IDENTITY;
	_data_->_tmp15_ = dino_stream_interactor_get_module (_data_->_tmp13_, DINO_PLUGINS_OMEMO_TYPE_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp14_);
	_data_->omemo_manager = (DinoPluginsOmemoManager*) _data_->_tmp15_;
	_data_->_tmp16_ = _data_->muc_manager;
	_data_->_tmp17_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->_tmp19_ = dino_entities_conversation_get_counterpart (_data_->conversation);
	_data_->_tmp20_ = _data_->_tmp19_;
	if (dino_muc_manager_is_private_room (_data_->_tmp16_, _data_->_tmp18_, _data_->_tmp20_)) {
		_data_->_tmp21_ = _data_->muc_manager;
		_data_->_tmp22_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = dino_entities_conversation_get_account (_data_->conversation);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_tmp26_ = dino_muc_manager_get_offline_members (_data_->_tmp21_, _data_->_tmp23_, _data_->_tmp25_);
		_data_->offline_members = _data_->_tmp26_;
		_data_->_tmp27_ = _data_->offline_members;
		if (_data_->_tmp27_ == NULL) {
			_g_object_unref0 (_data_->offline_members);
			_g_object_unref0 (_data_->omemo_manager);
			_g_object_unref0 (_data_->muc_manager);
			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_->_tmp28_ = _data_->offline_members;
			_data_->_offline_member_list = _data_->_tmp28_;
			_data_->_tmp29_ = _data_->_offline_member_list;
			_data_->_tmp30_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp29_);
			_data_->_tmp31_ = _data_->_tmp30_;
			_data_->_offline_member_size = _data_->_tmp31_;
			_data_->_offline_member_index = -1;
			while (TRUE) {
				_data_->_offline_member_index = _data_->_offline_member_index + 1;
				_data_->_tmp32_ = _data_->_offline_member_index;
				_data_->_tmp33_ = _data_->_offline_member_size;
				if (!(_data_->_tmp32_ < _data_->_tmp33_)) {
					break;
				}
				_data_->_tmp34_ = _data_->_offline_member_list;
				_data_->_tmp35_ = gee_list_get (_data_->_tmp34_, _data_->_offline_member_index);
				_data_->offline_member = (XmppJid*) _data_->_tmp35_;
				_data_->_tmp36_ = _data_->omemo_manager;
				_data_->_tmp37_ = dino_entities_conversation_get_account (_data_->conversation);
				_data_->_tmp38_ = _data_->_tmp37_;
				_data_->_tmp39_ = _data_->offline_member;
				_data_->_state_ = 1;
				dino_plugins_omemo_manager_ensure_get_keys_for_jid (_data_->_tmp36_, _data_->_tmp38_, _data_->_tmp39_, dino_plugins_omemo_encryption_list_entry_encryption_activated_async_ready, _data_);
				return FALSE;
				_state_1:
				_data_->ok = dino_plugins_omemo_manager_ensure_get_keys_for_jid_finish (_data_->_tmp36_, _data_->_res_);
				if (!_data_->ok) {
					_data_->_tmp40_ = _data_->offline_member;
					_data_->_tmp41_ = xmpp_jid_to_string (_data_->_tmp40_);
					_data_->_tmp42_ = _data_->_tmp41_;
					_data_->_tmp43_ = g_strdup_printf ("A member does not support OMEMO: %s", _data_->_tmp42_);
					_data_->_tmp44_ = _data_->_tmp43_;
					_data_->_tmp45_ = dino_plugins_input_field_status_new (_data_->_tmp44_, DINO_PLUGINS_INPUT_FIELD_STATUS_MESSAGE_TYPE_ERROR, DINO_PLUGINS_INPUT_FIELD_STATUS_INPUT_STATE_NO_SEND, FALSE);
					_data_->_tmp46_ = _data_->_tmp45_;
					_data_->input_status_callback (_data_->_tmp46_, _data_->input_status_callback_target);
					_g_object_unref0 (_data_->_tmp46_);
					_g_free0 (_data_->_tmp44_);
					_g_free0 (_data_->_tmp42_);
					_xmpp_jid_unref0 (_data_->offline_member);
					_g_object_unref0 (_data_->offline_members);
					_g_object_unref0 (_data_->omemo_manager);
					_g_object_unref0 (_data_->muc_manager);
					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;
				}
				_xmpp_jid_unref0 (_data_->offline_member);
			}
		}
		_g_object_unref0 (_data_->offline_members);
		_g_object_unref0 (_data_->omemo_manager);
		_g_object_unref0 (_data_->muc_manager);
		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_->_tmp47_ = _data_->omemo_manager;
	_data_->_tmp48_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp49_ = _data_->_tmp48_;
	_data_->_tmp50_ = dino_entities_conversation_get_counterpart (_data_->conversation);
	_data_->_tmp51_ = _data_->_tmp50_;
	_data_->_tmp52_ = xmpp_jid_get_bare_jid (_data_->_tmp51_);
	_data_->_tmp53_ = _data_->_tmp52_;
	_data_->_tmp54_ = _data_->_tmp53_;
	_data_->_state_ = 2;
	dino_plugins_omemo_manager_ensure_get_keys_for_jid (_data_->_tmp47_, _data_->_tmp49_, _data_->_tmp54_, dino_plugins_omemo_encryption_list_entry_encryption_activated_async_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp55_ = !dino_plugins_omemo_manager_ensure_get_keys_for_jid_finish (_data_->_tmp47_, _data_->_res_);
	_xmpp_jid_unref0 (_data_->_tmp54_);
	if (_data_->_tmp55_) {
		_data_->_tmp56_ = g_strdup_printf ("This contact does not support %s encryption", "OMEMO");
		_data_->_tmp57_ = _data_->_tmp56_;
		_data_->_tmp58_ = dino_plugins_input_field_status_new (_data_->_tmp57_, DINO_PLUGINS_INPUT_FIELD_STATUS_MESSAGE_TYPE_ERROR, DINO_PLUGINS_INPUT_FIELD_STATUS_INPUT_STATE_NO_SEND, FALSE);
		_data_->_tmp59_ = _data_->_tmp58_;
		_data_->input_status_callback (_data_->_tmp59_, _data_->input_status_callback_target);
		_g_object_unref0 (_data_->_tmp59_);
		_g_free0 (_data_->_tmp57_);
	}
	_g_object_unref0 (_data_->omemo_manager);
	_g_object_unref0 (_data_->muc_manager);
	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 DinoEntitiesEncryption
dino_plugins_omemo_encryption_list_entry_real_get_encryption (DinoPluginsEncryptionListEntry* base)
{
	DinoEntitiesEncryption result;
	DinoPluginsOmemoEncryptionListEntry* self;
	self = (DinoPluginsOmemoEncryptionListEntry*) base;
	result = DINO_ENTITIES_ENCRYPTION_OMEMO;
	return result;
}

static const gchar*
dino_plugins_omemo_encryption_list_entry_real_get_name (DinoPluginsEncryptionListEntry* base)
{
	const gchar* result;
	DinoPluginsOmemoEncryptionListEntry* self;
	self = (DinoPluginsOmemoEncryptionListEntry*) base;
	result = "OMEMO";
	return result;
}

static void
dino_plugins_omemo_encryption_list_entry_class_init (DinoPluginsOmemoEncryptionListEntryClass * klass,
                                                     gpointer klass_data)
{
	dino_plugins_omemo_encryption_list_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoPluginsOmemoEncryptionListEntry_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_plugins_omemo_encryption_list_entry_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_plugins_omemo_encryption_list_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_ENCRYPTION_PROPERTY, dino_plugins_omemo_encryption_list_entry_properties[DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_ENCRYPTION_PROPERTY] = g_param_spec_enum ("encryption", "encryption", "encryption", DINO_ENTITIES_TYPE_ENCRYPTION, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_NAME_PROPERTY, dino_plugins_omemo_encryption_list_entry_properties[DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dino_plugins_omemo_encryption_list_entry_dino_plugins_encryption_list_entry_interface_init (DinoPluginsEncryptionListEntryIface * iface,
                                                                                            gpointer iface_data)
{
	dino_plugins_omemo_encryption_list_entry_dino_plugins_encryption_list_entry_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_encryption_icon = (GObject* (*) (DinoPluginsEncryptionListEntry*, DinoEntitiesConversation*, DinoContentItem*)) dino_plugins_omemo_encryption_list_entry_real_get_encryption_icon;
	iface->get_encryption_icon_name = (gchar* (*) (DinoPluginsEncryptionListEntry*, DinoEntitiesConversation*, DinoContentItem*)) dino_plugins_omemo_encryption_list_entry_real_get_encryption_icon_name;
	iface->encryption_activated = (void (*) (DinoPluginsEncryptionListEntry*, DinoEntitiesConversation*, DinoPluginsSetInputFieldStatus, gpointer)) dino_plugins_omemo_encryption_list_entry_real_encryption_activated;
	iface->get_encryption = dino_plugins_omemo_encryption_list_entry_real_get_encryption;
	iface->get_name = dino_plugins_omemo_encryption_list_entry_real_get_name;
}

static void
dino_plugins_omemo_encryption_list_entry_instance_init (DinoPluginsOmemoEncryptionListEntry * self,
                                                        gpointer klass)
{
	self->priv = dino_plugins_omemo_encryption_list_entry_get_instance_private (self);
}

static void
dino_plugins_omemo_encryption_list_entry_finalize (GObject * obj)
{
	DinoPluginsOmemoEncryptionListEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OMEMO_TYPE_ENCRYPTION_LIST_ENTRY, DinoPluginsOmemoEncryptionListEntry);
	_g_object_unref0 (self->priv->plugin);
	_qlite_database_unref0 (self->priv->db);
	G_OBJECT_CLASS (dino_plugins_omemo_encryption_list_entry_parent_class)->finalize (obj);
}

static GType
dino_plugins_omemo_encryption_list_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOmemoEncryptionListEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_omemo_encryption_list_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOmemoEncryptionListEntry), 0, (GInstanceInitFunc) dino_plugins_omemo_encryption_list_entry_instance_init, NULL };
	static const GInterfaceInfo dino_plugins_encryption_list_entry_info = { (GInterfaceInitFunc) dino_plugins_omemo_encryption_list_entry_dino_plugins_encryption_list_entry_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_plugins_omemo_encryption_list_entry_type_id;
	dino_plugins_omemo_encryption_list_entry_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoPluginsOmemoEncryptionListEntry", &g_define_type_info, 0);
	g_type_add_interface_static (dino_plugins_omemo_encryption_list_entry_type_id, DINO_PLUGINS_TYPE_ENCRYPTION_LIST_ENTRY, &dino_plugins_encryption_list_entry_info);
	DinoPluginsOmemoEncryptionListEntry_private_offset = g_type_add_instance_private (dino_plugins_omemo_encryption_list_entry_type_id, sizeof (DinoPluginsOmemoEncryptionListEntryPrivate));
	return dino_plugins_omemo_encryption_list_entry_type_id;
}

GType
dino_plugins_omemo_encryption_list_entry_get_type (void)
{
	static volatile gsize dino_plugins_omemo_encryption_list_entry_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_omemo_encryption_list_entry_type_id__once)) {
		GType dino_plugins_omemo_encryption_list_entry_type_id;
		dino_plugins_omemo_encryption_list_entry_type_id = dino_plugins_omemo_encryption_list_entry_get_type_once ();
		g_once_init_leave (&dino_plugins_omemo_encryption_list_entry_type_id__once, dino_plugins_omemo_encryption_list_entry_type_id);
	}
	return dino_plugins_omemo_encryption_list_entry_type_id__once;
}

static void
_vala_dino_plugins_omemo_encryption_list_entry_get_property (GObject * object,
                                                             guint property_id,
                                                             GValue * value,
                                                             GParamSpec * pspec)
{
	DinoPluginsOmemoEncryptionListEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_PLUGINS_OMEMO_TYPE_ENCRYPTION_LIST_ENTRY, DinoPluginsOmemoEncryptionListEntry);
	switch (property_id) {
		case DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_ENCRYPTION_PROPERTY:
		g_value_set_enum (value, dino_plugins_encryption_list_entry_get_encryption ((DinoPluginsEncryptionListEntry*) self));
		break;
		case DINO_PLUGINS_OMEMO_ENCRYPTION_LIST_ENTRY_NAME_PROPERTY:
		g_value_set_string (value, dino_plugins_encryption_list_entry_get_name ((DinoPluginsEncryptionListEntry*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

