/* app-fill-window-operation.c generated by valac 0.56.19, the Vala compiler
 * generated from app-fill-window-operation.vala, do not modify */

/*
 * Copyright 2016 Software Freedom Conservancy Inc.
 * Copyright 2018-2019 Michael Gratton <mike@vee.net>
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later). See the COPYING file in this distribution.
 */

#include "geary-engine.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

#define GEARY_APP_FILL_WINDOW_OPERATION_MAX_FILL_COUNT 20
#define GEARY_APP_FILL_WINDOW_OPERATION_MIN_FILL_COUNT 5
#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

#define GEARY_APP_TYPE_CONVERSATION_OPERATION (geary_app_conversation_operation_get_type ())
#define GEARY_APP_CONVERSATION_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation))
#define GEARY_APP_CONVERSATION_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperationClass))
#define GEARY_APP_IS_CONVERSATION_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION))
#define GEARY_APP_IS_CONVERSATION_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_CONVERSATION_OPERATION))
#define GEARY_APP_CONVERSATION_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperationClass))

typedef struct _GearyAppConversationOperation GearyAppConversationOperation;
typedef struct _GearyAppConversationOperationClass GearyAppConversationOperationClass;
typedef struct _GearyAppConversationOperationPrivate GearyAppConversationOperationPrivate;

#define GEARY_APP_TYPE_FILL_WINDOW_OPERATION (geary_app_fill_window_operation_get_type ())
#define GEARY_APP_FILL_WINDOW_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_FILL_WINDOW_OPERATION, GearyAppFillWindowOperation))
#define GEARY_APP_FILL_WINDOW_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_FILL_WINDOW_OPERATION, GearyAppFillWindowOperationClass))
#define GEARY_APP_IS_FILL_WINDOW_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_FILL_WINDOW_OPERATION))
#define GEARY_APP_IS_FILL_WINDOW_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_FILL_WINDOW_OPERATION))
#define GEARY_APP_FILL_WINDOW_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_FILL_WINDOW_OPERATION, GearyAppFillWindowOperationClass))

typedef struct _GearyAppFillWindowOperation GearyAppFillWindowOperation;
typedef struct _GearyAppFillWindowOperationClass GearyAppFillWindowOperationClass;
typedef struct _GearyAppFillWindowOperationPrivate GearyAppFillWindowOperationPrivate;
enum  {
	GEARY_APP_FILL_WINDOW_OPERATION_0_PROPERTY,
	GEARY_APP_FILL_WINDOW_OPERATION_NUM_PROPERTIES
};
static GParamSpec* geary_app_fill_window_operation_properties[GEARY_APP_FILL_WINDOW_OPERATION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GEARY_APP_TYPE_CONVERSATION_SET (geary_app_conversation_set_get_type ())
#define GEARY_APP_CONVERSATION_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_CONVERSATION_SET, GearyAppConversationSet))
#define GEARY_APP_CONVERSATION_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_CONVERSATION_SET, GearyAppConversationSetClass))
#define GEARY_APP_IS_CONVERSATION_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_CONVERSATION_SET))
#define GEARY_APP_IS_CONVERSATION_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_CONVERSATION_SET))
#define GEARY_APP_CONVERSATION_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_CONVERSATION_SET, GearyAppConversationSetClass))

typedef struct _GearyAppConversationSet GearyAppConversationSet;
typedef struct _GearyAppConversationSetClass GearyAppConversationSetClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _GearyAppFillWindowOperationExecuteAsyncData GearyAppFillWindowOperationExecuteAsyncData;

struct _GearyAppConversationOperation {
	GearyBaseObject parent_instance;
	GearyAppConversationMonitor* monitor;
	GearyAppConversationOperationPrivate * priv;
};

struct _GearyAppConversationOperationClass {
	GearyBaseObjectClass parent_class;
	void (*execute_async) (GearyAppConversationOperation* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*execute_finish) (GearyAppConversationOperation* self, GAsyncResult* _res_, GError** error);
};

struct _GearyAppFillWindowOperation {
	GearyAppConversationOperation parent_instance;
	GearyAppFillWindowOperationPrivate * priv;
};

struct _GearyAppFillWindowOperationClass {
	GearyAppConversationOperationClass parent_class;
};

struct _GearyAppFillWindowOperationExecuteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppFillWindowOperation* self;
	gint num_to_load;
	GearyAppConversationMonitor* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GearyAppConversationMonitor* _tmp3_;
	GearyAppConversationSet* _tmp4_;
	GearyAppConversationSet* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	gint loaded;
	gint _tmp8_;
	GearyAppConversationMonitor* _tmp9_;
	GearyAppConversationMonitor* _tmp10_;
	GearyEmailIdentifier* _tmp11_;
	GearyEmailIdentifier* _tmp12_;
	GearyEmailIdentifier* _tmp13_;
	gint _tmp14_;
	GError* err;
	GError* _tmp15_;
	const gchar* _tmp16_;
	GearyAppConversationMonitor* _tmp17_;
	GearyAppConversationSet* _tmp18_;
	GearyAppConversationSet* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	GearyAppConversationMonitor* _tmp22_;
	GearyFolder* _tmp23_;
	GearyFolder* _tmp24_;
	GearyFolderProperties* _tmp25_;
	GearyFolderProperties* _tmp26_;
	gint _tmp27_;
	gint _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	GearyAppConversationMonitor* _tmp31_;
	gboolean _tmp32_;
	gboolean _tmp33_;
	GearyAppConversationMonitor* _tmp34_;
	GearyFolder* _tmp35_;
	GearyFolder* _tmp36_;
	gint _tmp37_;
	GearyAppConversationMonitor* _tmp38_;
	GearyAppConversationMonitor* _tmp39_;
	GearyEmailIdentifier* _tmp40_;
	GearyEmailIdentifier* _tmp41_;
	GearyEmailIdentifier* _tmp42_;
	gint _tmp43_;
	GError* _vala1_err;
	GError* _tmp44_;
	const gchar* _tmp45_;
	GearyAppConversationMonitor* _tmp46_;
	GearyAppConversationSet* _tmp47_;
	GearyAppConversationSet* _tmp48_;
	gint _tmp49_;
	gint _tmp50_;
	GearyAppConversationMonitor* _tmp51_;
	GearyFolder* _tmp52_;
	GearyFolder* _tmp53_;
	GearyFolderProperties* _tmp54_;
	GearyFolderProperties* _tmp55_;
	gint _tmp56_;
	gint _tmp57_;
	GearyAppConversationMonitor* _tmp58_;
	GearyAppConversationMonitor* _tmp59_;
	GError* _inner_error0_;
};

static gpointer geary_app_fill_window_operation_parent_class = NULL;

VALA_EXTERN GType geary_app_conversation_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_app_fill_window_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_app_conversation_operation_execute_async (GearyAppConversationOperation* self,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_operation_execute_finish (GearyAppConversationOperation* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
VALA_EXTERN GearyAppFillWindowOperation* geary_app_fill_window_operation_new (GearyAppConversationMonitor* monitor);
VALA_EXTERN GearyAppFillWindowOperation* geary_app_fill_window_operation_construct (GType object_type,
                                                                        GearyAppConversationMonitor* monitor);
VALA_EXTERN GearyAppConversationOperation* geary_app_conversation_operation_construct (GType object_type,
                                                                           GearyAppConversationMonitor* monitor,
                                                                           gboolean allow_duplicates);
static void geary_app_fill_window_operation_real_execute_async_data_free (gpointer _data);
static void geary_app_fill_window_operation_real_execute_async (GearyAppConversationOperation* base,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static gboolean geary_app_fill_window_operation_real_execute_async_co (GearyAppFillWindowOperationExecuteAsyncData* _data_);
VALA_EXTERN GType geary_app_conversation_set_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAppConversationSet* geary_app_conversation_monitor_get_conversations (GearyAppConversationMonitor* self);
VALA_EXTERN gint geary_app_conversation_set_get_size (GearyAppConversationSet* self);
VALA_EXTERN void geary_app_conversation_monitor_load_by_id_async (GearyAppConversationMonitor* self,
                                                      GearyEmailIdentifier* initial_id,
                                                      gint count,
                                                      GearyFolderListFlags flags,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
VALA_EXTERN gint geary_app_conversation_monitor_load_by_id_finish (GearyAppConversationMonitor* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
VALA_EXTERN GearyEmailIdentifier* geary_app_conversation_monitor_get_window_lowest (GearyAppConversationMonitor* self);
static void geary_app_fill_window_operation_execute_async_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_monitor_check_window_count (GearyAppConversationMonitor* self);
VALA_EXTERN void geary_app_conversation_monitor_set_fill_complete (GearyAppConversationMonitor* self,
                                                       gboolean value);
static GType geary_app_fill_window_operation_get_type_once (void);

GearyAppFillWindowOperation*
geary_app_fill_window_operation_construct (GType object_type,
                                           GearyAppConversationMonitor* monitor)
{
	GearyAppFillWindowOperation * self = NULL;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (monitor), NULL);
	self = (GearyAppFillWindowOperation*) geary_app_conversation_operation_construct (object_type, monitor, FALSE);
	return self;
}

GearyAppFillWindowOperation*
geary_app_fill_window_operation_new (GearyAppConversationMonitor* monitor)
{
	return geary_app_fill_window_operation_construct (GEARY_APP_TYPE_FILL_WINDOW_OPERATION, monitor);
}

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

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

static void
geary_app_fill_window_operation_real_execute_async (GearyAppConversationOperation* base,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	GearyAppFillWindowOperation * self;
	GearyAppFillWindowOperationExecuteAsyncData* _data_;
	GearyAppFillWindowOperation* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_APP_TYPE_FILL_WINDOW_OPERATION, GearyAppFillWindowOperation);
	_data_ = g_slice_new0 (GearyAppFillWindowOperationExecuteAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_fill_window_operation_real_execute_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	geary_app_fill_window_operation_real_execute_async_co (_data_);
}

static void
geary_app_fill_window_operation_execute_finish (GearyAppConversationOperation* base,
                                                GAsyncResult* _res_,
                                                GError** error)
{
	GearyAppFillWindowOperationExecuteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_app_fill_window_operation_execute_async_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_)
{
	GearyAppFillWindowOperationExecuteAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_fill_window_operation_real_execute_async_co (_data_);
}

static gboolean
geary_app_fill_window_operation_real_execute_async_co (GearyAppFillWindowOperationExecuteAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
	_data_->_tmp1_ = geary_app_conversation_monitor_get_min_window_count (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
	_data_->_tmp4_ = geary_app_conversation_monitor_get_conversations (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = geary_app_conversation_set_get_size (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->num_to_load = (gint) (_data_->_tmp2_ - _data_->_tmp7_);
	if (_data_->num_to_load < GEARY_APP_FILL_WINDOW_OPERATION_MIN_FILL_COUNT) {
		_data_->num_to_load = GEARY_APP_FILL_WINDOW_OPERATION_MIN_FILL_COUNT;
	} else {
		if (_data_->num_to_load > GEARY_APP_FILL_WINDOW_OPERATION_MAX_FILL_COUNT) {
			_data_->num_to_load = GEARY_APP_FILL_WINDOW_OPERATION_MAX_FILL_COUNT;
		}
	}
	_data_->loaded = 0;
	{
		_data_->_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		_data_->_tmp10_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		_data_->_tmp11_ = geary_app_conversation_monitor_get_window_lowest (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_state_ = 1;
		geary_app_conversation_monitor_load_by_id_async (_data_->_tmp9_, _data_->_tmp13_, _data_->num_to_load, GEARY_FOLDER_LIST_FLAGS_LOCAL_ONLY, geary_app_fill_window_operation_execute_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp14_ = geary_app_conversation_monitor_load_by_id_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp13_);
		_data_->_tmp8_ = _data_->_tmp14_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND)) {
				goto __catch0_geary_engine_error_not_found;
			}
			goto __finally0;
		}
		_data_->loaded = _data_->_tmp8_;
	}
	goto __finally0;
	__catch0_geary_engine_error_not_found:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp15_ = _data_->err;
		_data_->_tmp16_ = _data_->_tmp15_->message;
		g_debug ("app-fill-window-operation.vala:47: Stale FillWindowOperation: %s", _data_->_tmp16_);
		_g_error_free0 (_data_->err);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp17_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
	_data_->_tmp18_ = geary_app_conversation_monitor_get_conversations (_data_->_tmp17_);
	_data_->_tmp19_ = _data_->_tmp18_;
	_data_->_tmp20_ = geary_app_conversation_set_get_size (_data_->_tmp19_);
	_data_->_tmp21_ = _data_->_tmp20_;
	_data_->_tmp22_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
	_data_->_tmp23_ = geary_app_conversation_monitor_get_base_folder (_data_->_tmp22_);
	_data_->_tmp24_ = _data_->_tmp23_;
	_data_->_tmp25_ = geary_folder_get_properties (_data_->_tmp24_);
	_data_->_tmp26_ = _data_->_tmp25_;
	_data_->_tmp27_ = geary_folder_properties_get_email_total (_data_->_tmp26_);
	_data_->_tmp28_ = _data_->_tmp27_;
	g_debug ("app-fill-window-operation.vala:51: Filled %d of %d locally, window: %d" \
", total: %d", _data_->loaded, _data_->num_to_load, _data_->_tmp21_, _data_->_tmp28_);
	if (_data_->loaded < _data_->num_to_load) {
		_data_->_tmp31_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		_data_->_tmp32_ = geary_app_conversation_monitor_get_can_load_more (_data_->_tmp31_);
		_data_->_tmp33_ = _data_->_tmp32_;
		_data_->_tmp30_ = _data_->_tmp33_;
	} else {
		_data_->_tmp30_ = FALSE;
	}
	if (_data_->_tmp30_) {
		_data_->_tmp34_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		_data_->_tmp35_ = geary_app_conversation_monitor_get_base_folder (_data_->_tmp34_);
		_data_->_tmp36_ = _data_->_tmp35_;
		_data_->_tmp29_ = geary_folder_get_open_state (_data_->_tmp36_) == GEARY_FOLDER_OPEN_STATE_REMOTE;
	} else {
		_data_->_tmp29_ = FALSE;
	}
	if (_data_->_tmp29_) {
		_data_->num_to_load = GEARY_APP_FILL_WINDOW_OPERATION_MAX_FILL_COUNT;
		{
			_data_->_tmp38_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
			_data_->_tmp39_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
			_data_->_tmp40_ = geary_app_conversation_monitor_get_window_lowest (_data_->_tmp39_);
			_data_->_tmp41_ = _data_->_tmp40_;
			_data_->_tmp42_ = _data_->_tmp41_;
			_data_->_state_ = 2;
			geary_app_conversation_monitor_load_by_id_async (_data_->_tmp38_, _data_->_tmp42_, _data_->num_to_load, GEARY_FOLDER_LIST_FLAGS_FORCE_UPDATE, geary_app_fill_window_operation_execute_async_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp43_ = geary_app_conversation_monitor_load_by_id_finish (_data_->_tmp38_, _data_->_res_, &_data_->_inner_error0_);
			_g_object_unref0 (_data_->_tmp42_);
			_data_->_tmp37_ = _data_->_tmp43_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				if (g_error_matches (_data_->_inner_error0_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND)) {
					goto __catch1_geary_engine_error_not_found;
				}
				goto __finally1;
			}
			_data_->loaded = _data_->_tmp37_;
		}
		goto __finally1;
		__catch1_geary_engine_error_not_found:
		{
			_data_->_vala1_err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp44_ = _data_->_vala1_err;
			_data_->_tmp45_ = _data_->_tmp44_->message;
			g_debug ("app-fill-window-operation.vala:76: Stale FillWindowOperation: %s", _data_->_tmp45_);
			_g_error_free0 (_data_->_vala1_err);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp46_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		_data_->_tmp47_ = geary_app_conversation_monitor_get_conversations (_data_->_tmp46_);
		_data_->_tmp48_ = _data_->_tmp47_;
		_data_->_tmp49_ = geary_app_conversation_set_get_size (_data_->_tmp48_);
		_data_->_tmp50_ = _data_->_tmp49_;
		_data_->_tmp51_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		_data_->_tmp52_ = geary_app_conversation_monitor_get_base_folder (_data_->_tmp51_);
		_data_->_tmp53_ = _data_->_tmp52_;
		_data_->_tmp54_ = geary_folder_get_properties (_data_->_tmp53_);
		_data_->_tmp55_ = _data_->_tmp54_;
		_data_->_tmp56_ = geary_folder_properties_get_email_total (_data_->_tmp55_);
		_data_->_tmp57_ = _data_->_tmp56_;
		g_debug ("app-fill-window-operation.vala:80: Filled %d of %d from the remote, wi" \
"ndow: %d, total: %d", _data_->loaded, _data_->num_to_load, _data_->_tmp50_, _data_->_tmp57_);
	}
	if (_data_->loaded == _data_->num_to_load) {
		_data_->_tmp58_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		geary_app_conversation_monitor_check_window_count (_data_->_tmp58_);
	} else {
		_data_->_tmp59_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation)->monitor;
		geary_app_conversation_monitor_set_fill_complete (_data_->_tmp59_, TRUE);
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
geary_app_fill_window_operation_class_init (GearyAppFillWindowOperationClass * klass,
                                            gpointer klass_data)
{
	geary_app_fill_window_operation_parent_class = g_type_class_peek_parent (klass);
	((GearyAppConversationOperationClass *) klass)->execute_async = (void (*) (GearyAppConversationOperation*, GAsyncReadyCallback, gpointer)) geary_app_fill_window_operation_real_execute_async;
	((GearyAppConversationOperationClass *) klass)->execute_finish = (void (*) (GearyAppConversationOperation*, GAsyncResult*, GError**)) geary_app_fill_window_operation_execute_finish;
}

static void
geary_app_fill_window_operation_instance_init (GearyAppFillWindowOperation * self,
                                               gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
geary_app_fill_window_operation_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyAppFillWindowOperationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_app_fill_window_operation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyAppFillWindowOperation), 0, (GInstanceInitFunc) geary_app_fill_window_operation_instance_init, NULL };
	GType geary_app_fill_window_operation_type_id;
	geary_app_fill_window_operation_type_id = g_type_register_static (GEARY_APP_TYPE_CONVERSATION_OPERATION, "GearyAppFillWindowOperation", &g_define_type_info, 0);
	return geary_app_fill_window_operation_type_id;
}

GType
geary_app_fill_window_operation_get_type (void)
{
	static gsize geary_app_fill_window_operation_type_id__once = 0;
	if (g_once_init_enter (&geary_app_fill_window_operation_type_id__once)) {
		GType geary_app_fill_window_operation_type_id;
		geary_app_fill_window_operation_type_id = geary_app_fill_window_operation_get_type_once ();
		g_once_init_leave (&geary_app_fill_window_operation_type_id__once, geary_app_fill_window_operation_type_id);
	}
	return geary_app_fill_window_operation_type_id__once;
}

