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

#include "libdino.h"
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "qlite.h"
#include <gee.h>
#include "xmpp-vala.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_SEARCH_PROCESSOR_0_PROPERTY,
	DINO_SEARCH_PROCESSOR_ID_PROPERTY,
	DINO_SEARCH_PROCESSOR_NUM_PROPERTIES
};
static GParamSpec* dino_search_processor_properties[DINO_SEARCH_PROCESSOR_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 _g_free0(var) (var = (g_free (var), NULL))
#define _qlite_statement_builder_unref0(var) ((var == NULL) ? NULL : (var = (qlite_statement_builder_unref (var), NULL)))
#define _qlite_row_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_unref (var), NULL)))
#define _qlite_row_iterator_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_iterator_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
enum  {
	DINO_SEARCH_SUGGESTION_0_PROPERTY,
	DINO_SEARCH_SUGGESTION_ACCOUNT_PROPERTY,
	DINO_SEARCH_SUGGESTION_CONVERSATION_PROPERTY,
	DINO_SEARCH_SUGGESTION_JID_PROPERTY,
	DINO_SEARCH_SUGGESTION_COMPLETION_PROPERTY,
	DINO_SEARCH_SUGGESTION_START_INDEX_PROPERTY,
	DINO_SEARCH_SUGGESTION_END_INDEX_PROPERTY,
	DINO_SEARCH_SUGGESTION_ORDER_PROPERTY,
	DINO_SEARCH_SUGGESTION_NUM_PROPERTIES
};
static GParamSpec* dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_NUM_PROPERTIES];

struct _DinoSearchProcessorPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoDatabase* db;
};

struct _DinoSearchSuggestionPrivate {
	DinoEntitiesConversation* _conversation;
	XmppJid* _jid;
	gchar* _completion;
	gint _start_index;
	gint _end_index;
	glong _order;
};

static gint DinoSearchProcessor_private_offset;
static gpointer dino_search_processor_parent_class = NULL;
DinoModuleIdentity* dino_search_processor_IDENTITY = NULL;
static DinoStreamInteractionModuleIface * dino_search_processor_dino_stream_interaction_module_parent_iface = NULL;
static gint DinoSearchSuggestion_private_offset;
static gpointer dino_search_suggestion_parent_class = NULL;

static QliteQueryBuilder* dino_search_processor_prepare_search (DinoSearchProcessor* self,
                                                         const gchar* query,
                                                         gboolean join_content);
static gint _____lambda122_ (DinoSearchProcessor* self,
                      DinoSearchSuggestion* a,
                      DinoSearchSuggestion* b);
static gint ______lambda122__gcompare_data_func (gconstpointer a,
                                          gconstpointer b,
                                          gpointer self);
static void dino_search_processor_finalize (GObject * obj);
static GType dino_search_processor_get_type_once (void);
static void _vala_dino_search_processor_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void dino_search_suggestion_set_conversation (DinoSearchSuggestion* self,
                                              DinoEntitiesConversation* value);
static void dino_search_suggestion_set_jid (DinoSearchSuggestion* self,
                                     XmppJid* value);
static void dino_search_suggestion_set_completion (DinoSearchSuggestion* self,
                                            const gchar* value);
static void dino_search_suggestion_set_start_index (DinoSearchSuggestion* self,
                                             gint value);
static void dino_search_suggestion_set_end_index (DinoSearchSuggestion* self,
                                           gint value);
static void dino_search_suggestion_finalize (GObject * obj);
static GType dino_search_suggestion_get_type_once (void);
static void _vala_dino_search_suggestion_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_dino_search_suggestion_set_property (GObject * object,
                                                guint property_id,
                                                const 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 gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_search_processor_get_instance_private (DinoSearchProcessor* self)
{
	return G_STRUCT_MEMBER_P (self, DinoSearchProcessor_private_offset);
}

void
dino_search_processor_start (DinoStreamInteractor* stream_interactor,
                             DinoDatabase* db)
{
	DinoSearchProcessor* m = NULL;
	DinoSearchProcessor* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	g_return_if_fail (db != NULL);
	_tmp0_ = dino_search_processor_new (stream_interactor, db);
	m = _tmp0_;
	dino_stream_interactor_add_module (stream_interactor, (DinoStreamInteractionModule*) m);
	_g_object_unref0 (m);
}

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

DinoSearchProcessor*
dino_search_processor_construct (GType object_type,
                                 DinoStreamInteractor* stream_interactor,
                                 DinoDatabase* db)
{
	DinoSearchProcessor * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoDatabase* _tmp1_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoSearchProcessor*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp1_;
	return self;
}

DinoSearchProcessor*
dino_search_processor_new (DinoStreamInteractor* stream_interactor,
                           DinoDatabase* db)
{
	return dino_search_processor_construct (DINO_TYPE_SEARCH_PROCESSOR, stream_interactor, db);
}

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 gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static QliteQueryBuilder*
dino_search_processor_prepare_search (DinoSearchProcessor* self,
                                      const gchar* query,
                                      gboolean join_content)
{
	gchar* words = NULL;
	gchar* _tmp0_;
	gchar* with = NULL;
	gchar* in_ = NULL;
	gchar* from = NULL;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gboolean _tmp48_ = FALSE;
	const gchar* _tmp49_;
	QliteQueryBuilder* rows = NULL;
	DinoDatabase* _tmp60_;
	DinoDatabaseMessageTable* _tmp61_;
	DinoDatabaseMessageTable* _tmp62_;
	DinoDatabase* _tmp63_;
	DinoDatabaseMessageTable* _tmp64_;
	DinoDatabaseMessageTable* _tmp65_;
	QliteColumn* _tmp66_;
	const gchar* _tmp67_;
	QliteMatchQueryBuilder* _tmp68_;
	QliteMatchQueryBuilder* _tmp69_;
	DinoDatabase* _tmp70_;
	DinoDatabaseMessageTable* _tmp71_;
	DinoDatabaseMessageTable* _tmp72_;
	QliteColumn* _tmp73_;
	QliteQueryBuilder* _tmp74_;
	QliteQueryBuilder* _tmp75_;
	DinoDatabase* _tmp76_;
	DinoDatabaseJidTable* _tmp77_;
	DinoDatabaseJidTable* _tmp78_;
	DinoDatabase* _tmp79_;
	DinoDatabaseJidTable* _tmp80_;
	DinoDatabaseJidTable* _tmp81_;
	QliteColumn* _tmp82_;
	DinoDatabase* _tmp83_;
	DinoDatabaseMessageTable* _tmp84_;
	DinoDatabaseMessageTable* _tmp85_;
	QliteColumn* _tmp86_;
	QliteQueryBuilder* _tmp87_;
	QliteQueryBuilder* _tmp88_;
	DinoDatabase* _tmp89_;
	DinoDatabaseAccountTable* _tmp90_;
	DinoDatabaseAccountTable* _tmp91_;
	DinoDatabase* _tmp92_;
	DinoDatabaseAccountTable* _tmp93_;
	DinoDatabaseAccountTable* _tmp94_;
	QliteColumn* _tmp95_;
	DinoDatabase* _tmp96_;
	DinoDatabaseMessageTable* _tmp97_;
	DinoDatabaseMessageTable* _tmp98_;
	QliteColumn* _tmp99_;
	QliteQueryBuilder* _tmp100_;
	QliteQueryBuilder* _tmp101_;
	DinoDatabase* _tmp102_;
	DinoDatabaseRealJidTable* _tmp103_;
	DinoDatabaseRealJidTable* _tmp104_;
	DinoDatabase* _tmp105_;
	DinoDatabaseRealJidTable* _tmp106_;
	DinoDatabaseRealJidTable* _tmp107_;
	QliteColumn* _tmp108_;
	DinoDatabase* _tmp109_;
	DinoDatabaseMessageTable* _tmp110_;
	DinoDatabaseMessageTable* _tmp111_;
	QliteColumn* _tmp112_;
	QliteQueryBuilder* _tmp113_;
	QliteQueryBuilder* _tmp114_;
	DinoDatabase* _tmp115_;
	DinoDatabaseAccountTable* _tmp116_;
	DinoDatabaseAccountTable* _tmp117_;
	QliteColumn* _tmp118_;
	QliteQueryBuilder* _tmp119_;
	QliteQueryBuilder* _tmp120_;
	const gchar* _tmp133_;
	const gchar* _tmp240_;
	QliteQueryBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (query != NULL, NULL);
	_tmp0_ = g_strdup ("");
	words = _tmp0_;
	with = NULL;
	in_ = NULL;
	from = NULL;
	_tmp2_ = _tmp1_ = g_strsplit (query, " ", 0);
	{
		gchar** word_collection = NULL;
		gint word_collection_length1 = 0;
		gint _word_collection_size_ = 0;
		gint word_it = 0;
		word_collection = _tmp2_;
		word_collection_length1 = _vala_array_length (_tmp1_);
		for (word_it = 0; word_it < word_collection_length1; word_it = word_it + 1) {
			gchar* _tmp3_;
			gchar* word = NULL;
			_tmp3_ = g_strdup (word_collection[word_it]);
			word = _tmp3_;
			{
				const gchar* _tmp4_;
				_tmp4_ = word;
				if (g_str_has_prefix (_tmp4_, "with:")) {
					const gchar* _tmp5_;
					_tmp5_ = with;
					if (_tmp5_ == NULL) {
						const gchar* _tmp6_;
						gchar* _tmp7_;
						_tmp6_ = word;
						_tmp7_ = string_substring (_tmp6_, (glong) 5, (glong) -1);
						_g_free0 (with);
						with = _tmp7_;
					} else {
						DinoDatabase* _tmp8_;
						DinoDatabaseMessageTable* _tmp9_;
						DinoDatabaseMessageTable* _tmp10_;
						QliteQueryBuilder* _tmp11_;
						QliteQueryBuilder* _tmp12_;
						gchar** _tmp13_;
						gchar** _tmp14_;
						gint _tmp14__length1;
						QliteQueryBuilder* _tmp15_;
						QliteQueryBuilder* _tmp16_;
						_tmp8_ = self->priv->db;
						_tmp9_ = dino_database_get_message (_tmp8_);
						_tmp10_ = _tmp9_;
						_tmp11_ = qlite_table_select ((QliteTable*) _tmp10_, NULL, (gint) 0);
						_tmp12_ = _tmp11_;
						_tmp13_ = g_new0 (gchar*, 0 + 1);
						_tmp14_ = _tmp13_;
						_tmp14__length1 = 0;
						_tmp15_ = qlite_query_builder_where (_tmp12_, "0", _tmp14_, (gint) 0);
						_tmp16_ = _tmp15_;
						_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
						_qlite_statement_builder_unref0 (_tmp12_);
						result = _tmp16_;
						_g_free0 (word);
						word_collection = (_vala_array_free (word_collection, word_collection_length1, (GDestroyNotify) g_free), NULL);
						_g_free0 (from);
						_g_free0 (in_);
						_g_free0 (with);
						_g_free0 (words);
						return result;
					}
				} else {
					const gchar* _tmp17_;
					_tmp17_ = word;
					if (g_str_has_prefix (_tmp17_, "in:")) {
						const gchar* _tmp18_;
						_tmp18_ = in_;
						if (_tmp18_ == NULL) {
							const gchar* _tmp19_;
							gchar* _tmp20_;
							_tmp19_ = word;
							_tmp20_ = string_substring (_tmp19_, (glong) 3, (glong) -1);
							_g_free0 (in_);
							in_ = _tmp20_;
						} else {
							DinoDatabase* _tmp21_;
							DinoDatabaseMessageTable* _tmp22_;
							DinoDatabaseMessageTable* _tmp23_;
							QliteQueryBuilder* _tmp24_;
							QliteQueryBuilder* _tmp25_;
							gchar** _tmp26_;
							gchar** _tmp27_;
							gint _tmp27__length1;
							QliteQueryBuilder* _tmp28_;
							QliteQueryBuilder* _tmp29_;
							_tmp21_ = self->priv->db;
							_tmp22_ = dino_database_get_message (_tmp21_);
							_tmp23_ = _tmp22_;
							_tmp24_ = qlite_table_select ((QliteTable*) _tmp23_, NULL, (gint) 0);
							_tmp25_ = _tmp24_;
							_tmp26_ = g_new0 (gchar*, 0 + 1);
							_tmp27_ = _tmp26_;
							_tmp27__length1 = 0;
							_tmp28_ = qlite_query_builder_where (_tmp25_, "0", _tmp27_, (gint) 0);
							_tmp29_ = _tmp28_;
							_tmp27_ = (_vala_array_free (_tmp27_, _tmp27__length1, (GDestroyNotify) g_free), NULL);
							_qlite_statement_builder_unref0 (_tmp25_);
							result = _tmp29_;
							_g_free0 (word);
							word_collection = (_vala_array_free (word_collection, word_collection_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (from);
							_g_free0 (in_);
							_g_free0 (with);
							_g_free0 (words);
							return result;
						}
					} else {
						const gchar* _tmp30_;
						_tmp30_ = word;
						if (g_str_has_prefix (_tmp30_, "from:")) {
							const gchar* _tmp31_;
							_tmp31_ = from;
							if (_tmp31_ == NULL) {
								const gchar* _tmp32_;
								gchar* _tmp33_;
								_tmp32_ = word;
								_tmp33_ = string_substring (_tmp32_, (glong) 5, (glong) -1);
								_g_free0 (from);
								from = _tmp33_;
							} else {
								DinoDatabase* _tmp34_;
								DinoDatabaseMessageTable* _tmp35_;
								DinoDatabaseMessageTable* _tmp36_;
								QliteQueryBuilder* _tmp37_;
								QliteQueryBuilder* _tmp38_;
								gchar** _tmp39_;
								gchar** _tmp40_;
								gint _tmp40__length1;
								QliteQueryBuilder* _tmp41_;
								QliteQueryBuilder* _tmp42_;
								_tmp34_ = self->priv->db;
								_tmp35_ = dino_database_get_message (_tmp34_);
								_tmp36_ = _tmp35_;
								_tmp37_ = qlite_table_select ((QliteTable*) _tmp36_, NULL, (gint) 0);
								_tmp38_ = _tmp37_;
								_tmp39_ = g_new0 (gchar*, 0 + 1);
								_tmp40_ = _tmp39_;
								_tmp40__length1 = 0;
								_tmp41_ = qlite_query_builder_where (_tmp38_, "0", _tmp40_, (gint) 0);
								_tmp42_ = _tmp41_;
								_tmp40_ = (_vala_array_free (_tmp40_, _tmp40__length1, (GDestroyNotify) g_free), NULL);
								_qlite_statement_builder_unref0 (_tmp38_);
								result = _tmp42_;
								_g_free0 (word);
								word_collection = (_vala_array_free (word_collection, word_collection_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (from);
								_g_free0 (in_);
								_g_free0 (with);
								_g_free0 (words);
								return result;
							}
						} else {
							const gchar* _tmp43_;
							const gchar* _tmp44_;
							gchar* _tmp45_;
							gchar* _tmp46_;
							gchar* _tmp47_;
							_tmp43_ = words;
							_tmp44_ = word;
							_tmp45_ = g_strconcat (_tmp44_, "* ", NULL);
							_tmp46_ = _tmp45_;
							_tmp47_ = g_strconcat (_tmp43_, _tmp46_, NULL);
							_g_free0 (words);
							words = _tmp47_;
							_g_free0 (_tmp46_);
						}
					}
				}
				_g_free0 (word);
			}
		}
		word_collection = (_vala_array_free (word_collection, word_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp49_ = in_;
	if (_tmp49_ != NULL) {
		const gchar* _tmp50_;
		_tmp50_ = with;
		_tmp48_ = _tmp50_ != NULL;
	} else {
		_tmp48_ = FALSE;
	}
	if (_tmp48_) {
		DinoDatabase* _tmp51_;
		DinoDatabaseMessageTable* _tmp52_;
		DinoDatabaseMessageTable* _tmp53_;
		QliteQueryBuilder* _tmp54_;
		QliteQueryBuilder* _tmp55_;
		gchar** _tmp56_;
		gchar** _tmp57_;
		gint _tmp57__length1;
		QliteQueryBuilder* _tmp58_;
		QliteQueryBuilder* _tmp59_;
		_tmp51_ = self->priv->db;
		_tmp52_ = dino_database_get_message (_tmp51_);
		_tmp53_ = _tmp52_;
		_tmp54_ = qlite_table_select ((QliteTable*) _tmp53_, NULL, (gint) 0);
		_tmp55_ = _tmp54_;
		_tmp56_ = g_new0 (gchar*, 0 + 1);
		_tmp57_ = _tmp56_;
		_tmp57__length1 = 0;
		_tmp58_ = qlite_query_builder_where (_tmp55_, "0", _tmp57_, (gint) 0);
		_tmp59_ = _tmp58_;
		_tmp57_ = (_vala_array_free (_tmp57_, _tmp57__length1, (GDestroyNotify) g_free), NULL);
		_qlite_statement_builder_unref0 (_tmp55_);
		result = _tmp59_;
		_g_free0 (from);
		_g_free0 (in_);
		_g_free0 (with);
		_g_free0 (words);
		return result;
	}
	_tmp60_ = self->priv->db;
	_tmp61_ = dino_database_get_message (_tmp60_);
	_tmp62_ = _tmp61_;
	_tmp63_ = self->priv->db;
	_tmp64_ = dino_database_get_message (_tmp63_);
	_tmp65_ = _tmp64_;
	_tmp66_ = _tmp65_->body;
	_tmp67_ = words;
	_tmp68_ = qlite_table_match ((QliteTable*) _tmp62_, _tmp66_, _tmp67_);
	_tmp69_ = _tmp68_;
	_tmp70_ = self->priv->db;
	_tmp71_ = dino_database_get_message (_tmp70_);
	_tmp72_ = _tmp71_;
	_tmp73_ = _tmp72_->id;
	_tmp74_ = qlite_query_builder_order_by ((QliteQueryBuilder*) _tmp69_, _tmp73_, "DESC");
	_tmp75_ = _tmp74_;
	_tmp76_ = self->priv->db;
	_tmp77_ = dino_database_get_jid (_tmp76_);
	_tmp78_ = _tmp77_;
	_tmp79_ = self->priv->db;
	_tmp80_ = dino_database_get_jid (_tmp79_);
	_tmp81_ = _tmp80_;
	_tmp82_ = _tmp81_->id;
	_tmp83_ = self->priv->db;
	_tmp84_ = dino_database_get_message (_tmp83_);
	_tmp85_ = _tmp84_;
	_tmp86_ = _tmp85_->counterpart_id;
	_tmp87_ = qlite_query_builder_join_with (_tmp75_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp78_, _tmp82_, _tmp86_, NULL);
	_tmp88_ = _tmp87_;
	_tmp89_ = self->priv->db;
	_tmp90_ = dino_database_get_account (_tmp89_);
	_tmp91_ = _tmp90_;
	_tmp92_ = self->priv->db;
	_tmp93_ = dino_database_get_account (_tmp92_);
	_tmp94_ = _tmp93_;
	_tmp95_ = _tmp94_->id;
	_tmp96_ = self->priv->db;
	_tmp97_ = dino_database_get_message (_tmp96_);
	_tmp98_ = _tmp97_;
	_tmp99_ = _tmp98_->account_id;
	_tmp100_ = qlite_query_builder_join_with (_tmp88_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp91_, _tmp95_, _tmp99_, NULL);
	_tmp101_ = _tmp100_;
	_tmp102_ = self->priv->db;
	_tmp103_ = dino_database_get_real_jid (_tmp102_);
	_tmp104_ = _tmp103_;
	_tmp105_ = self->priv->db;
	_tmp106_ = dino_database_get_real_jid (_tmp105_);
	_tmp107_ = _tmp106_;
	_tmp108_ = _tmp107_->message_id;
	_tmp109_ = self->priv->db;
	_tmp110_ = dino_database_get_message (_tmp109_);
	_tmp111_ = _tmp110_;
	_tmp112_ = _tmp111_->id;
	_tmp113_ = qlite_query_builder_outer_join_with (_tmp101_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp104_, _tmp108_, _tmp112_, NULL);
	_tmp114_ = _tmp113_;
	_tmp115_ = self->priv->db;
	_tmp116_ = dino_database_get_account (_tmp115_);
	_tmp117_ = _tmp116_;
	_tmp118_ = _tmp117_->enabled;
	_tmp119_ = qlite_query_builder_with (_tmp114_, G_TYPE_BOOLEAN, NULL, NULL, _tmp118_, "=", (gpointer) ((gintptr) TRUE));
	_tmp120_ = _tmp119_;
	_qlite_statement_builder_unref0 (_tmp114_);
	_qlite_statement_builder_unref0 (_tmp101_);
	_qlite_statement_builder_unref0 (_tmp88_);
	_qlite_statement_builder_unref0 (_tmp75_);
	_qlite_statement_builder_unref0 (_tmp69_);
	rows = _tmp120_;
	if (join_content) {
		QliteQueryBuilder* _tmp121_;
		DinoDatabase* _tmp122_;
		DinoDatabaseContentItemTable* _tmp123_;
		DinoDatabaseContentItemTable* _tmp124_;
		QliteQueryBuilder* _tmp125_;
		QliteQueryBuilder* _tmp126_;
		DinoDatabase* _tmp127_;
		DinoDatabaseContentItemTable* _tmp128_;
		DinoDatabaseContentItemTable* _tmp129_;
		QliteColumn* _tmp130_;
		QliteQueryBuilder* _tmp131_;
		QliteQueryBuilder* _tmp132_;
		_tmp121_ = rows;
		_tmp122_ = self->priv->db;
		_tmp123_ = dino_database_get_content_item (_tmp122_);
		_tmp124_ = _tmp123_;
		_tmp125_ = qlite_query_builder_join_on (_tmp121_, (QliteTable*) _tmp124_, "message.id=content_item.foreign_id AND content_item.content_type=1", NULL);
		_tmp126_ = _tmp125_;
		_tmp127_ = self->priv->db;
		_tmp128_ = dino_database_get_content_item (_tmp127_);
		_tmp129_ = _tmp128_;
		_tmp130_ = _tmp129_->content_type;
		_tmp131_ = qlite_query_builder_with (_tmp126_, G_TYPE_INT, NULL, NULL, _tmp130_, "=", (gpointer) ((gintptr) 1));
		_tmp132_ = _tmp131_;
		_qlite_statement_builder_unref0 (_tmp132_);
		_qlite_statement_builder_unref0 (_tmp126_);
	}
	_tmp133_ = with;
	if (_tmp133_ != NULL) {
		const gchar* _tmp134_;
		_tmp134_ = with;
		if (string_index_of (_tmp134_, "/", 0) > 0) {
			QliteQueryBuilder* _tmp135_;
			DinoDatabase* _tmp136_;
			DinoDatabaseMessageTable* _tmp137_;
			DinoDatabaseMessageTable* _tmp138_;
			QliteColumn* _tmp139_;
			QliteQueryBuilder* _tmp140_;
			QliteQueryBuilder* _tmp141_;
			DinoDatabase* _tmp142_;
			DinoDatabaseJidTable* _tmp143_;
			DinoDatabaseJidTable* _tmp144_;
			QliteColumn* _tmp145_;
			const gchar* _tmp146_;
			const gchar* _tmp147_;
			gchar* _tmp148_;
			gchar* _tmp149_;
			QliteQueryBuilder* _tmp150_;
			QliteQueryBuilder* _tmp151_;
			DinoDatabase* _tmp152_;
			DinoDatabaseMessageTable* _tmp153_;
			DinoDatabaseMessageTable* _tmp154_;
			QliteColumn* _tmp155_;
			const gchar* _tmp156_;
			const gchar* _tmp157_;
			gchar* _tmp158_;
			gchar* _tmp159_;
			QliteQueryBuilder* _tmp160_;
			QliteQueryBuilder* _tmp161_;
			_tmp135_ = rows;
			_tmp136_ = self->priv->db;
			_tmp137_ = dino_database_get_message (_tmp136_);
			_tmp138_ = _tmp137_;
			_tmp139_ = _tmp138_->type_;
			_tmp140_ = qlite_query_builder_with (_tmp135_, G_TYPE_INT, NULL, NULL, _tmp139_, "=", (gpointer) ((gintptr) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM));
			_tmp141_ = _tmp140_;
			_tmp142_ = self->priv->db;
			_tmp143_ = dino_database_get_jid (_tmp142_);
			_tmp144_ = _tmp143_;
			_tmp145_ = _tmp144_->bare_jid;
			_tmp146_ = with;
			_tmp147_ = with;
			_tmp148_ = string_substring (_tmp146_, (glong) 0, (glong) string_index_of (_tmp147_, "/", 0));
			_tmp149_ = _tmp148_;
			_tmp150_ = qlite_query_builder_with (_tmp141_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp145_, "LIKE", _tmp149_);
			_tmp151_ = _tmp150_;
			_tmp152_ = self->priv->db;
			_tmp153_ = dino_database_get_message (_tmp152_);
			_tmp154_ = _tmp153_;
			_tmp155_ = _tmp154_->counterpart_resource;
			_tmp156_ = with;
			_tmp157_ = with;
			_tmp158_ = string_substring (_tmp156_, (glong) (string_index_of (_tmp157_, "/", 0) + 1), (glong) -1);
			_tmp159_ = _tmp158_;
			_tmp160_ = qlite_query_builder_with (_tmp151_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp155_, "LIKE", _tmp159_);
			_tmp161_ = _tmp160_;
			_qlite_statement_builder_unref0 (_tmp161_);
			_g_free0 (_tmp159_);
			_qlite_statement_builder_unref0 (_tmp151_);
			_g_free0 (_tmp149_);
			_qlite_statement_builder_unref0 (_tmp141_);
		} else {
			QliteQueryBuilder* _tmp162_;
			DinoDatabase* _tmp163_;
			DinoDatabaseMessageTable* _tmp164_;
			DinoDatabaseMessageTable* _tmp165_;
			QliteColumn* _tmp166_;
			gchar* _tmp167_;
			gchar* _tmp168_;
			gchar* _tmp169_;
			gchar* _tmp170_;
			DinoDatabase* _tmp171_;
			DinoDatabaseJidTable* _tmp172_;
			DinoDatabaseJidTable* _tmp173_;
			QliteColumn* _tmp174_;
			gchar* _tmp175_;
			gchar* _tmp176_;
			gchar* _tmp177_;
			gchar* _tmp178_;
			DinoDatabase* _tmp179_;
			DinoDatabaseMessageTable* _tmp180_;
			DinoDatabaseMessageTable* _tmp181_;
			QliteColumn* _tmp182_;
			gchar* _tmp183_;
			gchar* _tmp184_;
			gchar* _tmp185_;
			gchar* _tmp186_;
			DinoDatabase* _tmp187_;
			DinoDatabaseRealJidTable* _tmp188_;
			DinoDatabaseRealJidTable* _tmp189_;
			QliteColumn* _tmp190_;
			gchar* _tmp191_;
			gchar* _tmp192_;
			gchar* _tmp193_;
			gchar* _tmp194_;
			gchar* _tmp195_;
			gchar* _tmp196_;
			DinoDatabase* _tmp197_;
			DinoDatabaseMessageTable* _tmp198_;
			DinoDatabaseMessageTable* _tmp199_;
			QliteColumn* _tmp200_;
			gchar* _tmp201_;
			gchar* _tmp202_;
			gchar* _tmp203_;
			gchar* _tmp204_;
			DinoDatabase* _tmp205_;
			DinoDatabaseMessageTable* _tmp206_;
			DinoDatabaseMessageTable* _tmp207_;
			QliteColumn* _tmp208_;
			gchar* _tmp209_;
			gchar* _tmp210_;
			gchar* _tmp211_;
			gchar* _tmp212_;
			gchar* _tmp213_;
			gchar* _tmp214_;
			const gchar* _tmp215_;
			gchar* _tmp216_;
			const gchar* _tmp217_;
			gchar* _tmp218_;
			const gchar* _tmp219_;
			gchar* _tmp220_;
			gchar** _tmp221_;
			gchar** _tmp222_;
			gint _tmp222__length1;
			QliteQueryBuilder* _tmp223_;
			QliteQueryBuilder* _tmp224_;
			_tmp162_ = rows;
			_tmp163_ = self->priv->db;
			_tmp164_ = dino_database_get_message (_tmp163_);
			_tmp165_ = _tmp164_;
			_tmp166_ = _tmp165_->type_;
			_tmp167_ = qlite_column_to_string (_tmp166_);
			_tmp168_ = _tmp167_;
			_tmp169_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_CHAT);
			_tmp170_ = _tmp169_;
			_tmp171_ = self->priv->db;
			_tmp172_ = dino_database_get_jid (_tmp171_);
			_tmp173_ = _tmp172_;
			_tmp174_ = _tmp173_->bare_jid;
			_tmp175_ = qlite_column_to_string (_tmp174_);
			_tmp176_ = _tmp175_;
			_tmp177_ = g_strconcat ("(", _tmp168_, " = ", _tmp170_, " AND ", _tmp176_, " LIKE ?)", NULL);
			_tmp178_ = _tmp177_;
			_tmp179_ = self->priv->db;
			_tmp180_ = dino_database_get_message (_tmp179_);
			_tmp181_ = _tmp180_;
			_tmp182_ = _tmp181_->type_;
			_tmp183_ = qlite_column_to_string (_tmp182_);
			_tmp184_ = _tmp183_;
			_tmp185_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM);
			_tmp186_ = _tmp185_;
			_tmp187_ = self->priv->db;
			_tmp188_ = dino_database_get_real_jid (_tmp187_);
			_tmp189_ = _tmp188_;
			_tmp190_ = _tmp189_->real_jid;
			_tmp191_ = qlite_column_to_string (_tmp190_);
			_tmp192_ = _tmp191_;
			_tmp193_ = g_strconcat (" OR (", _tmp184_, " = ", _tmp186_, " AND ", _tmp192_, " LIKE ?)", NULL);
			_tmp194_ = _tmp193_;
			_tmp195_ = g_strconcat (_tmp178_, _tmp194_, NULL);
			_tmp196_ = _tmp195_;
			_tmp197_ = self->priv->db;
			_tmp198_ = dino_database_get_message (_tmp197_);
			_tmp199_ = _tmp198_;
			_tmp200_ = _tmp199_->type_;
			_tmp201_ = qlite_column_to_string (_tmp200_);
			_tmp202_ = _tmp201_;
			_tmp203_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM);
			_tmp204_ = _tmp203_;
			_tmp205_ = self->priv->db;
			_tmp206_ = dino_database_get_message (_tmp205_);
			_tmp207_ = _tmp206_;
			_tmp208_ = _tmp207_->counterpart_resource;
			_tmp209_ = qlite_column_to_string (_tmp208_);
			_tmp210_ = _tmp209_;
			_tmp211_ = g_strconcat (" OR (", _tmp202_, " = ", _tmp204_, " AND ", _tmp210_, " LIKE ?)", NULL);
			_tmp212_ = _tmp211_;
			_tmp213_ = g_strconcat (_tmp196_, _tmp212_, NULL);
			_tmp214_ = _tmp213_;
			_tmp215_ = with;
			_tmp216_ = g_strdup (_tmp215_);
			_tmp217_ = with;
			_tmp218_ = g_strdup (_tmp217_);
			_tmp219_ = with;
			_tmp220_ = g_strdup (_tmp219_);
			_tmp221_ = g_new0 (gchar*, 3 + 1);
			_tmp221_[0] = _tmp216_;
			_tmp221_[1] = _tmp218_;
			_tmp221_[2] = _tmp220_;
			_tmp222_ = _tmp221_;
			_tmp222__length1 = 3;
			_tmp223_ = qlite_query_builder_where (_tmp162_, _tmp214_, _tmp222_, (gint) 3);
			_tmp224_ = _tmp223_;
			_qlite_statement_builder_unref0 (_tmp224_);
			_tmp222_ = (_vala_array_free (_tmp222_, _tmp222__length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (_tmp214_);
			_g_free0 (_tmp212_);
			_g_free0 (_tmp210_);
			_g_free0 (_tmp204_);
			_g_free0 (_tmp202_);
			_g_free0 (_tmp196_);
			_g_free0 (_tmp194_);
			_g_free0 (_tmp192_);
			_g_free0 (_tmp186_);
			_g_free0 (_tmp184_);
			_g_free0 (_tmp178_);
			_g_free0 (_tmp176_);
			_g_free0 (_tmp170_);
			_g_free0 (_tmp168_);
		}
	} else {
		const gchar* _tmp225_;
		_tmp225_ = in_;
		if (_tmp225_ != NULL) {
			QliteQueryBuilder* _tmp226_;
			DinoDatabase* _tmp227_;
			DinoDatabaseJidTable* _tmp228_;
			DinoDatabaseJidTable* _tmp229_;
			QliteColumn* _tmp230_;
			const gchar* _tmp231_;
			QliteQueryBuilder* _tmp232_;
			QliteQueryBuilder* _tmp233_;
			DinoDatabase* _tmp234_;
			DinoDatabaseMessageTable* _tmp235_;
			DinoDatabaseMessageTable* _tmp236_;
			QliteColumn* _tmp237_;
			QliteQueryBuilder* _tmp238_;
			QliteQueryBuilder* _tmp239_;
			_tmp226_ = rows;
			_tmp227_ = self->priv->db;
			_tmp228_ = dino_database_get_jid (_tmp227_);
			_tmp229_ = _tmp228_;
			_tmp230_ = _tmp229_->bare_jid;
			_tmp231_ = in_;
			_tmp232_ = qlite_query_builder_with (_tmp226_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp230_, "LIKE", _tmp231_);
			_tmp233_ = _tmp232_;
			_tmp234_ = self->priv->db;
			_tmp235_ = dino_database_get_message (_tmp234_);
			_tmp236_ = _tmp235_;
			_tmp237_ = _tmp236_->type_;
			_tmp238_ = qlite_query_builder_with (_tmp233_, G_TYPE_INT, NULL, NULL, _tmp237_, "=", (gpointer) ((gintptr) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT));
			_tmp239_ = _tmp238_;
			_qlite_statement_builder_unref0 (_tmp239_);
			_qlite_statement_builder_unref0 (_tmp233_);
		}
	}
	_tmp240_ = from;
	if (_tmp240_ != NULL) {
		QliteQueryBuilder* _tmp241_;
		DinoDatabase* _tmp242_;
		DinoDatabaseMessageTable* _tmp243_;
		DinoDatabaseMessageTable* _tmp244_;
		QliteColumn* _tmp245_;
		gchar* _tmp246_;
		gchar* _tmp247_;
		DinoDatabase* _tmp248_;
		DinoDatabaseAccountTable* _tmp249_;
		DinoDatabaseAccountTable* _tmp250_;
		QliteColumn* _tmp251_;
		gchar* _tmp252_;
		gchar* _tmp253_;
		gchar* _tmp254_;
		gchar* _tmp255_;
		DinoDatabase* _tmp256_;
		DinoDatabaseMessageTable* _tmp257_;
		DinoDatabaseMessageTable* _tmp258_;
		QliteColumn* _tmp259_;
		gchar* _tmp260_;
		gchar* _tmp261_;
		DinoDatabase* _tmp262_;
		DinoDatabaseMessageTable* _tmp263_;
		DinoDatabaseMessageTable* _tmp264_;
		QliteColumn* _tmp265_;
		gchar* _tmp266_;
		gchar* _tmp267_;
		gchar* _tmp268_;
		gchar* _tmp269_;
		gchar* _tmp270_;
		gchar* _tmp271_;
		DinoDatabase* _tmp272_;
		DinoDatabaseMessageTable* _tmp273_;
		DinoDatabaseMessageTable* _tmp274_;
		QliteColumn* _tmp275_;
		gchar* _tmp276_;
		gchar* _tmp277_;
		gchar* _tmp278_;
		gchar* _tmp279_;
		gchar* _tmp280_;
		gchar* _tmp281_;
		DinoDatabase* _tmp282_;
		DinoDatabaseMessageTable* _tmp283_;
		DinoDatabaseMessageTable* _tmp284_;
		QliteColumn* _tmp285_;
		gchar* _tmp286_;
		gchar* _tmp287_;
		DinoDatabase* _tmp288_;
		DinoDatabaseMessageTable* _tmp289_;
		DinoDatabaseMessageTable* _tmp290_;
		QliteColumn* _tmp291_;
		gchar* _tmp292_;
		gchar* _tmp293_;
		gchar* _tmp294_;
		gchar* _tmp295_;
		DinoDatabase* _tmp296_;
		DinoDatabaseJidTable* _tmp297_;
		DinoDatabaseJidTable* _tmp298_;
		QliteColumn* _tmp299_;
		gchar* _tmp300_;
		gchar* _tmp301_;
		gchar* _tmp302_;
		gchar* _tmp303_;
		gchar* _tmp304_;
		gchar* _tmp305_;
		DinoDatabase* _tmp306_;
		DinoDatabaseMessageTable* _tmp307_;
		DinoDatabaseMessageTable* _tmp308_;
		QliteColumn* _tmp309_;
		gchar* _tmp310_;
		gchar* _tmp311_;
		DinoDatabase* _tmp312_;
		DinoDatabaseMessageTable* _tmp313_;
		DinoDatabaseMessageTable* _tmp314_;
		QliteColumn* _tmp315_;
		gchar* _tmp316_;
		gchar* _tmp317_;
		gchar* _tmp318_;
		gchar* _tmp319_;
		gchar* _tmp320_;
		gchar* _tmp321_;
		DinoDatabase* _tmp322_;
		DinoDatabaseRealJidTable* _tmp323_;
		DinoDatabaseRealJidTable* _tmp324_;
		QliteColumn* _tmp325_;
		gchar* _tmp326_;
		gchar* _tmp327_;
		gchar* _tmp328_;
		gchar* _tmp329_;
		gchar* _tmp330_;
		gchar* _tmp331_;
		DinoDatabase* _tmp332_;
		DinoDatabaseMessageTable* _tmp333_;
		DinoDatabaseMessageTable* _tmp334_;
		QliteColumn* _tmp335_;
		gchar* _tmp336_;
		gchar* _tmp337_;
		DinoDatabase* _tmp338_;
		DinoDatabaseMessageTable* _tmp339_;
		DinoDatabaseMessageTable* _tmp340_;
		QliteColumn* _tmp341_;
		gchar* _tmp342_;
		gchar* _tmp343_;
		gchar* _tmp344_;
		gchar* _tmp345_;
		gchar* _tmp346_;
		gchar* _tmp347_;
		DinoDatabase* _tmp348_;
		DinoDatabaseMessageTable* _tmp349_;
		DinoDatabaseMessageTable* _tmp350_;
		QliteColumn* _tmp351_;
		gchar* _tmp352_;
		gchar* _tmp353_;
		gchar* _tmp354_;
		gchar* _tmp355_;
		gchar* _tmp356_;
		gchar* _tmp357_;
		const gchar* _tmp358_;
		gchar* _tmp359_;
		const gchar* _tmp360_;
		gchar* _tmp361_;
		const gchar* _tmp362_;
		gchar* _tmp363_;
		const gchar* _tmp364_;
		gchar* _tmp365_;
		const gchar* _tmp366_;
		gchar* _tmp367_;
		gchar** _tmp368_;
		gchar** _tmp369_;
		gint _tmp369__length1;
		QliteQueryBuilder* _tmp370_;
		QliteQueryBuilder* _tmp371_;
		_tmp241_ = rows;
		_tmp242_ = self->priv->db;
		_tmp243_ = dino_database_get_message (_tmp242_);
		_tmp244_ = _tmp243_;
		_tmp245_ = _tmp244_->direction;
		_tmp246_ = qlite_column_to_string (_tmp245_);
		_tmp247_ = _tmp246_;
		_tmp248_ = self->priv->db;
		_tmp249_ = dino_database_get_account (_tmp248_);
		_tmp250_ = _tmp249_;
		_tmp251_ = _tmp250_->bare_jid;
		_tmp252_ = qlite_column_to_string (_tmp251_);
		_tmp253_ = _tmp252_;
		_tmp254_ = g_strconcat ("(", _tmp247_, " = 1 AND ", _tmp253_, " LIKE ?)", NULL);
		_tmp255_ = _tmp254_;
		_tmp256_ = self->priv->db;
		_tmp257_ = dino_database_get_message (_tmp256_);
		_tmp258_ = _tmp257_;
		_tmp259_ = _tmp258_->direction;
		_tmp260_ = qlite_column_to_string (_tmp259_);
		_tmp261_ = _tmp260_;
		_tmp262_ = self->priv->db;
		_tmp263_ = dino_database_get_message (_tmp262_);
		_tmp264_ = _tmp263_;
		_tmp265_ = _tmp264_->type_;
		_tmp266_ = qlite_column_to_string (_tmp265_);
		_tmp267_ = _tmp266_;
		_tmp268_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT);
		_tmp269_ = _tmp268_;
		_tmp270_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM);
		_tmp271_ = _tmp270_;
		_tmp272_ = self->priv->db;
		_tmp273_ = dino_database_get_message (_tmp272_);
		_tmp274_ = _tmp273_;
		_tmp275_ = _tmp274_->our_resource;
		_tmp276_ = qlite_column_to_string (_tmp275_);
		_tmp277_ = _tmp276_;
		_tmp278_ = g_strconcat (" OR (", _tmp261_, " = 1 AND ", _tmp267_, " IN (", _tmp269_, ", ", _tmp271_, ") AND ", _tmp277_, " LIKE ?)", NULL);
		_tmp279_ = _tmp278_;
		_tmp280_ = g_strconcat (_tmp255_, _tmp279_, NULL);
		_tmp281_ = _tmp280_;
		_tmp282_ = self->priv->db;
		_tmp283_ = dino_database_get_message (_tmp282_);
		_tmp284_ = _tmp283_;
		_tmp285_ = _tmp284_->direction;
		_tmp286_ = qlite_column_to_string (_tmp285_);
		_tmp287_ = _tmp286_;
		_tmp288_ = self->priv->db;
		_tmp289_ = dino_database_get_message (_tmp288_);
		_tmp290_ = _tmp289_;
		_tmp291_ = _tmp290_->type_;
		_tmp292_ = qlite_column_to_string (_tmp291_);
		_tmp293_ = _tmp292_;
		_tmp294_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_CHAT);
		_tmp295_ = _tmp294_;
		_tmp296_ = self->priv->db;
		_tmp297_ = dino_database_get_jid (_tmp296_);
		_tmp298_ = _tmp297_;
		_tmp299_ = _tmp298_->bare_jid;
		_tmp300_ = qlite_column_to_string (_tmp299_);
		_tmp301_ = _tmp300_;
		_tmp302_ = g_strconcat (" OR (", _tmp287_, " = 0 AND ", _tmp293_, " = ", _tmp295_, " AND ", _tmp301_, " LIKE ?)", NULL);
		_tmp303_ = _tmp302_;
		_tmp304_ = g_strconcat (_tmp281_, _tmp303_, NULL);
		_tmp305_ = _tmp304_;
		_tmp306_ = self->priv->db;
		_tmp307_ = dino_database_get_message (_tmp306_);
		_tmp308_ = _tmp307_;
		_tmp309_ = _tmp308_->direction;
		_tmp310_ = qlite_column_to_string (_tmp309_);
		_tmp311_ = _tmp310_;
		_tmp312_ = self->priv->db;
		_tmp313_ = dino_database_get_message (_tmp312_);
		_tmp314_ = _tmp313_;
		_tmp315_ = _tmp314_->type_;
		_tmp316_ = qlite_column_to_string (_tmp315_);
		_tmp317_ = _tmp316_;
		_tmp318_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT);
		_tmp319_ = _tmp318_;
		_tmp320_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM);
		_tmp321_ = _tmp320_;
		_tmp322_ = self->priv->db;
		_tmp323_ = dino_database_get_real_jid (_tmp322_);
		_tmp324_ = _tmp323_;
		_tmp325_ = _tmp324_->real_jid;
		_tmp326_ = qlite_column_to_string (_tmp325_);
		_tmp327_ = _tmp326_;
		_tmp328_ = g_strconcat (" OR (", _tmp311_, " = 0 AND ", _tmp317_, " IN (", _tmp319_, ", ", _tmp321_, ") AND ", _tmp327_, " LIKE ?)", NULL);
		_tmp329_ = _tmp328_;
		_tmp330_ = g_strconcat (_tmp305_, _tmp329_, NULL);
		_tmp331_ = _tmp330_;
		_tmp332_ = self->priv->db;
		_tmp333_ = dino_database_get_message (_tmp332_);
		_tmp334_ = _tmp333_;
		_tmp335_ = _tmp334_->direction;
		_tmp336_ = qlite_column_to_string (_tmp335_);
		_tmp337_ = _tmp336_;
		_tmp338_ = self->priv->db;
		_tmp339_ = dino_database_get_message (_tmp338_);
		_tmp340_ = _tmp339_;
		_tmp341_ = _tmp340_->type_;
		_tmp342_ = qlite_column_to_string (_tmp341_);
		_tmp343_ = _tmp342_;
		_tmp344_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT);
		_tmp345_ = _tmp344_;
		_tmp346_ = g_strdup_printf ("%i", (gint) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM);
		_tmp347_ = _tmp346_;
		_tmp348_ = self->priv->db;
		_tmp349_ = dino_database_get_message (_tmp348_);
		_tmp350_ = _tmp349_;
		_tmp351_ = _tmp350_->counterpart_resource;
		_tmp352_ = qlite_column_to_string (_tmp351_);
		_tmp353_ = _tmp352_;
		_tmp354_ = g_strconcat (" OR (", _tmp337_, " = 0 AND ", _tmp343_, " IN (", _tmp345_, ", ", _tmp347_, ") AND ", _tmp353_, " LIKE ?)", NULL);
		_tmp355_ = _tmp354_;
		_tmp356_ = g_strconcat (_tmp331_, _tmp355_, NULL);
		_tmp357_ = _tmp356_;
		_tmp358_ = from;
		_tmp359_ = g_strdup (_tmp358_);
		_tmp360_ = from;
		_tmp361_ = g_strdup (_tmp360_);
		_tmp362_ = from;
		_tmp363_ = g_strdup (_tmp362_);
		_tmp364_ = from;
		_tmp365_ = g_strdup (_tmp364_);
		_tmp366_ = from;
		_tmp367_ = g_strdup (_tmp366_);
		_tmp368_ = g_new0 (gchar*, 5 + 1);
		_tmp368_[0] = _tmp359_;
		_tmp368_[1] = _tmp361_;
		_tmp368_[2] = _tmp363_;
		_tmp368_[3] = _tmp365_;
		_tmp368_[4] = _tmp367_;
		_tmp369_ = _tmp368_;
		_tmp369__length1 = 5;
		_tmp370_ = qlite_query_builder_where (_tmp241_, _tmp357_, _tmp369_, (gint) 5);
		_tmp371_ = _tmp370_;
		_qlite_statement_builder_unref0 (_tmp371_);
		_tmp369_ = (_vala_array_free (_tmp369_, _tmp369__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp357_);
		_g_free0 (_tmp355_);
		_g_free0 (_tmp353_);
		_g_free0 (_tmp347_);
		_g_free0 (_tmp345_);
		_g_free0 (_tmp343_);
		_g_free0 (_tmp337_);
		_g_free0 (_tmp331_);
		_g_free0 (_tmp329_);
		_g_free0 (_tmp327_);
		_g_free0 (_tmp321_);
		_g_free0 (_tmp319_);
		_g_free0 (_tmp317_);
		_g_free0 (_tmp311_);
		_g_free0 (_tmp305_);
		_g_free0 (_tmp303_);
		_g_free0 (_tmp301_);
		_g_free0 (_tmp295_);
		_g_free0 (_tmp293_);
		_g_free0 (_tmp287_);
		_g_free0 (_tmp281_);
		_g_free0 (_tmp279_);
		_g_free0 (_tmp277_);
		_g_free0 (_tmp271_);
		_g_free0 (_tmp269_);
		_g_free0 (_tmp267_);
		_g_free0 (_tmp261_);
		_g_free0 (_tmp255_);
		_g_free0 (_tmp253_);
		_g_free0 (_tmp247_);
	}
	result = rows;
	_g_free0 (from);
	_g_free0 (in_);
	_g_free0 (with);
	_g_free0 (words);
	return result;
}

static gint
string_last_index_of (const gchar* self,
                      const gchar* needle,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = g_strrstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

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

static gint
_____lambda122_ (DinoSearchProcessor* self,
                 DinoSearchSuggestion* a,
                 DinoSearchSuggestion* b)
{
	glong _tmp0_;
	glong _tmp1_;
	glong _tmp2_;
	glong _tmp3_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = dino_search_suggestion_get_order (b);
	_tmp1_ = _tmp0_;
	_tmp2_ = dino_search_suggestion_get_order (a);
	_tmp3_ = _tmp2_;
	result = (gint) (_tmp1_ - _tmp3_);
	return result;
}

static gint
______lambda122__gcompare_data_func (gconstpointer a,
                                     gconstpointer b,
                                     gpointer self)
{
	gint result;
	result = _____lambda122_ ((DinoSearchProcessor*) self, (DinoSearchSuggestion*) a, (DinoSearchSuggestion*) b);
	return result;
}

GeeList*
dino_search_processor_suggest_auto_complete (DinoSearchProcessor* self,
                                             const gchar* query,
                                             gint cursor_position,
                                             gint limit)
{
	gint after_prev_space = 0;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint _tmp2_;
	gint next_space = 0;
	gchar* current_query = NULL;
	gchar* _tmp5_;
	GeeList* suggestions = NULL;
	GeeArrayList* _tmp6_;
	const gchar* _tmp7_;
	GError* _inner_error0_ = NULL;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (query != NULL, NULL);
	_tmp0_ = string_substring (query, (glong) 0, (glong) cursor_position);
	_tmp1_ = _tmp0_;
	_tmp2_ = string_last_index_of (_tmp1_, " ", 0) + 1;
	_g_free0 (_tmp1_);
	after_prev_space = _tmp2_;
	next_space = string_index_of (query, " ", after_prev_space);
	if (next_space < 0) {
		gint _tmp3_;
		gint _tmp4_;
		_tmp3_ = strlen (query);
		_tmp4_ = _tmp3_;
		next_space = _tmp4_;
	}
	_tmp5_ = string_substring (query, (glong) after_prev_space, (glong) (next_space - after_prev_space));
	current_query = _tmp5_;
	_tmp6_ = gee_array_list_new (DINO_TYPE_SEARCH_SUGGESTION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	suggestions = (GeeList*) _tmp6_;
	_tmp7_ = current_query;
	if (g_str_has_prefix (_tmp7_, "from:")) {
		gchar* current_from = NULL;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		gchar** splitted = NULL;
		gchar** _tmp10_;
		gchar** _tmp11_;
		gint splitted_length1;
		gint _splitted_size_;
		gchar** _tmp12_;
		gint _tmp12__length1;
		gchar* current_in = NULL;
		gchar* current_with = NULL;
		gchar** _tmp20_;
		gint _tmp20__length1;
		gboolean _tmp28_ = FALSE;
		const gchar* _tmp29_;
		const gchar* _tmp31_;
		const gchar* _tmp150_;
		if (cursor_position < (after_prev_space + 5)) {
			result = suggestions;
			_g_free0 (current_query);
			return result;
		}
		_tmp8_ = current_query;
		_tmp9_ = string_substring (_tmp8_, (glong) 5, (glong) -1);
		current_from = _tmp9_;
		_tmp11_ = _tmp10_ = g_strsplit (query, " ", 0);
		splitted = _tmp11_;
		splitted_length1 = _vala_array_length (_tmp10_);
		_splitted_size_ = splitted_length1;
		_tmp12_ = splitted;
		_tmp12__length1 = splitted_length1;
		{
			gchar** s_collection = NULL;
			gint s_collection_length1 = 0;
			gint _s_collection_size_ = 0;
			gint s_it = 0;
			s_collection = _tmp12_;
			s_collection_length1 = _tmp12__length1;
			for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
				gchar* _tmp13_;
				gchar* s = NULL;
				_tmp13_ = g_strdup (s_collection[s_it]);
				s = _tmp13_;
				{
					gboolean _tmp14_ = FALSE;
					const gchar* _tmp15_;
					_tmp15_ = s;
					if (g_str_has_prefix (_tmp15_, "from:")) {
						const gchar* _tmp16_;
						const gchar* _tmp17_;
						gchar* _tmp18_;
						gchar* _tmp19_;
						_tmp16_ = s;
						_tmp17_ = current_from;
						_tmp18_ = g_strconcat ("from:", _tmp17_, NULL);
						_tmp19_ = _tmp18_;
						_tmp14_ = g_strcmp0 (_tmp16_, _tmp19_) != 0;
						_g_free0 (_tmp19_);
					} else {
						_tmp14_ = FALSE;
					}
					if (_tmp14_) {
						result = suggestions;
						_g_free0 (s);
						splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
						_g_free0 (current_from);
						_g_free0 (current_query);
						return result;
					}
					_g_free0 (s);
				}
			}
		}
		current_in = NULL;
		current_with = NULL;
		_tmp20_ = splitted;
		_tmp20__length1 = splitted_length1;
		{
			gchar** s_collection = NULL;
			gint s_collection_length1 = 0;
			gint _s_collection_size_ = 0;
			gint s_it = 0;
			s_collection = _tmp20_;
			s_collection_length1 = _tmp20__length1;
			for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
				gchar* _tmp21_;
				gchar* s = NULL;
				_tmp21_ = g_strdup (s_collection[s_it]);
				s = _tmp21_;
				{
					const gchar* _tmp22_;
					_tmp22_ = s;
					if (g_str_has_prefix (_tmp22_, "in:")) {
						const gchar* _tmp23_;
						gchar* _tmp24_;
						_tmp23_ = s;
						_tmp24_ = string_substring (_tmp23_, (glong) 3, (glong) -1);
						_g_free0 (current_in);
						current_in = _tmp24_;
					} else {
						const gchar* _tmp25_;
						_tmp25_ = s;
						if (g_str_has_prefix (_tmp25_, "with:")) {
							const gchar* _tmp26_;
							gchar* _tmp27_;
							_tmp26_ = s;
							_tmp27_ = string_substring (_tmp26_, (glong) 5, (glong) -1);
							_g_free0 (current_with);
							current_with = _tmp27_;
						}
					}
					_g_free0 (s);
				}
			}
		}
		_tmp29_ = current_in;
		if (_tmp29_ != NULL) {
			const gchar* _tmp30_;
			_tmp30_ = current_with;
			_tmp28_ = _tmp30_ != NULL;
		} else {
			_tmp28_ = FALSE;
		}
		if (_tmp28_) {
			result = suggestions;
			_g_free0 (current_with);
			_g_free0 (current_in);
			splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (current_from);
			_g_free0 (current_query);
			return result;
		}
		_tmp31_ = current_with;
		if (_tmp31_ != NULL) {
			QliteQueryBuilder* chats = NULL;
			DinoDatabase* _tmp32_;
			DinoDatabaseConversationTable* _tmp33_;
			DinoDatabaseConversationTable* _tmp34_;
			QliteQueryBuilder* _tmp35_;
			QliteQueryBuilder* _tmp36_;
			DinoDatabase* _tmp37_;
			DinoDatabaseJidTable* _tmp38_;
			DinoDatabaseJidTable* _tmp39_;
			DinoDatabase* _tmp40_;
			DinoDatabaseJidTable* _tmp41_;
			DinoDatabaseJidTable* _tmp42_;
			QliteColumn* _tmp43_;
			DinoDatabase* _tmp44_;
			DinoDatabaseConversationTable* _tmp45_;
			DinoDatabaseConversationTable* _tmp46_;
			QliteColumn* _tmp47_;
			QliteQueryBuilder* _tmp48_;
			QliteQueryBuilder* _tmp49_;
			DinoDatabase* _tmp50_;
			DinoDatabaseAccountTable* _tmp51_;
			DinoDatabaseAccountTable* _tmp52_;
			DinoDatabase* _tmp53_;
			DinoDatabaseAccountTable* _tmp54_;
			DinoDatabaseAccountTable* _tmp55_;
			QliteColumn* _tmp56_;
			DinoDatabase* _tmp57_;
			DinoDatabaseConversationTable* _tmp58_;
			DinoDatabaseConversationTable* _tmp59_;
			QliteColumn* _tmp60_;
			QliteQueryBuilder* _tmp61_;
			QliteQueryBuilder* _tmp62_;
			DinoDatabase* _tmp63_;
			DinoDatabaseJidTable* _tmp64_;
			DinoDatabaseJidTable* _tmp65_;
			QliteColumn* _tmp66_;
			const gchar* _tmp67_;
			QliteQueryBuilder* _tmp68_;
			QliteQueryBuilder* _tmp69_;
			DinoDatabase* _tmp70_;
			DinoDatabaseAccountTable* _tmp71_;
			DinoDatabaseAccountTable* _tmp72_;
			QliteColumn* _tmp73_;
			QliteQueryBuilder* _tmp74_;
			QliteQueryBuilder* _tmp75_;
			DinoDatabase* _tmp76_;
			DinoDatabaseConversationTable* _tmp77_;
			DinoDatabaseConversationTable* _tmp78_;
			QliteColumn* _tmp79_;
			QliteQueryBuilder* _tmp80_;
			QliteQueryBuilder* _tmp81_;
			DinoDatabase* _tmp82_;
			DinoDatabaseConversationTable* _tmp83_;
			DinoDatabaseConversationTable* _tmp84_;
			QliteColumn* _tmp85_;
			QliteQueryBuilder* _tmp86_;
			QliteQueryBuilder* _tmp87_;
			_tmp32_ = self->priv->db;
			_tmp33_ = dino_database_get_conversation (_tmp32_);
			_tmp34_ = _tmp33_;
			_tmp35_ = qlite_table_select ((QliteTable*) _tmp34_, NULL, (gint) 0);
			_tmp36_ = _tmp35_;
			_tmp37_ = self->priv->db;
			_tmp38_ = dino_database_get_jid (_tmp37_);
			_tmp39_ = _tmp38_;
			_tmp40_ = self->priv->db;
			_tmp41_ = dino_database_get_jid (_tmp40_);
			_tmp42_ = _tmp41_;
			_tmp43_ = _tmp42_->id;
			_tmp44_ = self->priv->db;
			_tmp45_ = dino_database_get_conversation (_tmp44_);
			_tmp46_ = _tmp45_;
			_tmp47_ = _tmp46_->jid_id;
			_tmp48_ = qlite_query_builder_join_with (_tmp36_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp39_, _tmp43_, _tmp47_, NULL);
			_tmp49_ = _tmp48_;
			_tmp50_ = self->priv->db;
			_tmp51_ = dino_database_get_account (_tmp50_);
			_tmp52_ = _tmp51_;
			_tmp53_ = self->priv->db;
			_tmp54_ = dino_database_get_account (_tmp53_);
			_tmp55_ = _tmp54_;
			_tmp56_ = _tmp55_->id;
			_tmp57_ = self->priv->db;
			_tmp58_ = dino_database_get_conversation (_tmp57_);
			_tmp59_ = _tmp58_;
			_tmp60_ = _tmp59_->account_id;
			_tmp61_ = qlite_query_builder_join_with (_tmp49_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp52_, _tmp56_, _tmp60_, NULL);
			_tmp62_ = _tmp61_;
			_tmp63_ = self->priv->db;
			_tmp64_ = dino_database_get_jid (_tmp63_);
			_tmp65_ = _tmp64_;
			_tmp66_ = _tmp65_->bare_jid;
			_tmp67_ = current_with;
			_tmp68_ = qlite_query_builder_with (_tmp62_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp66_, "=", _tmp67_);
			_tmp69_ = _tmp68_;
			_tmp70_ = self->priv->db;
			_tmp71_ = dino_database_get_account (_tmp70_);
			_tmp72_ = _tmp71_;
			_tmp73_ = _tmp72_->enabled;
			_tmp74_ = qlite_query_builder_with (_tmp69_, G_TYPE_BOOLEAN, NULL, NULL, _tmp73_, "=", (gpointer) ((gintptr) TRUE));
			_tmp75_ = _tmp74_;
			_tmp76_ = self->priv->db;
			_tmp77_ = dino_database_get_conversation (_tmp76_);
			_tmp78_ = _tmp77_;
			_tmp79_ = _tmp78_->type_;
			_tmp80_ = qlite_query_builder_with (_tmp75_, G_TYPE_INT, NULL, NULL, _tmp79_, "=", (gpointer) ((gintptr) DINO_ENTITIES_CONVERSATION_TYPE_CHAT));
			_tmp81_ = _tmp80_;
			_tmp82_ = self->priv->db;
			_tmp83_ = dino_database_get_conversation (_tmp82_);
			_tmp84_ = _tmp83_;
			_tmp85_ = _tmp84_->last_active;
			_tmp86_ = qlite_query_builder_order_by (_tmp81_, _tmp85_, "DESC");
			_tmp87_ = _tmp86_;
			_qlite_statement_builder_unref0 (_tmp81_);
			_qlite_statement_builder_unref0 (_tmp75_);
			_qlite_statement_builder_unref0 (_tmp69_);
			_qlite_statement_builder_unref0 (_tmp62_);
			_qlite_statement_builder_unref0 (_tmp49_);
			_qlite_statement_builder_unref0 (_tmp36_);
			chats = _tmp87_;
			{
				QliteRowIterator* _chat_it = NULL;
				QliteQueryBuilder* _tmp88_;
				QliteRowIterator* _tmp89_;
				_tmp88_ = chats;
				_tmp89_ = qlite_query_builder_iterator (_tmp88_);
				_chat_it = _tmp89_;
				while (TRUE) {
					QliteRowIterator* _tmp90_;
					QliteRow* chat = NULL;
					QliteRowIterator* _tmp91_;
					QliteRow* _tmp92_;
					_tmp90_ = _chat_it;
					if (!qlite_row_iterator_next (_tmp90_)) {
						break;
					}
					_tmp91_ = _chat_it;
					_tmp92_ = qlite_row_iterator_get (_tmp91_);
					chat = _tmp92_;
					{
						GeeList* _tmp93_;
						gint _tmp94_;
						gint _tmp95_;
						DinoEntitiesConversation* _tmp122_ = NULL;
						DinoDatabase* _tmp123_;
						QliteRow* _tmp124_;
						DinoEntitiesConversation* _tmp125_;
						XmppJid* _tmp126_ = NULL;
						QliteRow* _tmp127_;
						DinoDatabase* _tmp128_;
						DinoDatabaseAccountTable* _tmp129_;
						DinoDatabaseAccountTable* _tmp130_;
						QliteColumn* _tmp131_;
						gpointer _tmp132_;
						gchar* _tmp133_;
						XmppJid* _tmp134_;
						XmppJid* _tmp135_;
						GeeList* _tmp136_;
						QliteRow* _tmp137_;
						DinoDatabase* _tmp138_;
						DinoDatabaseAccountTable* _tmp139_;
						DinoDatabaseAccountTable* _tmp140_;
						QliteColumn* _tmp141_;
						gpointer _tmp142_;
						gchar* _tmp143_;
						gchar* _tmp144_;
						gchar* _tmp145_;
						DinoSearchSuggestion* _tmp146_;
						DinoSearchSuggestion* _tmp147_;
						_tmp93_ = suggestions;
						_tmp94_ = gee_collection_get_size ((GeeCollection*) _tmp93_);
						_tmp95_ = _tmp94_;
						if (_tmp95_ == 0) {
							DinoEntitiesConversation* _tmp96_ = NULL;
							DinoDatabase* _tmp97_;
							QliteRow* _tmp98_;
							DinoEntitiesConversation* _tmp99_;
							XmppJid* _tmp100_ = NULL;
							QliteRow* _tmp101_;
							DinoDatabase* _tmp102_;
							DinoDatabaseJidTable* _tmp103_;
							DinoDatabaseJidTable* _tmp104_;
							QliteColumn* _tmp105_;
							gpointer _tmp106_;
							gchar* _tmp107_;
							XmppJid* _tmp108_;
							XmppJid* _tmp109_;
							GeeList* _tmp110_;
							QliteRow* _tmp111_;
							DinoDatabase* _tmp112_;
							DinoDatabaseJidTable* _tmp113_;
							DinoDatabaseJidTable* _tmp114_;
							QliteColumn* _tmp115_;
							gpointer _tmp116_;
							gchar* _tmp117_;
							gchar* _tmp118_;
							gchar* _tmp119_;
							DinoSearchSuggestion* _tmp120_;
							DinoSearchSuggestion* _tmp121_;
							_tmp97_ = self->priv->db;
							_tmp98_ = chat;
							_tmp99_ = dino_entities_conversation_new_from_row (_tmp97_, _tmp98_, &_inner_error0_);
							_tmp96_ = _tmp99_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
									goto __catch0_xmpp_invalid_jid_error;
								}
								_qlite_row_unref0 (chat);
								_qlite_row_iterator_unref0 (_chat_it);
								_qlite_statement_builder_unref0 (chats);
								_g_free0 (current_with);
								_g_free0 (current_in);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_from);
								_g_object_unref0 (suggestions);
								_g_free0 (current_query);
								g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
							_tmp101_ = chat;
							_tmp102_ = self->priv->db;
							_tmp103_ = dino_database_get_jid (_tmp102_);
							_tmp104_ = _tmp103_;
							_tmp105_ = _tmp104_->bare_jid;
							_tmp106_ = qlite_row_get (_tmp101_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp105_);
							_tmp107_ = (gchar*) _tmp106_;
							_tmp108_ = xmpp_jid_new (_tmp107_, &_inner_error0_);
							_tmp109_ = _tmp108_;
							_g_free0 (_tmp107_);
							_tmp100_ = _tmp109_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								_g_object_unref0 (_tmp96_);
								if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
									goto __catch0_xmpp_invalid_jid_error;
								}
								_qlite_row_unref0 (chat);
								_qlite_row_iterator_unref0 (_chat_it);
								_qlite_statement_builder_unref0 (chats);
								_g_free0 (current_with);
								_g_free0 (current_in);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_from);
								_g_object_unref0 (suggestions);
								_g_free0 (current_query);
								g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
							_tmp110_ = suggestions;
							_tmp111_ = chat;
							_tmp112_ = self->priv->db;
							_tmp113_ = dino_database_get_jid (_tmp112_);
							_tmp114_ = _tmp113_;
							_tmp115_ = _tmp114_->bare_jid;
							_tmp116_ = qlite_row_get (_tmp111_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp115_);
							_tmp117_ = (gchar*) _tmp116_;
							_tmp118_ = g_strconcat ("from:", _tmp117_, NULL);
							_tmp119_ = _tmp118_;
							_tmp120_ = dino_search_suggestion_new (_tmp96_, _tmp100_, _tmp119_, after_prev_space, next_space);
							_tmp121_ = _tmp120_;
							gee_collection_add ((GeeCollection*) _tmp110_, _tmp121_);
							_g_object_unref0 (_tmp121_);
							_g_free0 (_tmp119_);
							_g_free0 (_tmp117_);
							_xmpp_jid_unref0 (_tmp100_);
							_g_object_unref0 (_tmp96_);
						}
						_tmp123_ = self->priv->db;
						_tmp124_ = chat;
						_tmp125_ = dino_entities_conversation_new_from_row (_tmp123_, _tmp124_, &_inner_error0_);
						_tmp122_ = _tmp125_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
								goto __catch0_xmpp_invalid_jid_error;
							}
							_qlite_row_unref0 (chat);
							_qlite_row_iterator_unref0 (_chat_it);
							_qlite_statement_builder_unref0 (chats);
							_g_free0 (current_with);
							_g_free0 (current_in);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_from);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_tmp127_ = chat;
						_tmp128_ = self->priv->db;
						_tmp129_ = dino_database_get_account (_tmp128_);
						_tmp130_ = _tmp129_;
						_tmp131_ = _tmp130_->bare_jid;
						_tmp132_ = qlite_row_get (_tmp127_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp131_);
						_tmp133_ = (gchar*) _tmp132_;
						_tmp134_ = xmpp_jid_new (_tmp133_, &_inner_error0_);
						_tmp135_ = _tmp134_;
						_g_free0 (_tmp133_);
						_tmp126_ = _tmp135_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_g_object_unref0 (_tmp122_);
							if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
								goto __catch0_xmpp_invalid_jid_error;
							}
							_qlite_row_unref0 (chat);
							_qlite_row_iterator_unref0 (_chat_it);
							_qlite_statement_builder_unref0 (chats);
							_g_free0 (current_with);
							_g_free0 (current_in);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_from);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_tmp136_ = suggestions;
						_tmp137_ = chat;
						_tmp138_ = self->priv->db;
						_tmp139_ = dino_database_get_account (_tmp138_);
						_tmp140_ = _tmp139_;
						_tmp141_ = _tmp140_->bare_jid;
						_tmp142_ = qlite_row_get (_tmp137_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp141_);
						_tmp143_ = (gchar*) _tmp142_;
						_tmp144_ = g_strconcat ("from:", _tmp143_, NULL);
						_tmp145_ = _tmp144_;
						_tmp146_ = dino_search_suggestion_new (_tmp122_, _tmp126_, _tmp145_, after_prev_space, next_space);
						_tmp147_ = _tmp146_;
						gee_collection_add ((GeeCollection*) _tmp136_, _tmp147_);
						_g_object_unref0 (_tmp147_);
						_g_free0 (_tmp145_);
						_g_free0 (_tmp143_);
						_xmpp_jid_unref0 (_tmp126_);
						_g_object_unref0 (_tmp122_);
					}
					goto __finally0;
					__catch0_xmpp_invalid_jid_error:
					{
						GError* e = NULL;
						GError* _tmp148_;
						const gchar* _tmp149_;
						e = _inner_error0_;
						_inner_error0_ = NULL;
						_tmp148_ = e;
						_tmp149_ = _tmp148_->message;
						g_warning ("search_processor.vala:141: Ignoring search suggestion with invalid Jid" \
": %s", _tmp149_);
						_g_error_free0 (e);
					}
					__finally0:
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_qlite_row_unref0 (chat);
						_qlite_row_iterator_unref0 (_chat_it);
						_qlite_statement_builder_unref0 (chats);
						_g_free0 (current_with);
						_g_free0 (current_in);
						splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
						_g_free0 (current_from);
						_g_object_unref0 (suggestions);
						_g_free0 (current_query);
						g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
						g_clear_error (&_inner_error0_);
						return NULL;
					}
					_qlite_row_unref0 (chat);
				}
				_qlite_row_iterator_unref0 (_chat_it);
			}
			result = suggestions;
			_qlite_statement_builder_unref0 (chats);
			_g_free0 (current_with);
			_g_free0 (current_in);
			splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (current_from);
			_g_free0 (current_query);
			return result;
		}
		_tmp150_ = current_in;
		if (_tmp150_ != NULL) {
			QliteQueryBuilder* msgs = NULL;
			DinoDatabase* _tmp151_;
			DinoDatabaseMessageTable* _tmp152_;
			DinoDatabaseMessageTable* _tmp153_;
			QliteQueryBuilder* _tmp154_;
			QliteQueryBuilder* _tmp155_;
			DinoDatabase* _tmp156_;
			DinoDatabaseMessageTable* _tmp157_;
			DinoDatabaseMessageTable* _tmp158_;
			QliteColumn* _tmp159_;
			gchar* _tmp160_;
			gchar* _tmp161_;
			gchar* _tmp162_;
			gchar* _tmp163_;
			QliteQueryBuilder* _tmp164_;
			QliteQueryBuilder* _tmp165_;
			DinoDatabase* _tmp166_;
			DinoDatabaseJidTable* _tmp167_;
			DinoDatabaseJidTable* _tmp168_;
			DinoDatabase* _tmp169_;
			DinoDatabaseJidTable* _tmp170_;
			DinoDatabaseJidTable* _tmp171_;
			QliteColumn* _tmp172_;
			DinoDatabase* _tmp173_;
			DinoDatabaseMessageTable* _tmp174_;
			DinoDatabaseMessageTable* _tmp175_;
			QliteColumn* _tmp176_;
			QliteQueryBuilder* _tmp177_;
			QliteQueryBuilder* _tmp178_;
			DinoDatabase* _tmp179_;
			DinoDatabaseAccountTable* _tmp180_;
			DinoDatabaseAccountTable* _tmp181_;
			DinoDatabase* _tmp182_;
			DinoDatabaseAccountTable* _tmp183_;
			DinoDatabaseAccountTable* _tmp184_;
			QliteColumn* _tmp185_;
			DinoDatabase* _tmp186_;
			DinoDatabaseMessageTable* _tmp187_;
			DinoDatabaseMessageTable* _tmp188_;
			QliteColumn* _tmp189_;
			QliteQueryBuilder* _tmp190_;
			QliteQueryBuilder* _tmp191_;
			DinoDatabase* _tmp192_;
			DinoDatabaseConversationTable* _tmp193_;
			DinoDatabaseConversationTable* _tmp194_;
			DinoDatabase* _tmp195_;
			DinoDatabaseConversationTable* _tmp196_;
			DinoDatabaseConversationTable* _tmp197_;
			QliteColumn* _tmp198_;
			gchar* _tmp199_;
			gchar* _tmp200_;
			DinoDatabase* _tmp201_;
			DinoDatabaseAccountTable* _tmp202_;
			DinoDatabaseAccountTable* _tmp203_;
			QliteColumn* _tmp204_;
			gchar* _tmp205_;
			gchar* _tmp206_;
			DinoDatabase* _tmp207_;
			DinoDatabaseConversationTable* _tmp208_;
			DinoDatabaseConversationTable* _tmp209_;
			QliteColumn* _tmp210_;
			gchar* _tmp211_;
			gchar* _tmp212_;
			DinoDatabase* _tmp213_;
			DinoDatabaseJidTable* _tmp214_;
			DinoDatabaseJidTable* _tmp215_;
			QliteColumn* _tmp216_;
			gchar* _tmp217_;
			gchar* _tmp218_;
			gchar* _tmp219_;
			gchar* _tmp220_;
			QliteQueryBuilder* _tmp221_;
			QliteQueryBuilder* _tmp222_;
			DinoDatabase* _tmp223_;
			DinoDatabaseJidTable* _tmp224_;
			DinoDatabaseJidTable* _tmp225_;
			QliteColumn* _tmp226_;
			const gchar* _tmp227_;
			QliteQueryBuilder* _tmp228_;
			QliteQueryBuilder* _tmp229_;
			DinoDatabase* _tmp230_;
			DinoDatabaseAccountTable* _tmp231_;
			DinoDatabaseAccountTable* _tmp232_;
			QliteColumn* _tmp233_;
			QliteQueryBuilder* _tmp234_;
			QliteQueryBuilder* _tmp235_;
			DinoDatabase* _tmp236_;
			DinoDatabaseMessageTable* _tmp237_;
			DinoDatabaseMessageTable* _tmp238_;
			QliteColumn* _tmp239_;
			QliteQueryBuilder* _tmp240_;
			QliteQueryBuilder* _tmp241_;
			DinoDatabase* _tmp242_;
			DinoDatabaseConversationTable* _tmp243_;
			DinoDatabaseConversationTable* _tmp244_;
			QliteColumn* _tmp245_;
			QliteQueryBuilder* _tmp246_;
			QliteQueryBuilder* _tmp247_;
			DinoDatabase* _tmp248_;
			DinoDatabaseMessageTable* _tmp249_;
			DinoDatabaseMessageTable* _tmp250_;
			QliteColumn* _tmp251_;
			const gchar* _tmp252_;
			const gchar* _tmp253_;
			gchar* _tmp254_;
			gchar* _tmp255_;
			QliteQueryBuilder* _tmp256_;
			QliteQueryBuilder* _tmp257_;
			DinoDatabase* _tmp258_;
			DinoDatabaseMessageTable* _tmp259_;
			DinoDatabaseMessageTable* _tmp260_;
			QliteColumn* _tmp261_;
			QliteColumn* _tmp262_;
			QliteColumn** _tmp263_;
			QliteColumn** _tmp264_;
			gint _tmp264__length1;
			QliteQueryBuilder* _tmp265_;
			QliteQueryBuilder* _tmp266_;
			DinoDatabase* _tmp267_;
			DinoDatabaseMessageTable* _tmp268_;
			DinoDatabaseMessageTable* _tmp269_;
			QliteColumn* _tmp270_;
			gchar* _tmp271_;
			gchar* _tmp272_;
			gchar* _tmp273_;
			gchar* _tmp274_;
			QliteQueryBuilder* _tmp275_;
			QliteQueryBuilder* _tmp276_;
			QliteQueryBuilder* _tmp277_;
			QliteQueryBuilder* _tmp278_;
			_tmp151_ = self->priv->db;
			_tmp152_ = dino_database_get_message (_tmp151_);
			_tmp153_ = _tmp152_;
			_tmp154_ = qlite_table_select ((QliteTable*) _tmp153_, NULL, (gint) 0);
			_tmp155_ = _tmp154_;
			_tmp156_ = self->priv->db;
			_tmp157_ = dino_database_get_message (_tmp156_);
			_tmp158_ = _tmp157_;
			_tmp159_ = _tmp158_->counterpart_resource;
			_tmp160_ = qlite_column_to_string (_tmp159_);
			_tmp161_ = _tmp160_;
			_tmp162_ = g_strconcat ("account.*, ", _tmp161_, ", conversation.*", NULL);
			_tmp163_ = _tmp162_;
			_tmp164_ = qlite_query_builder_select_string (_tmp155_, _tmp163_);
			_tmp165_ = _tmp164_;
			_tmp166_ = self->priv->db;
			_tmp167_ = dino_database_get_jid (_tmp166_);
			_tmp168_ = _tmp167_;
			_tmp169_ = self->priv->db;
			_tmp170_ = dino_database_get_jid (_tmp169_);
			_tmp171_ = _tmp170_;
			_tmp172_ = _tmp171_->id;
			_tmp173_ = self->priv->db;
			_tmp174_ = dino_database_get_message (_tmp173_);
			_tmp175_ = _tmp174_;
			_tmp176_ = _tmp175_->counterpart_id;
			_tmp177_ = qlite_query_builder_join_with (_tmp165_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp168_, _tmp172_, _tmp176_, NULL);
			_tmp178_ = _tmp177_;
			_tmp179_ = self->priv->db;
			_tmp180_ = dino_database_get_account (_tmp179_);
			_tmp181_ = _tmp180_;
			_tmp182_ = self->priv->db;
			_tmp183_ = dino_database_get_account (_tmp182_);
			_tmp184_ = _tmp183_;
			_tmp185_ = _tmp184_->id;
			_tmp186_ = self->priv->db;
			_tmp187_ = dino_database_get_message (_tmp186_);
			_tmp188_ = _tmp187_;
			_tmp189_ = _tmp188_->account_id;
			_tmp190_ = qlite_query_builder_join_with (_tmp178_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp181_, _tmp185_, _tmp189_, NULL);
			_tmp191_ = _tmp190_;
			_tmp192_ = self->priv->db;
			_tmp193_ = dino_database_get_conversation (_tmp192_);
			_tmp194_ = _tmp193_;
			_tmp195_ = self->priv->db;
			_tmp196_ = dino_database_get_conversation (_tmp195_);
			_tmp197_ = _tmp196_;
			_tmp198_ = _tmp197_->account_id;
			_tmp199_ = qlite_column_to_string (_tmp198_);
			_tmp200_ = _tmp199_;
			_tmp201_ = self->priv->db;
			_tmp202_ = dino_database_get_account (_tmp201_);
			_tmp203_ = _tmp202_;
			_tmp204_ = _tmp203_->id;
			_tmp205_ = qlite_column_to_string (_tmp204_);
			_tmp206_ = _tmp205_;
			_tmp207_ = self->priv->db;
			_tmp208_ = dino_database_get_conversation (_tmp207_);
			_tmp209_ = _tmp208_;
			_tmp210_ = _tmp209_->jid_id;
			_tmp211_ = qlite_column_to_string (_tmp210_);
			_tmp212_ = _tmp211_;
			_tmp213_ = self->priv->db;
			_tmp214_ = dino_database_get_jid (_tmp213_);
			_tmp215_ = _tmp214_;
			_tmp216_ = _tmp215_->id;
			_tmp217_ = qlite_column_to_string (_tmp216_);
			_tmp218_ = _tmp217_;
			_tmp219_ = g_strconcat (_tmp200_, "=", _tmp206_, " AND ", _tmp212_, "=", _tmp218_, NULL);
			_tmp220_ = _tmp219_;
			_tmp221_ = qlite_query_builder_join_on (_tmp191_, (QliteTable*) _tmp194_, _tmp220_, NULL);
			_tmp222_ = _tmp221_;
			_tmp223_ = self->priv->db;
			_tmp224_ = dino_database_get_jid (_tmp223_);
			_tmp225_ = _tmp224_;
			_tmp226_ = _tmp225_->bare_jid;
			_tmp227_ = current_in;
			_tmp228_ = qlite_query_builder_with (_tmp222_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp226_, "=", _tmp227_);
			_tmp229_ = _tmp228_;
			_tmp230_ = self->priv->db;
			_tmp231_ = dino_database_get_account (_tmp230_);
			_tmp232_ = _tmp231_;
			_tmp233_ = _tmp232_->enabled;
			_tmp234_ = qlite_query_builder_with (_tmp229_, G_TYPE_BOOLEAN, NULL, NULL, _tmp233_, "=", (gpointer) ((gintptr) TRUE));
			_tmp235_ = _tmp234_;
			_tmp236_ = self->priv->db;
			_tmp237_ = dino_database_get_message (_tmp236_);
			_tmp238_ = _tmp237_;
			_tmp239_ = _tmp238_->type_;
			_tmp240_ = qlite_query_builder_with (_tmp235_, G_TYPE_INT, NULL, NULL, _tmp239_, "=", (gpointer) ((gintptr) DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT));
			_tmp241_ = _tmp240_;
			_tmp242_ = self->priv->db;
			_tmp243_ = dino_database_get_conversation (_tmp242_);
			_tmp244_ = _tmp243_;
			_tmp245_ = _tmp244_->type_;
			_tmp246_ = qlite_query_builder_with (_tmp241_, G_TYPE_INT, NULL, NULL, _tmp245_, "=", (gpointer) ((gintptr) DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT));
			_tmp247_ = _tmp246_;
			_tmp248_ = self->priv->db;
			_tmp249_ = dino_database_get_message (_tmp248_);
			_tmp250_ = _tmp249_;
			_tmp251_ = _tmp250_->counterpart_resource;
			_tmp252_ = current_from;
			_tmp253_ = string_to_string (_tmp252_);
			_tmp254_ = g_strconcat ("%", _tmp253_, "%", NULL);
			_tmp255_ = _tmp254_;
			_tmp256_ = qlite_query_builder_with (_tmp247_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp251_, "LIKE", _tmp255_);
			_tmp257_ = _tmp256_;
			_tmp258_ = self->priv->db;
			_tmp259_ = dino_database_get_message (_tmp258_);
			_tmp260_ = _tmp259_;
			_tmp261_ = _tmp260_->counterpart_resource;
			_tmp262_ = _qlite_column_ref0 (_tmp261_);
			_tmp263_ = g_new0 (QliteColumn*, 1 + 1);
			_tmp263_[0] = _tmp262_;
			_tmp264_ = _tmp263_;
			_tmp264__length1 = 1;
			_tmp265_ = qlite_query_builder_group_by (_tmp257_, _tmp264_, (gint) 1);
			_tmp266_ = _tmp265_;
			_tmp267_ = self->priv->db;
			_tmp268_ = dino_database_get_message (_tmp267_);
			_tmp269_ = _tmp268_;
			_tmp270_ = _tmp269_->time;
			_tmp271_ = qlite_column_to_string (_tmp270_);
			_tmp272_ = _tmp271_;
			_tmp273_ = g_strconcat ("MAX(", _tmp272_, ")", NULL);
			_tmp274_ = _tmp273_;
			_tmp275_ = qlite_query_builder_order_by_name (_tmp266_, _tmp274_, "DESC");
			_tmp276_ = _tmp275_;
			_tmp277_ = qlite_query_builder_limit (_tmp276_, 5);
			_tmp278_ = _tmp277_;
			_qlite_statement_builder_unref0 (_tmp276_);
			_g_free0 (_tmp274_);
			_g_free0 (_tmp272_);
			_qlite_statement_builder_unref0 (_tmp266_);
			_tmp264_ = (_vala_array_free (_tmp264_, _tmp264__length1, (GDestroyNotify) qlite_column_unref), NULL);
			_qlite_statement_builder_unref0 (_tmp257_);
			_g_free0 (_tmp255_);
			_qlite_statement_builder_unref0 (_tmp247_);
			_qlite_statement_builder_unref0 (_tmp241_);
			_qlite_statement_builder_unref0 (_tmp235_);
			_qlite_statement_builder_unref0 (_tmp229_);
			_qlite_statement_builder_unref0 (_tmp222_);
			_g_free0 (_tmp220_);
			_g_free0 (_tmp218_);
			_g_free0 (_tmp212_);
			_g_free0 (_tmp206_);
			_g_free0 (_tmp200_);
			_qlite_statement_builder_unref0 (_tmp191_);
			_qlite_statement_builder_unref0 (_tmp178_);
			_qlite_statement_builder_unref0 (_tmp165_);
			_g_free0 (_tmp163_);
			_g_free0 (_tmp161_);
			_qlite_statement_builder_unref0 (_tmp155_);
			msgs = _tmp278_;
			{
				QliteRowIterator* _msg_it = NULL;
				QliteQueryBuilder* _tmp279_;
				QliteRowIterator* _tmp280_;
				_tmp279_ = msgs;
				_tmp280_ = qlite_query_builder_iterator (_tmp279_);
				_msg_it = _tmp280_;
				while (TRUE) {
					QliteRowIterator* _tmp281_;
					QliteRow* msg = NULL;
					QliteRowIterator* _tmp282_;
					QliteRow* _tmp283_;
					_tmp281_ = _msg_it;
					if (!qlite_row_iterator_next (_tmp281_)) {
						break;
					}
					_tmp282_ = _msg_it;
					_tmp283_ = qlite_row_iterator_get (_tmp282_);
					msg = _tmp283_;
					{
						DinoEntitiesConversation* _tmp284_ = NULL;
						DinoDatabase* _tmp285_;
						QliteRow* _tmp286_;
						DinoEntitiesConversation* _tmp287_;
						XmppJid* _tmp288_ = NULL;
						const gchar* _tmp289_;
						XmppJid* _tmp290_;
						XmppJid* _tmp291_ = NULL;
						QliteRow* _tmp292_;
						DinoDatabase* _tmp293_;
						DinoDatabaseMessageTable* _tmp294_;
						DinoDatabaseMessageTable* _tmp295_;
						QliteColumn* _tmp296_;
						gpointer _tmp297_;
						gchar* _tmp298_;
						XmppJid* _tmp299_;
						XmppJid* _tmp300_;
						GeeList* _tmp301_;
						QliteRow* _tmp302_;
						DinoDatabase* _tmp303_;
						DinoDatabaseMessageTable* _tmp304_;
						DinoDatabaseMessageTable* _tmp305_;
						QliteColumn* _tmp306_;
						gpointer _tmp307_;
						gchar* _tmp308_;
						gchar* _tmp309_;
						gchar* _tmp310_;
						DinoSearchSuggestion* _tmp311_;
						DinoSearchSuggestion* _tmp312_;
						_tmp285_ = self->priv->db;
						_tmp286_ = msg;
						_tmp287_ = dino_entities_conversation_new_from_row (_tmp285_, _tmp286_, &_inner_error0_);
						_tmp284_ = _tmp287_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
								goto __catch1_xmpp_invalid_jid_error;
							}
							_qlite_row_unref0 (msg);
							_qlite_row_iterator_unref0 (_msg_it);
							_qlite_statement_builder_unref0 (msgs);
							_g_free0 (current_with);
							_g_free0 (current_in);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_from);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_tmp289_ = current_in;
						_tmp290_ = xmpp_jid_new (_tmp289_, &_inner_error0_);
						_tmp288_ = _tmp290_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_g_object_unref0 (_tmp284_);
							if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
								goto __catch1_xmpp_invalid_jid_error;
							}
							_qlite_row_unref0 (msg);
							_qlite_row_iterator_unref0 (_msg_it);
							_qlite_statement_builder_unref0 (msgs);
							_g_free0 (current_with);
							_g_free0 (current_in);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_from);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_tmp292_ = msg;
						_tmp293_ = self->priv->db;
						_tmp294_ = dino_database_get_message (_tmp293_);
						_tmp295_ = _tmp294_;
						_tmp296_ = _tmp295_->counterpart_resource;
						_tmp297_ = qlite_row_get (_tmp292_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp296_);
						_tmp298_ = (gchar*) _tmp297_;
						_tmp299_ = xmpp_jid_with_resource (_tmp288_, _tmp298_, &_inner_error0_);
						_tmp300_ = _tmp299_;
						_g_free0 (_tmp298_);
						_tmp291_ = _tmp300_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_xmpp_jid_unref0 (_tmp288_);
							_g_object_unref0 (_tmp284_);
							if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
								goto __catch1_xmpp_invalid_jid_error;
							}
							_qlite_row_unref0 (msg);
							_qlite_row_iterator_unref0 (_msg_it);
							_qlite_statement_builder_unref0 (msgs);
							_g_free0 (current_with);
							_g_free0 (current_in);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_from);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_tmp301_ = suggestions;
						_tmp302_ = msg;
						_tmp303_ = self->priv->db;
						_tmp304_ = dino_database_get_message (_tmp303_);
						_tmp305_ = _tmp304_;
						_tmp306_ = _tmp305_->counterpart_resource;
						_tmp307_ = qlite_row_get (_tmp302_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp306_);
						_tmp308_ = (gchar*) _tmp307_;
						_tmp309_ = g_strconcat ("from:", _tmp308_, NULL);
						_tmp310_ = _tmp309_;
						_tmp311_ = dino_search_suggestion_new (_tmp284_, _tmp291_, _tmp310_, after_prev_space, next_space);
						_tmp312_ = _tmp311_;
						gee_collection_add ((GeeCollection*) _tmp301_, _tmp312_);
						_g_object_unref0 (_tmp312_);
						_g_free0 (_tmp310_);
						_g_free0 (_tmp308_);
						_xmpp_jid_unref0 (_tmp291_);
						_xmpp_jid_unref0 (_tmp288_);
						_g_object_unref0 (_tmp284_);
					}
					goto __finally1;
					__catch1_xmpp_invalid_jid_error:
					{
						GError* e = NULL;
						GError* _tmp313_;
						const gchar* _tmp314_;
						e = _inner_error0_;
						_inner_error0_ = NULL;
						_tmp313_ = e;
						_tmp314_ = _tmp313_->message;
						g_warning ("search_processor.vala:165: Ignoring search suggestion with invalid Jid" \
": %s", _tmp314_);
						_g_error_free0 (e);
					}
					__finally1:
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_qlite_row_unref0 (msg);
						_qlite_row_iterator_unref0 (_msg_it);
						_qlite_statement_builder_unref0 (msgs);
						_g_free0 (current_with);
						_g_free0 (current_in);
						splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
						_g_free0 (current_from);
						_g_object_unref0 (suggestions);
						_g_free0 (current_query);
						g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
						g_clear_error (&_inner_error0_);
						return NULL;
					}
					_qlite_row_unref0 (msg);
				}
				_qlite_row_iterator_unref0 (_msg_it);
			}
			_qlite_statement_builder_unref0 (msgs);
		}
		_g_free0 (current_with);
		_g_free0 (current_in);
		splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (current_from);
	} else {
		const gchar* _tmp315_;
		_tmp315_ = current_query;
		if (g_str_has_prefix (_tmp315_, "with:")) {
			gchar* current_with = NULL;
			const gchar* _tmp316_;
			gchar* _tmp317_;
			gchar** splitted = NULL;
			gchar** _tmp318_;
			gchar** _tmp319_;
			gint splitted_length1;
			gint _splitted_size_;
			gchar** _tmp320_;
			gint _tmp320__length1;
			QliteQueryBuilder* chats = NULL;
			DinoDatabase* _tmp330_;
			DinoDatabaseConversationTable* _tmp331_;
			DinoDatabaseConversationTable* _tmp332_;
			QliteQueryBuilder* _tmp333_;
			QliteQueryBuilder* _tmp334_;
			DinoDatabase* _tmp335_;
			DinoDatabaseJidTable* _tmp336_;
			DinoDatabaseJidTable* _tmp337_;
			DinoDatabase* _tmp338_;
			DinoDatabaseJidTable* _tmp339_;
			DinoDatabaseJidTable* _tmp340_;
			QliteColumn* _tmp341_;
			DinoDatabase* _tmp342_;
			DinoDatabaseConversationTable* _tmp343_;
			DinoDatabaseConversationTable* _tmp344_;
			QliteColumn* _tmp345_;
			QliteQueryBuilder* _tmp346_;
			QliteQueryBuilder* _tmp347_;
			DinoDatabase* _tmp348_;
			DinoDatabaseAccountTable* _tmp349_;
			DinoDatabaseAccountTable* _tmp350_;
			DinoDatabase* _tmp351_;
			DinoDatabaseAccountTable* _tmp352_;
			DinoDatabaseAccountTable* _tmp353_;
			QliteColumn* _tmp354_;
			DinoDatabase* _tmp355_;
			DinoDatabaseConversationTable* _tmp356_;
			DinoDatabaseConversationTable* _tmp357_;
			QliteColumn* _tmp358_;
			QliteQueryBuilder* _tmp359_;
			QliteQueryBuilder* _tmp360_;
			DinoDatabase* _tmp361_;
			DinoDatabaseRosterTable* _tmp362_;
			DinoDatabaseRosterTable* _tmp363_;
			DinoDatabase* _tmp364_;
			DinoDatabaseJidTable* _tmp365_;
			DinoDatabaseJidTable* _tmp366_;
			QliteColumn* _tmp367_;
			gchar* _tmp368_;
			gchar* _tmp369_;
			DinoDatabase* _tmp370_;
			DinoDatabaseRosterTable* _tmp371_;
			DinoDatabaseRosterTable* _tmp372_;
			QliteColumn* _tmp373_;
			gchar* _tmp374_;
			gchar* _tmp375_;
			DinoDatabase* _tmp376_;
			DinoDatabaseAccountTable* _tmp377_;
			DinoDatabaseAccountTable* _tmp378_;
			QliteColumn* _tmp379_;
			gchar* _tmp380_;
			gchar* _tmp381_;
			DinoDatabase* _tmp382_;
			DinoDatabaseRosterTable* _tmp383_;
			DinoDatabaseRosterTable* _tmp384_;
			QliteColumn* _tmp385_;
			gchar* _tmp386_;
			gchar* _tmp387_;
			gchar* _tmp388_;
			gchar* _tmp389_;
			QliteQueryBuilder* _tmp390_;
			QliteQueryBuilder* _tmp391_;
			DinoDatabase* _tmp392_;
			DinoDatabaseJidTable* _tmp393_;
			DinoDatabaseJidTable* _tmp394_;
			QliteColumn* _tmp395_;
			gchar* _tmp396_;
			gchar* _tmp397_;
			DinoDatabase* _tmp398_;
			DinoDatabaseRosterTable* _tmp399_;
			DinoDatabaseRosterTable* _tmp400_;
			QliteColumn* _tmp401_;
			gchar* _tmp402_;
			gchar* _tmp403_;
			gchar* _tmp404_;
			gchar* _tmp405_;
			const gchar* _tmp406_;
			const gchar* _tmp407_;
			gchar* _tmp408_;
			const gchar* _tmp409_;
			const gchar* _tmp410_;
			gchar* _tmp411_;
			gchar** _tmp412_;
			gchar** _tmp413_;
			gint _tmp413__length1;
			QliteQueryBuilder* _tmp414_;
			QliteQueryBuilder* _tmp415_;
			DinoDatabase* _tmp416_;
			DinoDatabaseAccountTable* _tmp417_;
			DinoDatabaseAccountTable* _tmp418_;
			QliteColumn* _tmp419_;
			QliteQueryBuilder* _tmp420_;
			QliteQueryBuilder* _tmp421_;
			DinoDatabase* _tmp422_;
			DinoDatabaseConversationTable* _tmp423_;
			DinoDatabaseConversationTable* _tmp424_;
			QliteColumn* _tmp425_;
			QliteQueryBuilder* _tmp426_;
			QliteQueryBuilder* _tmp427_;
			DinoDatabase* _tmp428_;
			DinoDatabaseConversationTable* _tmp429_;
			DinoDatabaseConversationTable* _tmp430_;
			QliteColumn* _tmp431_;
			QliteQueryBuilder* _tmp432_;
			QliteQueryBuilder* _tmp433_;
			QliteQueryBuilder* _tmp434_;
			QliteQueryBuilder* _tmp435_;
			GeeList* _tmp475_;
			gint _tmp476_;
			gint _tmp477_;
			if (cursor_position < (after_prev_space + 5)) {
				result = suggestions;
				_g_free0 (current_query);
				return result;
			}
			_tmp316_ = current_query;
			_tmp317_ = string_substring (_tmp316_, (glong) 5, (glong) -1);
			current_with = _tmp317_;
			_tmp319_ = _tmp318_ = g_strsplit (query, " ", 0);
			splitted = _tmp319_;
			splitted_length1 = _vala_array_length (_tmp318_);
			_splitted_size_ = splitted_length1;
			_tmp320_ = splitted;
			_tmp320__length1 = splitted_length1;
			{
				gchar** s_collection = NULL;
				gint s_collection_length1 = 0;
				gint _s_collection_size_ = 0;
				gint s_it = 0;
				s_collection = _tmp320_;
				s_collection_length1 = _tmp320__length1;
				for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
					gchar* _tmp321_;
					gchar* s = NULL;
					_tmp321_ = g_strdup (s_collection[s_it]);
					s = _tmp321_;
					{
						gboolean _tmp322_ = FALSE;
						gboolean _tmp323_ = FALSE;
						const gchar* _tmp324_;
						_tmp324_ = s;
						if (g_str_has_prefix (_tmp324_, "with:")) {
							const gchar* _tmp325_;
							const gchar* _tmp326_;
							gchar* _tmp327_;
							gchar* _tmp328_;
							_tmp325_ = s;
							_tmp326_ = current_with;
							_tmp327_ = g_strconcat ("with:", _tmp326_, NULL);
							_tmp328_ = _tmp327_;
							_tmp323_ = g_strcmp0 (_tmp325_, _tmp328_) != 0;
							_g_free0 (_tmp328_);
						} else {
							_tmp323_ = FALSE;
						}
						if (_tmp323_) {
							_tmp322_ = TRUE;
						} else {
							const gchar* _tmp329_;
							_tmp329_ = s;
							_tmp322_ = g_str_has_prefix (_tmp329_, "in:");
						}
						if (_tmp322_) {
							result = suggestions;
							_g_free0 (s);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_with);
							_g_free0 (current_query);
							return result;
						}
						_g_free0 (s);
					}
				}
			}
			_tmp330_ = self->priv->db;
			_tmp331_ = dino_database_get_conversation (_tmp330_);
			_tmp332_ = _tmp331_;
			_tmp333_ = qlite_table_select ((QliteTable*) _tmp332_, NULL, (gint) 0);
			_tmp334_ = _tmp333_;
			_tmp335_ = self->priv->db;
			_tmp336_ = dino_database_get_jid (_tmp335_);
			_tmp337_ = _tmp336_;
			_tmp338_ = self->priv->db;
			_tmp339_ = dino_database_get_jid (_tmp338_);
			_tmp340_ = _tmp339_;
			_tmp341_ = _tmp340_->id;
			_tmp342_ = self->priv->db;
			_tmp343_ = dino_database_get_conversation (_tmp342_);
			_tmp344_ = _tmp343_;
			_tmp345_ = _tmp344_->jid_id;
			_tmp346_ = qlite_query_builder_join_with (_tmp334_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp337_, _tmp341_, _tmp345_, NULL);
			_tmp347_ = _tmp346_;
			_tmp348_ = self->priv->db;
			_tmp349_ = dino_database_get_account (_tmp348_);
			_tmp350_ = _tmp349_;
			_tmp351_ = self->priv->db;
			_tmp352_ = dino_database_get_account (_tmp351_);
			_tmp353_ = _tmp352_;
			_tmp354_ = _tmp353_->id;
			_tmp355_ = self->priv->db;
			_tmp356_ = dino_database_get_conversation (_tmp355_);
			_tmp357_ = _tmp356_;
			_tmp358_ = _tmp357_->account_id;
			_tmp359_ = qlite_query_builder_join_with (_tmp347_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp350_, _tmp354_, _tmp358_, NULL);
			_tmp360_ = _tmp359_;
			_tmp361_ = self->priv->db;
			_tmp362_ = dino_database_get_roster (_tmp361_);
			_tmp363_ = _tmp362_;
			_tmp364_ = self->priv->db;
			_tmp365_ = dino_database_get_jid (_tmp364_);
			_tmp366_ = _tmp365_;
			_tmp367_ = _tmp366_->bare_jid;
			_tmp368_ = qlite_column_to_string (_tmp367_);
			_tmp369_ = _tmp368_;
			_tmp370_ = self->priv->db;
			_tmp371_ = dino_database_get_roster (_tmp370_);
			_tmp372_ = _tmp371_;
			_tmp373_ = _tmp372_->jid;
			_tmp374_ = qlite_column_to_string (_tmp373_);
			_tmp375_ = _tmp374_;
			_tmp376_ = self->priv->db;
			_tmp377_ = dino_database_get_account (_tmp376_);
			_tmp378_ = _tmp377_;
			_tmp379_ = _tmp378_->id;
			_tmp380_ = qlite_column_to_string (_tmp379_);
			_tmp381_ = _tmp380_;
			_tmp382_ = self->priv->db;
			_tmp383_ = dino_database_get_roster (_tmp382_);
			_tmp384_ = _tmp383_;
			_tmp385_ = _tmp384_->account_id;
			_tmp386_ = qlite_column_to_string (_tmp385_);
			_tmp387_ = _tmp386_;
			_tmp388_ = g_strconcat (_tmp369_, " = ", _tmp375_, " AND ", _tmp381_, " = ", _tmp387_, NULL);
			_tmp389_ = _tmp388_;
			_tmp390_ = qlite_query_builder_outer_join_on (_tmp360_, (QliteTable*) _tmp363_, _tmp389_, NULL);
			_tmp391_ = _tmp390_;
			_tmp392_ = self->priv->db;
			_tmp393_ = dino_database_get_jid (_tmp392_);
			_tmp394_ = _tmp393_;
			_tmp395_ = _tmp394_->bare_jid;
			_tmp396_ = qlite_column_to_string (_tmp395_);
			_tmp397_ = _tmp396_;
			_tmp398_ = self->priv->db;
			_tmp399_ = dino_database_get_roster (_tmp398_);
			_tmp400_ = _tmp399_;
			_tmp401_ = _tmp400_->handle;
			_tmp402_ = qlite_column_to_string (_tmp401_);
			_tmp403_ = _tmp402_;
			_tmp404_ = g_strconcat (_tmp397_, " LIKE ? OR ", _tmp403_, " LIKE ?", NULL);
			_tmp405_ = _tmp404_;
			_tmp406_ = current_with;
			_tmp407_ = string_to_string (_tmp406_);
			_tmp408_ = g_strconcat ("%", _tmp407_, "%", NULL);
			_tmp409_ = current_with;
			_tmp410_ = string_to_string (_tmp409_);
			_tmp411_ = g_strconcat ("%", _tmp410_, "%", NULL);
			_tmp412_ = g_new0 (gchar*, 2 + 1);
			_tmp412_[0] = _tmp408_;
			_tmp412_[1] = _tmp411_;
			_tmp413_ = _tmp412_;
			_tmp413__length1 = 2;
			_tmp414_ = qlite_query_builder_where (_tmp391_, _tmp405_, _tmp413_, (gint) 2);
			_tmp415_ = _tmp414_;
			_tmp416_ = self->priv->db;
			_tmp417_ = dino_database_get_account (_tmp416_);
			_tmp418_ = _tmp417_;
			_tmp419_ = _tmp418_->enabled;
			_tmp420_ = qlite_query_builder_with (_tmp415_, G_TYPE_BOOLEAN, NULL, NULL, _tmp419_, "=", (gpointer) ((gintptr) TRUE));
			_tmp421_ = _tmp420_;
			_tmp422_ = self->priv->db;
			_tmp423_ = dino_database_get_conversation (_tmp422_);
			_tmp424_ = _tmp423_;
			_tmp425_ = _tmp424_->type_;
			_tmp426_ = qlite_query_builder_with (_tmp421_, G_TYPE_INT, NULL, NULL, _tmp425_, "=", (gpointer) ((gintptr) DINO_ENTITIES_CONVERSATION_TYPE_CHAT));
			_tmp427_ = _tmp426_;
			_tmp428_ = self->priv->db;
			_tmp429_ = dino_database_get_conversation (_tmp428_);
			_tmp430_ = _tmp429_;
			_tmp431_ = _tmp430_->last_active;
			_tmp432_ = qlite_query_builder_order_by (_tmp427_, _tmp431_, "DESC");
			_tmp433_ = _tmp432_;
			_tmp434_ = qlite_query_builder_limit (_tmp433_, limit);
			_tmp435_ = _tmp434_;
			_qlite_statement_builder_unref0 (_tmp433_);
			_qlite_statement_builder_unref0 (_tmp427_);
			_qlite_statement_builder_unref0 (_tmp421_);
			_qlite_statement_builder_unref0 (_tmp415_);
			_tmp413_ = (_vala_array_free (_tmp413_, _tmp413__length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (_tmp405_);
			_g_free0 (_tmp403_);
			_g_free0 (_tmp397_);
			_qlite_statement_builder_unref0 (_tmp391_);
			_g_free0 (_tmp389_);
			_g_free0 (_tmp387_);
			_g_free0 (_tmp381_);
			_g_free0 (_tmp375_);
			_g_free0 (_tmp369_);
			_qlite_statement_builder_unref0 (_tmp360_);
			_qlite_statement_builder_unref0 (_tmp347_);
			_qlite_statement_builder_unref0 (_tmp334_);
			chats = _tmp435_;
			{
				QliteRowIterator* _chat_it = NULL;
				QliteQueryBuilder* _tmp436_;
				QliteRowIterator* _tmp437_;
				_tmp436_ = chats;
				_tmp437_ = qlite_query_builder_iterator (_tmp436_);
				_chat_it = _tmp437_;
				while (TRUE) {
					QliteRowIterator* _tmp438_;
					QliteRow* chat = NULL;
					QliteRowIterator* _tmp439_;
					QliteRow* _tmp440_;
					_tmp438_ = _chat_it;
					if (!qlite_row_iterator_next (_tmp438_)) {
						break;
					}
					_tmp439_ = _chat_it;
					_tmp440_ = qlite_row_iterator_get (_tmp439_);
					chat = _tmp440_;
					{
						DinoEntitiesConversation* _tmp441_ = NULL;
						DinoDatabase* _tmp442_;
						QliteRow* _tmp443_;
						DinoEntitiesConversation* _tmp444_;
						XmppJid* _tmp445_ = NULL;
						QliteRow* _tmp446_;
						DinoDatabase* _tmp447_;
						DinoDatabaseJidTable* _tmp448_;
						DinoDatabaseJidTable* _tmp449_;
						QliteColumn* _tmp450_;
						gpointer _tmp451_;
						gchar* _tmp452_;
						XmppJid* _tmp453_;
						XmppJid* _tmp454_;
						GeeList* _tmp455_;
						QliteRow* _tmp456_;
						DinoDatabase* _tmp457_;
						DinoDatabaseJidTable* _tmp458_;
						DinoDatabaseJidTable* _tmp459_;
						QliteColumn* _tmp460_;
						gpointer _tmp461_;
						gchar* _tmp462_;
						gchar* _tmp463_;
						gchar* _tmp464_;
						QliteRow* _tmp465_;
						DinoDatabase* _tmp466_;
						DinoDatabaseConversationTable* _tmp467_;
						DinoDatabaseConversationTable* _tmp468_;
						QliteColumn* _tmp469_;
						gpointer _tmp470_;
						DinoSearchSuggestion* _tmp471_ = NULL;
						DinoSearchSuggestion* _tmp472_;
						_tmp442_ = self->priv->db;
						_tmp443_ = chat;
						_tmp444_ = dino_entities_conversation_new_from_row (_tmp442_, _tmp443_, &_inner_error0_);
						_tmp441_ = _tmp444_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
								goto __catch2_xmpp_invalid_jid_error;
							}
							_qlite_row_unref0 (chat);
							_qlite_row_iterator_unref0 (_chat_it);
							_qlite_statement_builder_unref0 (chats);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_with);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_tmp446_ = chat;
						_tmp447_ = self->priv->db;
						_tmp448_ = dino_database_get_jid (_tmp447_);
						_tmp449_ = _tmp448_;
						_tmp450_ = _tmp449_->bare_jid;
						_tmp451_ = qlite_row_get (_tmp446_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp450_);
						_tmp452_ = (gchar*) _tmp451_;
						_tmp453_ = xmpp_jid_new (_tmp452_, &_inner_error0_);
						_tmp454_ = _tmp453_;
						_g_free0 (_tmp452_);
						_tmp445_ = _tmp454_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_g_object_unref0 (_tmp441_);
							if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
								goto __catch2_xmpp_invalid_jid_error;
							}
							_qlite_row_unref0 (chat);
							_qlite_row_iterator_unref0 (_chat_it);
							_qlite_statement_builder_unref0 (chats);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_with);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_tmp455_ = suggestions;
						_tmp456_ = chat;
						_tmp457_ = self->priv->db;
						_tmp458_ = dino_database_get_jid (_tmp457_);
						_tmp459_ = _tmp458_;
						_tmp460_ = _tmp459_->bare_jid;
						_tmp461_ = qlite_row_get (_tmp456_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp460_);
						_tmp462_ = (gchar*) _tmp461_;
						_tmp463_ = g_strconcat ("with:", _tmp462_, NULL);
						_tmp464_ = _tmp463_;
						_tmp465_ = chat;
						_tmp466_ = self->priv->db;
						_tmp467_ = dino_database_get_conversation (_tmp466_);
						_tmp468_ = _tmp467_;
						_tmp469_ = _tmp468_->last_active;
						_tmp470_ = qlite_row_get (_tmp465_, G_TYPE_LONG, NULL, NULL, _tmp469_);
						_tmp471_ = dino_search_suggestion_new (_tmp441_, _tmp445_, _tmp464_, after_prev_space, next_space);
						dino_search_suggestion_set_order (_tmp471_, (glong) ((gintptr) _tmp470_));
						_tmp472_ = _tmp471_;
						gee_collection_add ((GeeCollection*) _tmp455_, _tmp472_);
						_g_object_unref0 (_tmp472_);
						_g_free0 (_tmp464_);
						_g_free0 (_tmp462_);
						_xmpp_jid_unref0 (_tmp445_);
						_g_object_unref0 (_tmp441_);
					}
					goto __finally2;
					__catch2_xmpp_invalid_jid_error:
					{
						GError* e = NULL;
						GError* _tmp473_;
						const gchar* _tmp474_;
						e = _inner_error0_;
						_inner_error0_ = NULL;
						_tmp473_ = e;
						_tmp474_ = _tmp473_->message;
						g_warning ("search_processor.vala:195: Ignoring search suggestion with invalid Jid" \
": %s", _tmp474_);
						_g_error_free0 (e);
					}
					__finally2:
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_qlite_row_unref0 (chat);
						_qlite_row_iterator_unref0 (_chat_it);
						_qlite_statement_builder_unref0 (chats);
						splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
						_g_free0 (current_with);
						_g_object_unref0 (suggestions);
						_g_free0 (current_query);
						g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
						g_clear_error (&_inner_error0_);
						return NULL;
					}
					_qlite_row_unref0 (chat);
				}
				_qlite_row_iterator_unref0 (_chat_it);
			}
			_tmp475_ = suggestions;
			_tmp476_ = gee_collection_get_size ((GeeCollection*) _tmp475_);
			_tmp477_ = _tmp476_;
			if (_tmp477_ < 5) {
				DinoDatabase* _tmp478_;
				DinoDatabaseConversationTable* _tmp479_;
				DinoDatabaseConversationTable* _tmp480_;
				QliteQueryBuilder* _tmp481_;
				QliteQueryBuilder* _tmp482_;
				DinoDatabase* _tmp483_;
				DinoDatabaseJidTable* _tmp484_;
				DinoDatabaseJidTable* _tmp485_;
				DinoDatabase* _tmp486_;
				DinoDatabaseJidTable* _tmp487_;
				DinoDatabaseJidTable* _tmp488_;
				QliteColumn* _tmp489_;
				DinoDatabase* _tmp490_;
				DinoDatabaseConversationTable* _tmp491_;
				DinoDatabaseConversationTable* _tmp492_;
				QliteColumn* _tmp493_;
				QliteQueryBuilder* _tmp494_;
				QliteQueryBuilder* _tmp495_;
				DinoDatabase* _tmp496_;
				DinoDatabaseAccountTable* _tmp497_;
				DinoDatabaseAccountTable* _tmp498_;
				DinoDatabase* _tmp499_;
				DinoDatabaseAccountTable* _tmp500_;
				DinoDatabaseAccountTable* _tmp501_;
				QliteColumn* _tmp502_;
				DinoDatabase* _tmp503_;
				DinoDatabaseConversationTable* _tmp504_;
				DinoDatabaseConversationTable* _tmp505_;
				QliteColumn* _tmp506_;
				QliteQueryBuilder* _tmp507_;
				QliteQueryBuilder* _tmp508_;
				DinoDatabase* _tmp509_;
				DinoDatabaseJidTable* _tmp510_;
				DinoDatabaseJidTable* _tmp511_;
				QliteColumn* _tmp512_;
				gchar* _tmp513_;
				gchar* _tmp514_;
				DinoDatabase* _tmp515_;
				DinoDatabaseConversationTable* _tmp516_;
				DinoDatabaseConversationTable* _tmp517_;
				QliteColumn* _tmp518_;
				gchar* _tmp519_;
				gchar* _tmp520_;
				gchar* _tmp521_;
				gchar* _tmp522_;
				const gchar* _tmp523_;
				const gchar* _tmp524_;
				gchar* _tmp525_;
				const gchar* _tmp526_;
				const gchar* _tmp527_;
				gchar* _tmp528_;
				gchar** _tmp529_;
				gchar** _tmp530_;
				gint _tmp530__length1;
				QliteQueryBuilder* _tmp531_;
				QliteQueryBuilder* _tmp532_;
				DinoDatabase* _tmp533_;
				DinoDatabaseAccountTable* _tmp534_;
				DinoDatabaseAccountTable* _tmp535_;
				QliteColumn* _tmp536_;
				QliteQueryBuilder* _tmp537_;
				QliteQueryBuilder* _tmp538_;
				DinoDatabase* _tmp539_;
				DinoDatabaseConversationTable* _tmp540_;
				DinoDatabaseConversationTable* _tmp541_;
				QliteColumn* _tmp542_;
				QliteQueryBuilder* _tmp543_;
				QliteQueryBuilder* _tmp544_;
				DinoDatabase* _tmp545_;
				DinoDatabaseConversationTable* _tmp546_;
				DinoDatabaseConversationTable* _tmp547_;
				QliteColumn* _tmp548_;
				QliteQueryBuilder* _tmp549_;
				QliteQueryBuilder* _tmp550_;
				GeeList* _tmp551_;
				gint _tmp552_;
				gint _tmp553_;
				QliteQueryBuilder* _tmp554_;
				GeeList* _tmp615_;
				_tmp478_ = self->priv->db;
				_tmp479_ = dino_database_get_conversation (_tmp478_);
				_tmp480_ = _tmp479_;
				_tmp481_ = qlite_table_select ((QliteTable*) _tmp480_, NULL, (gint) 0);
				_tmp482_ = _tmp481_;
				_tmp483_ = self->priv->db;
				_tmp484_ = dino_database_get_jid (_tmp483_);
				_tmp485_ = _tmp484_;
				_tmp486_ = self->priv->db;
				_tmp487_ = dino_database_get_jid (_tmp486_);
				_tmp488_ = _tmp487_;
				_tmp489_ = _tmp488_->id;
				_tmp490_ = self->priv->db;
				_tmp491_ = dino_database_get_conversation (_tmp490_);
				_tmp492_ = _tmp491_;
				_tmp493_ = _tmp492_->jid_id;
				_tmp494_ = qlite_query_builder_join_with (_tmp482_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp485_, _tmp489_, _tmp493_, NULL);
				_tmp495_ = _tmp494_;
				_tmp496_ = self->priv->db;
				_tmp497_ = dino_database_get_account (_tmp496_);
				_tmp498_ = _tmp497_;
				_tmp499_ = self->priv->db;
				_tmp500_ = dino_database_get_account (_tmp499_);
				_tmp501_ = _tmp500_;
				_tmp502_ = _tmp501_->id;
				_tmp503_ = self->priv->db;
				_tmp504_ = dino_database_get_conversation (_tmp503_);
				_tmp505_ = _tmp504_;
				_tmp506_ = _tmp505_->account_id;
				_tmp507_ = qlite_query_builder_join_with (_tmp495_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp498_, _tmp502_, _tmp506_, NULL);
				_tmp508_ = _tmp507_;
				_tmp509_ = self->priv->db;
				_tmp510_ = dino_database_get_jid (_tmp509_);
				_tmp511_ = _tmp510_;
				_tmp512_ = _tmp511_->bare_jid;
				_tmp513_ = qlite_column_to_string (_tmp512_);
				_tmp514_ = _tmp513_;
				_tmp515_ = self->priv->db;
				_tmp516_ = dino_database_get_conversation (_tmp515_);
				_tmp517_ = _tmp516_;
				_tmp518_ = _tmp517_->resource;
				_tmp519_ = qlite_column_to_string (_tmp518_);
				_tmp520_ = _tmp519_;
				_tmp521_ = g_strconcat (_tmp514_, " LIKE ? OR ", _tmp520_, " LIKE ?", NULL);
				_tmp522_ = _tmp521_;
				_tmp523_ = current_with;
				_tmp524_ = string_to_string (_tmp523_);
				_tmp525_ = g_strconcat ("%", _tmp524_, "%", NULL);
				_tmp526_ = current_with;
				_tmp527_ = string_to_string (_tmp526_);
				_tmp528_ = g_strconcat ("%", _tmp527_, "%", NULL);
				_tmp529_ = g_new0 (gchar*, 2 + 1);
				_tmp529_[0] = _tmp525_;
				_tmp529_[1] = _tmp528_;
				_tmp530_ = _tmp529_;
				_tmp530__length1 = 2;
				_tmp531_ = qlite_query_builder_where (_tmp508_, _tmp522_, _tmp530_, (gint) 2);
				_tmp532_ = _tmp531_;
				_tmp533_ = self->priv->db;
				_tmp534_ = dino_database_get_account (_tmp533_);
				_tmp535_ = _tmp534_;
				_tmp536_ = _tmp535_->enabled;
				_tmp537_ = qlite_query_builder_with (_tmp532_, G_TYPE_BOOLEAN, NULL, NULL, _tmp536_, "=", (gpointer) ((gintptr) TRUE));
				_tmp538_ = _tmp537_;
				_tmp539_ = self->priv->db;
				_tmp540_ = dino_database_get_conversation (_tmp539_);
				_tmp541_ = _tmp540_;
				_tmp542_ = _tmp541_->type_;
				_tmp543_ = qlite_query_builder_with (_tmp538_, G_TYPE_INT, NULL, NULL, _tmp542_, "=", (gpointer) ((gintptr) DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT_PM));
				_tmp544_ = _tmp543_;
				_tmp545_ = self->priv->db;
				_tmp546_ = dino_database_get_conversation (_tmp545_);
				_tmp547_ = _tmp546_;
				_tmp548_ = _tmp547_->last_active;
				_tmp549_ = qlite_query_builder_order_by (_tmp544_, _tmp548_, "DESC");
				_tmp550_ = _tmp549_;
				_tmp551_ = suggestions;
				_tmp552_ = gee_collection_get_size ((GeeCollection*) _tmp551_);
				_tmp553_ = _tmp552_;
				_tmp554_ = qlite_query_builder_limit (_tmp550_, limit - _tmp553_);
				_qlite_statement_builder_unref0 (chats);
				chats = _tmp554_;
				_qlite_statement_builder_unref0 (_tmp550_);
				_qlite_statement_builder_unref0 (_tmp544_);
				_qlite_statement_builder_unref0 (_tmp538_);
				_qlite_statement_builder_unref0 (_tmp532_);
				_tmp530_ = (_vala_array_free (_tmp530_, _tmp530__length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (_tmp522_);
				_g_free0 (_tmp520_);
				_g_free0 (_tmp514_);
				_qlite_statement_builder_unref0 (_tmp508_);
				_qlite_statement_builder_unref0 (_tmp495_);
				_qlite_statement_builder_unref0 (_tmp482_);
				{
					QliteRowIterator* _chat_it = NULL;
					QliteQueryBuilder* _tmp555_;
					QliteRowIterator* _tmp556_;
					_tmp555_ = chats;
					_tmp556_ = qlite_query_builder_iterator (_tmp555_);
					_chat_it = _tmp556_;
					while (TRUE) {
						QliteRowIterator* _tmp557_;
						QliteRow* chat = NULL;
						QliteRowIterator* _tmp558_;
						QliteRow* _tmp559_;
						_tmp557_ = _chat_it;
						if (!qlite_row_iterator_next (_tmp557_)) {
							break;
						}
						_tmp558_ = _chat_it;
						_tmp559_ = qlite_row_iterator_get (_tmp558_);
						chat = _tmp559_;
						{
							DinoEntitiesConversation* _tmp560_ = NULL;
							DinoDatabase* _tmp561_;
							QliteRow* _tmp562_;
							DinoEntitiesConversation* _tmp563_;
							XmppJid* _tmp564_ = NULL;
							QliteRow* _tmp565_;
							DinoDatabase* _tmp566_;
							DinoDatabaseJidTable* _tmp567_;
							DinoDatabaseJidTable* _tmp568_;
							QliteColumn* _tmp569_;
							gpointer _tmp570_;
							gchar* _tmp571_;
							XmppJid* _tmp572_;
							XmppJid* _tmp573_;
							XmppJid* _tmp574_ = NULL;
							QliteRow* _tmp575_;
							DinoDatabase* _tmp576_;
							DinoDatabaseConversationTable* _tmp577_;
							DinoDatabaseConversationTable* _tmp578_;
							QliteColumn* _tmp579_;
							gpointer _tmp580_;
							gchar* _tmp581_;
							XmppJid* _tmp582_;
							XmppJid* _tmp583_;
							GeeList* _tmp584_;
							QliteRow* _tmp585_;
							DinoDatabase* _tmp586_;
							DinoDatabaseJidTable* _tmp587_;
							DinoDatabaseJidTable* _tmp588_;
							QliteColumn* _tmp589_;
							gpointer _tmp590_;
							gchar* _tmp591_;
							gchar* _tmp592_;
							gchar* _tmp593_;
							gchar* _tmp594_;
							gchar* _tmp595_;
							QliteRow* _tmp596_;
							DinoDatabase* _tmp597_;
							DinoDatabaseConversationTable* _tmp598_;
							DinoDatabaseConversationTable* _tmp599_;
							QliteColumn* _tmp600_;
							gpointer _tmp601_;
							gchar* _tmp602_;
							gchar* _tmp603_;
							gchar* _tmp604_;
							QliteRow* _tmp605_;
							DinoDatabase* _tmp606_;
							DinoDatabaseConversationTable* _tmp607_;
							DinoDatabaseConversationTable* _tmp608_;
							QliteColumn* _tmp609_;
							gpointer _tmp610_;
							DinoSearchSuggestion* _tmp611_ = NULL;
							DinoSearchSuggestion* _tmp612_;
							_tmp561_ = self->priv->db;
							_tmp562_ = chat;
							_tmp563_ = dino_entities_conversation_new_from_row (_tmp561_, _tmp562_, &_inner_error0_);
							_tmp560_ = _tmp563_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
									goto __catch3_xmpp_invalid_jid_error;
								}
								_qlite_row_unref0 (chat);
								_qlite_row_iterator_unref0 (_chat_it);
								_qlite_statement_builder_unref0 (chats);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_with);
								_g_object_unref0 (suggestions);
								_g_free0 (current_query);
								g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
							_tmp565_ = chat;
							_tmp566_ = self->priv->db;
							_tmp567_ = dino_database_get_jid (_tmp566_);
							_tmp568_ = _tmp567_;
							_tmp569_ = _tmp568_->bare_jid;
							_tmp570_ = qlite_row_get (_tmp565_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp569_);
							_tmp571_ = (gchar*) _tmp570_;
							_tmp572_ = xmpp_jid_new (_tmp571_, &_inner_error0_);
							_tmp573_ = _tmp572_;
							_g_free0 (_tmp571_);
							_tmp564_ = _tmp573_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								_g_object_unref0 (_tmp560_);
								if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
									goto __catch3_xmpp_invalid_jid_error;
								}
								_qlite_row_unref0 (chat);
								_qlite_row_iterator_unref0 (_chat_it);
								_qlite_statement_builder_unref0 (chats);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_with);
								_g_object_unref0 (suggestions);
								_g_free0 (current_query);
								g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
							_tmp575_ = chat;
							_tmp576_ = self->priv->db;
							_tmp577_ = dino_database_get_conversation (_tmp576_);
							_tmp578_ = _tmp577_;
							_tmp579_ = _tmp578_->resource;
							_tmp580_ = qlite_row_get (_tmp575_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp579_);
							_tmp581_ = (gchar*) _tmp580_;
							_tmp582_ = xmpp_jid_with_resource (_tmp564_, _tmp581_, &_inner_error0_);
							_tmp583_ = _tmp582_;
							_g_free0 (_tmp581_);
							_tmp574_ = _tmp583_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								_xmpp_jid_unref0 (_tmp564_);
								_g_object_unref0 (_tmp560_);
								if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
									goto __catch3_xmpp_invalid_jid_error;
								}
								_qlite_row_unref0 (chat);
								_qlite_row_iterator_unref0 (_chat_it);
								_qlite_statement_builder_unref0 (chats);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_with);
								_g_object_unref0 (suggestions);
								_g_free0 (current_query);
								g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
							_tmp584_ = suggestions;
							_tmp585_ = chat;
							_tmp586_ = self->priv->db;
							_tmp587_ = dino_database_get_jid (_tmp586_);
							_tmp588_ = _tmp587_;
							_tmp589_ = _tmp588_->bare_jid;
							_tmp590_ = qlite_row_get (_tmp585_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp589_);
							_tmp591_ = (gchar*) _tmp590_;
							_tmp592_ = g_strconcat ("with:", _tmp591_, NULL);
							_tmp593_ = _tmp592_;
							_tmp594_ = g_strconcat (_tmp593_, "/", NULL);
							_tmp595_ = _tmp594_;
							_tmp596_ = chat;
							_tmp597_ = self->priv->db;
							_tmp598_ = dino_database_get_conversation (_tmp597_);
							_tmp599_ = _tmp598_;
							_tmp600_ = _tmp599_->resource;
							_tmp601_ = qlite_row_get (_tmp596_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp600_);
							_tmp602_ = (gchar*) _tmp601_;
							_tmp603_ = g_strconcat (_tmp595_, _tmp602_, NULL);
							_tmp604_ = _tmp603_;
							_tmp605_ = chat;
							_tmp606_ = self->priv->db;
							_tmp607_ = dino_database_get_conversation (_tmp606_);
							_tmp608_ = _tmp607_;
							_tmp609_ = _tmp608_->last_active;
							_tmp610_ = qlite_row_get (_tmp605_, G_TYPE_LONG, NULL, NULL, _tmp609_);
							_tmp611_ = dino_search_suggestion_new (_tmp560_, _tmp574_, _tmp604_, after_prev_space, next_space);
							dino_search_suggestion_set_order (_tmp611_, (glong) ((gintptr) _tmp610_));
							_tmp612_ = _tmp611_;
							gee_collection_add ((GeeCollection*) _tmp584_, _tmp612_);
							_g_object_unref0 (_tmp612_);
							_g_free0 (_tmp604_);
							_g_free0 (_tmp602_);
							_g_free0 (_tmp595_);
							_g_free0 (_tmp593_);
							_g_free0 (_tmp591_);
							_xmpp_jid_unref0 (_tmp574_);
							_xmpp_jid_unref0 (_tmp564_);
							_g_object_unref0 (_tmp560_);
						}
						goto __finally3;
						__catch3_xmpp_invalid_jid_error:
						{
							GError* e = NULL;
							GError* _tmp613_;
							const gchar* _tmp614_;
							e = _inner_error0_;
							_inner_error0_ = NULL;
							_tmp613_ = e;
							_tmp614_ = _tmp613_->message;
							g_warning ("search_processor.vala:213: Ignoring search suggestion with invalid Jid" \
": %s", _tmp614_);
							_g_error_free0 (e);
						}
						__finally3:
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_qlite_row_unref0 (chat);
							_qlite_row_iterator_unref0 (_chat_it);
							_qlite_statement_builder_unref0 (chats);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_with);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_qlite_row_unref0 (chat);
					}
					_qlite_row_iterator_unref0 (_chat_it);
				}
				_tmp615_ = suggestions;
				gee_list_sort (_tmp615_, ______lambda122__gcompare_data_func, g_object_ref (self), g_object_unref);
			}
			_qlite_statement_builder_unref0 (chats);
			splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (current_with);
		} else {
			const gchar* _tmp616_;
			_tmp616_ = current_query;
			if (g_str_has_prefix (_tmp616_, "in:")) {
				gchar* current_in = NULL;
				const gchar* _tmp617_;
				gchar* _tmp618_;
				gchar** splitted = NULL;
				gchar** _tmp619_;
				gchar** _tmp620_;
				gint splitted_length1;
				gint _splitted_size_;
				gchar** _tmp621_;
				gint _tmp621__length1;
				QliteQueryBuilder* groupchats = NULL;
				DinoDatabase* _tmp631_;
				DinoDatabaseConversationTable* _tmp632_;
				DinoDatabaseConversationTable* _tmp633_;
				QliteQueryBuilder* _tmp634_;
				QliteQueryBuilder* _tmp635_;
				DinoDatabase* _tmp636_;
				DinoDatabaseJidTable* _tmp637_;
				DinoDatabaseJidTable* _tmp638_;
				DinoDatabase* _tmp639_;
				DinoDatabaseJidTable* _tmp640_;
				DinoDatabaseJidTable* _tmp641_;
				QliteColumn* _tmp642_;
				DinoDatabase* _tmp643_;
				DinoDatabaseConversationTable* _tmp644_;
				DinoDatabaseConversationTable* _tmp645_;
				QliteColumn* _tmp646_;
				QliteQueryBuilder* _tmp647_;
				QliteQueryBuilder* _tmp648_;
				DinoDatabase* _tmp649_;
				DinoDatabaseAccountTable* _tmp650_;
				DinoDatabaseAccountTable* _tmp651_;
				DinoDatabase* _tmp652_;
				DinoDatabaseAccountTable* _tmp653_;
				DinoDatabaseAccountTable* _tmp654_;
				QliteColumn* _tmp655_;
				DinoDatabase* _tmp656_;
				DinoDatabaseConversationTable* _tmp657_;
				DinoDatabaseConversationTable* _tmp658_;
				QliteColumn* _tmp659_;
				QliteQueryBuilder* _tmp660_;
				QliteQueryBuilder* _tmp661_;
				DinoDatabase* _tmp662_;
				DinoDatabaseJidTable* _tmp663_;
				DinoDatabaseJidTable* _tmp664_;
				QliteColumn* _tmp665_;
				const gchar* _tmp666_;
				const gchar* _tmp667_;
				gchar* _tmp668_;
				gchar* _tmp669_;
				QliteQueryBuilder* _tmp670_;
				QliteQueryBuilder* _tmp671_;
				DinoDatabase* _tmp672_;
				DinoDatabaseAccountTable* _tmp673_;
				DinoDatabaseAccountTable* _tmp674_;
				QliteColumn* _tmp675_;
				QliteQueryBuilder* _tmp676_;
				QliteQueryBuilder* _tmp677_;
				DinoDatabase* _tmp678_;
				DinoDatabaseConversationTable* _tmp679_;
				DinoDatabaseConversationTable* _tmp680_;
				QliteColumn* _tmp681_;
				QliteQueryBuilder* _tmp682_;
				QliteQueryBuilder* _tmp683_;
				DinoDatabase* _tmp684_;
				DinoDatabaseConversationTable* _tmp685_;
				DinoDatabaseConversationTable* _tmp686_;
				QliteColumn* _tmp687_;
				QliteQueryBuilder* _tmp688_;
				QliteQueryBuilder* _tmp689_;
				QliteQueryBuilder* _tmp690_;
				QliteQueryBuilder* _tmp691_;
				if (cursor_position < (after_prev_space + 3)) {
					result = suggestions;
					_g_free0 (current_query);
					return result;
				}
				_tmp617_ = current_query;
				_tmp618_ = string_substring (_tmp617_, (glong) 3, (glong) -1);
				current_in = _tmp618_;
				_tmp620_ = _tmp619_ = g_strsplit (query, " ", 0);
				splitted = _tmp620_;
				splitted_length1 = _vala_array_length (_tmp619_);
				_splitted_size_ = splitted_length1;
				_tmp621_ = splitted;
				_tmp621__length1 = splitted_length1;
				{
					gchar** s_collection = NULL;
					gint s_collection_length1 = 0;
					gint _s_collection_size_ = 0;
					gint s_it = 0;
					s_collection = _tmp621_;
					s_collection_length1 = _tmp621__length1;
					for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
						gchar* _tmp622_;
						gchar* s = NULL;
						_tmp622_ = g_strdup (s_collection[s_it]);
						s = _tmp622_;
						{
							gboolean _tmp623_ = FALSE;
							gboolean _tmp624_ = FALSE;
							const gchar* _tmp625_;
							_tmp625_ = s;
							if (g_str_has_prefix (_tmp625_, "in:")) {
								const gchar* _tmp626_;
								const gchar* _tmp627_;
								gchar* _tmp628_;
								gchar* _tmp629_;
								_tmp626_ = s;
								_tmp627_ = current_in;
								_tmp628_ = g_strconcat ("in:", _tmp627_, NULL);
								_tmp629_ = _tmp628_;
								_tmp624_ = g_strcmp0 (_tmp626_, _tmp629_) != 0;
								_g_free0 (_tmp629_);
							} else {
								_tmp624_ = FALSE;
							}
							if (_tmp624_) {
								_tmp623_ = TRUE;
							} else {
								const gchar* _tmp630_;
								_tmp630_ = s;
								_tmp623_ = g_str_has_prefix (_tmp630_, "with:");
							}
							if (_tmp623_) {
								result = suggestions;
								_g_free0 (s);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_in);
								_g_free0 (current_query);
								return result;
							}
							_g_free0 (s);
						}
					}
				}
				_tmp631_ = self->priv->db;
				_tmp632_ = dino_database_get_conversation (_tmp631_);
				_tmp633_ = _tmp632_;
				_tmp634_ = qlite_table_select ((QliteTable*) _tmp633_, NULL, (gint) 0);
				_tmp635_ = _tmp634_;
				_tmp636_ = self->priv->db;
				_tmp637_ = dino_database_get_jid (_tmp636_);
				_tmp638_ = _tmp637_;
				_tmp639_ = self->priv->db;
				_tmp640_ = dino_database_get_jid (_tmp639_);
				_tmp641_ = _tmp640_;
				_tmp642_ = _tmp641_->id;
				_tmp643_ = self->priv->db;
				_tmp644_ = dino_database_get_conversation (_tmp643_);
				_tmp645_ = _tmp644_;
				_tmp646_ = _tmp645_->jid_id;
				_tmp647_ = qlite_query_builder_join_with (_tmp635_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp638_, _tmp642_, _tmp646_, NULL);
				_tmp648_ = _tmp647_;
				_tmp649_ = self->priv->db;
				_tmp650_ = dino_database_get_account (_tmp649_);
				_tmp651_ = _tmp650_;
				_tmp652_ = self->priv->db;
				_tmp653_ = dino_database_get_account (_tmp652_);
				_tmp654_ = _tmp653_;
				_tmp655_ = _tmp654_->id;
				_tmp656_ = self->priv->db;
				_tmp657_ = dino_database_get_conversation (_tmp656_);
				_tmp658_ = _tmp657_;
				_tmp659_ = _tmp658_->account_id;
				_tmp660_ = qlite_query_builder_join_with (_tmp648_, G_TYPE_INT, NULL, NULL, (QliteTable*) _tmp651_, _tmp655_, _tmp659_, NULL);
				_tmp661_ = _tmp660_;
				_tmp662_ = self->priv->db;
				_tmp663_ = dino_database_get_jid (_tmp662_);
				_tmp664_ = _tmp663_;
				_tmp665_ = _tmp664_->bare_jid;
				_tmp666_ = current_in;
				_tmp667_ = string_to_string (_tmp666_);
				_tmp668_ = g_strconcat ("%", _tmp667_, "%", NULL);
				_tmp669_ = _tmp668_;
				_tmp670_ = qlite_query_builder_with (_tmp661_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp665_, "LIKE", _tmp669_);
				_tmp671_ = _tmp670_;
				_tmp672_ = self->priv->db;
				_tmp673_ = dino_database_get_account (_tmp672_);
				_tmp674_ = _tmp673_;
				_tmp675_ = _tmp674_->enabled;
				_tmp676_ = qlite_query_builder_with (_tmp671_, G_TYPE_BOOLEAN, NULL, NULL, _tmp675_, "=", (gpointer) ((gintptr) TRUE));
				_tmp677_ = _tmp676_;
				_tmp678_ = self->priv->db;
				_tmp679_ = dino_database_get_conversation (_tmp678_);
				_tmp680_ = _tmp679_;
				_tmp681_ = _tmp680_->type_;
				_tmp682_ = qlite_query_builder_with (_tmp677_, G_TYPE_INT, NULL, NULL, _tmp681_, "=", (gpointer) ((gintptr) DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT));
				_tmp683_ = _tmp682_;
				_tmp684_ = self->priv->db;
				_tmp685_ = dino_database_get_conversation (_tmp684_);
				_tmp686_ = _tmp685_;
				_tmp687_ = _tmp686_->last_active;
				_tmp688_ = qlite_query_builder_order_by (_tmp683_, _tmp687_, "DESC");
				_tmp689_ = _tmp688_;
				_tmp690_ = qlite_query_builder_limit (_tmp689_, limit);
				_tmp691_ = _tmp690_;
				_qlite_statement_builder_unref0 (_tmp689_);
				_qlite_statement_builder_unref0 (_tmp683_);
				_qlite_statement_builder_unref0 (_tmp677_);
				_qlite_statement_builder_unref0 (_tmp671_);
				_g_free0 (_tmp669_);
				_qlite_statement_builder_unref0 (_tmp661_);
				_qlite_statement_builder_unref0 (_tmp648_);
				_qlite_statement_builder_unref0 (_tmp635_);
				groupchats = _tmp691_;
				{
					QliteRowIterator* _chat_it = NULL;
					QliteQueryBuilder* _tmp692_;
					QliteRowIterator* _tmp693_;
					_tmp692_ = groupchats;
					_tmp693_ = qlite_query_builder_iterator (_tmp692_);
					_chat_it = _tmp693_;
					while (TRUE) {
						QliteRowIterator* _tmp694_;
						QliteRow* chat = NULL;
						QliteRowIterator* _tmp695_;
						QliteRow* _tmp696_;
						_tmp694_ = _chat_it;
						if (!qlite_row_iterator_next (_tmp694_)) {
							break;
						}
						_tmp695_ = _chat_it;
						_tmp696_ = qlite_row_iterator_get (_tmp695_);
						chat = _tmp696_;
						{
							DinoEntitiesConversation* _tmp697_ = NULL;
							DinoDatabase* _tmp698_;
							QliteRow* _tmp699_;
							DinoEntitiesConversation* _tmp700_;
							XmppJid* _tmp701_ = NULL;
							QliteRow* _tmp702_;
							DinoDatabase* _tmp703_;
							DinoDatabaseJidTable* _tmp704_;
							DinoDatabaseJidTable* _tmp705_;
							QliteColumn* _tmp706_;
							gpointer _tmp707_;
							gchar* _tmp708_;
							XmppJid* _tmp709_;
							XmppJid* _tmp710_;
							GeeList* _tmp711_;
							QliteRow* _tmp712_;
							DinoDatabase* _tmp713_;
							DinoDatabaseJidTable* _tmp714_;
							DinoDatabaseJidTable* _tmp715_;
							QliteColumn* _tmp716_;
							gpointer _tmp717_;
							gchar* _tmp718_;
							gchar* _tmp719_;
							gchar* _tmp720_;
							DinoSearchSuggestion* _tmp721_;
							DinoSearchSuggestion* _tmp722_;
							_tmp698_ = self->priv->db;
							_tmp699_ = chat;
							_tmp700_ = dino_entities_conversation_new_from_row (_tmp698_, _tmp699_, &_inner_error0_);
							_tmp697_ = _tmp700_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
									goto __catch4_xmpp_invalid_jid_error;
								}
								_qlite_row_unref0 (chat);
								_qlite_row_iterator_unref0 (_chat_it);
								_qlite_statement_builder_unref0 (groupchats);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_in);
								_g_object_unref0 (suggestions);
								_g_free0 (current_query);
								g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
							_tmp702_ = chat;
							_tmp703_ = self->priv->db;
							_tmp704_ = dino_database_get_jid (_tmp703_);
							_tmp705_ = _tmp704_;
							_tmp706_ = _tmp705_->bare_jid;
							_tmp707_ = qlite_row_get (_tmp702_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp706_);
							_tmp708_ = (gchar*) _tmp707_;
							_tmp709_ = xmpp_jid_new (_tmp708_, &_inner_error0_);
							_tmp710_ = _tmp709_;
							_g_free0 (_tmp708_);
							_tmp701_ = _tmp710_;
							if (G_UNLIKELY (_inner_error0_ != NULL)) {
								_g_object_unref0 (_tmp697_);
								if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
									goto __catch4_xmpp_invalid_jid_error;
								}
								_qlite_row_unref0 (chat);
								_qlite_row_iterator_unref0 (_chat_it);
								_qlite_statement_builder_unref0 (groupchats);
								splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
								_g_free0 (current_in);
								_g_object_unref0 (suggestions);
								_g_free0 (current_query);
								g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
							_tmp711_ = suggestions;
							_tmp712_ = chat;
							_tmp713_ = self->priv->db;
							_tmp714_ = dino_database_get_jid (_tmp713_);
							_tmp715_ = _tmp714_;
							_tmp716_ = _tmp715_->bare_jid;
							_tmp717_ = qlite_row_get (_tmp712_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp716_);
							_tmp718_ = (gchar*) _tmp717_;
							_tmp719_ = g_strconcat ("in:", _tmp718_, NULL);
							_tmp720_ = _tmp719_;
							_tmp721_ = dino_search_suggestion_new (_tmp697_, _tmp701_, _tmp720_, after_prev_space, next_space);
							_tmp722_ = _tmp721_;
							gee_collection_add ((GeeCollection*) _tmp711_, _tmp722_);
							_g_object_unref0 (_tmp722_);
							_g_free0 (_tmp720_);
							_g_free0 (_tmp718_);
							_xmpp_jid_unref0 (_tmp701_);
							_g_object_unref0 (_tmp697_);
						}
						goto __finally4;
						__catch4_xmpp_invalid_jid_error:
						{
							GError* e = NULL;
							GError* _tmp723_;
							const gchar* _tmp724_;
							e = _inner_error0_;
							_inner_error0_ = NULL;
							_tmp723_ = e;
							_tmp724_ = _tmp723_->message;
							g_warning ("search_processor.vala:240: Ignoring search suggestion with invalid Jid" \
": %s", _tmp724_);
							_g_error_free0 (e);
						}
						__finally4:
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							_qlite_row_unref0 (chat);
							_qlite_row_iterator_unref0 (_chat_it);
							_qlite_statement_builder_unref0 (groupchats);
							splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
							_g_free0 (current_in);
							_g_object_unref0 (suggestions);
							_g_free0 (current_query);
							g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							return NULL;
						}
						_qlite_row_unref0 (chat);
					}
					_qlite_row_iterator_unref0 (_chat_it);
				}
				_qlite_statement_builder_unref0 (groupchats);
				splitted = (_vala_array_free (splitted, splitted_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (current_in);
			} else {
			}
		}
	}
	result = suggestions;
	_g_free0 (current_query);
	return result;
}

GeeList*
dino_search_processor_match_messages (DinoSearchProcessor* self,
                                      const gchar* query,
                                      gint offset)
{
	GeeList* ret = NULL;
	GeeArrayList* _tmp0_;
	QliteQueryBuilder* rows = NULL;
	QliteQueryBuilder* _tmp1_;
	QliteQueryBuilder* _tmp2_;
	QliteQueryBuilder* _tmp3_;
	QliteQueryBuilder* _tmp4_;
	GError* _inner_error0_ = NULL;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (query != NULL, NULL);
	_tmp0_ = gee_array_list_new (DINO_TYPE_MESSAGE_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	ret = (GeeList*) _tmp0_;
	_tmp1_ = dino_search_processor_prepare_search (self, query, TRUE);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_query_builder_limit (_tmp2_, 10);
	_tmp4_ = _tmp3_;
	_qlite_statement_builder_unref0 (_tmp2_);
	rows = _tmp4_;
	if (offset > 0) {
		QliteQueryBuilder* _tmp5_;
		QliteQueryBuilder* _tmp6_;
		QliteQueryBuilder* _tmp7_;
		_tmp5_ = rows;
		_tmp6_ = qlite_query_builder_offset (_tmp5_, offset);
		_tmp7_ = _tmp6_;
		_qlite_statement_builder_unref0 (_tmp7_);
	}
	{
		QliteRowIterator* _row_it = NULL;
		QliteQueryBuilder* _tmp8_;
		QliteRowIterator* _tmp9_;
		_tmp8_ = rows;
		_tmp9_ = qlite_query_builder_iterator (_tmp8_);
		_row_it = _tmp9_;
		while (TRUE) {
			QliteRowIterator* _tmp10_;
			QliteRow* row = NULL;
			QliteRowIterator* _tmp11_;
			QliteRow* _tmp12_;
			_tmp10_ = _row_it;
			if (!qlite_row_iterator_next (_tmp10_)) {
				break;
			}
			_tmp11_ = _row_it;
			_tmp12_ = qlite_row_iterator_get (_tmp11_);
			row = _tmp12_;
			{
				DinoEntitiesMessage* message = NULL;
				DinoDatabase* _tmp13_;
				QliteRow* _tmp14_;
				DinoEntitiesMessage* _tmp15_;
				DinoEntitiesConversation* conversation = NULL;
				DinoStreamInteractor* _tmp16_;
				DinoModuleIdentity* _tmp17_;
				gpointer _tmp18_;
				DinoConversationManager* _tmp19_;
				DinoEntitiesMessage* _tmp20_;
				DinoEntitiesConversation* _tmp21_;
				DinoEntitiesConversation* _tmp22_;
				GeeList* _tmp23_;
				DinoEntitiesMessage* _tmp24_;
				DinoEntitiesConversation* _tmp25_;
				QliteRow* _tmp26_;
				DinoDatabase* _tmp27_;
				DinoDatabaseContentItemTable* _tmp28_;
				DinoDatabaseContentItemTable* _tmp29_;
				QliteColumn* _tmp30_;
				gpointer _tmp31_;
				DinoMessageItem* _tmp32_;
				DinoMessageItem* _tmp33_;
				_tmp13_ = self->priv->db;
				_tmp14_ = row;
				_tmp15_ = dino_entities_message_new_from_row (_tmp13_, _tmp14_, &_inner_error0_);
				message = _tmp15_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
						goto __catch0_xmpp_invalid_jid_error;
					}
					_qlite_row_unref0 (row);
					_qlite_row_iterator_unref0 (_row_it);
					_qlite_statement_builder_unref0 (rows);
					_g_object_unref0 (ret);
					g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return NULL;
				}
				_tmp16_ = self->priv->stream_interactor;
				_tmp17_ = dino_conversation_manager_IDENTITY;
				_tmp18_ = dino_stream_interactor_get_module (_tmp16_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp17_);
				_tmp19_ = (DinoConversationManager*) _tmp18_;
				_tmp20_ = message;
				_tmp21_ = dino_conversation_manager_get_conversation_for_message (_tmp19_, _tmp20_);
				_tmp22_ = _tmp21_;
				_g_object_unref0 (_tmp19_);
				conversation = _tmp22_;
				_tmp23_ = ret;
				_tmp24_ = message;
				_tmp25_ = conversation;
				_tmp26_ = row;
				_tmp27_ = self->priv->db;
				_tmp28_ = dino_database_get_content_item (_tmp27_);
				_tmp29_ = _tmp28_;
				_tmp30_ = _tmp29_->id;
				_tmp31_ = qlite_row_get (_tmp26_, G_TYPE_INT, NULL, NULL, _tmp30_);
				_tmp32_ = dino_message_item_new (_tmp24_, _tmp25_, (gint) ((gintptr) _tmp31_));
				_tmp33_ = _tmp32_;
				gee_collection_add ((GeeCollection*) _tmp23_, _tmp33_);
				_g_object_unref0 (_tmp33_);
				_g_object_unref0 (conversation);
				_g_object_unref0 (message);
			}
			goto __finally0;
			__catch0_xmpp_invalid_jid_error:
			{
				GError* e = NULL;
				GError* _tmp34_;
				const gchar* _tmp35_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp34_ = e;
				_tmp35_ = _tmp34_->message;
				g_warning ("search_processor.vala:261: Ignoring search result with invalid Jid: %s", _tmp35_);
				_g_error_free0 (e);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_qlite_row_unref0 (row);
				_qlite_row_iterator_unref0 (_row_it);
				_qlite_statement_builder_unref0 (rows);
				_g_object_unref0 (ret);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
			_qlite_row_unref0 (row);
		}
		_qlite_row_iterator_unref0 (_row_it);
	}
	result = ret;
	_qlite_statement_builder_unref0 (rows);
	return result;
}

gint
dino_search_processor_count_match_messages (DinoSearchProcessor* self,
                                            const gchar* query)
{
	QliteQueryBuilder* _tmp0_;
	QliteQueryBuilder* _tmp1_;
	DinoDatabase* _tmp2_;
	DinoDatabaseMessageTable* _tmp3_;
	DinoDatabaseMessageTable* _tmp4_;
	QliteColumn* _tmp5_;
	QliteColumn* _tmp6_;
	QliteColumn** _tmp7_;
	QliteColumn** _tmp8_;
	gint _tmp8__length1;
	QliteQueryBuilder* _tmp9_;
	QliteQueryBuilder* _tmp10_;
	gint _tmp11_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (query != NULL, -1);
	_tmp0_ = dino_search_processor_prepare_search (self, query, FALSE);
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->db;
	_tmp3_ = dino_database_get_message (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_->id;
	_tmp6_ = _qlite_column_ref0 (_tmp5_);
	_tmp7_ = g_new0 (QliteColumn*, 1 + 1);
	_tmp7_[0] = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = 1;
	_tmp9_ = qlite_query_builder_select (_tmp1_, _tmp8_, (gint) 1);
	_tmp10_ = _tmp9_;
	_tmp11_ = (gint) qlite_query_builder_count (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) qlite_column_unref), NULL);
	_qlite_statement_builder_unref0 (_tmp1_);
	result = _tmp11_;
	return result;
}

static const gchar*
dino_search_processor_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoSearchProcessor* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoSearchProcessor*) base;
	_tmp0_ = dino_search_processor_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
dino_search_processor_class_init (DinoSearchProcessorClass * klass,
                                  gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_search_processor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoSearchProcessor_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_search_processor_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_search_processor_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_PROCESSOR_ID_PROPERTY, dino_search_processor_properties[DINO_SEARCH_PROCESSOR_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = dino_module_identity_new (DINO_TYPE_SEARCH_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "search_processor");
	dino_search_processor_IDENTITY = _tmp0_;
}

static void
dino_search_processor_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                                     gpointer iface_data)
{
	dino_search_processor_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_search_processor_real_get_id;
}

static void
dino_search_processor_instance_init (DinoSearchProcessor * self,
                                     gpointer klass)
{
	self->priv = dino_search_processor_get_instance_private (self);
}

static void
dino_search_processor_finalize (GObject * obj)
{
	DinoSearchProcessor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_SEARCH_PROCESSOR, DinoSearchProcessor);
	_g_object_unref0 (self->priv->stream_interactor);
	_qlite_database_unref0 (self->priv->db);
	G_OBJECT_CLASS (dino_search_processor_parent_class)->finalize (obj);
}

static GType
dino_search_processor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoSearchProcessorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_search_processor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoSearchProcessor), 0, (GInstanceInitFunc) dino_search_processor_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_search_processor_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_search_processor_type_id;
	dino_search_processor_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoSearchProcessor", &g_define_type_info, 0);
	g_type_add_interface_static (dino_search_processor_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	DinoSearchProcessor_private_offset = g_type_add_instance_private (dino_search_processor_type_id, sizeof (DinoSearchProcessorPrivate));
	return dino_search_processor_type_id;
}

GType
dino_search_processor_get_type (void)
{
	static volatile gsize dino_search_processor_type_id__once = 0;
	if (g_once_init_enter (&dino_search_processor_type_id__once)) {
		GType dino_search_processor_type_id;
		dino_search_processor_type_id = dino_search_processor_get_type_once ();
		g_once_init_leave (&dino_search_processor_type_id__once, dino_search_processor_type_id);
	}
	return dino_search_processor_type_id__once;
}

static void
_vala_dino_search_processor_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	DinoSearchProcessor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_SEARCH_PROCESSOR, DinoSearchProcessor);
	switch (property_id) {
		case DINO_SEARCH_PROCESSOR_ID_PROPERTY:
		g_value_set_string (value, dino_stream_interaction_module_get_id ((DinoStreamInteractionModule*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
dino_search_suggestion_get_instance_private (DinoSearchSuggestion* self)
{
	return G_STRUCT_MEMBER_P (self, DinoSearchSuggestion_private_offset);
}

DinoSearchSuggestion*
dino_search_suggestion_construct (GType object_type,
                                  DinoEntitiesConversation* conversation,
                                  XmppJid* jid,
                                  const gchar* completion,
                                  gint start_index,
                                  gint end_index)
{
	DinoSearchSuggestion * self = NULL;
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (completion != NULL, NULL);
	self = (DinoSearchSuggestion*) g_object_new (object_type, NULL);
	dino_search_suggestion_set_conversation (self, conversation);
	dino_search_suggestion_set_jid (self, jid);
	dino_search_suggestion_set_completion (self, completion);
	dino_search_suggestion_set_start_index (self, start_index);
	dino_search_suggestion_set_end_index (self, end_index);
	return self;
}

DinoSearchSuggestion*
dino_search_suggestion_new (DinoEntitiesConversation* conversation,
                            XmppJid* jid,
                            const gchar* completion,
                            gint start_index,
                            gint end_index)
{
	return dino_search_suggestion_construct (DINO_TYPE_SEARCH_SUGGESTION, conversation, jid, completion, start_index, end_index);
}

DinoEntitiesAccount*
dino_search_suggestion_get_account (DinoSearchSuggestion* self)
{
	DinoEntitiesAccount* result;
	DinoEntitiesConversation* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_conversation;
	_tmp1_ = dino_entities_conversation_get_account (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

DinoEntitiesConversation*
dino_search_suggestion_get_conversation (DinoSearchSuggestion* self)
{
	DinoEntitiesConversation* result;
	DinoEntitiesConversation* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_conversation;
	result = _tmp0_;
	return result;
}

static void
dino_search_suggestion_set_conversation (DinoSearchSuggestion* self,
                                         DinoEntitiesConversation* value)
{
	DinoEntitiesConversation* old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_search_suggestion_get_conversation (self);
	if (old_value != value) {
		DinoEntitiesConversation* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_conversation);
		self->priv->_conversation = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_CONVERSATION_PROPERTY]);
	}
}

XmppJid*
dino_search_suggestion_get_jid (DinoSearchSuggestion* self)
{
	XmppJid* result;
	XmppJid* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_jid;
	result = _tmp0_;
	return result;
}

static gpointer
_xmpp_jid_ref0 (gpointer self)
{
	return self ? xmpp_jid_ref (self) : NULL;
}

static void
dino_search_suggestion_set_jid (DinoSearchSuggestion* self,
                                XmppJid* value)
{
	XmppJid* old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_search_suggestion_get_jid (self);
	if (old_value != value) {
		XmppJid* _tmp0_;
		_tmp0_ = _xmpp_jid_ref0 (value);
		_xmpp_jid_unref0 (self->priv->_jid);
		self->priv->_jid = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_JID_PROPERTY]);
	}
}

const gchar*
dino_search_suggestion_get_completion (DinoSearchSuggestion* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_completion;
	result = _tmp0_;
	return result;
}

static void
dino_search_suggestion_set_completion (DinoSearchSuggestion* self,
                                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_search_suggestion_get_completion (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_completion);
		self->priv->_completion = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_COMPLETION_PROPERTY]);
	}
}

gint
dino_search_suggestion_get_start_index (DinoSearchSuggestion* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_start_index;
	return result;
}

static void
dino_search_suggestion_set_start_index (DinoSearchSuggestion* self,
                                        gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_search_suggestion_get_start_index (self);
	if (old_value != value) {
		self->priv->_start_index = value;
		g_object_notify_by_pspec ((GObject *) self, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_START_INDEX_PROPERTY]);
	}
}

gint
dino_search_suggestion_get_end_index (DinoSearchSuggestion* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_end_index;
	return result;
}

static void
dino_search_suggestion_set_end_index (DinoSearchSuggestion* self,
                                      gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_search_suggestion_get_end_index (self);
	if (old_value != value) {
		self->priv->_end_index = value;
		g_object_notify_by_pspec ((GObject *) self, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_END_INDEX_PROPERTY]);
	}
}

glong
dino_search_suggestion_get_order (DinoSearchSuggestion* self)
{
	glong result;
	g_return_val_if_fail (self != NULL, -1L);
	result = self->priv->_order;
	return result;
}

void
dino_search_suggestion_set_order (DinoSearchSuggestion* self,
                                  glong value)
{
	glong old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_search_suggestion_get_order (self);
	if (old_value != value) {
		self->priv->_order = value;
		g_object_notify_by_pspec ((GObject *) self, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_ORDER_PROPERTY]);
	}
}

static void
dino_search_suggestion_class_init (DinoSearchSuggestionClass * klass,
                                   gpointer klass_data)
{
	dino_search_suggestion_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoSearchSuggestion_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_search_suggestion_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dino_search_suggestion_set_property;
	G_OBJECT_CLASS (klass)->finalize = dino_search_suggestion_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_SUGGESTION_ACCOUNT_PROPERTY, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_ACCOUNT_PROPERTY] = g_param_spec_object ("account", "account", "account", DINO_ENTITIES_TYPE_ACCOUNT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_SUGGESTION_CONVERSATION_PROPERTY, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_CONVERSATION_PROPERTY] = g_param_spec_object ("conversation", "conversation", "conversation", DINO_ENTITIES_TYPE_CONVERSATION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_SUGGESTION_JID_PROPERTY, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_JID_PROPERTY] = xmpp_param_spec_jid ("jid", "jid", "jid", XMPP_TYPE_JID, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_SUGGESTION_COMPLETION_PROPERTY, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_COMPLETION_PROPERTY] = g_param_spec_string ("completion", "completion", "completion", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_SUGGESTION_START_INDEX_PROPERTY, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_START_INDEX_PROPERTY] = g_param_spec_int ("start-index", "start-index", "start-index", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_SUGGESTION_END_INDEX_PROPERTY, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_END_INDEX_PROPERTY] = g_param_spec_int ("end-index", "end-index", "end-index", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_SEARCH_SUGGESTION_ORDER_PROPERTY, dino_search_suggestion_properties[DINO_SEARCH_SUGGESTION_ORDER_PROPERTY] = g_param_spec_long ("order", "order", "order", G_MINLONG, G_MAXLONG, 0L, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dino_search_suggestion_instance_init (DinoSearchSuggestion * self,
                                      gpointer klass)
{
	self->priv = dino_search_suggestion_get_instance_private (self);
}

static void
dino_search_suggestion_finalize (GObject * obj)
{
	DinoSearchSuggestion * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_SEARCH_SUGGESTION, DinoSearchSuggestion);
	_g_object_unref0 (self->priv->_conversation);
	_xmpp_jid_unref0 (self->priv->_jid);
	_g_free0 (self->priv->_completion);
	G_OBJECT_CLASS (dino_search_suggestion_parent_class)->finalize (obj);
}

static GType
dino_search_suggestion_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoSearchSuggestionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_search_suggestion_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoSearchSuggestion), 0, (GInstanceInitFunc) dino_search_suggestion_instance_init, NULL };
	GType dino_search_suggestion_type_id;
	dino_search_suggestion_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoSearchSuggestion", &g_define_type_info, 0);
	DinoSearchSuggestion_private_offset = g_type_add_instance_private (dino_search_suggestion_type_id, sizeof (DinoSearchSuggestionPrivate));
	return dino_search_suggestion_type_id;
}

GType
dino_search_suggestion_get_type (void)
{
	static volatile gsize dino_search_suggestion_type_id__once = 0;
	if (g_once_init_enter (&dino_search_suggestion_type_id__once)) {
		GType dino_search_suggestion_type_id;
		dino_search_suggestion_type_id = dino_search_suggestion_get_type_once ();
		g_once_init_leave (&dino_search_suggestion_type_id__once, dino_search_suggestion_type_id);
	}
	return dino_search_suggestion_type_id__once;
}

static void
_vala_dino_search_suggestion_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	DinoSearchSuggestion * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_SEARCH_SUGGESTION, DinoSearchSuggestion);
	switch (property_id) {
		case DINO_SEARCH_SUGGESTION_ACCOUNT_PROPERTY:
		g_value_set_object (value, dino_search_suggestion_get_account (self));
		break;
		case DINO_SEARCH_SUGGESTION_CONVERSATION_PROPERTY:
		g_value_set_object (value, dino_search_suggestion_get_conversation (self));
		break;
		case DINO_SEARCH_SUGGESTION_JID_PROPERTY:
		xmpp_value_set_jid (value, dino_search_suggestion_get_jid (self));
		break;
		case DINO_SEARCH_SUGGESTION_COMPLETION_PROPERTY:
		g_value_set_string (value, dino_search_suggestion_get_completion (self));
		break;
		case DINO_SEARCH_SUGGESTION_START_INDEX_PROPERTY:
		g_value_set_int (value, dino_search_suggestion_get_start_index (self));
		break;
		case DINO_SEARCH_SUGGESTION_END_INDEX_PROPERTY:
		g_value_set_int (value, dino_search_suggestion_get_end_index (self));
		break;
		case DINO_SEARCH_SUGGESTION_ORDER_PROPERTY:
		g_value_set_long (value, dino_search_suggestion_get_order (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dino_search_suggestion_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	DinoSearchSuggestion * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_SEARCH_SUGGESTION, DinoSearchSuggestion);
	switch (property_id) {
		case DINO_SEARCH_SUGGESTION_CONVERSATION_PROPERTY:
		dino_search_suggestion_set_conversation (self, g_value_get_object (value));
		break;
		case DINO_SEARCH_SUGGESTION_JID_PROPERTY:
		dino_search_suggestion_set_jid (self, xmpp_value_get_jid (value));
		break;
		case DINO_SEARCH_SUGGESTION_COMPLETION_PROPERTY:
		dino_search_suggestion_set_completion (self, g_value_get_string (value));
		break;
		case DINO_SEARCH_SUGGESTION_START_INDEX_PROPERTY:
		dino_search_suggestion_set_start_index (self, g_value_get_int (value));
		break;
		case DINO_SEARCH_SUGGESTION_END_INDEX_PROPERTY:
		dino_search_suggestion_set_end_index (self, g_value_get_int (value));
		break;
		case DINO_SEARCH_SUGGESTION_ORDER_PROPERTY:
		dino_search_suggestion_set_order (self, g_value_get_long (value));
		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 gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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

