/* app-conversation-monitor.c generated by valac 0.56.19, the Vala compiler
 * generated from app-conversation-monitor.vala, do not modify */

/*
 * Copyright © 2016 Software Freedom Conservancy Inc.
 * Copyright © 2018, 2020 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.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gee.h>
#include <stdlib.h>
#include <string.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

#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 GEARY_APP_TYPE_CONVERSATION_OPERATION_QUEUE (geary_app_conversation_operation_queue_get_type ())
#define GEARY_APP_CONVERSATION_OPERATION_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION_QUEUE, GearyAppConversationOperationQueue))
#define GEARY_APP_CONVERSATION_OPERATION_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_CONVERSATION_OPERATION_QUEUE, GearyAppConversationOperationQueueClass))
#define GEARY_APP_IS_CONVERSATION_OPERATION_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION_QUEUE))
#define GEARY_APP_IS_CONVERSATION_OPERATION_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_CONVERSATION_OPERATION_QUEUE))
#define GEARY_APP_CONVERSATION_OPERATION_QUEUE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION_QUEUE, GearyAppConversationOperationQueueClass))

typedef struct _GearyAppConversationOperationQueue GearyAppConversationOperationQueue;
typedef struct _GearyAppConversationOperationQueueClass GearyAppConversationOperationQueueClass;
enum  {
	GEARY_APP_CONVERSATION_MONITOR_0_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_READ_ONLY_VIEW_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_SIZE_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_BASE_FOLDER_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_IS_MONITORING_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_SHOULD_LOAD_MORE_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_CAN_LOAD_MORE_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_MIN_WINDOW_COUNT_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_PROGRESS_MONITOR_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_LOGGING_PARENT_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_FOLDER_WINDOW_SIZE_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_WINDOW_LOWEST_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_FILL_COMPLETE_PROPERTY,
	GEARY_APP_CONVERSATION_MONITOR_NUM_PROPERTIES
};
static GParamSpec* geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block14Data Block14Data;

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

#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;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _GearyAppConversationMonitorStartMonitoringData GearyAppConversationMonitorStartMonitoringData;
typedef struct _GearyAppConversationMonitorStopMonitoringData GearyAppConversationMonitorStopMonitoringData;

#define GEARY_APP_TYPE_LOAD_OPERATION (geary_app_load_operation_get_type ())
#define GEARY_APP_LOAD_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_LOAD_OPERATION, GearyAppLoadOperation))
#define GEARY_APP_LOAD_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_LOAD_OPERATION, GearyAppLoadOperationClass))
#define GEARY_APP_IS_LOAD_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_LOAD_OPERATION))
#define GEARY_APP_IS_LOAD_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_LOAD_OPERATION))
#define GEARY_APP_LOAD_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_LOAD_OPERATION, GearyAppLoadOperationClass))

typedef struct _GearyAppLoadOperation GearyAppLoadOperation;
typedef struct _GearyAppLoadOperationClass GearyAppLoadOperationClass;
typedef struct _GearyAppConversationMonitorLoadEmailData GearyAppConversationMonitorLoadEmailData;
#define _g_free0(var) (var = (g_free (var), NULL))

#define GEARY_APP_CONVERSATION_MONITOR_TYPE_PROCESS_JOB_CONTEXT (geary_app_conversation_monitor_process_job_context_get_type ())
typedef struct _GearyAppConversationMonitorProcessJobContext GearyAppConversationMonitorProcessJobContext;
typedef struct _GearyAppConversationMonitorLoadByIdAsyncData GearyAppConversationMonitorLoadByIdAsyncData;
typedef struct _GearyAppConversationMonitorLoadBySparseIdData GearyAppConversationMonitorLoadBySparseIdData;
typedef struct _GearyAppConversationMonitorExternalLoadBySparseIdData GearyAppConversationMonitorExternalLoadBySparseIdData;
typedef struct _GearyAppConversationMonitorStopMonitoringInternalData GearyAppConversationMonitorStopMonitoringInternalData;
typedef struct _Block15Data Block15Data;
typedef struct _GearyAppConversationMonitorProcessEmailAsyncData GearyAppConversationMonitorProcessEmailAsyncData;
typedef struct _GearyAppConversationMonitorProcessEmailCompleteAsyncData GearyAppConversationMonitorProcessEmailCompleteAsyncData;
typedef struct _Block16Data Block16Data;

#define GEARY_APP_TYPE_LOCAL_SEARCH_OPERATION (geary_app_local_search_operation_get_type ())
#define GEARY_APP_LOCAL_SEARCH_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_LOCAL_SEARCH_OPERATION, GearyAppLocalSearchOperation))
#define GEARY_APP_LOCAL_SEARCH_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_LOCAL_SEARCH_OPERATION, GearyAppLocalSearchOperationClass))
#define GEARY_APP_IS_LOCAL_SEARCH_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_LOCAL_SEARCH_OPERATION))
#define GEARY_APP_IS_LOCAL_SEARCH_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_LOCAL_SEARCH_OPERATION))
#define GEARY_APP_LOCAL_SEARCH_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_LOCAL_SEARCH_OPERATION, GearyAppLocalSearchOperationClass))

typedef struct _GearyAppLocalSearchOperation GearyAppLocalSearchOperation;
typedef struct _GearyAppLocalSearchOperationClass GearyAppLocalSearchOperationClass;
typedef struct _GearyAppLocalSearchOperationPrivate GearyAppLocalSearchOperationPrivate;
typedef struct _GearyAppConversationMonitorExpandConversationsAsyncData GearyAppConversationMonitorExpandConversationsAsyncData;

#define GEARY_APP_TYPE_RESEED_OPERATION (geary_app_reseed_operation_get_type ())
#define GEARY_APP_RESEED_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_RESEED_OPERATION, GearyAppReseedOperation))
#define GEARY_APP_RESEED_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_RESEED_OPERATION, GearyAppReseedOperationClass))
#define GEARY_APP_IS_RESEED_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_RESEED_OPERATION))
#define GEARY_APP_IS_RESEED_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_RESEED_OPERATION))
#define GEARY_APP_RESEED_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_RESEED_OPERATION, GearyAppReseedOperationClass))

typedef struct _GearyAppReseedOperation GearyAppReseedOperation;
typedef struct _GearyAppReseedOperationClass GearyAppReseedOperationClass;

#define GEARY_APP_TYPE_BATCH_OPERATION (geary_app_batch_operation_get_type ())
#define GEARY_APP_BATCH_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_BATCH_OPERATION, GearyAppBatchOperation))
#define GEARY_APP_BATCH_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_BATCH_OPERATION, GearyAppBatchOperationClass))
#define GEARY_APP_IS_BATCH_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_BATCH_OPERATION))
#define GEARY_APP_IS_BATCH_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_BATCH_OPERATION))
#define GEARY_APP_BATCH_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_BATCH_OPERATION, GearyAppBatchOperationClass))

typedef struct _GearyAppBatchOperation GearyAppBatchOperation;
typedef struct _GearyAppBatchOperationClass GearyAppBatchOperationClass;

#define GEARY_APP_TYPE_APPEND_OPERATION (geary_app_append_operation_get_type ())
#define GEARY_APP_APPEND_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_APPEND_OPERATION, GearyAppAppendOperation))
#define GEARY_APP_APPEND_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_APPEND_OPERATION, GearyAppAppendOperationClass))
#define GEARY_APP_IS_APPEND_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_APPEND_OPERATION))
#define GEARY_APP_IS_APPEND_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_APPEND_OPERATION))
#define GEARY_APP_APPEND_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_APPEND_OPERATION, GearyAppAppendOperationClass))

typedef struct _GearyAppAppendOperation GearyAppAppendOperation;
typedef struct _GearyAppAppendOperationClass GearyAppAppendOperationClass;

#define GEARY_APP_TYPE_INSERT_OPERATION (geary_app_insert_operation_get_type ())
#define GEARY_APP_INSERT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_INSERT_OPERATION, GearyAppInsertOperation))
#define GEARY_APP_INSERT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_INSERT_OPERATION, GearyAppInsertOperationClass))
#define GEARY_APP_IS_INSERT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_INSERT_OPERATION))
#define GEARY_APP_IS_INSERT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_INSERT_OPERATION))
#define GEARY_APP_INSERT_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_INSERT_OPERATION, GearyAppInsertOperationClass))

typedef struct _GearyAppInsertOperation GearyAppInsertOperation;
typedef struct _GearyAppInsertOperationClass GearyAppInsertOperationClass;

#define GEARY_APP_TYPE_REMOVE_OPERATION (geary_app_remove_operation_get_type ())
#define GEARY_APP_REMOVE_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_REMOVE_OPERATION, GearyAppRemoveOperation))
#define GEARY_APP_REMOVE_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_REMOVE_OPERATION, GearyAppRemoveOperationClass))
#define GEARY_APP_IS_REMOVE_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_REMOVE_OPERATION))
#define GEARY_APP_IS_REMOVE_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_REMOVE_OPERATION))
#define GEARY_APP_REMOVE_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_REMOVE_OPERATION, GearyAppRemoveOperationClass))

typedef struct _GearyAppRemoveOperation GearyAppRemoveOperation;
typedef struct _GearyAppRemoveOperationClass GearyAppRemoveOperationClass;

#define GEARY_APP_TYPE_EXTERNAL_APPEND_OPERATION (geary_app_external_append_operation_get_type ())
#define GEARY_APP_EXTERNAL_APPEND_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_EXTERNAL_APPEND_OPERATION, GearyAppExternalAppendOperation))
#define GEARY_APP_EXTERNAL_APPEND_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_EXTERNAL_APPEND_OPERATION, GearyAppExternalAppendOperationClass))
#define GEARY_APP_IS_EXTERNAL_APPEND_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_EXTERNAL_APPEND_OPERATION))
#define GEARY_APP_IS_EXTERNAL_APPEND_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_EXTERNAL_APPEND_OPERATION))
#define GEARY_APP_EXTERNAL_APPEND_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_EXTERNAL_APPEND_OPERATION, GearyAppExternalAppendOperationClass))

typedef struct _GearyAppExternalAppendOperation GearyAppExternalAppendOperation;
typedef struct _GearyAppExternalAppendOperationClass GearyAppExternalAppendOperationClass;
enum  {
	GEARY_APP_CONVERSATION_MONITOR_SCAN_STARTED_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_SCAN_COMPLETED_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_SCAN_ERROR_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_ADDED_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_REMOVED_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_CONVERSATION_APPENDED_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_CONVERSATION_TRIMMED_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_EMAIL_FLAGS_CHANGED_SIGNAL,
	GEARY_APP_CONVERSATION_MONITOR_NUM_SIGNALS
};
static guint geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_NUM_SIGNALS] = {0};

struct _GearyAppConversationMonitorPrivate {
	GearyFolder* _base_folder;
	gboolean _is_monitoring;
	gint _min_window_count;
	GearyProgressMonitor* _progress_monitor;
	GearyAppConversationSet* _conversations;
	gboolean _fill_complete;
	gboolean base_was_opened;
	GearyEmailField required_fields;
	GearyAppConversationOperationQueue* queue;
	GCancellable* operation_cancellable;
	GeeSortedSet* window;
};

struct _Block14Data {
	int _ref_count_;
	GearyAppConversationMonitor* self;
	GCancellable* opening;
	gpointer _async_data_;
};

struct _GearyAppConversationMonitorStartMonitoringData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GearyFolderOpenFlags open_flags;
	GCancellable* cancellable;
	gboolean result;
	Block14Data* _data14_;
	gboolean _tmp0_;
	GearyFolder* _tmp1_;
	GearyFolder* _tmp2_;
	GearyFolder* _tmp3_;
	GearyFolder* _tmp4_;
	GearyFolder* _tmp5_;
	GearyFolder* _tmp6_;
	GearyFolder* _tmp7_;
	GearyAccount* _tmp8_;
	GearyAccount* _tmp9_;
	GearyFolder* _tmp10_;
	GearyAccount* _tmp11_;
	GearyAccount* _tmp12_;
	GearyFolder* _tmp13_;
	GearyAccount* _tmp14_;
	GearyAccount* _tmp15_;
	GearyFolder* _tmp16_;
	GearyAccount* _tmp17_;
	GearyAccount* _tmp18_;
	GearyFolder* _tmp19_;
	GearyAccount* _tmp20_;
	GearyAccount* _tmp21_;
	GearyAppConversationOperationQueue* _tmp22_;
	GearyAppConversationOperationQueue* _tmp23_;
	GearyAppFillWindowOperation* _tmp24_;
	GearyAppFillWindowOperation* _tmp25_;
	GCancellable* _tmp26_;
	GCancellable* _tmp27_;
	GearyFolder* _tmp28_;
	GCancellable* _tmp29_;
	GError* err;
	gboolean _tmp30_;
	GError* _tmp31_;
	const gchar* _tmp32_;
	GError* _tmp33_;
	GError* _tmp34_;
	gboolean _tmp35_;
	GearyAppConversationOperationQueue* _tmp36_;
	GError* _inner_error0_;
};

struct _GearyAppConversationMonitorStopMonitoringData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GCancellable* cancellable;
	gboolean result;
	gboolean is_closing;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GError* _inner_error0_;
};

struct _GearyAppConversationMonitorLoadEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GeeCollection* to_load;
	GCancellable* cancellable;
	gboolean _tmp0_;
	GError* _tmp1_;
	GeeArrayList* remaining;
	GearyIterable* _tmp2_;
	GearyIterable* _tmp3_;
	GearyIterable* _tmp4_;
	GearyIterable* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	GeeArrayList* _tmp11_;
	GearyAppLoadOperation* op;
	GeeArrayList* _tmp12_;
	gpointer _tmp13_;
	GearyEmailIdentifier* _tmp14_;
	GCancellable* _tmp15_;
	GearyAppLoadOperation* _tmp16_;
	GearyAppLoadOperation* _tmp17_;
	GearyAppConversationOperationQueue* _tmp18_;
	GearyAppLoadOperation* _tmp19_;
	GearyAppLoadOperation* _tmp20_;
	GError* _inner_error0_;
};

struct _GearyAppConversationMonitorProcessJobContext {
	GeeMap* emails;
};

struct _GearyAppConversationMonitorLoadByIdAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GearyEmailIdentifier* initial_id;
	gint count;
	GearyFolderListFlags flags;
	gint result;
	gint load_count;
	GError* scan_error;
	GeeCollection* messages;
	GearyFolder* _tmp0_;
	GCancellable* _tmp1_;
	GeeList* _tmp2_;
	gboolean _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	GeeCollection* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	GeeIterator* _email_it;
	GeeCollection* _tmp11_;
	GeeIterator* _tmp12_;
	GeeIterator* _tmp13_;
	GearyEmail* email;
	GeeIterator* _tmp14_;
	gpointer _tmp15_;
	GeeSortedSet* _tmp16_;
	GearyEmail* _tmp17_;
	GearyEmailIdentifier* _tmp18_;
	GearyEmailIdentifier* _tmp19_;
	GeeCollection* _tmp20_;
	GearyAppConversationMonitorProcessJobContext _tmp21_;
	GearyAppConversationMonitorProcessJobContext _tmp22_;
	GError* err;
	GError* _tmp23_;
	GError* _tmp24_;
	GError* _tmp25_;
	GError* _tmp26_;
	GError* _tmp27_;
	GError* _inner_error0_;
};

struct _GearyAppConversationMonitorLoadBySparseIdData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GeeCollection* ids;
	GearyFolderListFlags flags;
	GError* scan_error;
	GeeCollection* messages;
	GearyFolder* _tmp0_;
	GCancellable* _tmp1_;
	GeeList* _tmp2_;
	gboolean _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	GeeIterator* _email_it;
	GeeCollection* _tmp8_;
	GeeIterator* _tmp9_;
	GeeIterator* _tmp10_;
	GearyEmail* email;
	GeeIterator* _tmp11_;
	gpointer _tmp12_;
	GeeSortedSet* _tmp13_;
	GearyEmail* _tmp14_;
	GearyEmailIdentifier* _tmp15_;
	GearyEmailIdentifier* _tmp16_;
	GeeCollection* _tmp17_;
	GearyAppConversationMonitorProcessJobContext _tmp18_;
	GearyAppConversationMonitorProcessJobContext _tmp19_;
	GError* err;
	GError* _tmp20_;
	GError* _tmp21_;
	GError* _tmp22_;
	GError* _tmp23_;
	GError* _tmp24_;
	GError* _inner_error0_;
};

struct _GearyAppConversationMonitorExternalLoadBySparseIdData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GearyFolder* folder;
	GeeCollection* ids;
	GearyFolderListFlags flags;
	gboolean opened;
	GeeList* emails;
	GCancellable* _tmp0_;
	GeeList* _tmp1_;
	GCancellable* _tmp2_;
	GeeList* _tmp3_;
	GeeList* _tmp4_;
	GeeList* _tmp5_;
	GeeHashSet* relevant_ids;
	GeeHashSet* _tmp6_;
	GeeList* _email_list;
	GeeList* _tmp7_;
	gint _email_size;
	GeeList* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gint _email_index;
	gint _tmp11_;
	gint _tmp12_;
	GearyEmail* email;
	GeeList* _tmp13_;
	gpointer _tmp14_;
	GeeSet* ancestors;
	GearyEmail* _tmp15_;
	GeeSet* _tmp16_;
	gboolean _tmp17_;
	GeeSet* _tmp18_;
	GeeSet* _tmp19_;
	GearyIterable* _tmp20_;
	GearyIterable* _tmp21_;
	GeeHashSet* _tmp22_;
	GearyEmail* _tmp23_;
	GearyEmailIdentifier* _tmp24_;
	GearyEmailIdentifier* _tmp25_;
	GeeHashSet* _tmp26_;
	gboolean _tmp27_;
	gboolean _tmp28_;
	GeeList* _tmp29_;
	GeeHashSet* _tmp30_;
	GCancellable* _tmp31_;
	GeeList* _tmp32_;
	GeeList* _tmp33_;
	GError* err;
	GError* close_err;
	gchar* _tmp34_;
	gchar* _tmp35_;
	GError* _tmp36_;
	const gchar* _tmp37_;
	GError* _tmp38_;
	GError* _tmp39_;
	gboolean _tmp40_;
	GeeList* _tmp41_;
	GeeList* _tmp42_;
	gboolean _tmp43_;
	gboolean _tmp44_;
	GeeList* _tmp45_;
	gint _tmp46_;
	gint _tmp47_;
	GeeList* _tmp48_;
	GearyAppConversationMonitorProcessJobContext _tmp49_;
	GearyAppConversationMonitorProcessJobContext _tmp50_;
	GError* _inner_error0_;
};

struct _GearyAppConversationMonitorStopMonitoringInternalData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GCancellable* cancellable;
	gboolean result;
	GearyFolder* _tmp0_;
	guint _tmp1_;
	GearyFolder* _tmp2_;
	guint _tmp3_;
	GearyFolder* _tmp4_;
	guint _tmp5_;
	GearyFolder* _tmp6_;
	guint _tmp7_;
	GearyFolder* _tmp8_;
	guint _tmp9_;
	GearyFolder* _tmp10_;
	guint _tmp11_;
	GearyFolder* _tmp12_;
	GearyAccount* _tmp13_;
	GearyAccount* _tmp14_;
	guint _tmp15_;
	GearyFolder* _tmp16_;
	GearyAccount* _tmp17_;
	GearyAccount* _tmp18_;
	guint _tmp19_;
	GearyFolder* _tmp20_;
	GearyAccount* _tmp21_;
	GearyAccount* _tmp22_;
	guint _tmp23_;
	GearyFolder* _tmp24_;
	GearyAccount* _tmp25_;
	GearyAccount* _tmp26_;
	guint _tmp27_;
	GearyFolder* _tmp28_;
	GearyAccount* _tmp29_;
	GearyAccount* _tmp30_;
	guint _tmp31_;
	GCancellable* _tmp32_;
	GError* close_err;
	GearyAppConversationOperationQueue* _tmp33_;
	GError* err;
	GError* _tmp34_;
	GError* _tmp35_;
	gboolean closing;
	gboolean _tmp36_;
	GearyFolder* _tmp37_;
	GError* _vala1_err;
	GError* _tmp38_;
	GError* _tmp39_;
	GError* _tmp40_;
	GearyFolder* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	GError* _tmp44_;
	const gchar* _tmp45_;
	GError* _tmp46_;
	GError* _tmp47_;
	GError* _tmp48_;
	GError* _inner_error0_;
};

struct _Block15Data {
	int _ref_count_;
	GearyAppConversationMonitor* self;
	GeeHashSet* new_message_ids;
	gpointer _async_data_;
};

struct _GearyAppConversationMonitorProcessEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GeeCollection* emails;
	GearyAppConversationMonitorProcessJobContext job;
	Block15Data* _data15_;
	gboolean _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GearyAppConversationMonitorProcessJobContext _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GeeHashSet* _tmp6_;
	GeeIterator* _email_it;
	GeeIterator* _tmp7_;
	GeeIterator* _tmp8_;
	GearyEmail* email;
	GeeIterator* _tmp9_;
	gpointer _tmp10_;
	GearyAppConversationMonitorProcessJobContext _tmp11_;
	GeeMap* _tmp12_;
	GearyEmail* _tmp13_;
	GearyEmailIdentifier* _tmp14_;
	GearyEmailIdentifier* _tmp15_;
	GearyAppConversationMonitorProcessJobContext _tmp16_;
	GeeMap* _tmp17_;
	GearyEmail* _tmp18_;
	GearyEmailIdentifier* _tmp19_;
	GearyEmailIdentifier* _tmp20_;
	GearyEmail* _tmp21_;
	GearyEmailFlags* flags;
	GearyEmail* _tmp22_;
	GearyEmailFlags* _tmp23_;
	GearyEmailFlags* _tmp24_;
	GearyEmailFlags* _tmp25_;
	gboolean _tmp26_;
	GearyEmailFlags* _tmp27_;
	GearyEmailFlags* _tmp28_;
	gboolean marked_for_deletion;
	GeeSet* ancestors;
	GearyEmail* _tmp29_;
	GeeSet* _tmp30_;
	gboolean _tmp31_;
	GeeSet* _tmp32_;
	GeeSet* _tmp33_;
	GearyIterable* _tmp34_;
	GearyIterable* _tmp35_;
	GearyIterable* _tmp36_;
	GearyIterable* _tmp37_;
	GeeHashSet* _tmp38_;
	GeeCollection* _tmp39_;
	GeeCollection* _tmp40_;
	GeeHashSet* _tmp41_;
	GearyAppConversationMonitorProcessJobContext _tmp42_;
	gint _tmp43_;
	gint _tmp44_;
	GError* _inner_error0_;
};

struct _GearyAppConversationMonitorProcessEmailCompleteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GearyAppConversationMonitorProcessJobContext job;
	GeeCollection* added;
	GeeMultiMap* appended;
	GeeCollection* removed_due_to_merge;
	GeeMultiMap* email_paths;
	GearyFolder* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAppConversationMonitorProcessJobContext _tmp3_;
	GeeMap* _tmp4_;
	GeeSet* _tmp5_;
	GeeSet* _tmp6_;
	GeeSet* _tmp7_;
	GCancellable* _tmp8_;
	GeeMultiMap* _tmp9_;
	GeeMultiMap* _tmp10_;
	GeeMultiMap* _tmp11_;
	GearyAppConversationSet* _tmp12_;
	GearyAppConversationMonitorProcessJobContext _tmp13_;
	GeeMap* _tmp14_;
	GeeCollection* _tmp15_;
	GeeCollection* _tmp16_;
	GeeCollection* _tmp17_;
	GeeMultiMap* _tmp18_;
	GeeCollection* _tmp19_;
	GeeMultiMap* _tmp20_;
	GeeCollection* _tmp21_;
	GError* err;
	GError* _tmp22_;
	const gchar* _tmp23_;
	gboolean _tmp24_;
	GeeCollection* _tmp25_;
	GeeCollection* _tmp26_;
	gint _tmp27_;
	gint _tmp28_;
	GeeCollection* _tmp29_;
	gboolean _tmp30_;
	GeeCollection* _tmp31_;
	GeeCollection* _tmp32_;
	gint _tmp33_;
	gint _tmp34_;
	GeeCollection* _tmp35_;
	GeeMultiMap* _tmp36_;
	GeeIterator* _conversation_it;
	GeeMultiMap* _tmp37_;
	GeeSet* _tmp38_;
	GeeSet* _tmp39_;
	GeeIterator* _tmp40_;
	GeeIterator* _tmp41_;
	GeeIterator* _tmp42_;
	GearyAppConversation* conversation;
	GeeIterator* _tmp43_;
	gpointer _tmp44_;
	GearyAppConversation* _tmp45_;
	GeeMultiMap* _tmp46_;
	GearyAppConversation* _tmp47_;
	GeeCollection* _tmp48_;
	GeeCollection* _tmp49_;
	GError* _inner_error0_;
};

struct _Block16Data {
	int _ref_count_;
	GearyAppConversationMonitor* self;
	GeeHashMap* needed_messages;
	gpointer _async_data_;
};

struct _GearyAppLocalSearchOperation {
	GearyNonblockingBatchOperation parent_instance;
	GearyAccount* account;
	GearyRFC822MessageID* message_id;
	GearyEmailField required_fields;
	GeeCollection* blacklist;
	GearyEmailFlags* flag_blacklist;
	GeeMultiMap* emails;
	GearyAppLocalSearchOperationPrivate * priv;
};

struct _GearyAppLocalSearchOperationClass {
	GearyNonblockingBatchOperationClass parent_class;
};

struct _GearyAppConversationMonitorExpandConversationsAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppConversationMonitor* self;
	GeeSet* needed_message_ids;
	GearyAppConversationMonitorProcessJobContext job;
	Block16Data* _data16_;
	gint _tmp0_;
	gint _tmp1_;
	GearyAppConversationMonitorProcessJobContext _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GeeCollection* folder_blacklist;
	GeeCollection* _tmp5_;
	GearyEmailFlags* flag_blacklist;
	GearyEmailFlags* _tmp6_;
	GearyNonblockingBatch* batch;
	GearyNonblockingBatch* _tmp7_;
	GeeIterator* _message_id_it;
	GeeIterator* _tmp8_;
	GeeIterator* _tmp9_;
	GearyRFC822MessageID* message_id;
	GeeIterator* _tmp10_;
	gpointer _tmp11_;
	GearyNonblockingBatch* _tmp12_;
	GearyFolder* _tmp13_;
	GearyAccount* _tmp14_;
	GearyAccount* _tmp15_;
	GearyRFC822MessageID* _tmp16_;
	GeeCollection* _tmp17_;
	GearyEmailFlags* _tmp18_;
	GearyAppLocalSearchOperation* _tmp19_;
	GearyAppLocalSearchOperation* _tmp20_;
	GearyNonblockingBatch* _tmp21_;
	GeeHashMap* _tmp22_;
	GeeIterator* _id_it;
	GearyNonblockingBatch* _tmp23_;
	GeeSet* _tmp24_;
	GeeSet* _tmp25_;
	GeeIterator* _tmp26_;
	GeeIterator* _tmp27_;
	GeeIterator* _tmp28_;
	gint id;
	GeeIterator* _tmp29_;
	gpointer _tmp30_;
	GearyAppLocalSearchOperation* op;
	GearyNonblockingBatch* _tmp31_;
	GearyNonblockingBatchOperation* _tmp32_;
	GearyAppLocalSearchOperation* _tmp33_;
	GeeMultiMap* _tmp34_;
	GearyAppLocalSearchOperation* _tmp35_;
	GeeMultiMap* _tmp36_;
	GeeSet* _tmp37_;
	GeeSet* _tmp38_;
	GearyIterable* _tmp39_;
	GearyIterable* _tmp40_;
	GearyIterable* _tmp41_;
	GearyIterable* _tmp42_;
	GeeHashMap* _tmp43_;
	GeeMap* _tmp44_;
	GeeMap* _tmp45_;
	GeeHashMap* _tmp46_;
	GeeCollection* _tmp47_;
	GeeCollection* _tmp48_;
	GeeCollection* _tmp49_;
	GearyAppConversationMonitorProcessJobContext _tmp50_;
	gint _tmp51_;
	gint _tmp52_;
	GeeHashMap* _tmp53_;
	gint _tmp54_;
	gint _tmp55_;
	GError* _inner_error0_;
};

static gint GearyAppConversationMonitor_private_offset;
static gpointer geary_app_conversation_monitor_parent_class = NULL;
static GearyLoggingSourceIface * geary_app_conversation_monitor_geary_logging_source_parent_iface = NULL;

VALA_EXTERN GType geary_app_conversation_set_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_app_conversation_operation_queue_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAppConversationSet* geary_app_conversation_monitor_get_conversations (GearyAppConversationMonitor* self);
VALA_EXTERN GeeSet* geary_app_conversation_set_get_read_only_view (GearyAppConversationSet* self);
VALA_EXTERN gint geary_app_conversation_set_get_size (GearyAppConversationSet* self);
static void geary_app_conversation_monitor_set_base_folder (GearyAppConversationMonitor* self,
                                                     GearyFolder* value);
static void geary_app_conversation_monitor_set_is_monitoring (GearyAppConversationMonitor* self,
                                                       gboolean value);
VALA_EXTERN guint geary_app_conversation_monitor_get_folder_window_size (GearyAppConversationMonitor* self);
VALA_EXTERN gboolean geary_app_conversation_monitor_get_fill_complete (GearyAppConversationMonitor* self);
VALA_EXTERN void geary_app_conversation_monitor_check_window_count (GearyAppConversationMonitor* self);
static void geary_app_conversation_monitor_set_progress_monitor (GearyAppConversationMonitor* self,
                                                          GearyProgressMonitor* value);
static void geary_app_conversation_monitor_set_conversations (GearyAppConversationMonitor* self,
                                                       GearyAppConversationSet* value);
VALA_EXTERN GearyEmailIdentifier* geary_app_conversation_monitor_get_window_lowest (GearyAppConversationMonitor* self);
VALA_EXTERN void geary_app_conversation_monitor_set_fill_complete (GearyAppConversationMonitor* self,
                                                       gboolean value);
static gint _geary_app_conversation_monitor_window_lambda165_ (GearyEmailIdentifier* a,
                                                        GearyEmailIdentifier* b);
static gint __geary_app_conversation_monitor_window_lambda165__gcompare_data_func (gconstpointer a,
                                                                            gconstpointer b,
                                                                            gpointer self);
static void geary_app_conversation_monitor_real_scan_started (GearyAppConversationMonitor* self);
static void geary_app_conversation_monitor_real_scan_completed (GearyAppConversationMonitor* self);
static void geary_app_conversation_monitor_real_scan_error (GearyAppConversationMonitor* self,
                                                     GError* err);
static void geary_app_conversation_monitor_real_conversations_added (GearyAppConversationMonitor* self,
                                                              GeeCollection* conversations);
static void geary_app_conversation_monitor_real_conversations_removed (GearyAppConversationMonitor* self,
                                                                GeeCollection* conversations);
static void geary_app_conversation_monitor_real_conversation_appended (GearyAppConversationMonitor* self,
                                                                GearyAppConversation* conversation,
                                                                GeeCollection* email);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data);
static void geary_app_conversation_monitor_real_conversation_trimmed (GearyAppConversationMonitor* self,
                                                               GearyAppConversation* conversation,
                                                               GeeCollection* email);
static void geary_app_conversation_monitor_real_email_flags_changed (GearyAppConversationMonitor* self,
                                                              GearyAppConversation* conversation,
                                                              GearyEmail* email);
VALA_EXTERN GearyAppConversationSet* geary_app_conversation_set_new (GearyFolder* base_folder);
VALA_EXTERN GearyAppConversationSet* geary_app_conversation_set_construct (GType object_type,
                                                               GearyFolder* base_folder);
VALA_EXTERN GearyAppConversationOperationQueue* geary_app_conversation_operation_queue_new (GearyProgressMonitor* progress);
VALA_EXTERN GearyAppConversationOperationQueue* geary_app_conversation_operation_queue_construct (GType object_type,
                                                                                      GearyProgressMonitor* progress);
static void geary_app_conversation_monitor_start_monitoring_data_free (gpointer _data);
static gboolean geary_app_conversation_monitor_start_monitoring_co (GearyAppConversationMonitorStartMonitoringData* _data_);
static Block14Data* block14_data_ref (Block14Data* _data14_);
static void block14_data_unref (void * _userdata_);
static void geary_app_conversation_monitor_on_folder_email_appended (GearyAppConversationMonitor* self,
                                                              GeeCollection* appended);
static void _geary_app_conversation_monitor_on_folder_email_appended_geary_folder_email_appended (GearyFolder* _sender,
                                                                                           GeeCollection* ids,
                                                                                           gpointer self);
static void geary_app_conversation_monitor_on_folder_email_inserted (GearyAppConversationMonitor* self,
                                                              GeeCollection* inserted);
static void _geary_app_conversation_monitor_on_folder_email_inserted_geary_folder_email_inserted (GearyFolder* _sender,
                                                                                           GeeCollection* ids,
                                                                                           gpointer self);
static void geary_app_conversation_monitor_on_folder_email_complete (GearyAppConversationMonitor* self,
                                                              GeeCollection* completed);
static void _geary_app_conversation_monitor_on_folder_email_complete_geary_folder_email_locally_complete (GearyFolder* _sender,
                                                                                                   GeeCollection* ids,
                                                                                                   gpointer self);
static void geary_app_conversation_monitor_on_folder_email_removed (GearyAppConversationMonitor* self,
                                                             GeeCollection* removed);
static void _geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_removed (GearyFolder* _sender,
                                                                                         GeeCollection* ids,
                                                                                         gpointer self);
static void _geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_locally_removed (GearyFolder* _sender,
                                                                                                 GeeCollection* ids,
                                                                                                 gpointer self);
static void geary_app_conversation_monitor_on_folder_opened (GearyAppConversationMonitor* self,
                                                      GearyFolderOpenState state,
                                                      gint count);
static void _geary_app_conversation_monitor_on_folder_opened_geary_folder_opened (GearyFolder* _sender,
                                                                           GearyFolderOpenState state,
                                                                           gint count,
                                                                           gpointer self);
static void geary_app_conversation_monitor_on_account_email_appended (GearyAppConversationMonitor* self,
                                                               GearyFolder* folder,
                                                               GeeCollection* added);
static void _geary_app_conversation_monitor_on_account_email_appended_geary_account_email_appended (GearyAccount* _sender,
                                                                                             GearyFolder* folder,
                                                                                             GeeCollection* ids,
                                                                                             gpointer self);
static void geary_app_conversation_monitor_on_account_email_inserted (GearyAppConversationMonitor* self,
                                                               GearyFolder* folder,
                                                               GeeCollection* inserted);
static void _geary_app_conversation_monitor_on_account_email_inserted_geary_account_email_inserted (GearyAccount* _sender,
                                                                                             GearyFolder* folder,
                                                                                             GeeCollection* ids,
                                                                                             gpointer self);
static void geary_app_conversation_monitor_on_account_email_complete (GearyAppConversationMonitor* self,
                                                               GearyFolder* folder,
                                                               GeeCollection* inserted);
static void _geary_app_conversation_monitor_on_account_email_complete_geary_account_email_locally_complete (GearyAccount* _sender,
                                                                                                     GearyFolder* folder,
                                                                                                     GeeCollection* ids,
                                                                                                     gpointer self);
static void geary_app_conversation_monitor_on_account_email_removed (GearyAppConversationMonitor* self,
                                                              GearyFolder* folder,
                                                              GeeCollection* removed);
static void _geary_app_conversation_monitor_on_account_email_removed_geary_account_email_removed (GearyAccount* _sender,
                                                                                           GearyFolder* folder,
                                                                                           GeeCollection* ids,
                                                                                           gpointer self);
static void geary_app_conversation_monitor_on_account_email_flags_changed (GearyAppConversationMonitor* self,
                                                                    GearyFolder* folder,
                                                                    GeeMap* map);
static void _geary_app_conversation_monitor_on_account_email_flags_changed_geary_account_email_flags_changed (GearyAccount* _sender,
                                                                                                       GearyFolder* folder,
                                                                                                       GeeMap* map,
                                                                                                       gpointer self);
VALA_EXTERN GType geary_app_conversation_operation_get_type (void) G_GNUC_CONST ;
static void geary_app_conversation_monitor_on_operation_error (GearyAppConversationMonitor* self,
                                                        GearyAppConversationOperation* op,
                                                        GError* err);
static void _geary_app_conversation_monitor_on_operation_error_geary_app_conversation_operation_queue_operation_error (GearyAppConversationOperationQueue* _sender,
                                                                                                                GearyAppConversationOperation* op,
                                                                                                                GError* err,
                                                                                                                gpointer self);
VALA_EXTERN void geary_app_conversation_operation_queue_add (GearyAppConversationOperationQueue* self,
                                                 GearyAppConversationOperation* op);
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 GType geary_app_fill_window_operation_get_type (void) G_GNUC_CONST ;
static void ___lambda170_ (Block14Data* _data14_);
static void ____lambda170__g_cancellable_cancelled (GCancellable* _sender,
                                             gpointer self);
static void __lambda171_ (Block14Data* _data14_);
static void ___lambda171__g_cancellable_cancelled (GCancellable* _sender,
                                            gpointer self);
static void geary_app_conversation_monitor_start_monitoring_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static void geary_app_conversation_monitor_stop_monitoring_internal (GearyAppConversationMonitor* self,
                                                              GCancellable* cancellable,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_);
static gboolean geary_app_conversation_monitor_stop_monitoring_internal_finish (GearyAppConversationMonitor* self,
                                                                         GAsyncResult* _res_,
                                                                         GError** error);
VALA_EXTERN void geary_app_conversation_operation_queue_run_process_async (GearyAppConversationOperationQueue* self,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_operation_queue_run_process_finish (GearyAppConversationOperationQueue* self,
                                                                GAsyncResult* _res_);
static void geary_app_conversation_monitor_stop_monitoring_data_free (gpointer _data);
static gboolean geary_app_conversation_monitor_stop_monitoring_co (GearyAppConversationMonitorStopMonitoringData* _data_);
static void geary_app_conversation_monitor_stop_monitoring_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
static void geary_app_conversation_monitor_load_email_data_free (gpointer _data);
static gboolean geary_app_conversation_monitor_load_email_co (GearyAppConversationMonitorLoadEmailData* _data_);
static gboolean __lambda172_ (GearyAppConversationMonitor* self,
                       GearyEmailIdentifier* id);
VALA_EXTERN GearyAppConversation* geary_app_conversation_set_get_by_email_identifier (GearyAppConversationSet* self,
                                                                          GearyEmailIdentifier* id);
static gboolean ___lambda172__gee_predicate (gconstpointer g,
                                      gpointer self);
static gint ___lambda173_ (GearyAppConversationMonitor* self,
                    GearyEmailIdentifier* a,
                    GearyEmailIdentifier* b);
static gint ____lambda173__gcompare_data_func (gconstpointer a,
                                        gconstpointer b,
                                        gpointer self);
VALA_EXTERN GType geary_app_load_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAppLoadOperation* geary_app_load_operation_new (GearyAppConversationMonitor* monitor,
                                                     GearyEmailIdentifier* to_load,
                                                     GCancellable* cancellable);
VALA_EXTERN GearyAppLoadOperation* geary_app_load_operation_construct (GType object_type,
                                                           GearyAppConversationMonitor* monitor,
                                                           GearyEmailIdentifier* to_load,
                                                           GCancellable* cancellable);
VALA_EXTERN void geary_app_load_operation_wait_until_complete (GearyAppLoadOperation* self,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
VALA_EXTERN void geary_app_load_operation_wait_until_complete_finish (GearyAppLoadOperation* self,
                                                          GAsyncResult* _res_,
                                                          GError** error);
static void geary_app_conversation_monitor_load_email_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static GearyLoggingState* geary_app_conversation_monitor_real_to_logging_state (GearyLoggingSource* base);
VALA_EXTERN GeeCollection* geary_app_conversation_monitor_get_search_folder_blacklist (GearyAppConversationMonitor* self);
VALA_EXTERN GearyEmailFlags* geary_app_conversation_monitor_get_search_flag_blacklist (GearyAppConversationMonitor* self);
static void geary_app_conversation_monitor_load_by_id_async_data_free (gpointer _data);
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);
static gboolean geary_app_conversation_monitor_load_by_id_async_co (GearyAppConversationMonitorLoadByIdAsyncData* _data_);
static void geary_app_conversation_monitor_load_by_id_async_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static GType geary_app_conversation_monitor_process_job_context_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static GearyAppConversationMonitorProcessJobContext* geary_app_conversation_monitor_process_job_context_dup (const GearyAppConversationMonitorProcessJobContext* self);
static void geary_app_conversation_monitor_process_job_context_free (GearyAppConversationMonitorProcessJobContext* self);
static void geary_app_conversation_monitor_process_job_context_copy (const GearyAppConversationMonitorProcessJobContext* self,
                                                              GearyAppConversationMonitorProcessJobContext* dest);
static void geary_app_conversation_monitor_process_job_context_destroy (GearyAppConversationMonitorProcessJobContext* self);
static void geary_app_conversation_monitor_process_email_async (GearyAppConversationMonitor* self,
                                                         GeeCollection* emails,
                                                         GearyAppConversationMonitorProcessJobContext* job,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static void geary_app_conversation_monitor_process_email_finish (GearyAppConversationMonitor* self,
                                                          GAsyncResult* _res_,
                                                          GError** error);
static void geary_app_conversation_monitor_process_job_context_init (GearyAppConversationMonitorProcessJobContext *self);
static void geary_app_conversation_monitor_load_by_sparse_id_data_free (gpointer _data);
VALA_EXTERN void geary_app_conversation_monitor_load_by_sparse_id (GearyAppConversationMonitor* self,
                                                       GeeCollection* ids,
                                                       GearyFolderListFlags flags,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_monitor_load_by_sparse_id_finish (GearyAppConversationMonitor* self,
                                                              GAsyncResult* _res_,
                                                              GError** error);
static gboolean geary_app_conversation_monitor_load_by_sparse_id_co (GearyAppConversationMonitorLoadBySparseIdData* _data_);
static void geary_app_conversation_monitor_load_by_sparse_id_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_);
static void geary_app_conversation_monitor_external_load_by_sparse_id_data_free (gpointer _data);
VALA_EXTERN void geary_app_conversation_monitor_external_load_by_sparse_id (GearyAppConversationMonitor* self,
                                                                GearyFolder* folder,
                                                                GeeCollection* ids,
                                                                GearyFolderListFlags flags,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_monitor_external_load_by_sparse_id_finish (GearyAppConversationMonitor* self,
                                                                       GAsyncResult* _res_,
                                                                       GError** error);
static gboolean geary_app_conversation_monitor_external_load_by_sparse_id_co (GearyAppConversationMonitorExternalLoadBySparseIdData* _data_);
static void geary_app_conversation_monitor_external_load_by_sparse_id_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);
static gboolean _______lambda169_ (GearyAppConversationMonitor* self,
                            GearyRFC822MessageID* id);
VALA_EXTERN gboolean geary_app_conversation_set_has_message_id (GearyAppConversationSet* self,
                                                    GearyRFC822MessageID* message_id);
static gboolean ________lambda169__gee_predicate (gconstpointer g,
                                           gpointer self);
VALA_EXTERN void geary_app_conversation_monitor_removed (GearyAppConversationMonitor* self,
                                             GeeCollection* removed,
                                             GeeMultiMap* trimmed,
                                             GeeCollection* base_folder_removed);
static void geary_app_conversation_monitor_real_notify_scan_started (GearyAppConversationMonitor* self);
static void geary_app_conversation_monitor_real_notify_scan_error (GearyAppConversationMonitor* self,
                                                            GError* err);
static void geary_app_conversation_monitor_real_notify_scan_completed (GearyAppConversationMonitor* self);
static void geary_app_conversation_monitor_real_notify_conversations_added (GearyAppConversationMonitor* self,
                                                                     GeeCollection* conversations);
static void geary_app_conversation_monitor_real_notify_conversations_removed (GearyAppConversationMonitor* self,
                                                                       GeeCollection* conversations);
static void geary_app_conversation_monitor_real_notify_conversation_appended (GearyAppConversationMonitor* self,
                                                                       GearyAppConversation* conversation,
                                                                       GeeCollection* emails);
static void geary_app_conversation_monitor_real_notify_conversation_trimmed (GearyAppConversationMonitor* self,
                                                                      GearyAppConversation* conversation,
                                                                      GeeCollection* emails);
static void geary_app_conversation_monitor_real_notify_email_flags_changed (GearyAppConversationMonitor* self,
                                                                     GearyAppConversation* conversation,
                                                                     GearyEmail* email);
static void geary_app_conversation_monitor_stop_monitoring_internal_data_free (gpointer _data);
static gboolean geary_app_conversation_monitor_stop_monitoring_internal_co (GearyAppConversationMonitorStopMonitoringInternalData* _data_);
VALA_EXTERN void geary_app_conversation_operation_queue_stop_processing_async (GearyAppConversationOperationQueue* self,
                                                                   GCancellable* cancellable,
                                                                   GAsyncReadyCallback _callback_,
                                                                   gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_operation_queue_stop_processing_finish (GearyAppConversationOperationQueue* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error);
static void geary_app_conversation_monitor_stop_monitoring_internal_ready (GObject* source_object,
                                                                    GAsyncResult* _res_,
                                                                    gpointer _user_data_);
static void geary_app_conversation_monitor_process_email_async_data_free (gpointer _data);
static gboolean geary_app_conversation_monitor_process_email_async_co (GearyAppConversationMonitorProcessEmailAsyncData* _data_);
static Block15Data* block15_data_ref (Block15Data* _data15_);
static void block15_data_unref (void * _userdata_);
static void geary_app_conversation_monitor_process_email_complete_async (GearyAppConversationMonitor* self,
                                                                  GearyAppConversationMonitorProcessJobContext* job,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
static void geary_app_conversation_monitor_process_email_complete_finish (GearyAppConversationMonitor* self,
                                                                   GAsyncResult* _res_);
static void geary_app_conversation_monitor_process_email_async_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_);
static gboolean ______lambda166_ (Block15Data* _data15_,
                           GearyRFC822MessageID* id);
static gboolean _______lambda166__gee_predicate (gconstpointer g,
                                          gpointer self);
static void geary_app_conversation_monitor_expand_conversations_async (GearyAppConversationMonitor* self,
                                                                GeeSet* needed_message_ids,
                                                                GearyAppConversationMonitorProcessJobContext* job,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
static void geary_app_conversation_monitor_expand_conversations_finish (GearyAppConversationMonitor* self,
                                                                 GAsyncResult* _res_,
                                                                 GError** error);
static void geary_app_conversation_monitor_process_email_complete_async_data_free (gpointer _data);
static gboolean geary_app_conversation_monitor_process_email_complete_async_co (GearyAppConversationMonitorProcessEmailCompleteAsyncData* _data_);
static void geary_app_conversation_monitor_process_email_complete_async_ready (GObject* source_object,
                                                                        GAsyncResult* _res_,
                                                                        gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_set_add_all_emails (GearyAppConversationSet* self,
                                                GeeCollection* emails,
                                                GeeMultiMap* id_to_paths,
                                                GeeCollection** added,
                                                GeeMultiMap** appended,
                                                GeeCollection** removed_due_to_merge);
static void geary_app_conversation_monitor_expand_conversations_async_data_free (gpointer _data);
static gboolean geary_app_conversation_monitor_expand_conversations_async_co (GearyAppConversationMonitorExpandConversationsAsyncData* _data_);
static Block16Data* block16_data_ref (Block16Data* _data16_);
static void block16_data_unref (void * _userdata_);
static void geary_app_conversation_monitor_expand_conversations_async_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);
VALA_EXTERN GearyAppLocalSearchOperation* geary_app_local_search_operation_new (GearyAccount* account,
                                                                    GearyRFC822MessageID* message_id,
                                                                    GearyEmailField required_fields,
                                                                    GeeCollection* blacklist,
                                                                    GearyEmailFlags* flag_blacklist);
VALA_EXTERN GearyAppLocalSearchOperation* geary_app_local_search_operation_construct (GType object_type,
                                                                          GearyAccount* account,
                                                                          GearyRFC822MessageID* message_id,
                                                                          GearyEmailField required_fields,
                                                                          GeeCollection* blacklist,
                                                                          GearyEmailFlags* flag_blacklist);
VALA_EXTERN GType geary_app_local_search_operation_get_type (void) G_GNUC_CONST ;
static gboolean _____lambda167_ (Block16Data* _data16_,
                          GearyEmail* e);
static gboolean ______lambda167__gee_predicate (gconstpointer g,
                                         gpointer self);
static GearyEmailIdentifier* _____lambda168_ (GearyAppConversationMonitor* self,
                                       GearyEmail* e);
static gpointer ______lambda168__gee_map_func (gpointer g,
                                        gpointer self);
VALA_EXTERN GearyAppReseedOperation* geary_app_reseed_operation_new (GearyAppConversationMonitor* monitor);
VALA_EXTERN GearyAppReseedOperation* geary_app_reseed_operation_construct (GType object_type,
                                                               GearyAppConversationMonitor* monitor);
VALA_EXTERN GType geary_app_reseed_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAppAppendOperation* geary_app_append_operation_new (GearyAppConversationMonitor* monitor,
                                                         GeeCollection* appended_ids);
VALA_EXTERN GearyAppAppendOperation* geary_app_append_operation_construct (GType object_type,
                                                               GearyAppConversationMonitor* monitor,
                                                               GeeCollection* appended_ids);
VALA_EXTERN GType geary_app_batch_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_app_append_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAppInsertOperation* geary_app_insert_operation_new (GearyAppConversationMonitor* monitor,
                                                         GeeCollection* inserted_ids);
VALA_EXTERN GearyAppInsertOperation* geary_app_insert_operation_construct (GType object_type,
                                                               GearyAppConversationMonitor* monitor,
                                                               GeeCollection* inserted_ids);
VALA_EXTERN GType geary_app_insert_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAppRemoveOperation* geary_app_remove_operation_new (GearyAppConversationMonitor* monitor,
                                                         GearyFolder* source_folder,
                                                         GeeCollection* removed_ids);
VALA_EXTERN GearyAppRemoveOperation* geary_app_remove_operation_construct (GType object_type,
                                                               GearyAppConversationMonitor* monitor,
                                                               GearyFolder* source_folder,
                                                               GeeCollection* removed_ids);
VALA_EXTERN GType geary_app_remove_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAppExternalAppendOperation* geary_app_external_append_operation_new (GearyAppConversationMonitor* monitor,
                                                                          GearyFolder* folder,
                                                                          GeeCollection* appended_ids);
VALA_EXTERN GearyAppExternalAppendOperation* geary_app_external_append_operation_construct (GType object_type,
                                                                                GearyAppConversationMonitor* monitor,
                                                                                GearyFolder* folder,
                                                                                GeeCollection* appended_ids);
VALA_EXTERN GType geary_app_external_append_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_app_conversation_set_remove_conversation (GearyAppConversationSet* self,
                                                     GearyAppConversation* conversation);
static void geary_app_conversation_monitor_finalize (GObject * obj);
static GType geary_app_conversation_monitor_get_type_once (void);
static void _vala_geary_app_conversation_monitor_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void _vala_geary_app_conversation_monitor_set_property (GObject * object,
                                                        guint property_id,
                                                        const GValue * value,
                                                        GParamSpec * pspec);

static inline gpointer
geary_app_conversation_monitor_get_instance_private (GearyAppConversationMonitor* self)
{
	return G_STRUCT_MEMBER_P (self, GearyAppConversationMonitor_private_offset);
}

GeeSet*
geary_app_conversation_monitor_get_read_only_view (GearyAppConversationMonitor* self)
{
	GeeSet* result;
	GearyAppConversationSet* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	_tmp0_ = self->priv->_conversations;
	_tmp1_ = geary_app_conversation_set_get_read_only_view (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

gint
geary_app_conversation_monitor_get_size (GearyAppConversationMonitor* self)
{
	gint result;
	GearyAppConversationSet* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), -1);
	_tmp0_ = self->priv->_conversations;
	_tmp1_ = geary_app_conversation_set_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

GearyFolder*
geary_app_conversation_monitor_get_base_folder (GearyAppConversationMonitor* self)
{
	GearyFolder* result;
	GearyFolder* _tmp0_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	_tmp0_ = self->priv->_base_folder;
	result = _tmp0_;
	return result;
}

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

static void
geary_app_conversation_monitor_set_base_folder (GearyAppConversationMonitor* self,
                                                GearyFolder* value)
{
	GearyFolder* old_value;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	old_value = geary_app_conversation_monitor_get_base_folder (self);
	if (old_value != value) {
		GearyFolder* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_base_folder);
		self->priv->_base_folder = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_BASE_FOLDER_PROPERTY]);
	}
}

gboolean
geary_app_conversation_monitor_get_is_monitoring (GearyAppConversationMonitor* self)
{
	gboolean result;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), FALSE);
	result = self->priv->_is_monitoring;
	return result;
}

static void
geary_app_conversation_monitor_set_is_monitoring (GearyAppConversationMonitor* self,
                                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	old_value = geary_app_conversation_monitor_get_is_monitoring (self);
	if (old_value != value) {
		self->priv->_is_monitoring = value;
		g_object_notify_by_pspec ((GObject *) self, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_IS_MONITORING_PROPERTY]);
	}
}

gboolean
geary_app_conversation_monitor_get_should_load_more (GearyAppConversationMonitor* self)
{
	gboolean result;
	GearyAppConversationSet* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), FALSE);
	_tmp0_ = self->priv->_conversations;
	_tmp1_ = geary_app_conversation_set_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = geary_app_conversation_monitor_get_min_window_count (self);
	_tmp4_ = _tmp3_;
	result = _tmp2_ < _tmp4_;
	return result;
}

gboolean
geary_app_conversation_monitor_get_can_load_more (GearyAppConversationMonitor* self)
{
	gboolean result;
	gboolean _tmp0_ = FALSE;
	GearyFolder* _tmp1_;
	GearyFolderProperties* _tmp2_;
	GearyFolderProperties* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	guint _tmp6_;
	guint _tmp7_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), FALSE);
	_tmp1_ = self->priv->_base_folder;
	_tmp2_ = geary_folder_get_properties (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_folder_properties_get_email_total (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = geary_app_conversation_monitor_get_folder_window_size (self);
	_tmp7_ = _tmp6_;
	if (((guint) _tmp5_) > _tmp7_) {
		gboolean _tmp8_;
		_tmp8_ = self->priv->_fill_complete;
		_tmp0_ = !_tmp8_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

gint
geary_app_conversation_monitor_get_min_window_count (GearyAppConversationMonitor* self)
{
	gint result;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), -1);
	result = self->priv->_min_window_count;
	return result;
}

void
geary_app_conversation_monitor_set_min_window_count (GearyAppConversationMonitor* self,
                                                     gint value)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	self->priv->_min_window_count = value;
	geary_app_conversation_monitor_check_window_count (self);
	g_object_notify_by_pspec ((GObject *) self, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_MIN_WINDOW_COUNT_PROPERTY]);
}

GearyProgressMonitor*
geary_app_conversation_monitor_get_progress_monitor (GearyAppConversationMonitor* self)
{
	GearyProgressMonitor* result;
	GearyProgressMonitor* _tmp0_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	_tmp0_ = self->priv->_progress_monitor;
	result = _tmp0_;
	return result;
}

static void
geary_app_conversation_monitor_set_progress_monitor (GearyAppConversationMonitor* self,
                                                     GearyProgressMonitor* value)
{
	GearyProgressMonitor* old_value;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	old_value = geary_app_conversation_monitor_get_progress_monitor (self);
	if (old_value != value) {
		GearyProgressMonitor* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_progress_monitor);
		self->priv->_progress_monitor = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_PROGRESS_MONITOR_PROPERTY]);
	}
}

static const gchar*
geary_app_conversation_monitor_real_get_logging_domain (GearyLoggingSource* base)
{
	const gchar* result;
	GearyAppConversationMonitor* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_APP_TYPE_CONVERSATION_MONITOR, GearyAppConversationMonitor);
	result = GEARY_APP_CONVERSATION_MONITOR_LOGGING_DOMAIN;
	return result;
}

static GearyLoggingSource*
geary_app_conversation_monitor_real_get_logging_parent (GearyLoggingSource* base)
{
	GearyLoggingSource* result;
	GearyAppConversationMonitor* self;
	GearyFolder* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_APP_TYPE_CONVERSATION_MONITOR, GearyAppConversationMonitor);
	_tmp0_ = self->priv->_base_folder;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource);
	return result;
}

GearyAppConversationSet*
geary_app_conversation_monitor_get_conversations (GearyAppConversationMonitor* self)
{
	GearyAppConversationSet* result;
	GearyAppConversationSet* _tmp0_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	_tmp0_ = self->priv->_conversations;
	result = _tmp0_;
	return result;
}

static void
geary_app_conversation_monitor_set_conversations (GearyAppConversationMonitor* self,
                                                  GearyAppConversationSet* value)
{
	GearyAppConversationSet* old_value;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	old_value = geary_app_conversation_monitor_get_conversations (self);
	if (old_value != value) {
		GearyAppConversationSet* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_conversations);
		self->priv->_conversations = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_PROPERTY]);
	}
}

guint
geary_app_conversation_monitor_get_folder_window_size (GearyAppConversationMonitor* self)
{
	guint result;
	gint _tmp0_ = 0;
	GeeSortedSet* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), 0U);
	_tmp1_ = self->priv->window;
	_tmp2_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		_tmp0_ = 0;
	} else {
		GeeSortedSet* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		_tmp4_ = self->priv->window;
		_tmp5_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	}
	result = (guint) _tmp0_;
	return result;
}

GearyEmailIdentifier*
geary_app_conversation_monitor_get_window_lowest (GearyAppConversationMonitor* self)
{
	GearyEmailIdentifier* result;
	GearyEmailIdentifier* _tmp0_ = NULL;
	GeeSortedSet* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GearyEmailIdentifier* _tmp6_;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	_tmp1_ = self->priv->window;
	_tmp2_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		_g_object_unref0 (_tmp0_);
		_tmp0_ = NULL;
	} else {
		GeeSortedSet* _tmp4_;
		gpointer _tmp5_;
		_tmp4_ = self->priv->window;
		_tmp5_ = gee_sorted_set_first (_tmp4_);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = (GearyEmailIdentifier*) _tmp5_;
	}
	_tmp6_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp6_;
	_g_object_unref0 (_tmp0_);
	return result;
}

gboolean
geary_app_conversation_monitor_get_fill_complete (GearyAppConversationMonitor* self)
{
	gboolean result;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), FALSE);
	result = self->priv->_fill_complete;
	return result;
}

void
geary_app_conversation_monitor_set_fill_complete (GearyAppConversationMonitor* self,
                                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	old_value = geary_app_conversation_monitor_get_fill_complete (self);
	if (old_value != value) {
		self->priv->_fill_complete = value;
		g_object_notify_by_pspec ((GObject *) self, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_FILL_COMPLETE_PROPERTY]);
	}
}

static gint
_geary_app_conversation_monitor_window_lambda165_ (GearyEmailIdentifier* a,
                                                   GearyEmailIdentifier* b)
{
	gint result;
	g_return_val_if_fail (GEARY_IS_EMAIL_IDENTIFIER (a), -1);
	g_return_val_if_fail (GEARY_IS_EMAIL_IDENTIFIER (b), -1);
	result = geary_email_identifier_natural_sort_comparator (a, b);
	return result;
}

static gint
__geary_app_conversation_monitor_window_lambda165__gcompare_data_func (gconstpointer a,
                                                                       gconstpointer b,
                                                                       gpointer self)
{
	gint result;
	result = _geary_app_conversation_monitor_window_lambda165_ ((GearyEmailIdentifier*) a, (GearyEmailIdentifier*) b);
	return result;
}

static void
geary_app_conversation_monitor_real_scan_started (GearyAppConversationMonitor* self)
{
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "scan_started");
}

static void
geary_app_conversation_monitor_real_scan_completed (GearyAppConversationMonitor* self)
{
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "scan_completed");
}

static void
geary_app_conversation_monitor_real_scan_error (GearyAppConversationMonitor* self,
                                                GError* err)
{
	const gchar* _tmp0_;
	g_return_if_fail (err != NULL);
	_tmp0_ = err->message;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "scan_error: %s", _tmp0_);
}

static void
geary_app_conversation_monitor_real_conversations_added (GearyAppConversationMonitor* self,
                                                         GeeCollection* conversations)
{
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	_tmp0_ = gee_collection_get_size (conversations);
	_tmp1_ = _tmp0_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "conversations_added: %d", _tmp1_);
}

static void
geary_app_conversation_monitor_real_conversations_removed (GearyAppConversationMonitor* self,
                                                           GeeCollection* conversations)
{
	gint _tmp0_;
	gint _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	_tmp0_ = gee_collection_get_size (conversations);
	_tmp1_ = _tmp0_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "conversations_removed: %d", _tmp1_);
}

static void
geary_app_conversation_monitor_real_conversation_appended (GearyAppConversationMonitor* self,
                                                           GearyAppConversation* conversation,
                                                           GeeCollection* email)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION (conversation));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, GEE_TYPE_COLLECTION));
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "conversation_appended");
}

static void
g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                             GValue * return_value,
                                             guint n_param_values,
                                             const GValue * param_values,
                                             gpointer invocation_hint,
                                             gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_OBJECT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), data2);
}

static void
geary_app_conversation_monitor_real_conversation_trimmed (GearyAppConversationMonitor* self,
                                                          GearyAppConversation* conversation,
                                                          GeeCollection* email)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION (conversation));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, GEE_TYPE_COLLECTION));
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "conversation_trimmed");
}

static void
geary_app_conversation_monitor_real_email_flags_changed (GearyAppConversationMonitor* self,
                                                         GearyAppConversation* conversation,
                                                         GearyEmail* email)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION (conversation));
	g_return_if_fail (GEARY_IS_EMAIL (email));
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "email_flag_changed");
}

/**
     * Creates a conversation monitor for the given folder.
     *
     * @param base_folder a Folder to monitor for conversations
     * @param required_fields See {@link Geary.Folder}
     * @param min_window_count Minimum number of conversations that will be loaded
     */
GearyAppConversationMonitor*
geary_app_conversation_monitor_construct (GType object_type,
                                          GearyFolder* base_folder,
                                          GearyEmailField required_fields,
                                          gint min_window_count)
{
	GearyAppConversationMonitor * self = NULL;
	GearyAppConversationSet* _tmp0_;
	GearyAppConversationSet* _tmp1_;
	GCancellable* _tmp2_;
	GearyProgressMonitor* _tmp3_;
	GearyAppConversationOperationQueue* _tmp4_;
	g_return_val_if_fail (GEARY_IS_FOLDER (base_folder), NULL);
	self = (GearyAppConversationMonitor*) geary_base_object_construct (object_type);
	geary_app_conversation_monitor_set_base_folder (self, base_folder);
	self->priv->required_fields = required_fields | GEARY_APP_CONVERSATION_MONITOR_REQUIRED_FIELDS;
	self->priv->_min_window_count = min_window_count;
	_tmp0_ = geary_app_conversation_set_new (base_folder);
	_tmp1_ = _tmp0_;
	geary_app_conversation_monitor_set_conversations (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = g_cancellable_new ();
	_g_object_unref0 (self->priv->operation_cancellable);
	self->priv->operation_cancellable = _tmp2_;
	_tmp3_ = self->priv->_progress_monitor;
	_tmp4_ = geary_app_conversation_operation_queue_new (_tmp3_);
	_g_object_unref0 (self->priv->queue);
	self->priv->queue = _tmp4_;
	return self;
}

GearyAppConversationMonitor*
geary_app_conversation_monitor_new (GearyFolder* base_folder,
                                    GearyEmailField required_fields,
                                    gint min_window_count)
{
	return geary_app_conversation_monitor_construct (GEARY_APP_TYPE_CONVERSATION_MONITOR, base_folder, required_fields, min_window_count);
}

static void
geary_app_conversation_monitor_start_monitoring_data_free (gpointer _data)
{
	GearyAppConversationMonitorStartMonitoringData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorStartMonitoringData, _data_);
}

void
geary_app_conversation_monitor_start_monitoring (GearyAppConversationMonitor* self,
                                                 GearyFolderOpenFlags open_flags,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	GearyAppConversationMonitorStartMonitoringData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyAppConversationMonitorStartMonitoringData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_start_monitoring_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->open_flags = open_flags;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_app_conversation_monitor_start_monitoring_co (_data_);
}

gboolean
geary_app_conversation_monitor_start_monitoring_finish (GearyAppConversationMonitor* self,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	gboolean result;
	GearyAppConversationMonitorStartMonitoringData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

/**
     * Opens the base folder scans and starts monitoring conversations.
     *
     * This method will open the base folder, start a scan to load
     * conversations from it, and starts monitoring the folder and
     * account for messages being added or removed.
     *
     * The //cancellable// parameter will be used when opening the
     * folder, but not subsequently when scanning for new messages. To
     * cancel any such operations, simply close the monitor via {@link
     * stop_monitoring}.
     *
     * @param open_flags See {@link Geary.Folder}
     * @param cancellable Passed to the folder open operation
     */
static Block14Data*
block14_data_ref (Block14Data* _data14_)
{
	g_atomic_int_inc (&_data14_->_ref_count_);
	return _data14_;
}

static void
block14_data_unref (void * _userdata_)
{
	Block14Data* _data14_;
	_data14_ = (Block14Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data14_->_ref_count_)) {
		GearyAppConversationMonitor* self;
		self = _data14_->self;
		_g_object_unref0 (_data14_->opening);
		_g_object_unref0 (self);
		g_slice_free (Block14Data, _data14_);
	}
}

static void
_geary_app_conversation_monitor_on_folder_email_appended_geary_folder_email_appended (GearyFolder* _sender,
                                                                                      GeeCollection* ids,
                                                                                      gpointer self)
{
	geary_app_conversation_monitor_on_folder_email_appended ((GearyAppConversationMonitor*) self, ids);
}

static void
_geary_app_conversation_monitor_on_folder_email_inserted_geary_folder_email_inserted (GearyFolder* _sender,
                                                                                      GeeCollection* ids,
                                                                                      gpointer self)
{
	geary_app_conversation_monitor_on_folder_email_inserted ((GearyAppConversationMonitor*) self, ids);
}

static void
_geary_app_conversation_monitor_on_folder_email_complete_geary_folder_email_locally_complete (GearyFolder* _sender,
                                                                                              GeeCollection* ids,
                                                                                              gpointer self)
{
	geary_app_conversation_monitor_on_folder_email_complete ((GearyAppConversationMonitor*) self, ids);
}

static void
_geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_removed (GearyFolder* _sender,
                                                                                    GeeCollection* ids,
                                                                                    gpointer self)
{
	geary_app_conversation_monitor_on_folder_email_removed ((GearyAppConversationMonitor*) self, ids);
}

static void
_geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_locally_removed (GearyFolder* _sender,
                                                                                            GeeCollection* ids,
                                                                                            gpointer self)
{
	geary_app_conversation_monitor_on_folder_email_removed ((GearyAppConversationMonitor*) self, ids);
}

static void
_geary_app_conversation_monitor_on_folder_opened_geary_folder_opened (GearyFolder* _sender,
                                                                      GearyFolderOpenState state,
                                                                      gint count,
                                                                      gpointer self)
{
	geary_app_conversation_monitor_on_folder_opened ((GearyAppConversationMonitor*) self, state, count);
}

static void
_geary_app_conversation_monitor_on_account_email_appended_geary_account_email_appended (GearyAccount* _sender,
                                                                                        GearyFolder* folder,
                                                                                        GeeCollection* ids,
                                                                                        gpointer self)
{
	geary_app_conversation_monitor_on_account_email_appended ((GearyAppConversationMonitor*) self, folder, ids);
}

static void
_geary_app_conversation_monitor_on_account_email_inserted_geary_account_email_inserted (GearyAccount* _sender,
                                                                                        GearyFolder* folder,
                                                                                        GeeCollection* ids,
                                                                                        gpointer self)
{
	geary_app_conversation_monitor_on_account_email_inserted ((GearyAppConversationMonitor*) self, folder, ids);
}

static void
_geary_app_conversation_monitor_on_account_email_complete_geary_account_email_locally_complete (GearyAccount* _sender,
                                                                                                GearyFolder* folder,
                                                                                                GeeCollection* ids,
                                                                                                gpointer self)
{
	geary_app_conversation_monitor_on_account_email_complete ((GearyAppConversationMonitor*) self, folder, ids);
}

static void
_geary_app_conversation_monitor_on_account_email_removed_geary_account_email_removed (GearyAccount* _sender,
                                                                                      GearyFolder* folder,
                                                                                      GeeCollection* ids,
                                                                                      gpointer self)
{
	geary_app_conversation_monitor_on_account_email_removed ((GearyAppConversationMonitor*) self, folder, ids);
}

static void
_geary_app_conversation_monitor_on_account_email_flags_changed_geary_account_email_flags_changed (GearyAccount* _sender,
                                                                                                  GearyFolder* folder,
                                                                                                  GeeMap* map,
                                                                                                  gpointer self)
{
	geary_app_conversation_monitor_on_account_email_flags_changed ((GearyAppConversationMonitor*) self, folder, map);
}

static void
_geary_app_conversation_monitor_on_operation_error_geary_app_conversation_operation_queue_operation_error (GearyAppConversationOperationQueue* _sender,
                                                                                                           GearyAppConversationOperation* op,
                                                                                                           GError* err,
                                                                                                           gpointer self)
{
	geary_app_conversation_monitor_on_operation_error ((GearyAppConversationMonitor*) self, op, err);
}

static void
___lambda170_ (Block14Data* _data14_)
{
	GearyAppConversationMonitor* self;
	GCancellable* _tmp0_;
	self = _data14_->self;
	_tmp0_ = _data14_->opening;
	g_cancellable_cancel (_tmp0_);
}

static void
____lambda170__g_cancellable_cancelled (GCancellable* _sender,
                                        gpointer self)
{
	___lambda170_ (self);
}

static void
__lambda171_ (Block14Data* _data14_)
{
	GearyAppConversationMonitor* self;
	GCancellable* _tmp0_;
	self = _data14_->self;
	_tmp0_ = _data14_->opening;
	g_cancellable_cancel (_tmp0_);
}

static void
___lambda171__g_cancellable_cancelled (GCancellable* _sender,
                                       gpointer self)
{
	__lambda171_ (self);
}

static void
geary_app_conversation_monitor_start_monitoring_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	GearyAppConversationMonitorStartMonitoringData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_start_monitoring_co (_data_);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

static gboolean
geary_app_conversation_monitor_start_monitoring_co (GearyAppConversationMonitorStartMonitoringData* _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_->_data14_ = g_slice_new0 (Block14Data);
	_data_->_data14_->_ref_count_ = 1;
	_data_->_data14_->self = g_object_ref (_data_->self);
	_data_->_data14_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->_is_monitoring;
	if (_data_->_tmp0_) {
		_data_->result = FALSE;
		block14_data_unref (_data_->_data14_);
		_data_->_data14_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	geary_app_conversation_monitor_set_is_monitoring (_data_->self, TRUE);
	_data_->self->priv->base_was_opened = FALSE;
	_data_->_tmp1_ = _data_->self->priv->_base_folder;
	g_signal_connect_object (_data_->_tmp1_, "email-appended", (GCallback) _geary_app_conversation_monitor_on_folder_email_appended_geary_folder_email_appended, _data_->self, 0);
	_data_->_tmp2_ = _data_->self->priv->_base_folder;
	g_signal_connect_object (_data_->_tmp2_, "email-inserted", (GCallback) _geary_app_conversation_monitor_on_folder_email_inserted_geary_folder_email_inserted, _data_->self, 0);
	_data_->_tmp3_ = _data_->self->priv->_base_folder;
	g_signal_connect_object (_data_->_tmp3_, "email-locally-complete", (GCallback) _geary_app_conversation_monitor_on_folder_email_complete_geary_folder_email_locally_complete, _data_->self, 0);
	_data_->_tmp4_ = _data_->self->priv->_base_folder;
	g_signal_connect_object (_data_->_tmp4_, "email-removed", (GCallback) _geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_removed, _data_->self, 0);
	_data_->_tmp5_ = _data_->self->priv->_base_folder;
	g_signal_connect_object (_data_->_tmp5_, "email-locally-removed", (GCallback) _geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_locally_removed, _data_->self, 0);
	_data_->_tmp6_ = _data_->self->priv->_base_folder;
	g_signal_connect_object (_data_->_tmp6_, "opened", (GCallback) _geary_app_conversation_monitor_on_folder_opened_geary_folder_opened, _data_->self, 0);
	_data_->_tmp7_ = _data_->self->priv->_base_folder;
	_data_->_tmp8_ = geary_folder_get_account (_data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	g_signal_connect_object (_data_->_tmp9_, "email-appended", (GCallback) _geary_app_conversation_monitor_on_account_email_appended_geary_account_email_appended, _data_->self, 0);
	_data_->_tmp10_ = _data_->self->priv->_base_folder;
	_data_->_tmp11_ = geary_folder_get_account (_data_->_tmp10_);
	_data_->_tmp12_ = _data_->_tmp11_;
	g_signal_connect_object (_data_->_tmp12_, "email-inserted", (GCallback) _geary_app_conversation_monitor_on_account_email_inserted_geary_account_email_inserted, _data_->self, 0);
	_data_->_tmp13_ = _data_->self->priv->_base_folder;
	_data_->_tmp14_ = geary_folder_get_account (_data_->_tmp13_);
	_data_->_tmp15_ = _data_->_tmp14_;
	g_signal_connect_object (_data_->_tmp15_, "email-locally-complete", (GCallback) _geary_app_conversation_monitor_on_account_email_complete_geary_account_email_locally_complete, _data_->self, 0);
	_data_->_tmp16_ = _data_->self->priv->_base_folder;
	_data_->_tmp17_ = geary_folder_get_account (_data_->_tmp16_);
	_data_->_tmp18_ = _data_->_tmp17_;
	g_signal_connect_object (_data_->_tmp18_, "email-removed", (GCallback) _geary_app_conversation_monitor_on_account_email_removed_geary_account_email_removed, _data_->self, 0);
	_data_->_tmp19_ = _data_->self->priv->_base_folder;
	_data_->_tmp20_ = geary_folder_get_account (_data_->_tmp19_);
	_data_->_tmp21_ = _data_->_tmp20_;
	g_signal_connect_object (_data_->_tmp21_, "email-flags-changed", (GCallback) _geary_app_conversation_monitor_on_account_email_flags_changed_geary_account_email_flags_changed, _data_->self, 0);
	_data_->_tmp22_ = _data_->self->priv->queue;
	g_signal_connect_object (_data_->_tmp22_, "operation-error", (GCallback) _geary_app_conversation_monitor_on_operation_error_geary_app_conversation_operation_queue_operation_error, _data_->self, 0);
	_data_->_tmp23_ = _data_->self->priv->queue;
	_data_->_tmp24_ = geary_app_fill_window_operation_new (_data_->self);
	_data_->_tmp25_ = _data_->_tmp24_;
	geary_app_conversation_operation_queue_add (_data_->_tmp23_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp25_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
	_g_object_unref0 (_data_->_tmp25_);
	_data_->_tmp26_ = g_cancellable_new ();
	_data_->_data14_->opening = _data_->_tmp26_;
	if (_data_->cancellable != NULL) {
		g_signal_connect_data (_data_->cancellable, "cancelled", (GCallback) ____lambda170__g_cancellable_cancelled, block14_data_ref (_data_->_data14_), (GClosureNotify) block14_data_unref, 0);
	}
	_data_->_tmp27_ = _data_->self->priv->operation_cancellable;
	g_signal_connect_data (_data_->_tmp27_, "cancelled", (GCallback) ___lambda171__g_cancellable_cancelled, block14_data_ref (_data_->_data14_), (GClosureNotify) block14_data_unref, 0);
	{
		_data_->_tmp28_ = _data_->self->priv->_base_folder;
		_data_->_tmp29_ = _data_->_data14_->opening;
		_data_->_state_ = 1;
		geary_folder_open_async (_data_->_tmp28_, _data_->open_flags, _data_->_tmp29_, geary_app_conversation_monitor_start_monitoring_ready, _data_);
		return FALSE;
		_state_1:
		geary_folder_open_finish (_data_->_tmp28_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->self->priv->base_was_opened = TRUE;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp30_ = _data_->self->priv->_is_monitoring;
		if (_data_->_tmp30_) {
			{
				_data_->_state_ = 2;
				geary_app_conversation_monitor_stop_monitoring_internal (_data_->self, NULL, geary_app_conversation_monitor_start_monitoring_ready, _data_);
				return FALSE;
				_state_2:
				geary_app_conversation_monitor_stop_monitoring_internal_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				g_clear_error (&_data_->_inner_error0_);
				_data_->_tmp31_ = _data_->err;
				_data_->_tmp32_ = _data_->_tmp31_->message;
				geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error cleaning up after folder open error: %s", _data_->_tmp32_);
			}
			__finally1:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_error_free0 (_data_->err);
				block14_data_unref (_data_->_data14_);
				_data_->_data14_ = NULL;
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
				g_clear_error (&_data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
		geary_app_conversation_monitor_set_is_monitoring (_data_->self, FALSE);
		_data_->_tmp33_ = _data_->err;
		_data_->_tmp34_ = _g_error_copy0 (_data_->_tmp33_);
		_data_->_inner_error0_ = _data_->_tmp34_;
		_g_error_free0 (_data_->err);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		block14_data_unref (_data_->_data14_);
		_data_->_data14_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp35_ = _data_->self->priv->_is_monitoring;
	if (_data_->_tmp35_) {
		_data_->_tmp36_ = _data_->self->priv->queue;
		geary_app_conversation_operation_queue_run_process_async (_data_->_tmp36_, NULL, NULL);
	}
	_data_->result = TRUE;
	block14_data_unref (_data_->_data14_);
	_data_->_data14_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
geary_app_conversation_monitor_stop_monitoring_data_free (gpointer _data)
{
	GearyAppConversationMonitorStopMonitoringData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorStopMonitoringData, _data_);
}

void
geary_app_conversation_monitor_stop_monitoring (GearyAppConversationMonitor* self,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	GearyAppConversationMonitorStopMonitoringData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyAppConversationMonitorStopMonitoringData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_stop_monitoring_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_app_conversation_monitor_stop_monitoring_co (_data_);
}

gboolean
geary_app_conversation_monitor_stop_monitoring_finish (GearyAppConversationMonitor* self,
                                                       GAsyncResult* _res_,
                                                       GError** error)
{
	gboolean result;
	GearyAppConversationMonitorStopMonitoringData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

/**
     * Stops monitoring for new messages and closes the base folder.
     *
     * Returns a result code that is semantically identical to the
     * result of {@link Geary.Folder.close_async}.
     *
     * The //cancellable// parameter will be used when waiting for
     * internal monitor operations to complete, but will not prevent
     * attempts to close the base folder.
     */
static void
geary_app_conversation_monitor_stop_monitoring_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	GearyAppConversationMonitorStopMonitoringData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_stop_monitoring_co (_data_);
}

static gboolean
geary_app_conversation_monitor_stop_monitoring_co (GearyAppConversationMonitorStopMonitoringData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->is_closing = FALSE;
	_data_->_tmp0_ = _data_->self->priv->_is_monitoring;
	if (_data_->_tmp0_) {
		geary_app_conversation_monitor_set_is_monitoring (_data_->self, FALSE);
		_data_->_state_ = 1;
		geary_app_conversation_monitor_stop_monitoring_internal (_data_->self, _data_->cancellable, geary_app_conversation_monitor_stop_monitoring_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = geary_app_conversation_monitor_stop_monitoring_internal_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->is_closing = _data_->_tmp1_;
	}
	_data_->result = _data_->is_closing;
	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_conversation_monitor_load_email_data_free (gpointer _data)
{
	GearyAppConversationMonitorLoadEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->to_load);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorLoadEmailData, _data_);
}

void
geary_app_conversation_monitor_load_email (GearyAppConversationMonitor* self,
                                           GeeCollection* to_load,
                                           GCancellable* cancellable,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	GearyAppConversationMonitorLoadEmailData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GeeCollection* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (to_load, GEE_TYPE_COLLECTION));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyAppConversationMonitorLoadEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_load_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (to_load);
	_g_object_unref0 (_data_->to_load);
	_data_->to_load = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_app_conversation_monitor_load_email_co (_data_);
}

void
geary_app_conversation_monitor_load_email_finish (GearyAppConversationMonitor* self,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	GearyAppConversationMonitorLoadEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** Ensures the given email are loaded in the monitor. */
static gboolean
__lambda172_ (GearyAppConversationMonitor* self,
              GearyEmailIdentifier* id)
{
	GearyAppConversationSet* _tmp0_;
	GearyAppConversation* _tmp1_;
	GearyAppConversation* _tmp2_;
	gboolean _tmp3_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_EMAIL_IDENTIFIER (id), FALSE);
	_tmp0_ = self->priv->_conversations;
	_tmp1_ = geary_app_conversation_set_get_by_email_identifier (_tmp0_, id);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static gboolean
___lambda172__gee_predicate (gconstpointer g,
                             gpointer self)
{
	gboolean result;
	result = __lambda172_ ((GearyAppConversationMonitor*) self, (GearyEmailIdentifier*) g);
	return result;
}

static gint
___lambda173_ (GearyAppConversationMonitor* self,
               GearyEmailIdentifier* a,
               GearyEmailIdentifier* b)
{
	gint result;
	g_return_val_if_fail (GEARY_IS_EMAIL_IDENTIFIER (a), -1);
	g_return_val_if_fail (GEARY_IS_EMAIL_IDENTIFIER (b), -1);
	result = geary_email_identifier_natural_sort_comparator (a, b);
	return result;
}

static gint
____lambda173__gcompare_data_func (gconstpointer a,
                                   gconstpointer b,
                                   gpointer self)
{
	gint result;
	result = ___lambda173_ ((GearyAppConversationMonitor*) self, (GearyEmailIdentifier*) a, (GearyEmailIdentifier*) b);
	return result;
}

static void
geary_app_conversation_monitor_load_email_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	GearyAppConversationMonitorLoadEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_load_email_co (_data_);
}

static gboolean
geary_app_conversation_monitor_load_email_co (GearyAppConversationMonitorLoadEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_is_monitoring;
	if (!_data_->_tmp0_) {
		_data_->_tmp1_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_OPEN_REQUIRED, "Monitor is not open");
		_data_->_inner_error0_ = _data_->_tmp1_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = geary_traverse (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->to_load, GEE_TYPE_ITERABLE, GeeIterable));
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = geary_iterable_filter (_data_->_tmp3_, ___lambda172__gee_predicate, g_object_ref (_data_->self), g_object_unref);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = geary_iterable_to_array_list (_data_->_tmp5_, NULL, NULL, NULL);
	_data_->_tmp7_ = _data_->_tmp6_;
	_g_object_unref0 (_data_->_tmp5_);
	_g_object_unref0 (_data_->_tmp3_);
	_data_->remaining = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->remaining;
	_data_->_tmp9_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp10_ = _data_->_tmp9_;
	if (!_data_->_tmp10_) {
		_data_->_tmp11_ = _data_->remaining;
		gee_list_sort (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEE_TYPE_LIST, GeeList), ____lambda173__gcompare_data_func, g_object_ref (_data_->self), g_object_unref);
		_data_->_tmp12_ = _data_->remaining;
		_data_->_tmp13_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp12_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), 0);
		_data_->_tmp14_ = (GearyEmailIdentifier*) _data_->_tmp13_;
		_data_->_tmp15_ = _data_->self->priv->operation_cancellable;
		_data_->_tmp16_ = geary_app_load_operation_new (_data_->self, _data_->_tmp14_, _data_->_tmp15_);
		_data_->_tmp17_ = _data_->_tmp16_;
		_g_object_unref0 (_data_->_tmp14_);
		_data_->op = _data_->_tmp17_;
		_data_->_tmp18_ = _data_->self->priv->queue;
		_data_->_tmp19_ = _data_->op;
		geary_app_conversation_operation_queue_add (_data_->_tmp18_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp19_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_data_->_tmp20_ = _data_->op;
		_data_->_state_ = 1;
		geary_app_load_operation_wait_until_complete (_data_->_tmp20_, _data_->cancellable, geary_app_conversation_monitor_load_email_ready, _data_);
		return FALSE;
		_state_1:
		geary_app_load_operation_wait_until_complete_finish (_data_->_tmp20_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->op);
			_g_object_unref0 (_data_->remaining);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->op);
	}
	_g_object_unref0 (_data_->remaining);
	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;
}

/**
     * Returns the conversation containing the given email, if any.
     */
GearyAppConversation*
geary_app_conversation_monitor_get_by_email_identifier (GearyAppConversationMonitor* self,
                                                        GearyEmailIdentifier* email_id)
{
	GearyAppConversationSet* _tmp0_;
	GearyAppConversation* _tmp1_;
	GearyAppConversation* result;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	g_return_val_if_fail (GEARY_IS_EMAIL_IDENTIFIER (email_id), NULL);
	_tmp0_ = self->priv->_conversations;
	_tmp1_ = geary_app_conversation_set_get_by_email_identifier (_tmp0_, email_id);
	result = _tmp1_;
	return result;
}

/** {@inheritDoc} */
static gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

static GearyLoggingState*
geary_app_conversation_monitor_real_to_logging_state (GearyLoggingSource* base)
{
	GearyAppConversationMonitor * self;
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GearyLoggingState* _tmp12_;
	GearyLoggingState* _tmp13_;
	GearyLoggingState* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_APP_TYPE_CONVERSATION_MONITOR, GearyAppConversationMonitor);
	_tmp0_ = geary_app_conversation_monitor_get_size (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_app_conversation_monitor_get_min_window_count (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_app_conversation_monitor_get_can_load_more (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = bool_to_string (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = geary_app_conversation_monitor_get_should_load_more (self);
	_tmp9_ = _tmp8_;
	_tmp10_ = bool_to_string (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = geary_logging_state_new (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "size=%d, min_window_count=%u, can_load_more=%s, should_load_more=%s", _tmp1_, (guint) _tmp3_, _tmp7_, _tmp11_);
	_tmp13_ = _tmp12_;
	_g_free0 (_tmp11_);
	_g_free0 (_tmp7_);
	result = _tmp13_;
	return result;
}

/** Ensures enough conversations are present, otherwise loads more. */
void
geary_app_conversation_monitor_check_window_count (GearyAppConversationMonitor* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_tmp2_ = self->priv->_is_monitoring;
	if (_tmp2_) {
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp3_ = geary_app_conversation_monitor_get_can_load_more (self);
		_tmp4_ = _tmp3_;
		_tmp1_ = _tmp4_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp5_ = geary_app_conversation_monitor_get_should_load_more (self);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GearyAppConversationOperationQueue* _tmp7_;
		GearyAppFillWindowOperation* _tmp8_;
		GearyAppFillWindowOperation* _tmp9_;
		_tmp7_ = self->priv->queue;
		_tmp8_ = geary_app_fill_window_operation_new (self);
		_tmp9_ = _tmp8_;
		geary_app_conversation_operation_queue_add (_tmp7_, G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_g_object_unref0 (_tmp9_);
	}
}

/**
     * Returns the list of folders that disqualify emails from conversations.
     */
GeeCollection*
geary_app_conversation_monitor_get_search_folder_blacklist (GearyAppConversationMonitor* self)
{
	GearyFolderSpecialUse* blacklisted_folder_types = NULL;
	GearyFolderSpecialUse* _tmp0_;
	gint blacklisted_folder_types_length1;
	gint _blacklisted_folder_types_size_;
	GeeArrayList* blacklist = NULL;
	GeeArrayList* _tmp1_;
	GearyFolderSpecialUse* _tmp2_;
	gint _tmp2__length1;
	GeeArrayList* _tmp12_;
	GeeCollection* result;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	_tmp0_ = g_new0 (GearyFolderSpecialUse, 3);
	_tmp0_[0] = GEARY_FOLDER_SPECIAL_USE_JUNK;
	_tmp0_[1] = GEARY_FOLDER_SPECIAL_USE_TRASH;
	_tmp0_[2] = GEARY_FOLDER_SPECIAL_USE_DRAFTS;
	blacklisted_folder_types = _tmp0_;
	blacklisted_folder_types_length1 = 3;
	_blacklisted_folder_types_size_ = blacklisted_folder_types_length1;
	_tmp1_ = gee_array_list_new (GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	blacklist = _tmp1_;
	_tmp2_ = blacklisted_folder_types;
	_tmp2__length1 = blacklisted_folder_types_length1;
	{
		GearyFolderSpecialUse* type_collection = NULL;
		gint type_collection_length1 = 0;
		gint _type_collection_size_ = 0;
		gint type_it = 0;
		type_collection = _tmp2_;
		type_collection_length1 = _tmp2__length1;
		for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
			GearyFolderSpecialUse type = 0;
			type = type_collection[type_it];
			{
				GearyFolder* blacklist_folder = NULL;
				GearyFolder* _tmp3_;
				GearyAccount* _tmp4_;
				GearyAccount* _tmp5_;
				GearyFolder* _tmp6_;
				GearyFolder* _tmp7_;
				_tmp3_ = self->priv->_base_folder;
				_tmp4_ = geary_folder_get_account (_tmp3_);
				_tmp5_ = _tmp4_;
				_tmp6_ = geary_account_get_special_folder (_tmp5_, type);
				blacklist_folder = _tmp6_;
				_tmp7_ = blacklist_folder;
				if (_tmp7_ != NULL) {
					GeeArrayList* _tmp8_;
					GearyFolder* _tmp9_;
					GearyFolderPath* _tmp10_;
					GearyFolderPath* _tmp11_;
					_tmp8_ = blacklist;
					_tmp9_ = blacklist_folder;
					_tmp10_ = geary_folder_get_path (_tmp9_);
					_tmp11_ = _tmp10_;
					gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp11_);
				}
				_g_object_unref0 (blacklist_folder);
			}
		}
	}
	_tmp12_ = blacklist;
	gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), NULL);
	result = G_TYPE_CHECK_INSTANCE_CAST (blacklist, GEE_TYPE_COLLECTION, GeeCollection);
	blacklisted_folder_types = (g_free (blacklisted_folder_types), NULL);
	return result;
}

/**
     * Returns the list of flags that disqualify emails from conversations.
     */
GearyEmailFlags*
geary_app_conversation_monitor_get_search_flag_blacklist (GearyAppConversationMonitor* self)
{
	GearyEmailFlags* flags = NULL;
	GearyEmailFlags* _tmp0_;
	GearyNamedFlag* _tmp1_;
	GearyNamedFlag* _tmp2_;
	GearyNamedFlag* _tmp3_;
	GearyEmailFlags* result;
	g_return_val_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self), NULL);
	_tmp0_ = geary_email_flags_new ();
	flags = _tmp0_;
	_tmp1_ = geary_email_flags_get_DRAFT ();
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	geary_named_flags_add (G_TYPE_CHECK_INSTANCE_CAST (flags, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp3_);
	_g_object_unref0 (_tmp3_);
	result = flags;
	return result;
}

static void
geary_app_conversation_monitor_load_by_id_async_data_free (gpointer _data)
{
	GearyAppConversationMonitorLoadByIdAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->initial_id);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorLoadByIdAsyncData, _data_);
}

void
geary_app_conversation_monitor_load_by_id_async (GearyAppConversationMonitor* self,
                                                 GearyEmailIdentifier* initial_id,
                                                 gint count,
                                                 GearyFolderListFlags flags,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	GearyAppConversationMonitorLoadByIdAsyncData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail ((initial_id == NULL) || GEARY_IS_EMAIL_IDENTIFIER (initial_id));
	_data_ = g_slice_new0 (GearyAppConversationMonitorLoadByIdAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_load_by_id_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (initial_id);
	_g_object_unref0 (_data_->initial_id);
	_data_->initial_id = _tmp1_;
	_data_->count = count;
	_data_->flags = flags;
	geary_app_conversation_monitor_load_by_id_async_co (_data_);
}

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

/** Loads messages from the base folder into the window. */
static void
geary_app_conversation_monitor_load_by_id_async_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	GearyAppConversationMonitorLoadByIdAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_load_by_id_async_co (_data_);
}

static gboolean
geary_app_conversation_monitor_load_by_id_async_co (GearyAppConversationMonitorLoadByIdAsyncData* _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:
	geary_app_conversation_monitor_notify_scan_started (_data_->self);
	_data_->load_count = 0;
	_data_->scan_error = NULL;
	{
		_data_->_tmp0_ = _data_->self->priv->_base_folder;
		_data_->_tmp1_ = _data_->self->priv->operation_cancellable;
		_data_->_state_ = 1;
		geary_folder_list_email_by_id_async (_data_->_tmp0_, _data_->initial_id, _data_->count, _data_->self->priv->required_fields, _data_->flags, _data_->_tmp1_, geary_app_conversation_monitor_load_by_id_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = geary_folder_list_email_by_id_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		_data_->messages = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEE_TYPE_COLLECTION, GeeCollection);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = _data_->messages;
		if (_data_->_tmp4_ != NULL) {
			_data_->_tmp5_ = _data_->messages;
			_data_->_tmp6_ = gee_collection_get_is_empty (_data_->_tmp5_);
			_data_->_tmp7_ = _data_->_tmp6_;
			_data_->_tmp3_ = !_data_->_tmp7_;
		} else {
			_data_->_tmp3_ = FALSE;
		}
		if (_data_->_tmp3_) {
			_data_->_tmp8_ = _data_->messages;
			_data_->_tmp9_ = gee_collection_get_size (_data_->_tmp8_);
			_data_->_tmp10_ = _data_->_tmp9_;
			_data_->load_count = _data_->_tmp10_;
			{
				_data_->_tmp11_ = _data_->messages;
				_data_->_tmp12_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEE_TYPE_ITERABLE, GeeIterable));
				_data_->_email_it = _data_->_tmp12_;
				while (TRUE) {
					_data_->_tmp13_ = _data_->_email_it;
					if (!gee_iterator_next (_data_->_tmp13_)) {
						break;
					}
					_data_->_tmp14_ = _data_->_email_it;
					_data_->_tmp15_ = gee_iterator_get (_data_->_tmp14_);
					_data_->email = (GearyEmail*) _data_->_tmp15_;
					_data_->_tmp16_ = _data_->self->priv->window;
					_data_->_tmp17_ = _data_->email;
					_data_->_tmp18_ = geary_email_get_id (_data_->_tmp17_);
					_data_->_tmp19_ = _data_->_tmp18_;
					gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp16_, GEE_TYPE_COLLECTION, GeeCollection), _data_->_tmp19_);
					_g_object_unref0 (_data_->email);
				}
				_g_object_unref0 (_data_->_email_it);
			}
			_data_->_tmp20_ = _data_->messages;
			memset (&_data_->_tmp21_, 0, sizeof (GearyAppConversationMonitorProcessJobContext));
			geary_app_conversation_monitor_process_job_context_init (&_data_->_tmp21_);
			_data_->_tmp22_ = _data_->_tmp21_;
			_data_->_state_ = 2;
			geary_app_conversation_monitor_process_email_async (_data_->self, _data_->_tmp20_, &_data_->_tmp22_, geary_app_conversation_monitor_load_by_id_async_ready, _data_);
			return FALSE;
			_state_2:
			geary_app_conversation_monitor_process_email_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
			geary_app_conversation_monitor_process_job_context_destroy (&_data_->_tmp22_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->messages);
				goto __catch0_g_error;
			}
		}
		_g_object_unref0 (_data_->messages);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp23_ = _data_->err;
		_data_->_tmp24_ = _g_error_copy0 (_data_->_tmp23_);
		_g_error_free0 (_data_->scan_error);
		_data_->scan_error = _data_->_tmp24_;
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->scan_error);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	geary_app_conversation_monitor_notify_scan_completed (_data_->self);
	_data_->_tmp25_ = _data_->scan_error;
	if (_data_->_tmp25_ != NULL) {
		_data_->_tmp26_ = _data_->scan_error;
		_data_->_tmp27_ = _g_error_copy0 (_data_->_tmp26_);
		_data_->_inner_error0_ = _data_->_tmp27_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->scan_error);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->load_count;
	_g_error_free0 (_data_->scan_error);
	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_conversation_monitor_load_by_sparse_id_data_free (gpointer _data)
{
	GearyAppConversationMonitorLoadBySparseIdData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->ids);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorLoadBySparseIdData, _data_);
}

void
geary_app_conversation_monitor_load_by_sparse_id (GearyAppConversationMonitor* self,
                                                  GeeCollection* ids,
                                                  GearyFolderListFlags flags,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	GearyAppConversationMonitorLoadBySparseIdData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GeeCollection* _tmp1_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (GearyAppConversationMonitorLoadBySparseIdData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_load_by_sparse_id_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (ids);
	_g_object_unref0 (_data_->ids);
	_data_->ids = _tmp1_;
	_data_->flags = flags;
	geary_app_conversation_monitor_load_by_sparse_id_co (_data_);
}

void
geary_app_conversation_monitor_load_by_sparse_id_finish (GearyAppConversationMonitor* self,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	GearyAppConversationMonitorLoadBySparseIdData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** Loads messages from the base folder into the window. */
static void
geary_app_conversation_monitor_load_by_sparse_id_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_)
{
	GearyAppConversationMonitorLoadBySparseIdData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_load_by_sparse_id_co (_data_);
}

static gboolean
geary_app_conversation_monitor_load_by_sparse_id_co (GearyAppConversationMonitorLoadBySparseIdData* _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:
	geary_app_conversation_monitor_notify_scan_started (_data_->self);
	_data_->scan_error = NULL;
	{
		_data_->_tmp0_ = _data_->self->priv->_base_folder;
		_data_->_tmp1_ = _data_->self->priv->operation_cancellable;
		_data_->_state_ = 1;
		geary_folder_list_email_by_sparse_id_async (_data_->_tmp0_, _data_->ids, _data_->self->priv->required_fields, _data_->flags, _data_->_tmp1_, geary_app_conversation_monitor_load_by_sparse_id_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = geary_folder_list_email_by_sparse_id_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		_data_->messages = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEE_TYPE_COLLECTION, GeeCollection);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = _data_->messages;
		if (_data_->_tmp4_ != NULL) {
			_data_->_tmp5_ = _data_->messages;
			_data_->_tmp6_ = gee_collection_get_is_empty (_data_->_tmp5_);
			_data_->_tmp7_ = _data_->_tmp6_;
			_data_->_tmp3_ = !_data_->_tmp7_;
		} else {
			_data_->_tmp3_ = FALSE;
		}
		if (_data_->_tmp3_) {
			{
				_data_->_tmp8_ = _data_->messages;
				_data_->_tmp9_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_ITERABLE, GeeIterable));
				_data_->_email_it = _data_->_tmp9_;
				while (TRUE) {
					_data_->_tmp10_ = _data_->_email_it;
					if (!gee_iterator_next (_data_->_tmp10_)) {
						break;
					}
					_data_->_tmp11_ = _data_->_email_it;
					_data_->_tmp12_ = gee_iterator_get (_data_->_tmp11_);
					_data_->email = (GearyEmail*) _data_->_tmp12_;
					_data_->_tmp13_ = _data_->self->priv->window;
					_data_->_tmp14_ = _data_->email;
					_data_->_tmp15_ = geary_email_get_id (_data_->_tmp14_);
					_data_->_tmp16_ = _data_->_tmp15_;
					gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp13_, GEE_TYPE_COLLECTION, GeeCollection), _data_->_tmp16_);
					_g_object_unref0 (_data_->email);
				}
				_g_object_unref0 (_data_->_email_it);
			}
			_data_->_tmp17_ = _data_->messages;
			memset (&_data_->_tmp18_, 0, sizeof (GearyAppConversationMonitorProcessJobContext));
			geary_app_conversation_monitor_process_job_context_init (&_data_->_tmp18_);
			_data_->_tmp19_ = _data_->_tmp18_;
			_data_->_state_ = 2;
			geary_app_conversation_monitor_process_email_async (_data_->self, _data_->_tmp17_, &_data_->_tmp19_, geary_app_conversation_monitor_load_by_sparse_id_ready, _data_);
			return FALSE;
			_state_2:
			geary_app_conversation_monitor_process_email_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
			geary_app_conversation_monitor_process_job_context_destroy (&_data_->_tmp19_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->messages);
				goto __catch0_g_error;
			}
		}
		_g_object_unref0 (_data_->messages);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp20_ = _data_->err;
		_data_->_tmp21_ = _g_error_copy0 (_data_->_tmp20_);
		_g_error_free0 (_data_->scan_error);
		_data_->scan_error = _data_->_tmp21_;
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->scan_error);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	geary_app_conversation_monitor_notify_scan_completed (_data_->self);
	_data_->_tmp22_ = _data_->scan_error;
	if (_data_->_tmp22_ != NULL) {
		_data_->_tmp23_ = _data_->scan_error;
		_data_->_tmp24_ = _g_error_copy0 (_data_->_tmp23_);
		_data_->_inner_error0_ = _data_->_tmp24_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->scan_error);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_error_free0 (_data_->scan_error);
	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_conversation_monitor_external_load_by_sparse_id_data_free (gpointer _data)
{
	GearyAppConversationMonitorExternalLoadBySparseIdData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->folder);
	_g_object_unref0 (_data_->ids);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorExternalLoadBySparseIdData, _data_);
}

void
geary_app_conversation_monitor_external_load_by_sparse_id (GearyAppConversationMonitor* self,
                                                           GearyFolder* folder,
                                                           GeeCollection* ids,
                                                           GearyFolderListFlags flags,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	GearyAppConversationMonitorExternalLoadBySparseIdData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GearyFolder* _tmp1_;
	GeeCollection* _tmp2_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (GearyAppConversationMonitorExternalLoadBySparseIdData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_external_load_by_sparse_id_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (folder);
	_g_object_unref0 (_data_->folder);
	_data_->folder = _tmp1_;
	_tmp2_ = _g_object_ref0 (ids);
	_g_object_unref0 (_data_->ids);
	_data_->ids = _tmp2_;
	_data_->flags = flags;
	geary_app_conversation_monitor_external_load_by_sparse_id_co (_data_);
}

void
geary_app_conversation_monitor_external_load_by_sparse_id_finish (GearyAppConversationMonitor* self,
                                                                  GAsyncResult* _res_,
                                                                  GError** error)
{
	GearyAppConversationMonitorExternalLoadBySparseIdData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/**
     * Loads messages from outside the monitor's base folder.
     *
     * Since this requires opening and closing the other folder, it is
     * handled separately.
     */
static void
geary_app_conversation_monitor_external_load_by_sparse_id_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	GearyAppConversationMonitorExternalLoadBySparseIdData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_external_load_by_sparse_id_co (_data_);
}

static gboolean
_______lambda169_ (GearyAppConversationMonitor* self,
                   GearyRFC822MessageID* id)
{
	GearyAppConversationSet* _tmp0_;
	gboolean result;
	g_return_val_if_fail (GEARY_RF_C822_IS_MESSAGE_ID (id), FALSE);
	_tmp0_ = self->priv->_conversations;
	result = geary_app_conversation_set_has_message_id (_tmp0_, id);
	return result;
}

static gboolean
________lambda169__gee_predicate (gconstpointer g,
                                  gpointer self)
{
	gboolean result;
	result = _______lambda169_ ((GearyAppConversationMonitor*) self, (GearyRFC822MessageID*) g);
	return result;
}

static gboolean
geary_app_conversation_monitor_external_load_by_sparse_id_co (GearyAppConversationMonitorExternalLoadBySparseIdData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->opened = FALSE;
	_data_->emails = NULL;
	{
		_data_->_tmp0_ = _data_->self->priv->operation_cancellable;
		_data_->_state_ = 1;
		geary_folder_open_async (_data_->folder, GEARY_FOLDER_OPEN_FLAGS_NONE, _data_->_tmp0_, geary_app_conversation_monitor_external_load_by_sparse_id_ready, _data_);
		return FALSE;
		_state_1:
		geary_folder_open_finish (_data_->folder, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->opened = TRUE;
		_data_->_tmp2_ = _data_->self->priv->operation_cancellable;
		_data_->_state_ = 2;
		geary_folder_list_email_by_sparse_id_async (_data_->folder, _data_->ids, GEARY_EMAIL_FIELD_REFERENCES, _data_->flags, _data_->_tmp2_, geary_app_conversation_monitor_external_load_by_sparse_id_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp3_ = geary_folder_list_email_by_sparse_id_finish (_data_->folder, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp3_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		_g_object_unref0 (_data_->emails);
		_data_->emails = _data_->_tmp4_;
		_data_->_tmp5_ = _data_->emails;
		if (_data_->_tmp5_ != NULL) {
			_data_->_tmp6_ = gee_hash_set_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
			_data_->relevant_ids = _data_->_tmp6_;
			{
				_data_->_tmp7_ = _data_->emails;
				_data_->_email_list = _data_->_tmp7_;
				_data_->_tmp8_ = _data_->_email_list;
				_data_->_tmp9_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_COLLECTION, GeeCollection));
				_data_->_tmp10_ = _data_->_tmp9_;
				_data_->_email_size = _data_->_tmp10_;
				_data_->_email_index = -1;
				while (TRUE) {
					_data_->_email_index = _data_->_email_index + 1;
					_data_->_tmp11_ = _data_->_email_index;
					_data_->_tmp12_ = _data_->_email_size;
					if (!(_data_->_tmp11_ < _data_->_tmp12_)) {
						break;
					}
					_data_->_tmp13_ = _data_->_email_list;
					_data_->_tmp14_ = gee_list_get (_data_->_tmp13_, _data_->_email_index);
					_data_->email = (GearyEmail*) _data_->_tmp14_;
					_data_->_tmp15_ = _data_->email;
					_data_->_tmp16_ = geary_email_get_ancestors (_data_->_tmp15_);
					_data_->ancestors = _data_->_tmp16_;
					_data_->_tmp18_ = _data_->ancestors;
					if (_data_->_tmp18_ != NULL) {
						_data_->_tmp19_ = _data_->ancestors;
						_data_->_tmp20_ = geary_traverse (GEARY_RF_C822_TYPE_MESSAGE_ID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp19_, GEE_TYPE_ITERABLE, GeeIterable));
						_data_->_tmp21_ = _data_->_tmp20_;
						_data_->_tmp17_ = geary_iterable_any (_data_->_tmp21_, ________lambda169__gee_predicate, g_object_ref (_data_->self), g_object_unref);
						_g_object_unref0 (_data_->_tmp21_);
					} else {
						_data_->_tmp17_ = FALSE;
					}
					if (_data_->_tmp17_) {
						_data_->_tmp22_ = _data_->relevant_ids;
						_data_->_tmp23_ = _data_->email;
						_data_->_tmp24_ = geary_email_get_id (_data_->_tmp23_);
						_data_->_tmp25_ = _data_->_tmp24_;
						gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp22_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _data_->_tmp25_);
					}
					_g_object_unref0 (_data_->ancestors);
					_g_object_unref0 (_data_->email);
				}
			}
			_data_->_tmp26_ = _data_->relevant_ids;
			_data_->_tmp27_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp26_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp28_ = _data_->_tmp27_;
			if (!_data_->_tmp28_) {
				_data_->_tmp30_ = _data_->relevant_ids;
				_data_->_tmp31_ = _data_->self->priv->operation_cancellable;
				_data_->_state_ = 3;
				geary_folder_list_email_by_sparse_id_async (_data_->folder, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp30_, GEE_TYPE_COLLECTION, GeeCollection), _data_->self->priv->required_fields, _data_->flags, _data_->_tmp31_, geary_app_conversation_monitor_external_load_by_sparse_id_ready, _data_);
				return FALSE;
				_state_3:
				_data_->_tmp32_ = geary_folder_list_email_by_sparse_id_finish (_data_->folder, _data_->_res_, &_data_->_inner_error0_);
				_data_->_tmp29_ = _data_->_tmp32_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->relevant_ids);
					_g_object_unref0 (_data_->_tmp1_);
					goto __catch0_g_error;
				}
				_data_->_tmp33_ = _data_->_tmp29_;
				_data_->_tmp29_ = NULL;
				_g_object_unref0 (_data_->emails);
				_data_->emails = _data_->_tmp33_;
				_g_object_unref0 (_data_->_tmp29_);
			} else {
				_g_object_unref0 (_data_->emails);
				_data_->emails = NULL;
			}
			_g_object_unref0 (_data_->relevant_ids);
		}
		_data_->_state_ = 4;
		geary_folder_close_async (_data_->folder, NULL, geary_app_conversation_monitor_external_load_by_sparse_id_ready, _data_);
		return FALSE;
		_state_4:
		geary_folder_close_finish (_data_->folder, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->_tmp1_);
			goto __catch0_g_error;
		}
		_data_->opened = FALSE;
		_g_object_unref0 (_data_->_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		if (_data_->opened) {
			{
				_data_->_state_ = 5;
				geary_folder_close_async (_data_->folder, NULL, geary_app_conversation_monitor_external_load_by_sparse_id_ready, _data_);
				return FALSE;
				_state_5:
				geary_folder_close_finish (_data_->folder, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				_data_->close_err = _data_->_inner_error0_;
				_data_->_inner_error0_ = NULL;
				_data_->_tmp34_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->folder, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp35_ = _data_->_tmp34_;
				_data_->_tmp36_ = _data_->close_err;
				_data_->_tmp37_ = _data_->_tmp36_->message;
				geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error closing folder %s: %s", _data_->_tmp35_, _data_->_tmp37_);
				_g_free0 (_data_->_tmp35_);
				_g_error_free0 (_data_->close_err);
			}
			__finally1:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_error_free0 (_data_->err);
				_g_object_unref0 (_data_->emails);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
				g_clear_error (&_data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
		_data_->_tmp38_ = _data_->err;
		_data_->_tmp39_ = _g_error_copy0 (_data_->_tmp38_);
		_data_->_inner_error0_ = _data_->_tmp39_;
		_g_error_free0 (_data_->err);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->emails);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp41_ = _data_->emails;
	if (_data_->_tmp41_ != NULL) {
		_data_->_tmp42_ = _data_->emails;
		_data_->_tmp43_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp42_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp44_ = _data_->_tmp43_;
		_data_->_tmp40_ = !_data_->_tmp44_;
	} else {
		_data_->_tmp40_ = FALSE;
	}
	if (_data_->_tmp40_) {
		_data_->_tmp45_ = _data_->emails;
		_data_->_tmp46_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp45_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp47_ = _data_->_tmp46_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Fetched %d relevant emails locally", _data_->_tmp47_);
		_data_->_tmp48_ = _data_->emails;
		memset (&_data_->_tmp49_, 0, sizeof (GearyAppConversationMonitorProcessJobContext));
		geary_app_conversation_monitor_process_job_context_init (&_data_->_tmp49_);
		_data_->_tmp50_ = _data_->_tmp49_;
		_data_->_state_ = 6;
		geary_app_conversation_monitor_process_email_async (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp48_, GEE_TYPE_COLLECTION, GeeCollection), &_data_->_tmp50_, geary_app_conversation_monitor_external_load_by_sparse_id_ready, _data_);
		return FALSE;
		_state_6:
		geary_app_conversation_monitor_process_email_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		geary_app_conversation_monitor_process_job_context_destroy (&_data_->_tmp50_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->emails);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_object_unref0 (_data_->emails);
	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;
}

/** Notifies of removed conversations and removes emails from the window. */
void
geary_app_conversation_monitor_removed (GearyAppConversationMonitor* self,
                                        GeeCollection* removed,
                                        GeeMultiMap* trimmed,
                                        GeeCollection* base_folder_removed)
{
	gint _tmp11_;
	gint _tmp12_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (trimmed, GEE_TYPE_MULTI_MAP));
	g_return_if_fail ((base_folder_removed == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (base_folder_removed, GEE_TYPE_COLLECTION));
	{
		GeeIterator* _conversation_it = NULL;
		GeeSet* _tmp0_;
		GeeSet* _tmp1_;
		GeeIterator* _tmp2_;
		GeeIterator* _tmp3_;
		_tmp0_ = gee_multi_map_get_keys (trimmed);
		_tmp1_ = _tmp0_;
		_tmp2_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp1_);
		_conversation_it = _tmp3_;
		while (TRUE) {
			GeeIterator* _tmp4_;
			GearyAppConversation* conversation = NULL;
			GeeIterator* _tmp5_;
			gpointer _tmp6_;
			GearyAppConversation* _tmp7_;
			GearyAppConversation* _tmp8_;
			GeeCollection* _tmp9_;
			GeeCollection* _tmp10_;
			_tmp4_ = _conversation_it;
			if (!gee_iterator_next (_tmp4_)) {
				break;
			}
			_tmp5_ = _conversation_it;
			_tmp6_ = gee_iterator_get (_tmp5_);
			conversation = (GearyAppConversation*) _tmp6_;
			_tmp7_ = conversation;
			_tmp8_ = conversation;
			_tmp9_ = gee_multi_map_get (trimmed, _tmp8_);
			_tmp10_ = _tmp9_;
			geary_app_conversation_monitor_notify_conversation_trimmed (self, _tmp7_, _tmp10_);
			_g_object_unref0 (_tmp10_);
			_g_object_unref0 (conversation);
		}
		_g_object_unref0 (_conversation_it);
	}
	_tmp11_ = gee_collection_get_size (removed);
	_tmp12_ = _tmp11_;
	if (_tmp12_ > 0) {
		geary_app_conversation_monitor_notify_conversations_removed (self, removed);
	}
	if (base_folder_removed != NULL) {
		GeeSortedSet* _tmp13_;
		_tmp13_ = self->priv->window;
		gee_collection_remove_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEE_TYPE_COLLECTION, GeeCollection), base_folder_removed);
	}
}

static void
geary_app_conversation_monitor_real_notify_scan_started (GearyAppConversationMonitor* self)
{
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_SCAN_STARTED_SIGNAL], 0);
}

void
geary_app_conversation_monitor_notify_scan_started (GearyAppConversationMonitor* self)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_scan_started) {
		_klass_->notify_scan_started (self);
	}
}

static void
geary_app_conversation_monitor_real_notify_scan_error (GearyAppConversationMonitor* self,
                                                       GError* err)
{
	g_return_if_fail (err != NULL);
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_SCAN_ERROR_SIGNAL], 0, err);
}

void
geary_app_conversation_monitor_notify_scan_error (GearyAppConversationMonitor* self,
                                                  GError* err)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_scan_error) {
		_klass_->notify_scan_error (self, err);
	}
}

static void
geary_app_conversation_monitor_real_notify_scan_completed (GearyAppConversationMonitor* self)
{
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_SCAN_COMPLETED_SIGNAL], 0);
}

void
geary_app_conversation_monitor_notify_scan_completed (GearyAppConversationMonitor* self)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_scan_completed) {
		_klass_->notify_scan_completed (self);
	}
}

static void
geary_app_conversation_monitor_real_notify_conversations_added (GearyAppConversationMonitor* self,
                                                                GeeCollection* conversations)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_ADDED_SIGNAL], 0, conversations);
}

void
geary_app_conversation_monitor_notify_conversations_added (GearyAppConversationMonitor* self,
                                                           GeeCollection* conversations)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_conversations_added) {
		_klass_->notify_conversations_added (self, conversations);
	}
}

static void
geary_app_conversation_monitor_real_notify_conversations_removed (GearyAppConversationMonitor* self,
                                                                  GeeCollection* conversations)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_REMOVED_SIGNAL], 0, conversations);
}

void
geary_app_conversation_monitor_notify_conversations_removed (GearyAppConversationMonitor* self,
                                                             GeeCollection* conversations)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_conversations_removed) {
		_klass_->notify_conversations_removed (self, conversations);
	}
}

static void
geary_app_conversation_monitor_real_notify_conversation_appended (GearyAppConversationMonitor* self,
                                                                  GearyAppConversation* conversation,
                                                                  GeeCollection* emails)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION (conversation));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (emails, GEE_TYPE_COLLECTION));
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATION_APPENDED_SIGNAL], 0, conversation, emails);
}

void
geary_app_conversation_monitor_notify_conversation_appended (GearyAppConversationMonitor* self,
                                                             GearyAppConversation* conversation,
                                                             GeeCollection* emails)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_conversation_appended) {
		_klass_->notify_conversation_appended (self, conversation, emails);
	}
}

static void
geary_app_conversation_monitor_real_notify_conversation_trimmed (GearyAppConversationMonitor* self,
                                                                 GearyAppConversation* conversation,
                                                                 GeeCollection* emails)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION (conversation));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (emails, GEE_TYPE_COLLECTION));
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATION_TRIMMED_SIGNAL], 0, conversation, emails);
}

void
geary_app_conversation_monitor_notify_conversation_trimmed (GearyAppConversationMonitor* self,
                                                            GearyAppConversation* conversation,
                                                            GeeCollection* emails)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_conversation_trimmed) {
		_klass_->notify_conversation_trimmed (self, conversation, emails);
	}
}

static void
geary_app_conversation_monitor_real_notify_email_flags_changed (GearyAppConversationMonitor* self,
                                                                GearyAppConversation* conversation,
                                                                GearyEmail* email)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION (conversation));
	g_return_if_fail (GEARY_IS_EMAIL (email));
	g_signal_emit_by_name (conversation, "email-flags-changed", email);
	g_signal_emit (self, geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_EMAIL_FLAGS_CHANGED_SIGNAL], 0, conversation, email);
}

void
geary_app_conversation_monitor_notify_email_flags_changed (GearyAppConversationMonitor* self,
                                                           GearyAppConversation* conversation,
                                                           GearyEmail* email)
{
	GearyAppConversationMonitorClass* _klass_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	_klass_ = GEARY_APP_CONVERSATION_MONITOR_GET_CLASS (self);
	if (_klass_->notify_email_flags_changed) {
		_klass_->notify_email_flags_changed (self, conversation, email);
	}
}

static void
geary_app_conversation_monitor_stop_monitoring_internal_data_free (gpointer _data)
{
	GearyAppConversationMonitorStopMonitoringInternalData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorStopMonitoringInternalData, _data_);
}

static void
geary_app_conversation_monitor_stop_monitoring_internal (GearyAppConversationMonitor* self,
                                                         GCancellable* cancellable,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_)
{
	GearyAppConversationMonitorStopMonitoringInternalData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyAppConversationMonitorStopMonitoringInternalData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_stop_monitoring_internal_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_app_conversation_monitor_stop_monitoring_internal_co (_data_);
}

static gboolean
geary_app_conversation_monitor_stop_monitoring_internal_finish (GearyAppConversationMonitor* self,
                                                                GAsyncResult* _res_,
                                                                GError** error)
{
	gboolean result;
	GearyAppConversationMonitorStopMonitoringInternalData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
geary_app_conversation_monitor_stop_monitoring_internal_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_)
{
	GearyAppConversationMonitorStopMonitoringInternalData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_stop_monitoring_internal_co (_data_);
}

static gboolean
geary_app_conversation_monitor_stop_monitoring_internal_co (GearyAppConversationMonitorStopMonitoringInternalData* _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_ = _data_->self->priv->_base_folder;
	g_signal_parse_name ("email-appended", GEARY_TYPE_FOLDER, &_data_->_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp1_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_folder_email_appended_geary_folder_email_appended, _data_->self);
	_data_->_tmp2_ = _data_->self->priv->_base_folder;
	g_signal_parse_name ("email-inserted", GEARY_TYPE_FOLDER, &_data_->_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp3_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_folder_email_inserted_geary_folder_email_inserted, _data_->self);
	_data_->_tmp4_ = _data_->self->priv->_base_folder;
	g_signal_parse_name ("email-locally-complete", GEARY_TYPE_FOLDER, &_data_->_tmp5_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp5_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_folder_email_complete_geary_folder_email_locally_complete, _data_->self);
	_data_->_tmp6_ = _data_->self->priv->_base_folder;
	g_signal_parse_name ("email-removed", GEARY_TYPE_FOLDER, &_data_->_tmp7_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp7_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_removed, _data_->self);
	_data_->_tmp8_ = _data_->self->priv->_base_folder;
	g_signal_parse_name ("email-locally-removed", GEARY_TYPE_FOLDER, &_data_->_tmp9_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp8_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp9_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_folder_email_removed_geary_folder_email_locally_removed, _data_->self);
	_data_->_tmp10_ = _data_->self->priv->_base_folder;
	g_signal_parse_name ("opened", GEARY_TYPE_FOLDER, &_data_->_tmp11_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp10_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp11_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_folder_opened_geary_folder_opened, _data_->self);
	_data_->_tmp12_ = _data_->self->priv->_base_folder;
	_data_->_tmp13_ = geary_folder_get_account (_data_->_tmp12_);
	_data_->_tmp14_ = _data_->_tmp13_;
	g_signal_parse_name ("email-appended", GEARY_TYPE_ACCOUNT, &_data_->_tmp15_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp14_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp15_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_account_email_appended_geary_account_email_appended, _data_->self);
	_data_->_tmp16_ = _data_->self->priv->_base_folder;
	_data_->_tmp17_ = geary_folder_get_account (_data_->_tmp16_);
	_data_->_tmp18_ = _data_->_tmp17_;
	g_signal_parse_name ("email-inserted", GEARY_TYPE_ACCOUNT, &_data_->_tmp19_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp18_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp19_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_account_email_inserted_geary_account_email_inserted, _data_->self);
	_data_->_tmp20_ = _data_->self->priv->_base_folder;
	_data_->_tmp21_ = geary_folder_get_account (_data_->_tmp20_);
	_data_->_tmp22_ = _data_->_tmp21_;
	g_signal_parse_name ("email-locally-complete", GEARY_TYPE_ACCOUNT, &_data_->_tmp23_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp22_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp23_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_account_email_complete_geary_account_email_locally_complete, _data_->self);
	_data_->_tmp24_ = _data_->self->priv->_base_folder;
	_data_->_tmp25_ = geary_folder_get_account (_data_->_tmp24_);
	_data_->_tmp26_ = _data_->_tmp25_;
	g_signal_parse_name ("email-removed", GEARY_TYPE_ACCOUNT, &_data_->_tmp27_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp26_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp27_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_account_email_removed_geary_account_email_removed, _data_->self);
	_data_->_tmp28_ = _data_->self->priv->_base_folder;
	_data_->_tmp29_ = geary_folder_get_account (_data_->_tmp28_);
	_data_->_tmp30_ = _data_->_tmp29_;
	g_signal_parse_name ("email-flags-changed", GEARY_TYPE_ACCOUNT, &_data_->_tmp31_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp30_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp31_, 0, NULL, (GCallback) _geary_app_conversation_monitor_on_account_email_flags_changed_geary_account_email_flags_changed, _data_->self);
	_data_->_tmp32_ = _data_->self->priv->operation_cancellable;
	g_cancellable_cancel (_data_->_tmp32_);
	_data_->close_err = NULL;
	{
		_data_->_tmp33_ = _data_->self->priv->queue;
		_data_->_state_ = 1;
		geary_app_conversation_operation_queue_stop_processing_async (_data_->_tmp33_, _data_->cancellable, geary_app_conversation_monitor_stop_monitoring_internal_ready, _data_);
		return FALSE;
		_state_1:
		geary_app_conversation_operation_queue_stop_processing_finish (_data_->_tmp33_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp34_ = _data_->err;
		_data_->_tmp35_ = _g_error_copy0 (_data_->_tmp34_);
		_g_error_free0 (_data_->close_err);
		_data_->close_err = _data_->_tmp35_;
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->close_err);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->closing = FALSE;
	if (_data_->self->priv->base_was_opened) {
		{
			_data_->_tmp37_ = _data_->self->priv->_base_folder;
			_data_->_state_ = 2;
			geary_folder_close_async (_data_->_tmp37_, NULL, geary_app_conversation_monitor_stop_monitoring_internal_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp36_ = geary_folder_close_finish (_data_->_tmp37_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_data_->closing = _data_->_tmp36_;
		}
		goto __finally1;
		__catch1_g_error:
		{
			_data_->_vala1_err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp38_ = _data_->close_err;
			if (_data_->_tmp38_ == NULL) {
				_data_->_tmp39_ = _data_->_vala1_err;
				_data_->_tmp40_ = _g_error_copy0 (_data_->_tmp39_);
				_g_error_free0 (_data_->close_err);
				_data_->close_err = _data_->_tmp40_;
			} else {
				_data_->_tmp41_ = _data_->self->priv->_base_folder;
				_data_->_tmp42_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp41_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp43_ = _data_->_tmp42_;
				_data_->_tmp44_ = _data_->_vala1_err;
				_data_->_tmp45_ = _data_->_tmp44_->message;
				geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to close monitored folder %s: %s", _data_->_tmp43_, _data_->_tmp45_);
				_g_free0 (_data_->_tmp43_);
			}
			_g_error_free0 (_data_->_vala1_err);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_error_free0 (_data_->close_err);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->_tmp46_ = _data_->close_err;
	if (_data_->_tmp46_ != NULL) {
		_data_->_tmp47_ = _data_->close_err;
		_data_->_tmp48_ = _g_error_copy0 (_data_->_tmp47_);
		_data_->_inner_error0_ = _data_->_tmp48_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->close_err);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->closing;
	_g_error_free0 (_data_->close_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;
}

static void
geary_app_conversation_monitor_process_email_async_data_free (gpointer _data)
{
	GearyAppConversationMonitorProcessEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->emails);
	geary_app_conversation_monitor_process_job_context_destroy (&_data_->job);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorProcessEmailAsyncData, _data_);
}

static void
geary_app_conversation_monitor_process_email_async (GearyAppConversationMonitor* self,
                                                    GeeCollection* emails,
                                                    GearyAppConversationMonitorProcessJobContext* job,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	GearyAppConversationMonitorProcessEmailAsyncData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GeeCollection* _tmp1_;
	GearyAppConversationMonitorProcessJobContext _tmp2_;
	GearyAppConversationMonitorProcessJobContext _tmp3_;
	GearyAppConversationMonitorProcessJobContext _tmp4_ = {0};
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail ((emails == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (emails, GEE_TYPE_COLLECTION));
	g_return_if_fail (job != NULL);
	_data_ = g_slice_new0 (GearyAppConversationMonitorProcessEmailAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_process_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (emails);
	_g_object_unref0 (_data_->emails);
	_data_->emails = _tmp1_;
	_tmp2_ = *job;
	_tmp3_ = _tmp2_;
	geary_app_conversation_monitor_process_job_context_copy (&_tmp3_, &_tmp4_);
	geary_app_conversation_monitor_process_job_context_destroy (&_data_->job);
	_data_->job = _tmp4_;
	geary_app_conversation_monitor_process_email_async_co (_data_);
}

static void
geary_app_conversation_monitor_process_email_finish (GearyAppConversationMonitor* self,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	GearyAppConversationMonitorProcessEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static Block15Data*
block15_data_ref (Block15Data* _data15_)
{
	g_atomic_int_inc (&_data15_->_ref_count_);
	return _data15_;
}

static void
block15_data_unref (void * _userdata_)
{
	Block15Data* _data15_;
	_data15_ = (Block15Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data15_->_ref_count_)) {
		GearyAppConversationMonitor* self;
		self = _data15_->self;
		_g_object_unref0 (_data15_->new_message_ids);
		_g_object_unref0 (self);
		g_slice_free (Block15Data, _data15_);
	}
}

static void
geary_app_conversation_monitor_process_email_async_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_)
{
	GearyAppConversationMonitorProcessEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_process_email_async_co (_data_);
}

static gboolean
______lambda166_ (Block15Data* _data15_,
                  GearyRFC822MessageID* id)
{
	GearyAppConversationMonitor* self;
	GeeHashSet* _tmp0_;
	gboolean result;
	self = _data15_->self;
	g_return_val_if_fail (GEARY_RF_C822_IS_MESSAGE_ID (id), FALSE);
	_tmp0_ = _data15_->new_message_ids;
	result = !gee_abstract_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), id);
	return result;
}

static gboolean
_______lambda166__gee_predicate (gconstpointer g,
                                 gpointer self)
{
	gboolean result;
	result = ______lambda166_ (self, (GearyRFC822MessageID*) g);
	return result;
}

static gboolean
geary_app_conversation_monitor_process_email_async_co (GearyAppConversationMonitorProcessEmailAsyncData* _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_->_data15_ = g_slice_new0 (Block15Data);
	_data_->_data15_->_ref_count_ = 1;
	_data_->_data15_->self = g_object_ref (_data_->self);
	_data_->_data15_->_async_data_ = _data_;
	if (_data_->emails == NULL) {
		_data_->_tmp0_ = TRUE;
	} else {
		_data_->_tmp1_ = gee_collection_get_size (_data_->emails);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp0_ = _data_->_tmp2_ == 0;
	}
	if (_data_->_tmp0_) {
		_data_->_tmp3_ = _data_->job;
		_data_->_state_ = 1;
		geary_app_conversation_monitor_process_email_complete_async (_data_->self, &_data_->_tmp3_, geary_app_conversation_monitor_process_email_async_ready, _data_);
		return FALSE;
		_state_1:
		geary_app_conversation_monitor_process_email_complete_finish (_data_->self, _data_->_res_);
		block15_data_unref (_data_->_data15_);
		_data_->_data15_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = gee_collection_get_size (_data_->emails);
	_data_->_tmp5_ = _data_->_tmp4_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "process_email: %d emails", _data_->_tmp5_);
	_data_->_tmp6_ = gee_hash_set_new (GEARY_RF_C822_TYPE_MESSAGE_ID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data15_->new_message_ids = _data_->_tmp6_;
	{
		_data_->_tmp7_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->emails, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_email_it = _data_->_tmp7_;
		while (TRUE) {
			_data_->_tmp8_ = _data_->_email_it;
			if (!gee_iterator_next (_data_->_tmp8_)) {
				break;
			}
			_data_->_tmp9_ = _data_->_email_it;
			_data_->_tmp10_ = gee_iterator_get (_data_->_tmp9_);
			_data_->email = (GearyEmail*) _data_->_tmp10_;
			_data_->_tmp11_ = _data_->job;
			_data_->_tmp12_ = _data_->_tmp11_.emails;
			_data_->_tmp13_ = _data_->email;
			_data_->_tmp14_ = geary_email_get_id (_data_->_tmp13_);
			_data_->_tmp15_ = _data_->_tmp14_;
			if (!gee_map_has_key (_data_->_tmp12_, _data_->_tmp15_)) {
				_data_->_tmp16_ = _data_->job;
				_data_->_tmp17_ = _data_->_tmp16_.emails;
				_data_->_tmp18_ = _data_->email;
				_data_->_tmp19_ = geary_email_get_id (_data_->_tmp18_);
				_data_->_tmp20_ = _data_->_tmp19_;
				_data_->_tmp21_ = _data_->email;
				gee_map_set (_data_->_tmp17_, _data_->_tmp20_, _data_->_tmp21_);
				_data_->_tmp22_ = _data_->email;
				_data_->_tmp23_ = geary_email_get_email_flags (_data_->_tmp22_);
				_data_->_tmp24_ = _data_->_tmp23_;
				_data_->_tmp25_ = _g_object_ref0 (_data_->_tmp24_);
				_data_->flags = _data_->_tmp25_;
				_data_->_tmp27_ = _data_->flags;
				if (_data_->_tmp27_ != NULL) {
					_data_->_tmp28_ = _data_->flags;
					_data_->_tmp26_ = geary_email_flags_is_deleted (_data_->_tmp28_);
				} else {
					_data_->_tmp26_ = FALSE;
				}
				_data_->marked_for_deletion = _data_->_tmp26_;
				_data_->_tmp29_ = _data_->email;
				_data_->_tmp30_ = geary_email_get_ancestors (_data_->_tmp29_);
				_data_->ancestors = _data_->_tmp30_;
				_data_->_tmp32_ = _data_->ancestors;
				if (_data_->_tmp32_ != NULL) {
					_data_->_tmp31_ = !_data_->marked_for_deletion;
				} else {
					_data_->_tmp31_ = FALSE;
				}
				if (_data_->_tmp31_) {
					_data_->_tmp33_ = _data_->ancestors;
					_data_->_tmp34_ = geary_traverse (GEARY_RF_C822_TYPE_MESSAGE_ID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp33_, GEE_TYPE_ITERABLE, GeeIterable));
					_data_->_tmp35_ = _data_->_tmp34_;
					_data_->_tmp36_ = geary_iterable_filter (_data_->_tmp35_, _______lambda166__gee_predicate, block15_data_ref (_data_->_data15_), block15_data_unref);
					_data_->_tmp37_ = _data_->_tmp36_;
					_data_->_tmp38_ = _data_->_data15_->new_message_ids;
					_data_->_tmp39_ = geary_iterable_add_all_to (_data_->_tmp37_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp38_, GEE_TYPE_COLLECTION, GeeCollection));
					_data_->_tmp40_ = _data_->_tmp39_;
					_g_object_unref0 (_data_->_tmp40_);
					_g_object_unref0 (_data_->_tmp37_);
					_g_object_unref0 (_data_->_tmp35_);
				}
				_g_object_unref0 (_data_->ancestors);
				_g_object_unref0 (_data_->flags);
			}
			_g_object_unref0 (_data_->email);
		}
		_g_object_unref0 (_data_->_email_it);
	}
	_data_->_tmp41_ = _data_->_data15_->new_message_ids;
	_data_->_tmp42_ = _data_->job;
	_data_->_state_ = 2;
	geary_app_conversation_monitor_expand_conversations_async (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp41_, GEE_TYPE_SET, GeeSet), &_data_->_tmp42_, geary_app_conversation_monitor_process_email_async_ready, _data_);
	return FALSE;
	_state_2:
	geary_app_conversation_monitor_expand_conversations_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		block15_data_unref (_data_->_data15_);
		_data_->_data15_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp43_ = gee_collection_get_size (_data_->emails);
	_data_->_tmp44_ = _data_->_tmp43_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "process_email completed: %d emails", _data_->_tmp44_);
	block15_data_unref (_data_->_data15_);
	_data_->_data15_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
geary_app_conversation_monitor_process_email_complete_async_data_free (gpointer _data)
{
	GearyAppConversationMonitorProcessEmailCompleteAsyncData* _data_;
	_data_ = _data;
	geary_app_conversation_monitor_process_job_context_destroy (&_data_->job);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorProcessEmailCompleteAsyncData, _data_);
}

static void
geary_app_conversation_monitor_process_email_complete_async (GearyAppConversationMonitor* self,
                                                             GearyAppConversationMonitorProcessJobContext* job,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	GearyAppConversationMonitorProcessEmailCompleteAsyncData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GearyAppConversationMonitorProcessJobContext _tmp1_;
	GearyAppConversationMonitorProcessJobContext _tmp2_;
	GearyAppConversationMonitorProcessJobContext _tmp3_ = {0};
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (job != NULL);
	_data_ = g_slice_new0 (GearyAppConversationMonitorProcessEmailCompleteAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_process_email_complete_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = *job;
	_tmp2_ = _tmp1_;
	geary_app_conversation_monitor_process_job_context_copy (&_tmp2_, &_tmp3_);
	geary_app_conversation_monitor_process_job_context_destroy (&_data_->job);
	_data_->job = _tmp3_;
	geary_app_conversation_monitor_process_email_complete_async_co (_data_);
}

static void
geary_app_conversation_monitor_process_email_complete_finish (GearyAppConversationMonitor* self,
                                                              GAsyncResult* _res_)
{
	GearyAppConversationMonitorProcessEmailCompleteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
geary_app_conversation_monitor_process_email_complete_async_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_)
{
	GearyAppConversationMonitorProcessEmailCompleteAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_process_email_complete_async_co (_data_);
}

static gboolean
geary_app_conversation_monitor_process_email_complete_async_co (GearyAppConversationMonitorProcessEmailCompleteAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->added = NULL;
	_data_->appended = NULL;
	_data_->removed_due_to_merge = NULL;
	{
		_data_->_tmp0_ = _data_->self->priv->_base_folder;
		_data_->_tmp1_ = geary_folder_get_account (_data_->_tmp0_);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = _data_->job;
		_data_->_tmp4_ = _data_->_tmp3_.emails;
		_data_->_tmp5_ = gee_map_get_keys (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = _data_->self->priv->operation_cancellable;
		_data_->_state_ = 1;
		geary_account_get_containing_folders_async (_data_->_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEE_TYPE_COLLECTION, GeeCollection), _data_->_tmp8_, geary_app_conversation_monitor_process_email_complete_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp9_ = geary_account_get_containing_folders_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp10_ = _data_->_tmp9_;
		_g_object_unref0 (_data_->_tmp7_);
		_data_->email_paths = _data_->_tmp10_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
				goto __catch0_g_io_error_cancelled;
			}
			goto __catch0_g_error;
		}
		_data_->_tmp11_ = _data_->email_paths;
		if (_data_->_tmp11_ != NULL) {
			_data_->_tmp12_ = _data_->self->priv->_conversations;
			_data_->_tmp13_ = _data_->job;
			_data_->_tmp14_ = _data_->_tmp13_.emails;
			_data_->_tmp15_ = gee_map_get_values (_data_->_tmp14_);
			_data_->_tmp16_ = _data_->_tmp15_;
			_data_->_tmp17_ = _data_->_tmp16_;
			_data_->_tmp18_ = _data_->email_paths;
			_data_->_tmp19_ = NULL;
			_data_->_tmp20_ = NULL;
			_data_->_tmp21_ = NULL;
			geary_app_conversation_set_add_all_emails (_data_->_tmp12_, _data_->_tmp17_, _data_->_tmp18_, &_data_->_tmp19_, &_data_->_tmp20_, &_data_->_tmp21_);
			_g_object_unref0 (_data_->added);
			_data_->added = _data_->_tmp19_;
			_g_object_unref0 (_data_->appended);
			_data_->appended = _data_->_tmp20_;
			_g_object_unref0 (_data_->removed_due_to_merge);
			_data_->removed_due_to_merge = _data_->_tmp21_;
			_g_object_unref0 (_data_->_tmp17_);
		}
		_g_object_unref0 (_data_->email_paths);
	}
	goto __finally0;
	__catch0_g_io_error_cancelled:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp22_ = _data_->err;
		_data_->_tmp23_ = _data_->_tmp22_->message;
		geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to add emails to conversation: %s", _data_->_tmp23_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->removed_due_to_merge);
		_g_object_unref0 (_data_->appended);
		_g_object_unref0 (_data_->added);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp25_ = _data_->removed_due_to_merge;
	if (_data_->_tmp25_ != NULL) {
		_data_->_tmp26_ = _data_->removed_due_to_merge;
		_data_->_tmp27_ = gee_collection_get_size (_data_->_tmp26_);
		_data_->_tmp28_ = _data_->_tmp27_;
		_data_->_tmp24_ = _data_->_tmp28_ > 0;
	} else {
		_data_->_tmp24_ = FALSE;
	}
	if (_data_->_tmp24_) {
		_data_->_tmp29_ = _data_->removed_due_to_merge;
		geary_app_conversation_monitor_notify_conversations_removed (_data_->self, _data_->_tmp29_);
	}
	_data_->_tmp31_ = _data_->added;
	if (_data_->_tmp31_ != NULL) {
		_data_->_tmp32_ = _data_->added;
		_data_->_tmp33_ = gee_collection_get_size (_data_->_tmp32_);
		_data_->_tmp34_ = _data_->_tmp33_;
		_data_->_tmp30_ = _data_->_tmp34_ > 0;
	} else {
		_data_->_tmp30_ = FALSE;
	}
	if (_data_->_tmp30_) {
		_data_->_tmp35_ = _data_->added;
		geary_app_conversation_monitor_notify_conversations_added (_data_->self, _data_->_tmp35_);
	}
	_data_->_tmp36_ = _data_->appended;
	if (_data_->_tmp36_ != NULL) {
		{
			_data_->_tmp37_ = _data_->appended;
			_data_->_tmp38_ = gee_multi_map_get_keys (_data_->_tmp37_);
			_data_->_tmp39_ = _data_->_tmp38_;
			_data_->_tmp40_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp39_, GEE_TYPE_ITERABLE, GeeIterable));
			_data_->_tmp41_ = _data_->_tmp40_;
			_g_object_unref0 (_data_->_tmp39_);
			_data_->_conversation_it = _data_->_tmp41_;
			while (TRUE) {
				_data_->_tmp42_ = _data_->_conversation_it;
				if (!gee_iterator_next (_data_->_tmp42_)) {
					break;
				}
				_data_->_tmp43_ = _data_->_conversation_it;
				_data_->_tmp44_ = gee_iterator_get (_data_->_tmp43_);
				_data_->conversation = (GearyAppConversation*) _data_->_tmp44_;
				_data_->_tmp45_ = _data_->conversation;
				_data_->_tmp46_ = _data_->appended;
				_data_->_tmp47_ = _data_->conversation;
				_data_->_tmp48_ = gee_multi_map_get (_data_->_tmp46_, _data_->_tmp47_);
				_data_->_tmp49_ = _data_->_tmp48_;
				geary_app_conversation_monitor_notify_conversation_appended (_data_->self, _data_->_tmp45_, _data_->_tmp49_);
				_g_object_unref0 (_data_->_tmp49_);
				_g_object_unref0 (_data_->conversation);
			}
			_g_object_unref0 (_data_->_conversation_it);
		}
	}
	_g_object_unref0 (_data_->removed_due_to_merge);
	_g_object_unref0 (_data_->appended);
	_g_object_unref0 (_data_->added);
	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_conversation_monitor_expand_conversations_async_data_free (gpointer _data)
{
	GearyAppConversationMonitorExpandConversationsAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->needed_message_ids);
	geary_app_conversation_monitor_process_job_context_destroy (&_data_->job);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyAppConversationMonitorExpandConversationsAsyncData, _data_);
}

static void
geary_app_conversation_monitor_expand_conversations_async (GearyAppConversationMonitor* self,
                                                           GeeSet* needed_message_ids,
                                                           GearyAppConversationMonitorProcessJobContext* job,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	GearyAppConversationMonitorExpandConversationsAsyncData* _data_;
	GearyAppConversationMonitor* _tmp0_;
	GeeSet* _tmp1_;
	GearyAppConversationMonitorProcessJobContext _tmp2_;
	GearyAppConversationMonitorProcessJobContext _tmp3_;
	GearyAppConversationMonitorProcessJobContext _tmp4_ = {0};
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (needed_message_ids, GEE_TYPE_SET));
	g_return_if_fail (job != NULL);
	_data_ = g_slice_new0 (GearyAppConversationMonitorExpandConversationsAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_conversation_monitor_expand_conversations_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (needed_message_ids);
	_g_object_unref0 (_data_->needed_message_ids);
	_data_->needed_message_ids = _tmp1_;
	_tmp2_ = *job;
	_tmp3_ = _tmp2_;
	geary_app_conversation_monitor_process_job_context_copy (&_tmp3_, &_tmp4_);
	geary_app_conversation_monitor_process_job_context_destroy (&_data_->job);
	_data_->job = _tmp4_;
	geary_app_conversation_monitor_expand_conversations_async_co (_data_);
}

static void
geary_app_conversation_monitor_expand_conversations_finish (GearyAppConversationMonitor* self,
                                                            GAsyncResult* _res_,
                                                            GError** error)
{
	GearyAppConversationMonitorExpandConversationsAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static Block16Data*
block16_data_ref (Block16Data* _data16_)
{
	g_atomic_int_inc (&_data16_->_ref_count_);
	return _data16_;
}

static void
block16_data_unref (void * _userdata_)
{
	Block16Data* _data16_;
	_data16_ = (Block16Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data16_->_ref_count_)) {
		GearyAppConversationMonitor* self;
		self = _data16_->self;
		_g_object_unref0 (_data16_->needed_messages);
		_g_object_unref0 (self);
		g_slice_free (Block16Data, _data16_);
	}
}

static void
geary_app_conversation_monitor_expand_conversations_async_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	GearyAppConversationMonitorExpandConversationsAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_app_conversation_monitor_expand_conversations_async_co (_data_);
}

static gboolean
_____lambda167_ (Block16Data* _data16_,
                 GearyEmail* e)
{
	GearyAppConversationMonitor* self;
	GeeHashMap* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	GearyEmailIdentifier* _tmp2_;
	gboolean result;
	self = _data16_->self;
	g_return_val_if_fail (GEARY_IS_EMAIL (e), FALSE);
	_tmp0_ = _data16_->needed_messages;
	_tmp1_ = geary_email_get_id (e);
	_tmp2_ = _tmp1_;
	result = !gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _tmp2_);
	return result;
}

static gboolean
______lambda167__gee_predicate (gconstpointer g,
                                gpointer self)
{
	gboolean result;
	result = _____lambda167_ (self, (GearyEmail*) g);
	return result;
}

static GearyEmailIdentifier*
_____lambda168_ (GearyAppConversationMonitor* self,
                 GearyEmail* e)
{
	GearyEmailIdentifier* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	GearyEmailIdentifier* _tmp2_;
	GearyEmailIdentifier* result;
	g_return_val_if_fail (GEARY_IS_EMAIL (e), NULL);
	_tmp0_ = geary_email_get_id (e);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	_g_object_unref0 (e);
	return result;
}

static gpointer
______lambda168__gee_map_func (gpointer g,
                               gpointer self)
{
	gpointer result;
	result = _____lambda168_ ((GearyAppConversationMonitor*) self, (GearyEmail*) g);
	return result;
}

static gboolean
geary_app_conversation_monitor_expand_conversations_async_co (GearyAppConversationMonitorExpandConversationsAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data16_ = g_slice_new0 (Block16Data);
	_data_->_data16_->_ref_count_ = 1;
	_data_->_data16_->self = g_object_ref (_data_->self);
	_data_->_data16_->_async_data_ = _data_;
	_data_->_tmp0_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->needed_message_ids, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_ == 0) {
		_data_->_tmp2_ = _data_->job;
		_data_->_state_ = 1;
		geary_app_conversation_monitor_process_email_complete_async (_data_->self, &_data_->_tmp2_, geary_app_conversation_monitor_expand_conversations_async_ready, _data_);
		return FALSE;
		_state_1:
		geary_app_conversation_monitor_process_email_complete_finish (_data_->self, _data_->_res_);
		block16_data_unref (_data_->_data16_);
		_data_->_data16_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->needed_message_ids, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp4_ = _data_->_tmp3_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "expand_conversations: %d email ids", _data_->_tmp4_);
	_data_->_tmp5_ = geary_app_conversation_monitor_get_search_folder_blacklist (_data_->self);
	_data_->folder_blacklist = _data_->_tmp5_;
	_data_->_tmp6_ = geary_app_conversation_monitor_get_search_flag_blacklist (_data_->self);
	_data_->flag_blacklist = _data_->_tmp6_;
	_data_->_tmp7_ = geary_nonblocking_batch_new ();
	_data_->batch = _data_->_tmp7_;
	{
		_data_->_tmp8_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->needed_message_ids, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_message_id_it = _data_->_tmp8_;
		while (TRUE) {
			_data_->_tmp9_ = _data_->_message_id_it;
			if (!gee_iterator_next (_data_->_tmp9_)) {
				break;
			}
			_data_->_tmp10_ = _data_->_message_id_it;
			_data_->_tmp11_ = gee_iterator_get (_data_->_tmp10_);
			_data_->message_id = (GearyRFC822MessageID*) _data_->_tmp11_;
			_data_->_tmp12_ = _data_->batch;
			_data_->_tmp13_ = _data_->self->priv->_base_folder;
			_data_->_tmp14_ = geary_folder_get_account (_data_->_tmp13_);
			_data_->_tmp15_ = _data_->_tmp14_;
			_data_->_tmp16_ = _data_->message_id;
			_data_->_tmp17_ = _data_->folder_blacklist;
			_data_->_tmp18_ = _data_->flag_blacklist;
			_data_->_tmp19_ = geary_app_local_search_operation_new (_data_->_tmp15_, _data_->_tmp16_, _data_->self->priv->required_fields, _data_->_tmp17_, _data_->_tmp18_);
			_data_->_tmp20_ = _data_->_tmp19_;
			geary_nonblocking_batch_add (_data_->_tmp12_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp20_, GEARY_NONBLOCKING_TYPE_BATCH_OPERATION, GearyNonblockingBatchOperation));
			_g_object_unref0 (_data_->_tmp20_);
			_g_object_unref0 (_data_->message_id);
		}
		_g_object_unref0 (_data_->_message_id_it);
	}
	_data_->_tmp21_ = _data_->batch;
	_data_->_state_ = 2;
	geary_nonblocking_batch_execute_all_async (_data_->_tmp21_, NULL, geary_app_conversation_monitor_expand_conversations_async_ready, _data_);
	return FALSE;
	_state_2:
	geary_nonblocking_batch_execute_all_finish (_data_->_tmp21_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->batch);
		_g_object_unref0 (_data_->flag_blacklist);
		_g_object_unref0 (_data_->folder_blacklist);
		block16_data_unref (_data_->_data16_);
		_data_->_data16_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp22_ = gee_hash_map_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data16_->needed_messages = _data_->_tmp22_;
	{
		_data_->_tmp23_ = _data_->batch;
		_data_->_tmp24_ = geary_nonblocking_batch_get_ids (_data_->_tmp23_);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_tmp26_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp25_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp27_ = _data_->_tmp26_;
		_g_object_unref0 (_data_->_tmp25_);
		_data_->_id_it = _data_->_tmp27_;
		while (TRUE) {
			_data_->_tmp28_ = _data_->_id_it;
			if (!gee_iterator_next (_data_->_tmp28_)) {
				break;
			}
			_data_->_tmp29_ = _data_->_id_it;
			_data_->_tmp30_ = gee_iterator_get (_data_->_tmp29_);
			_data_->id = (gint) ((gintptr) _data_->_tmp30_);
			_data_->_tmp31_ = _data_->batch;
			_data_->_tmp32_ = geary_nonblocking_batch_get_operation (_data_->_tmp31_, _data_->id);
			_data_->op = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp32_, GEARY_APP_TYPE_LOCAL_SEARCH_OPERATION, GearyAppLocalSearchOperation);
			_data_->_tmp33_ = _data_->op;
			_data_->_tmp34_ = _data_->_tmp33_->emails;
			if (_data_->_tmp34_ != NULL) {
				_data_->_tmp35_ = _data_->op;
				_data_->_tmp36_ = _data_->_tmp35_->emails;
				_data_->_tmp37_ = gee_multi_map_get_keys (_data_->_tmp36_);
				_data_->_tmp38_ = _data_->_tmp37_;
				_data_->_tmp39_ = geary_traverse (GEARY_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp38_, GEE_TYPE_ITERABLE, GeeIterable));
				_data_->_tmp40_ = _data_->_tmp39_;
				_data_->_tmp41_ = geary_iterable_filter (_data_->_tmp40_, ______lambda167__gee_predicate, block16_data_ref (_data_->_data16_), block16_data_unref);
				_data_->_tmp42_ = _data_->_tmp41_;
				_data_->_tmp43_ = _data_->_data16_->needed_messages;
				_data_->_tmp44_ = geary_iterable_add_all_to_map (_data_->_tmp42_, GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp43_, GEE_TYPE_MAP, GeeMap), ______lambda168__gee_map_func, _data_->self);
				_data_->_tmp45_ = _data_->_tmp44_;
				_g_object_unref0 (_data_->_tmp45_);
				_g_object_unref0 (_data_->_tmp42_);
				_g_object_unref0 (_data_->_tmp40_);
				_g_object_unref0 (_data_->_tmp38_);
			}
			_g_object_unref0 (_data_->op);
		}
		_g_object_unref0 (_data_->_id_it);
	}
	_data_->_tmp46_ = _data_->_data16_->needed_messages;
	_data_->_tmp47_ = gee_abstract_map_get_values (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp46_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
	_data_->_tmp48_ = _data_->_tmp47_;
	_data_->_tmp49_ = _data_->_tmp48_;
	_data_->_tmp50_ = _data_->job;
	_data_->_state_ = 3;
	geary_app_conversation_monitor_process_email_async (_data_->self, _data_->_tmp49_, &_data_->_tmp50_, geary_app_conversation_monitor_expand_conversations_async_ready, _data_);
	return FALSE;
	_state_3:
	geary_app_conversation_monitor_process_email_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	_g_object_unref0 (_data_->_tmp49_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->batch);
		_g_object_unref0 (_data_->flag_blacklist);
		_g_object_unref0 (_data_->folder_blacklist);
		block16_data_unref (_data_->_data16_);
		_data_->_data16_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp51_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->needed_message_ids, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp52_ = _data_->_tmp51_;
	_data_->_tmp53_ = _data_->_data16_->needed_messages;
	_data_->_tmp54_ = gee_abstract_map_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp53_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
	_data_->_tmp55_ = _data_->_tmp54_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "expand_conversations completed: %d email ids (%d found)", _data_->_tmp52_, _data_->_tmp55_);
	_g_object_unref0 (_data_->batch);
	_g_object_unref0 (_data_->flag_blacklist);
	_g_object_unref0 (_data_->folder_blacklist);
	block16_data_unref (_data_->_data16_);
	_data_->_data16_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
geary_app_conversation_monitor_on_folder_opened (GearyAppConversationMonitor* self,
                                                 GearyFolderOpenState state,
                                                 gint count)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	if (state == GEARY_FOLDER_OPEN_STATE_REMOTE) {
		GearyAppConversationOperationQueue* _tmp0_;
		GearyAppReseedOperation* _tmp1_;
		GearyAppReseedOperation* _tmp2_;
		_tmp0_ = self->priv->queue;
		_tmp1_ = geary_app_reseed_operation_new (self);
		_tmp2_ = _tmp1_;
		geary_app_conversation_operation_queue_add (_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_g_object_unref0 (_tmp2_);
	}
}

static void
geary_app_conversation_monitor_on_folder_email_appended (GearyAppConversationMonitor* self,
                                                         GeeCollection* appended)
{
	GearyAppConversationOperationQueue* _tmp0_;
	GearyAppAppendOperation* _tmp1_;
	GearyAppAppendOperation* _tmp2_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (appended, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->queue;
	_tmp1_ = geary_app_append_operation_new (self, appended);
	_tmp2_ = _tmp1_;
	geary_app_conversation_operation_queue_add (_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
	_g_object_unref0 (_tmp2_);
}

static void
geary_app_conversation_monitor_on_folder_email_complete (GearyAppConversationMonitor* self,
                                                         GeeCollection* completed)
{
	GearyAppConversationOperationQueue* _tmp0_;
	GearyAppInsertOperation* _tmp1_;
	GearyAppInsertOperation* _tmp2_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (completed, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->queue;
	_tmp1_ = geary_app_insert_operation_new (self, completed);
	_tmp2_ = _tmp1_;
	geary_app_conversation_operation_queue_add (_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
	_g_object_unref0 (_tmp2_);
}

static void
geary_app_conversation_monitor_on_folder_email_inserted (GearyAppConversationMonitor* self,
                                                         GeeCollection* inserted)
{
	GearyAppConversationOperationQueue* _tmp0_;
	GearyAppInsertOperation* _tmp1_;
	GearyAppInsertOperation* _tmp2_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (inserted, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->queue;
	_tmp1_ = geary_app_insert_operation_new (self, inserted);
	_tmp2_ = _tmp1_;
	geary_app_conversation_operation_queue_add (_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
	_g_object_unref0 (_tmp2_);
}

static void
geary_app_conversation_monitor_on_folder_email_removed (GearyAppConversationMonitor* self,
                                                        GeeCollection* removed)
{
	GearyAppConversationOperationQueue* _tmp0_;
	GearyFolder* _tmp1_;
	GearyAppRemoveOperation* _tmp2_;
	GearyAppRemoveOperation* _tmp3_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->queue;
	_tmp1_ = self->priv->_base_folder;
	_tmp2_ = geary_app_remove_operation_new (self, _tmp1_, removed);
	_tmp3_ = _tmp2_;
	geary_app_conversation_operation_queue_add (_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
	_g_object_unref0 (_tmp3_);
}

static void
geary_app_conversation_monitor_on_account_email_appended (GearyAppConversationMonitor* self,
                                                          GearyFolder* folder,
                                                          GeeCollection* added)
{
	GearyFolder* _tmp0_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (added, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->_base_folder;
	if (folder != _tmp0_) {
		GearyAppConversationOperationQueue* _tmp1_;
		GearyAppExternalAppendOperation* _tmp2_;
		GearyAppExternalAppendOperation* _tmp3_;
		_tmp1_ = self->priv->queue;
		_tmp2_ = geary_app_external_append_operation_new (self, folder, added);
		_tmp3_ = _tmp2_;
		geary_app_conversation_operation_queue_add (_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_g_object_unref0 (_tmp3_);
	}
}

static void
geary_app_conversation_monitor_on_account_email_complete (GearyAppConversationMonitor* self,
                                                          GearyFolder* folder,
                                                          GeeCollection* inserted)
{
	GearyFolder* _tmp0_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (inserted, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->_base_folder;
	if (folder != _tmp0_) {
		GearyAppConversationOperationQueue* _tmp1_;
		GearyAppExternalAppendOperation* _tmp2_;
		GearyAppExternalAppendOperation* _tmp3_;
		_tmp1_ = self->priv->queue;
		_tmp2_ = geary_app_external_append_operation_new (self, folder, inserted);
		_tmp3_ = _tmp2_;
		geary_app_conversation_operation_queue_add (_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_g_object_unref0 (_tmp3_);
	}
}

static void
geary_app_conversation_monitor_on_account_email_inserted (GearyAppConversationMonitor* self,
                                                          GearyFolder* folder,
                                                          GeeCollection* inserted)
{
	GearyFolder* _tmp0_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (inserted, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->_base_folder;
	if (folder != _tmp0_) {
		GearyAppConversationOperationQueue* _tmp1_;
		GearyAppExternalAppendOperation* _tmp2_;
		GearyAppExternalAppendOperation* _tmp3_;
		_tmp1_ = self->priv->queue;
		_tmp2_ = geary_app_external_append_operation_new (self, folder, inserted);
		_tmp3_ = _tmp2_;
		geary_app_conversation_operation_queue_add (_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_g_object_unref0 (_tmp3_);
	}
}

static void
geary_app_conversation_monitor_on_account_email_removed (GearyAppConversationMonitor* self,
                                                         GearyFolder* folder,
                                                         GeeCollection* removed)
{
	GearyFolder* _tmp0_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->_base_folder;
	if (folder != _tmp0_) {
		GearyAppConversationOperationQueue* _tmp1_;
		GearyAppRemoveOperation* _tmp2_;
		GearyAppRemoveOperation* _tmp3_;
		_tmp1_ = self->priv->queue;
		_tmp2_ = geary_app_remove_operation_new (self, folder, removed);
		_tmp3_ = _tmp2_;
		geary_app_conversation_operation_queue_add (_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_g_object_unref0 (_tmp3_);
	}
}

static void
geary_app_conversation_monitor_on_account_email_flags_changed (GearyAppConversationMonitor* self,
                                                               GearyFolder* folder,
                                                               GeeMap* map)
{
	GeeHashSet* inserted_ids = NULL;
	GeeHashSet* _tmp0_;
	GeeHashSet* removed_ids = NULL;
	GeeHashSet* _tmp1_;
	GeeHashSet* removed_conversations = NULL;
	GeeHashSet* _tmp2_;
	GeeHashSet* _tmp57_;
	gint _tmp58_;
	gint _tmp59_;
	GeeHashSet* _tmp64_ = NULL;
	GearyFolder* _tmp65_;
	GeeHashSet* _tmp67_;
	GeeHashMultiMap* _tmp68_;
	GeeHashMultiMap* _tmp69_;
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (map, GEE_TYPE_MAP));
	_tmp0_ = gee_hash_set_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	inserted_ids = _tmp0_;
	_tmp1_ = gee_hash_set_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	removed_ids = _tmp1_;
	_tmp2_ = gee_hash_set_new (GEARY_APP_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	removed_conversations = _tmp2_;
	{
		GeeIterator* _id_it = NULL;
		GeeSet* _tmp3_;
		GeeSet* _tmp4_;
		GeeSet* _tmp5_;
		GeeIterator* _tmp6_;
		GeeIterator* _tmp7_;
		_tmp3_ = gee_map_get_keys (map);
		_tmp4_ = _tmp3_;
		_tmp5_ = _tmp4_;
		_tmp6_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp7_ = _tmp6_;
		_g_object_unref0 (_tmp5_);
		_id_it = _tmp7_;
		while (TRUE) {
			GeeIterator* _tmp8_;
			GearyEmailIdentifier* id = NULL;
			GeeIterator* _tmp9_;
			gpointer _tmp10_;
			GearyAppConversation* conversation = NULL;
			GearyAppConversationSet* _tmp11_;
			GearyEmailIdentifier* _tmp12_;
			GearyAppConversation* _tmp13_;
			GearyAppConversation* _tmp14_;
			GearyEmail* email = NULL;
			GearyAppConversation* _tmp29_;
			GearyEmailIdentifier* _tmp30_;
			GearyEmail* _tmp31_;
			GearyEmail* _tmp32_;
			GearyEmail* _tmp33_;
			GearyEmailIdentifier* _tmp34_;
			gpointer _tmp35_;
			GearyEmailFlags* _tmp36_;
			GearyAppConversation* _tmp37_;
			GearyEmail* _tmp38_;
			GearyAppConversation* _tmp39_;
			GeeList* _tmp40_;
			GeeList* _tmp41_;
			gint _tmp42_;
			gint _tmp43_;
			gboolean _tmp44_;
			_tmp8_ = _id_it;
			if (!gee_iterator_next (_tmp8_)) {
				break;
			}
			_tmp9_ = _id_it;
			_tmp10_ = gee_iterator_get (_tmp9_);
			id = (GearyEmailIdentifier*) _tmp10_;
			_tmp11_ = self->priv->_conversations;
			_tmp12_ = id;
			_tmp13_ = geary_app_conversation_set_get_by_email_identifier (_tmp11_, _tmp12_);
			conversation = _tmp13_;
			_tmp14_ = conversation;
			if (_tmp14_ == NULL) {
				GearyFolder* _tmp15_;
				_tmp15_ = self->priv->_base_folder;
				if (folder == _tmp15_) {
					GearyEmailIdentifier* lowest = NULL;
					GearyEmailIdentifier* _tmp16_;
					GearyEmailIdentifier* _tmp17_;
					GearyEmailIdentifier* _tmp18_;
					_tmp16_ = geary_app_conversation_monitor_get_window_lowest (self);
					_tmp17_ = _tmp16_;
					lowest = _tmp17_;
					_tmp18_ = lowest;
					if (_tmp18_ != NULL) {
						GearyEmailIdentifier* _tmp19_;
						GearyEmailIdentifier* _tmp20_;
						_tmp19_ = lowest;
						_tmp20_ = id;
						if (geary_email_identifier_natural_sort_comparator (_tmp19_, _tmp20_) < 0) {
							GearyEmailIdentifier* _tmp21_;
							gchar* _tmp22_;
							gchar* _tmp23_;
							GeeHashSet* _tmp24_;
							GearyEmailIdentifier* _tmp25_;
							_tmp21_ = id;
							_tmp22_ = geary_email_identifier_to_string (_tmp21_);
							_tmp23_ = _tmp22_;
							geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unflagging email %s for deletion resurrects conversation", _tmp23_);
							_g_free0 (_tmp23_);
							_tmp24_ = inserted_ids;
							_tmp25_ = id;
							gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp25_);
						} else {
							GearyEmailIdentifier* _tmp26_;
							gchar* _tmp27_;
							gchar* _tmp28_;
							_tmp26_ = id;
							_tmp27_ = geary_email_identifier_to_string (_tmp26_);
							_tmp28_ = _tmp27_;
							geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Not resurrecting undeleted email %s outside of window", _tmp28_);
							_g_free0 (_tmp28_);
						}
					}
					_g_object_unref0 (lowest);
				}
				_g_object_unref0 (conversation);
				_g_object_unref0 (id);
				continue;
			}
			_tmp29_ = conversation;
			_tmp30_ = id;
			_tmp31_ = geary_app_conversation_get_email_by_id (_tmp29_, _tmp30_);
			email = _tmp31_;
			_tmp32_ = email;
			if (_tmp32_ == NULL) {
				_g_object_unref0 (email);
				_g_object_unref0 (conversation);
				_g_object_unref0 (id);
				continue;
			}
			_tmp33_ = email;
			_tmp34_ = id;
			_tmp35_ = gee_map_get (map, _tmp34_);
			_tmp36_ = (GearyEmailFlags*) _tmp35_;
			geary_email_set_flags (_tmp33_, _tmp36_);
			_g_object_unref0 (_tmp36_);
			_tmp37_ = conversation;
			_tmp38_ = email;
			geary_app_conversation_monitor_notify_email_flags_changed (self, _tmp37_, _tmp38_);
			_tmp39_ = conversation;
			_tmp40_ = geary_app_conversation_get_emails (_tmp39_, GEARY_APP_CONVERSATION_ORDERING_NONE, GEARY_APP_CONVERSATION_LOCATION_ANYWHERE, NULL, TRUE);
			_tmp41_ = _tmp40_;
			_tmp42_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, GEE_TYPE_COLLECTION, GeeCollection));
			_tmp43_ = _tmp42_;
			_tmp44_ = _tmp43_ == 0;
			_g_object_unref0 (_tmp41_);
			if (_tmp44_) {
				GearyEmailIdentifier* _tmp45_;
				gchar* _tmp46_;
				gchar* _tmp47_;
				GearyAppConversation* _tmp48_;
				gchar* _tmp49_;
				gchar* _tmp50_;
				GearyAppConversationSet* _tmp51_;
				GearyAppConversation* _tmp52_;
				GeeHashSet* _tmp53_;
				GearyAppConversation* _tmp54_;
				GeeHashSet* _tmp55_;
				GearyEmailIdentifier* _tmp56_;
				_tmp45_ = id;
				_tmp46_ = geary_email_identifier_to_string (_tmp45_);
				_tmp47_ = _tmp46_;
				_tmp48_ = conversation;
				_tmp49_ = geary_app_conversation_to_string (_tmp48_);
				_tmp50_ = _tmp49_;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Flagging email %s for deletion evaporates conversation %s", _tmp47_, _tmp50_);
				_g_free0 (_tmp50_);
				_g_free0 (_tmp47_);
				_tmp51_ = self->priv->_conversations;
				_tmp52_ = conversation;
				geary_app_conversation_set_remove_conversation (_tmp51_, _tmp52_);
				_tmp53_ = removed_conversations;
				_tmp54_ = conversation;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp53_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp54_);
				_tmp55_ = removed_ids;
				_tmp56_ = id;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp55_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp56_);
			}
			_g_object_unref0 (email);
			_g_object_unref0 (conversation);
			_g_object_unref0 (id);
		}
		_g_object_unref0 (_id_it);
	}
	_tmp57_ = inserted_ids;
	_tmp58_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp57_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
	_tmp59_ = _tmp58_;
	if (_tmp59_ > 0) {
		GearyAppConversationOperationQueue* _tmp60_;
		GeeHashSet* _tmp61_;
		GearyAppInsertOperation* _tmp62_;
		GearyAppInsertOperation* _tmp63_;
		_tmp60_ = self->priv->queue;
		_tmp61_ = inserted_ids;
		_tmp62_ = geary_app_insert_operation_new (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp61_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp63_ = _tmp62_;
		geary_app_conversation_operation_queue_add (_tmp60_, G_TYPE_CHECK_INSTANCE_CAST (_tmp63_, GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation));
		_g_object_unref0 (_tmp63_);
	}
	_tmp65_ = self->priv->_base_folder;
	if (folder == _tmp65_) {
		GeeHashSet* _tmp66_;
		_tmp66_ = removed_ids;
		_tmp64_ = _tmp66_;
	} else {
		_tmp64_ = NULL;
	}
	_tmp67_ = removed_conversations;
	_tmp68_ = gee_hash_multi_map_new (GEARY_APP_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_tmp69_ = _tmp68_;
	geary_app_conversation_monitor_removed (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp67_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_tmp69_, GEE_TYPE_MULTI_MAP, GeeMultiMap), G_TYPE_CHECK_INSTANCE_CAST (_tmp64_, GEE_TYPE_COLLECTION, GeeCollection));
	_g_object_unref0 (_tmp69_);
	_g_object_unref0 (removed_conversations);
	_g_object_unref0 (removed_ids);
	_g_object_unref0 (inserted_ids);
}

static void
geary_app_conversation_monitor_on_operation_error (GearyAppConversationMonitor* self,
                                                   GearyAppConversationOperation* op,
                                                   GError* err)
{
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_MONITOR (self));
	g_return_if_fail (GEARY_APP_IS_CONVERSATION_OPERATION (op));
	g_return_if_fail (err != NULL);
	if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
		const gchar* _tmp0_;
		const gchar* _tmp1_;
		_tmp0_ = g_type_name (G_TYPE_FROM_INSTANCE (G_TYPE_CHECK_INSTANCE_CAST (op, G_TYPE_OBJECT, GObject)));
		_tmp1_ = err->message;
		geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error executing %s: %s", _tmp0_, _tmp1_);
	}
	geary_app_conversation_monitor_notify_scan_error (self, err);
}

static void
geary_app_conversation_monitor_process_job_context_init (GearyAppConversationMonitorProcessJobContext *self)
{
	GeeHashMap* _tmp0_;
	memset (self, 0, sizeof (GearyAppConversationMonitorProcessJobContext));
	_tmp0_ = gee_hash_map_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 ((*self).emails);
	(*self).emails = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_MAP, GeeMap);
}

static void
geary_app_conversation_monitor_process_job_context_copy (const GearyAppConversationMonitorProcessJobContext* self,
                                                         GearyAppConversationMonitorProcessJobContext* dest)
{
	GeeMap* _tmp0_;
	GeeMap* _tmp1_;
	_tmp0_ = (*self).emails;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 ((*dest).emails);
	(*dest).emails = _tmp1_;
}

static void
geary_app_conversation_monitor_process_job_context_destroy (GearyAppConversationMonitorProcessJobContext* self)
{
	_g_object_unref0 ((*self).emails);
}

static GearyAppConversationMonitorProcessJobContext*
geary_app_conversation_monitor_process_job_context_dup (const GearyAppConversationMonitorProcessJobContext* self)
{
	GearyAppConversationMonitorProcessJobContext* dup;
	dup = g_new0 (GearyAppConversationMonitorProcessJobContext, 1);
	geary_app_conversation_monitor_process_job_context_copy (self, dup);
	return dup;
}

static void
geary_app_conversation_monitor_process_job_context_free (GearyAppConversationMonitorProcessJobContext* self)
{
	geary_app_conversation_monitor_process_job_context_destroy (self);
	g_free (self);
}

 G_GNUC_NO_INLINE static GType
geary_app_conversation_monitor_process_job_context_get_type_once (void)
{
	GType geary_app_conversation_monitor_process_job_context_type_id;
	geary_app_conversation_monitor_process_job_context_type_id = g_boxed_type_register_static ("GearyAppConversationMonitorProcessJobContext", (GBoxedCopyFunc) geary_app_conversation_monitor_process_job_context_dup, (GBoxedFreeFunc) geary_app_conversation_monitor_process_job_context_free);
	return geary_app_conversation_monitor_process_job_context_type_id;
}

static GType
geary_app_conversation_monitor_process_job_context_get_type (void)
{
	static gsize geary_app_conversation_monitor_process_job_context_type_id__once = 0;
	if (g_once_init_enter (&geary_app_conversation_monitor_process_job_context_type_id__once)) {
		GType geary_app_conversation_monitor_process_job_context_type_id;
		geary_app_conversation_monitor_process_job_context_type_id = geary_app_conversation_monitor_process_job_context_get_type_once ();
		g_once_init_leave (&geary_app_conversation_monitor_process_job_context_type_id__once, geary_app_conversation_monitor_process_job_context_type_id);
	}
	return geary_app_conversation_monitor_process_job_context_type_id__once;
}

static void
geary_app_conversation_monitor_class_init (GearyAppConversationMonitorClass * klass,
                                           gpointer klass_data)
{
	geary_app_conversation_monitor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyAppConversationMonitor_private_offset);
	((GearyAppConversationMonitorClass *) klass)->notify_scan_started = (void (*) (GearyAppConversationMonitor*)) geary_app_conversation_monitor_real_notify_scan_started;
	((GearyAppConversationMonitorClass *) klass)->notify_scan_error = (void (*) (GearyAppConversationMonitor*, GError*)) geary_app_conversation_monitor_real_notify_scan_error;
	((GearyAppConversationMonitorClass *) klass)->notify_scan_completed = (void (*) (GearyAppConversationMonitor*)) geary_app_conversation_monitor_real_notify_scan_completed;
	((GearyAppConversationMonitorClass *) klass)->notify_conversations_added = (void (*) (GearyAppConversationMonitor*, GeeCollection*)) geary_app_conversation_monitor_real_notify_conversations_added;
	((GearyAppConversationMonitorClass *) klass)->notify_conversations_removed = (void (*) (GearyAppConversationMonitor*, GeeCollection*)) geary_app_conversation_monitor_real_notify_conversations_removed;
	((GearyAppConversationMonitorClass *) klass)->notify_conversation_appended = (void (*) (GearyAppConversationMonitor*, GearyAppConversation*, GeeCollection*)) geary_app_conversation_monitor_real_notify_conversation_appended;
	((GearyAppConversationMonitorClass *) klass)->notify_conversation_trimmed = (void (*) (GearyAppConversationMonitor*, GearyAppConversation*, GeeCollection*)) geary_app_conversation_monitor_real_notify_conversation_trimmed;
	((GearyAppConversationMonitorClass *) klass)->notify_email_flags_changed = (void (*) (GearyAppConversationMonitor*, GearyAppConversation*, GearyEmail*)) geary_app_conversation_monitor_real_notify_email_flags_changed;
	((GearyAppConversationMonitorClass *) klass)->scan_started = geary_app_conversation_monitor_real_scan_started;
	((GearyAppConversationMonitorClass *) klass)->scan_completed = geary_app_conversation_monitor_real_scan_completed;
	((GearyAppConversationMonitorClass *) klass)->scan_error = geary_app_conversation_monitor_real_scan_error;
	((GearyAppConversationMonitorClass *) klass)->conversations_added = geary_app_conversation_monitor_real_conversations_added;
	((GearyAppConversationMonitorClass *) klass)->conversations_removed = geary_app_conversation_monitor_real_conversations_removed;
	((GearyAppConversationMonitorClass *) klass)->conversation_appended = geary_app_conversation_monitor_real_conversation_appended;
	((GearyAppConversationMonitorClass *) klass)->conversation_trimmed = geary_app_conversation_monitor_real_conversation_trimmed;
	((GearyAppConversationMonitorClass *) klass)->email_flags_changed = geary_app_conversation_monitor_real_email_flags_changed;
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_app_conversation_monitor_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_app_conversation_monitor_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_app_conversation_monitor_finalize;
	/**
	     * A read-only view of loaded conversations.
	     *
	     * Note that since background tasks may asynchronously update the
	     * set at ant time, any asynchronous tasks carried out while
	     * holding an returned by this method may allow the iterator to
	     * become invalid.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_READ_ONLY_VIEW_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_READ_ONLY_VIEW_PROPERTY] = g_param_spec_object ("read-only-view", "read-only-view", "read-only-view", GEE_TYPE_SET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	     * Number of conversations currently loaded by the monitor.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_SIZE_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_SIZE_PROPERTY] = g_param_spec_int ("size", "size", "size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Folder from which the conversation is originating. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_BASE_FOLDER_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_BASE_FOLDER_PROPERTY] = g_param_spec_object ("base-folder", "base-folder", "base-folder", GEARY_TYPE_FOLDER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Determines if this monitor is monitoring the base folder. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_IS_MONITORING_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_IS_MONITORING_PROPERTY] = g_param_spec_boolean ("is-monitoring", "is-monitoring", "is-monitoring", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Determines if more conversations should be loaded. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_SHOULD_LOAD_MORE_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_SHOULD_LOAD_MORE_PROPERTY] = g_param_spec_boolean ("should-load-more", "should-load-more", "should-load-more", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Determines if more conversations can be loaded. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_CAN_LOAD_MORE_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_CAN_LOAD_MORE_PROPERTY] = g_param_spec_boolean ("can-load-more", "can-load-more", "can-load-more", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Minimum number of emails large conversations should contain. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_MIN_WINDOW_COUNT_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_MIN_WINDOW_COUNT_PROPERTY] = g_param_spec_int ("min-window-count", "min-window-count", "min-window-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Indicates progress conversations are being loaded. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_PROGRESS_MONITOR_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_PROGRESS_MONITOR_PROPERTY] = g_param_spec_object ("progress-monitor", "progress-monitor", "progress-monitor", GEARY_TYPE_PROGRESS_MONITOR, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** {@inheritDoc} */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_LOGGING_PARENT_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_LOGGING_PARENT_PROPERTY] = g_param_spec_object ("logging-parent", "logging-parent", "logging-parent", GEARY_LOGGING_TYPE_SOURCE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** The set of all conversations loaded by the monitor. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_PROPERTY] = g_param_spec_object ("conversations", "conversations", "conversations", GEARY_APP_TYPE_CONVERSATION_SET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** The number of messages currently loaded from the base folder. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_FOLDER_WINDOW_SIZE_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_FOLDER_WINDOW_SIZE_PROPERTY] = g_param_spec_uint ("folder-window-size", "folder-window-size", "folder-window-size", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** The oldest message from the base folder in the loaded window. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_WINDOW_LOWEST_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_WINDOW_LOWEST_PROPERTY] = g_param_spec_object ("window-lowest", "window-lowest", "window-lowest", GEARY_TYPE_EMAIL_IDENTIFIER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Determines if the fill operation can load more messages. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_APP_CONVERSATION_MONITOR_FILL_COMPLETE_PROPERTY, geary_app_conversation_monitor_properties[GEARY_APP_CONVERSATION_MONITOR_FILL_COMPLETE_PROPERTY] = g_param_spec_boolean ("fill-complete", "fill-complete", "fill-complete", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Fired when a message load has started.
	     *
	     * Note that more than one load can be initiated, due to
	     * Conversations being completely asynchronous. Both this, and
	     * {@link scan_completed} will be fired for each individual load
	     * request; that is, there is no internal counter to ensure only a
	     * single completed signal is fired to indicate multiple loads
	     * have finished.
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_SCAN_STARTED_SIGNAL] = g_signal_new ("scan-started", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, scan_started), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	/**
	     * Fired when all extant message loads have completed.
	     *
	     * @see scan_started
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_SCAN_COMPLETED_SIGNAL] = g_signal_new ("scan-completed", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, scan_completed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	/**
	     * Fired when an error was encountered while loading messages.
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_SCAN_ERROR_SIGNAL] = g_signal_new ("scan-error", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, scan_error), NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, G_TYPE_ERROR);
	/**
	     * Fired when one or more new conversations have been detected.
	     *
	     * This may be due to either a user-initiated load request or due
	     * to background monitoring.
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_ADDED_SIGNAL] = g_signal_new ("conversations-added", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, conversations_added), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_COLLECTION);
	/**
	     * Fired when all email in a conversation has been removed.
	     *
	     * It's possible this will be called without a signal alerting
	     * that it's emails have been removed, i.e. a
	     * "conversations-removed" signal may fire with no accompanying
	     * "conversation-trimmed".
	     *
	     * This may be due to either a user-initiated load request or due
	     * to background monitoring.
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_REMOVED_SIGNAL] = g_signal_new ("conversations-removed", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, conversations_removed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_COLLECTION);
	/**
	     * Fired when one or more email have been added to a conversation.
	     *
	     * This may be due to either a user-initiated load request or due
	     * to background monitoring.
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATION_APPENDED_SIGNAL] = g_signal_new ("conversation-appended", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, conversation_appended), NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, GEARY_APP_TYPE_CONVERSATION, GEE_TYPE_COLLECTION);
	/**
	     * Fired when one or more email have been removed from a conversation.
	     *
	     * If the trimmed email is the last usable email in the
	     * Conversation, this signal will be followed by
	     * "conversation-removed".  However, it's possible for
	     * "conversation-removed" to fire without "conversation-trimmed"
	     * preceding it, in the case of all emails being removed from a
	     * conversation at once.
	     *
	     * This may be due to either a user-initiated load request or due
	     * to background monitoring.
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_CONVERSATION_TRIMMED_SIGNAL] = g_signal_new ("conversation-trimmed", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, conversation_trimmed), NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, GEARY_APP_TYPE_CONVERSATION, GEE_TYPE_COLLECTION);
	/**
	     * Fired when a conversation's email's flags have changed.
	     *
	     * The local copy of the email is first updated and then this
	     * signal is fired.
	     *
	     * Note that if the flags of an email not captured by the
	     * Conversations object change, no signal is fired.  To know of
	     * all changes to all flags, subscribe to the base folder's
	     * "email-flags-changed" signal.
	     */
	geary_app_conversation_monitor_signals[GEARY_APP_CONVERSATION_MONITOR_EMAIL_FLAGS_CHANGED_SIGNAL] = g_signal_new ("email-flags-changed", GEARY_APP_TYPE_CONVERSATION_MONITOR, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyAppConversationMonitorClass, email_flags_changed), NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, GEARY_APP_TYPE_CONVERSATION, GEARY_TYPE_EMAIL);
}

static void
geary_app_conversation_monitor_geary_logging_source_interface_init (GearyLoggingSourceIface * iface,
                                                                    gpointer iface_data)
{
	geary_app_conversation_monitor_geary_logging_source_parent_iface = g_type_interface_peek_parent (iface);
	iface->to_logging_state = (GearyLoggingState* (*) (GearyLoggingSource*)) geary_app_conversation_monitor_real_to_logging_state;
	iface->get_logging_domain = geary_app_conversation_monitor_real_get_logging_domain;
	iface->get_logging_parent = geary_app_conversation_monitor_real_get_logging_parent;
}

static void
geary_app_conversation_monitor_instance_init (GearyAppConversationMonitor * self,
                                              gpointer klass)
{
	GearySimpleProgressMonitor* _tmp0_;
	GCancellable* _tmp1_;
	GeeTreeSet* _tmp2_;
	self->priv = geary_app_conversation_monitor_get_instance_private (self);
	self->priv->_is_monitoring = FALSE;
	self->priv->_min_window_count = 0;
	_tmp0_ = geary_simple_progress_monitor_new (GEARY_PROGRESS_TYPE_ACTIVITY);
	self->priv->_progress_monitor = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEARY_TYPE_PROGRESS_MONITOR, GearyProgressMonitor);
	self->priv->_fill_complete = FALSE;
	self->priv->base_was_opened = FALSE;
	_tmp1_ = g_cancellable_new ();
	self->priv->operation_cancellable = _tmp1_;
	_tmp2_ = gee_tree_set_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, __geary_app_conversation_monitor_window_lambda165__gcompare_data_func, NULL, NULL);
	self->priv->window = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_SORTED_SET, GeeSortedSet);
}

static void
geary_app_conversation_monitor_finalize (GObject * obj)
{
	GearyAppConversationMonitor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_APP_TYPE_CONVERSATION_MONITOR, GearyAppConversationMonitor);
	_g_object_unref0 (self->priv->_base_folder);
	_g_object_unref0 (self->priv->_progress_monitor);
	_g_object_unref0 (self->priv->_conversations);
	_g_object_unref0 (self->priv->queue);
	_g_object_unref0 (self->priv->operation_cancellable);
	_g_object_unref0 (self->priv->window);
	G_OBJECT_CLASS (geary_app_conversation_monitor_parent_class)->finalize (obj);
}

/**
 * Loads conversation in a folder and monitors changes to them.
 *
 * The standard IMAP model does not provide a means of easily
 * aggregating messages in a single conversation across mailboxes,
 * hence this class provides applications with a means of loading
 * complete conversations, one for each email message found in a
 * specified base folder. This is an expensive operation since it may
 * require opening several other folders to find all messages in the
 * conversation, and so the monitor is lazy and will only load enough
 * conversations to fill a minimal window size. Additional
 * conversations can be loaded afterwards as needed.
 *
 * When monitoring starts via a call to {@link
 * start_monitoring}, the folder will perform an initial
 * //scan// of messages in the base folder and load conversation load
 * based on that. Increasing {@link min_window_count} will cause
 * additional scan operations to be executed as needed to fill the new
 * window size.
 *
 * If the folder is backed by a remote mailbox, scans will be
 * local-only if the remote is not open so as to not block. However
 * this means any messages (and their conversations) that are not
 * sufficiently complete to satisfy both the monitor's and the owner's
 * email field requirements will not be found. If or when the folder
 * does open a remote connection, the folder will be re-scanned to
 * ensure any missing messages are picked up.
 *
 * The monitor will also keep track of messages being appended or
 * removed account-wide, so that known conversations can be updated as
 * needed.
 */
 G_GNUC_NO_INLINE static GType
geary_app_conversation_monitor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyAppConversationMonitorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_app_conversation_monitor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyAppConversationMonitor), 0, (GInstanceInitFunc) geary_app_conversation_monitor_instance_init, NULL };
	static const GInterfaceInfo geary_logging_source_info = { (GInterfaceInitFunc) geary_app_conversation_monitor_geary_logging_source_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType geary_app_conversation_monitor_type_id;
	geary_app_conversation_monitor_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "GearyAppConversationMonitor", &g_define_type_info, 0);
	g_type_add_interface_static (geary_app_conversation_monitor_type_id, GEARY_LOGGING_TYPE_SOURCE, &geary_logging_source_info);
	GearyAppConversationMonitor_private_offset = g_type_add_instance_private (geary_app_conversation_monitor_type_id, sizeof (GearyAppConversationMonitorPrivate));
	return geary_app_conversation_monitor_type_id;
}

GType
geary_app_conversation_monitor_get_type (void)
{
	static gsize geary_app_conversation_monitor_type_id__once = 0;
	if (g_once_init_enter (&geary_app_conversation_monitor_type_id__once)) {
		GType geary_app_conversation_monitor_type_id;
		geary_app_conversation_monitor_type_id = geary_app_conversation_monitor_get_type_once ();
		g_once_init_leave (&geary_app_conversation_monitor_type_id__once, geary_app_conversation_monitor_type_id);
	}
	return geary_app_conversation_monitor_type_id__once;
}

static void
_vala_geary_app_conversation_monitor_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	GearyAppConversationMonitor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_APP_TYPE_CONVERSATION_MONITOR, GearyAppConversationMonitor);
	switch (property_id) {
		case GEARY_APP_CONVERSATION_MONITOR_READ_ONLY_VIEW_PROPERTY:
		g_value_take_object (value, geary_app_conversation_monitor_get_read_only_view (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_SIZE_PROPERTY:
		g_value_set_int (value, geary_app_conversation_monitor_get_size (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_BASE_FOLDER_PROPERTY:
		g_value_set_object (value, geary_app_conversation_monitor_get_base_folder (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_IS_MONITORING_PROPERTY:
		g_value_set_boolean (value, geary_app_conversation_monitor_get_is_monitoring (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_SHOULD_LOAD_MORE_PROPERTY:
		g_value_set_boolean (value, geary_app_conversation_monitor_get_should_load_more (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_CAN_LOAD_MORE_PROPERTY:
		g_value_set_boolean (value, geary_app_conversation_monitor_get_can_load_more (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_MIN_WINDOW_COUNT_PROPERTY:
		g_value_set_int (value, geary_app_conversation_monitor_get_min_window_count (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_PROGRESS_MONITOR_PROPERTY:
		g_value_set_object (value, geary_app_conversation_monitor_get_progress_monitor (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_LOGGING_PARENT_PROPERTY:
		g_value_set_object (value, geary_logging_source_get_logging_parent (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource)));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_PROPERTY:
		g_value_set_object (value, geary_app_conversation_monitor_get_conversations (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_FOLDER_WINDOW_SIZE_PROPERTY:
		g_value_set_uint (value, geary_app_conversation_monitor_get_folder_window_size (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_WINDOW_LOWEST_PROPERTY:
		g_value_take_object (value, geary_app_conversation_monitor_get_window_lowest (self));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_FILL_COMPLETE_PROPERTY:
		g_value_set_boolean (value, geary_app_conversation_monitor_get_fill_complete (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_app_conversation_monitor_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec)
{
	GearyAppConversationMonitor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_APP_TYPE_CONVERSATION_MONITOR, GearyAppConversationMonitor);
	switch (property_id) {
		case GEARY_APP_CONVERSATION_MONITOR_BASE_FOLDER_PROPERTY:
		geary_app_conversation_monitor_set_base_folder (self, g_value_get_object (value));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_IS_MONITORING_PROPERTY:
		geary_app_conversation_monitor_set_is_monitoring (self, g_value_get_boolean (value));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_MIN_WINDOW_COUNT_PROPERTY:
		geary_app_conversation_monitor_set_min_window_count (self, g_value_get_int (value));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_PROGRESS_MONITOR_PROPERTY:
		geary_app_conversation_monitor_set_progress_monitor (self, g_value_get_object (value));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_CONVERSATIONS_PROPERTY:
		geary_app_conversation_monitor_set_conversations (self, g_value_get_object (value));
		break;
		case GEARY_APP_CONVERSATION_MONITOR_FILL_COMPLETE_PROPERTY:
		geary_app_conversation_monitor_set_fill_complete (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

