/* imap-engine-list-email-by-id.c generated by valac 0.56.3, the Vala compiler
 * generated from imap-engine-list-email-by-id.vala, do not modify */

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

#define GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION (geary_imap_engine_replay_operation_get_type ())
#define GEARY_IMAP_ENGINE_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation))
#define GEARY_IMAP_ENGINE_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperationClass))
#define GEARY_IMAP_ENGINE_IS_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_IS_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_REPLAY_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperationClass))

typedef struct _GearyImapEngineReplayOperation GearyImapEngineReplayOperation;
typedef struct _GearyImapEngineReplayOperationClass GearyImapEngineReplayOperationClass;
typedef struct _GearyImapEngineReplayOperationPrivate GearyImapEngineReplayOperationPrivate;

#define GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER (geary_imap_db_email_identifier_get_type ())
#define GEARY_IMAP_DB_EMAIL_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier))
#define GEARY_IMAP_DB_EMAIL_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifierClass))
#define GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER))
#define GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER))
#define GEARY_IMAP_DB_EMAIL_IDENTIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifierClass))

typedef struct _GearyImapDBEmailIdentifier GearyImapDBEmailIdentifier;
typedef struct _GearyImapDBEmailIdentifierClass GearyImapDBEmailIdentifierClass;
typedef enum  {
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_COMPLETED,
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_CONTINUE
} GearyImapEngineReplayOperationStatus;

#define GEARY_IMAP_ENGINE_REPLAY_OPERATION_TYPE_STATUS (geary_imap_engine_replay_operation_status_get_type ())

#define GEARY_IMAP_TYPE_FOLDER_SESSION (geary_imap_folder_session_get_type ())
#define GEARY_IMAP_FOLDER_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_TYPE_FOLDER_SESSION, GearyImapFolderSession))
#define GEARY_IMAP_FOLDER_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_TYPE_FOLDER_SESSION, GearyImapFolderSessionClass))
#define GEARY_IMAP_IS_FOLDER_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_TYPE_FOLDER_SESSION))
#define GEARY_IMAP_IS_FOLDER_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_TYPE_FOLDER_SESSION))
#define GEARY_IMAP_FOLDER_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_TYPE_FOLDER_SESSION, GearyImapFolderSessionClass))

typedef struct _GearyImapFolderSession GearyImapFolderSession;
typedef struct _GearyImapFolderSessionClass GearyImapFolderSessionClass;

#define GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION (geary_imap_engine_send_replay_operation_get_type ())
#define GEARY_IMAP_ENGINE_SEND_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION, GearyImapEngineSendReplayOperation))
#define GEARY_IMAP_ENGINE_SEND_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION, GearyImapEngineSendReplayOperationClass))
#define GEARY_IMAP_ENGINE_IS_SEND_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_IS_SEND_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_SEND_REPLAY_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION, GearyImapEngineSendReplayOperationClass))

typedef struct _GearyImapEngineSendReplayOperation GearyImapEngineSendReplayOperation;
typedef struct _GearyImapEngineSendReplayOperationClass GearyImapEngineSendReplayOperationClass;
typedef struct _GearyImapEngineSendReplayOperationPrivate GearyImapEngineSendReplayOperationPrivate;

#define GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL (geary_imap_engine_abstract_list_email_get_type ())
#define GEARY_IMAP_ENGINE_ABSTRACT_LIST_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail))
#define GEARY_IMAP_ENGINE_ABSTRACT_LIST_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmailClass))
#define GEARY_IMAP_ENGINE_IS_ABSTRACT_LIST_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL))
#define GEARY_IMAP_ENGINE_IS_ABSTRACT_LIST_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL))
#define GEARY_IMAP_ENGINE_ABSTRACT_LIST_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmailClass))

typedef struct _GearyImapEngineAbstractListEmail GearyImapEngineAbstractListEmail;
typedef struct _GearyImapEngineAbstractListEmailClass GearyImapEngineAbstractListEmailClass;
typedef struct _GearyImapEngineAbstractListEmailPrivate GearyImapEngineAbstractListEmailPrivate;

#define GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER (geary_imap_engine_minimal_folder_get_type ())
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder))
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolderClass))
#define GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER))
#define GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER))
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolderClass))

typedef struct _GearyImapEngineMinimalFolder GearyImapEngineMinimalFolder;
typedef struct _GearyImapEngineMinimalFolderClass GearyImapEngineMinimalFolderClass;

#define GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID (geary_imap_engine_list_email_by_id_get_type ())
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByID))
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByIDClass))
#define GEARY_IMAP_ENGINE_IS_LIST_EMAIL_BY_ID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID))
#define GEARY_IMAP_ENGINE_IS_LIST_EMAIL_BY_ID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID))
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByIDClass))

typedef struct _GearyImapEngineListEmailByID GearyImapEngineListEmailByID;
typedef struct _GearyImapEngineListEmailByIDClass GearyImapEngineListEmailByIDClass;
typedef struct _GearyImapEngineListEmailByIDPrivate GearyImapEngineListEmailByIDPrivate;
enum  {
	GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID_0_PROPERTY,
	GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_list_email_by_id_properties[GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GEARY_IMAP_DB_TYPE_FOLDER (geary_imap_db_folder_get_type ())
#define GEARY_IMAP_DB_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_DB_TYPE_FOLDER, GearyImapDBFolder))
#define GEARY_IMAP_DB_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_DB_TYPE_FOLDER, GearyImapDBFolderClass))
#define GEARY_IMAP_DB_IS_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_DB_TYPE_FOLDER))
#define GEARY_IMAP_DB_IS_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_DB_TYPE_FOLDER))
#define GEARY_IMAP_DB_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_DB_TYPE_FOLDER, GearyImapDBFolderClass))

typedef struct _GearyImapDBFolder GearyImapDBFolder;
typedef struct _GearyImapDBFolderClass GearyImapDBFolderClass;
typedef enum  {
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_NONE = 0,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_PARTIAL_OK = 1 << 0,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_INCLUDE_MARKED_FOR_REMOVE = 1 << 1,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_INCLUDING_ID = 1 << 2,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_OLDEST_TO_NEWEST = 1 << 3,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_ONLY_INCOMPLETE = 1 << 4
} GearyImapDBFolderListFlags;

#define GEARY_IMAP_DB_FOLDER_TYPE_LIST_FLAGS (geary_imap_db_folder_list_flags_get_type ())
typedef struct _GearyImapEngineListEmailByIdReplayLocalAsyncData GearyImapEngineListEmailByIdReplayLocalAsyncData;
typedef struct _GearyImapEngineListEmailByIdReplayRemoteAsyncData GearyImapEngineListEmailByIdReplayRemoteAsyncData;
#define _g_free0(var) (var = (g_free (var), NULL))

#define GEARY_IMAP_TYPE_FOLDER (geary_imap_folder_get_type ())
#define GEARY_IMAP_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_TYPE_FOLDER, GearyImapFolder))
#define GEARY_IMAP_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_TYPE_FOLDER, GearyImapFolderClass))
#define GEARY_IMAP_IS_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_TYPE_FOLDER))
#define GEARY_IMAP_IS_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_TYPE_FOLDER))
#define GEARY_IMAP_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_TYPE_FOLDER, GearyImapFolderClass))

typedef struct _GearyImapFolder GearyImapFolder;
typedef struct _GearyImapFolderClass GearyImapFolderClass;
typedef struct _GearyImapEngineListEmailByIdIsFullyExpandedAsyncData GearyImapEngineListEmailByIdIsFullyExpandedAsyncData;

struct _GearyImapEngineReplayOperation {
	GearyBaseObject parent_instance;
	GearyImapEngineReplayOperationPrivate * priv;
};

struct _GearyImapEngineReplayOperationClass {
	GearyBaseObjectClass parent_class;
	void (*notify_remote_removed_position) (GearyImapEngineReplayOperation* self, GearyImapSequenceNumber* removed);
	void (*notify_remote_removed_ids) (GearyImapEngineReplayOperation* self, GeeCollection* ids);
	void (*get_ids_to_be_remote_removed) (GearyImapEngineReplayOperation* self, GeeCollection* ids);
	void (*replay_local_async) (GearyImapEngineReplayOperation* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GearyImapEngineReplayOperationStatus (*replay_local_finish) (GearyImapEngineReplayOperation* self, GAsyncResult* _res_, GError** error);
	void (*replay_remote_async) (GearyImapEngineReplayOperation* self, GearyImapFolderSession* remote, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*replay_remote_finish) (GearyImapEngineReplayOperation* self, GAsyncResult* _res_, GError** error);
	void (*backout_local_async) (GearyImapEngineReplayOperation* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*backout_local_finish) (GearyImapEngineReplayOperation* self, GAsyncResult* _res_, GError** error);
	gchar* (*describe_state) (GearyImapEngineReplayOperation* self);
};

struct _GearyImapEngineSendReplayOperation {
	GearyImapEngineReplayOperation parent_instance;
	GearyImapEngineSendReplayOperationPrivate * priv;
};

struct _GearyImapEngineSendReplayOperationClass {
	GearyImapEngineReplayOperationClass parent_class;
};

struct _GearyImapEngineAbstractListEmail {
	GearyImapEngineSendReplayOperation parent_instance;
	GeeList* accumulator;
	GearyImapEngineMinimalFolder* owner;
	GearyEmailField required_fields;
	GCancellable* cancellable;
	GearyFolderListFlags flags;
	GearyImapEngineAbstractListEmailPrivate * priv;
};

struct _GearyImapEngineAbstractListEmailClass {
	GearyImapEngineSendReplayOperationClass parent_class;
};

struct _GearyImapEngineListEmailByID {
	GearyImapEngineAbstractListEmail parent_instance;
	GearyImapEngineListEmailByIDPrivate * priv;
};

struct _GearyImapEngineListEmailByIDClass {
	GearyImapEngineAbstractListEmailClass parent_class;
};

struct _GearyImapEngineListEmailByIDPrivate {
	GearyImapDBEmailIdentifier* initial_id;
	gint count;
	gint fulfilled_count;
	GearyImapUID* initial_uid;
};

struct _GearyImapEngineListEmailByIdReplayLocalAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineListEmailByID* self;
	GearyImapEngineReplayOperationStatus result;
	GearyImapDBEmailIdentifier* _tmp0_;
	GearyEmail* email;
	GearyImapEngineMinimalFolder* _tmp1_;
	GearyImapDBFolder* _tmp2_;
	GearyImapDBFolder* _tmp3_;
	GearyImapDBEmailIdentifier* _tmp4_;
	GCancellable* _tmp5_;
	GearyEmail* _tmp6_;
	GearyEmail* _tmp7_;
	GearyEmailIdentifier* _tmp8_;
	GearyEmailIdentifier* _tmp9_;
	GearyImapUID* _tmp10_;
	GearyImapUID* _tmp11_;
	GearyImapUID* _tmp12_;
	GearyImapDBFolderListFlags local_flags;
	GeeList* list;
	GearyImapEngineMinimalFolder* _tmp13_;
	GearyImapDBFolder* _tmp14_;
	GearyImapDBFolder* _tmp15_;
	GearyImapDBEmailIdentifier* _tmp16_;
	GCancellable* _tmp17_;
	GeeList* _tmp18_;
	GeeArrayList* fulfilled;
	GeeArrayList* _tmp19_;
	GeeList* _tmp20_;
	GeeList* _email_list;
	GeeList* _tmp21_;
	gint _email_size;
	GeeList* _tmp22_;
	gint _tmp23_;
	gint _tmp24_;
	gint _email_index;
	gint _tmp25_;
	gint _tmp26_;
	GearyEmail* _vala1_email;
	GeeList* _tmp27_;
	gpointer _tmp28_;
	GearyEmail* _tmp29_;
	GearyEmailField _tmp30_;
	GearyEmailField _tmp31_;
	GeeArrayList* _tmp32_;
	GearyEmail* _tmp33_;
	GearyImapUID* uid;
	GearyEmail* _tmp34_;
	GearyEmailIdentifier* _tmp35_;
	GearyEmailIdentifier* _tmp36_;
	GearyImapUID* _tmp37_;
	GearyImapUID* _tmp38_;
	GearyImapUID* _tmp39_;
	GearyImapUID* _tmp40_;
	GearyEmail* _tmp41_;
	GearyEmailField _tmp42_;
	GearyEmailField _tmp43_;
	GeeArrayList* _tmp44_;
	gint _tmp45_;
	gint _tmp46_;
	GeeList* _tmp47_;
	GeeArrayList* _tmp48_;
	gboolean finished;
	gboolean _tmp49_;
	gboolean _tmp50_;
	GearyImapEngineReplayOperationStatus _tmp51_;
	GError* _inner_error0_;
};

struct _GearyImapEngineListEmailByIdReplayRemoteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineListEmailByID* self;
	GearyImapFolderSession* remote;
	gboolean expansion_required;
	gboolean _tmp0_;
	GeeSet* uids;
	GearyImapUID* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	GeeSet* _tmp4_;
	GError* _inner_error0_;
};

struct _GearyImapEngineListEmailByIdIsFullyExpandedAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineListEmailByID* self;
	GearyImapFolderSession* remote;
	gboolean result;
	gint remote_count;
	GearyImapFolder* _tmp0_;
	GearyImapFolder* _tmp1_;
	GearyImapFolderProperties* _tmp2_;
	GearyImapFolderProperties* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint local_count_with_marked;
	GearyImapEngineMinimalFolder* _tmp6_;
	GearyImapDBFolder* _tmp7_;
	GearyImapDBFolder* _tmp8_;
	GCancellable* _tmp9_;
	GError* _inner_error0_;
};

static gint GearyImapEngineListEmailByID_private_offset;
static gpointer geary_imap_engine_list_email_by_id_parent_class = NULL;

VALA_EXTERN GType geary_imap_engine_replay_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_db_email_identifier_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_replay_operation_status_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_folder_session_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_send_replay_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_abstract_list_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_minimal_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_list_email_by_id_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_replay_operation_replay_local_async (GearyImapEngineReplayOperation* self,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
VALA_EXTERN GearyImapEngineReplayOperationStatus geary_imap_engine_replay_operation_replay_local_finish (GearyImapEngineReplayOperation* self,
                                                                                             GAsyncResult* _res_,
                                                                                             GError** error);
VALA_EXTERN void geary_imap_engine_replay_operation_replay_remote_async (GearyImapEngineReplayOperation* self,
                                                             GearyImapFolderSession* remote,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_replay_operation_replay_remote_finish (GearyImapEngineReplayOperation* self,
                                                              GAsyncResult* _res_,
                                                              GError** error);
VALA_EXTERN gchar* geary_imap_engine_replay_operation_describe_state (GearyImapEngineReplayOperation* self);
VALA_EXTERN GearyImapEngineListEmailByID* geary_imap_engine_list_email_by_id_new (GearyImapEngineMinimalFolder* owner,
                                                                      GearyImapDBEmailIdentifier* initial_id,
                                                                      gint count,
                                                                      GearyEmailField required_fields,
                                                                      GearyFolderListFlags flags,
                                                                      GCancellable* cancellable);
VALA_EXTERN GearyImapEngineListEmailByID* geary_imap_engine_list_email_by_id_construct (GType object_type,
                                                                            GearyImapEngineMinimalFolder* owner,
                                                                            GearyImapDBEmailIdentifier* initial_id,
                                                                            gint count,
                                                                            GearyEmailField required_fields,
                                                                            GearyFolderListFlags flags,
                                                                            GCancellable* cancellable);
VALA_EXTERN GearyImapEngineAbstractListEmail* geary_imap_engine_abstract_list_email_construct (GType object_type,
                                                                                   const gchar* name,
                                                                                   GearyImapEngineMinimalFolder* owner,
                                                                                   GearyEmailField required_fields,
                                                                                   GearyFolderListFlags flags,
                                                                                   GCancellable* cancellable);
static void geary_imap_engine_list_email_by_id_real_replay_local_async_data_free (gpointer _data);
static void geary_imap_engine_list_email_by_id_real_replay_local_async (GearyImapEngineReplayOperation* base,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_);
static gboolean geary_imap_engine_list_email_by_id_real_replay_local_async_co (GearyImapEngineListEmailByIdReplayLocalAsyncData* _data_);
VALA_EXTERN GType geary_imap_db_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapDBFolder* geary_imap_engine_minimal_folder_get_local_folder (GearyImapEngineMinimalFolder* self);
VALA_EXTERN GType geary_imap_db_folder_list_flags_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_db_folder_fetch_email_async (GearyImapDBFolder* self,
                                             GearyImapDBEmailIdentifier* id,
                                             GearyEmailField required_fields,
                                             GearyImapDBFolderListFlags flags,
                                             GCancellable* cancellable,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN GearyEmail* geary_imap_db_folder_fetch_email_finish (GearyImapDBFolder* self,
                                                     GAsyncResult* _res_,
                                                     GError** error);
static void geary_imap_engine_list_email_by_id_replay_local_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
VALA_EXTERN GearyImapUID* geary_imap_db_email_identifier_get_uid (GearyImapDBEmailIdentifier* self);
VALA_EXTERN GearyImapDBFolderListFlags geary_imap_db_folder_list_flags_from_folder_flags (GearyFolderListFlags flags);
VALA_EXTERN void geary_imap_db_folder_list_email_by_id_async (GearyImapDBFolder* self,
                                                  GearyImapDBEmailIdentifier* initial_id,
                                                  gint count,
                                                  GearyEmailField required_fields,
                                                  GearyImapDBFolderListFlags flags,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN GeeList* geary_imap_db_folder_list_email_by_id_finish (GearyImapDBFolder* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
VALA_EXTERN void geary_imap_engine_abstract_list_email_add_unfulfilled_fields (GearyImapEngineAbstractListEmail* self,
                                                                   GearyImapUID* uid,
                                                                   GearyEmailField unfulfilled_fields);
VALA_EXTERN gint geary_imap_engine_abstract_list_email_get_unfulfilled_count (GearyImapEngineAbstractListEmail* self);
static void geary_imap_engine_list_email_by_id_real_replay_remote_async_data_free (gpointer _data);
static void geary_imap_engine_list_email_by_id_real_replay_remote_async (GearyImapEngineReplayOperation* base,
                                                                  GearyImapFolderSession* remote,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
static gboolean geary_imap_engine_list_email_by_id_real_replay_remote_async_co (GearyImapEngineListEmailByIdReplayRemoteAsyncData* _data_);
static void geary_imap_engine_list_email_by_id_is_fully_expanded_async (GearyImapEngineListEmailByID* self,
                                                                 GearyImapFolderSession* remote,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_);
static gboolean geary_imap_engine_list_email_by_id_is_fully_expanded_finish (GearyImapEngineListEmailByID* self,
                                                                      GAsyncResult* _res_,
                                                                      GError** error);
static void geary_imap_engine_list_email_by_id_replay_remote_async_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_abstract_list_email_expand_vector_async (GearyImapEngineAbstractListEmail* self,
                                                                GearyImapFolderSession* remote,
                                                                GearyImapUID* initial_uid,
                                                                gint count,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_engine_abstract_list_email_expand_vector_finish (GearyImapEngineAbstractListEmail* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error);
VALA_EXTERN void geary_imap_engine_abstract_list_email_add_many_unfulfilled_fields (GearyImapEngineAbstractListEmail* self,
                                                                        GeeCollection* uids,
                                                                        GearyEmailField unfulfilled_fields);
static gchar* geary_imap_engine_list_email_by_id_real_describe_state (GearyImapEngineReplayOperation* base);
static void geary_imap_engine_list_email_by_id_is_fully_expanded_async_data_free (gpointer _data);
static gboolean geary_imap_engine_list_email_by_id_is_fully_expanded_async_co (GearyImapEngineListEmailByIdIsFullyExpandedAsyncData* _data_);
VALA_EXTERN GType geary_imap_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapFolder* geary_imap_folder_session_get_folder (GearyImapFolderSession* self);
VALA_EXTERN GearyImapFolderProperties* geary_imap_folder_get_properties (GearyImapFolder* self);
VALA_EXTERN void geary_imap_db_folder_get_email_count_async (GearyImapDBFolder* self,
                                                 GearyImapDBFolderListFlags flags,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
VALA_EXTERN gint geary_imap_db_folder_get_email_count_finish (GearyImapDBFolder* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
static void geary_imap_engine_list_email_by_id_is_fully_expanded_async_ready (GObject* source_object,
                                                                       GAsyncResult* _res_,
                                                                       gpointer _user_data_);
static void geary_imap_engine_list_email_by_id_finalize (GObject * obj);
static GType geary_imap_engine_list_email_by_id_get_type_once (void);

static inline gpointer
geary_imap_engine_list_email_by_id_get_instance_private (GearyImapEngineListEmailByID* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineListEmailByID_private_offset);
}

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

GearyImapEngineListEmailByID*
geary_imap_engine_list_email_by_id_construct (GType object_type,
                                              GearyImapEngineMinimalFolder* owner,
                                              GearyImapDBEmailIdentifier* initial_id,
                                              gint count,
                                              GearyEmailField required_fields,
                                              GearyFolderListFlags flags,
                                              GCancellable* cancellable)
{
	GearyImapEngineListEmailByID * self = NULL;
	GearyImapDBEmailIdentifier* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (owner), NULL);
	g_return_val_if_fail ((initial_id == NULL) || GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER (initial_id), NULL);
	g_return_val_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()), NULL);
	self = (GearyImapEngineListEmailByID*) geary_imap_engine_abstract_list_email_construct (object_type, "ListEmailByID", owner, required_fields, flags, cancellable);
	_tmp0_ = _g_object_ref0 (initial_id);
	_g_object_unref0 (self->priv->initial_id);
	self->priv->initial_id = _tmp0_;
	self->priv->count = count;
	return self;
}

GearyImapEngineListEmailByID*
geary_imap_engine_list_email_by_id_new (GearyImapEngineMinimalFolder* owner,
                                        GearyImapDBEmailIdentifier* initial_id,
                                        gint count,
                                        GearyEmailField required_fields,
                                        GearyFolderListFlags flags,
                                        GCancellable* cancellable)
{
	return geary_imap_engine_list_email_by_id_construct (GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, owner, initial_id, count, required_fields, flags, cancellable);
}

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

static void
geary_imap_engine_list_email_by_id_real_replay_local_async (GearyImapEngineReplayOperation* base,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_)
{
	GearyImapEngineListEmailByID * self;
	GearyImapEngineListEmailByIdReplayLocalAsyncData* _data_;
	GearyImapEngineListEmailByID* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByID);
	_data_ = g_slice_new0 (GearyImapEngineListEmailByIdReplayLocalAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_imap_engine_list_email_by_id_real_replay_local_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	geary_imap_engine_list_email_by_id_real_replay_local_async_co (_data_);
}

static GearyImapEngineReplayOperationStatus
geary_imap_engine_list_email_by_id_replay_local_finish (GearyImapEngineReplayOperation* base,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	GearyImapEngineReplayOperationStatus result;
	GearyImapEngineListEmailByIdReplayLocalAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return 0;
	}
	result = _data_->result;
	return result;
}

static void
geary_imap_engine_list_email_by_id_replay_local_async_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	GearyImapEngineListEmailByIdReplayLocalAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_list_email_by_id_real_replay_local_async_co (_data_);
}

static gboolean
geary_imap_engine_list_email_by_id_real_replay_local_async_co (GearyImapEngineListEmailByIdReplayLocalAsyncData* _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:
	if (geary_folder_list_flags_is_force_update (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->flags)) {
		_data_->result = GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_CONTINUE;
		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_->_tmp0_ = _data_->self->priv->initial_id;
	if (_data_->_tmp0_ != NULL) {
		_data_->_tmp1_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->owner;
		_data_->_tmp2_ = geary_imap_engine_minimal_folder_get_local_folder (_data_->_tmp1_);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = _data_->self->priv->initial_id;
		_data_->_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->cancellable;
		_data_->_state_ = 1;
		geary_imap_db_folder_fetch_email_async (_data_->_tmp3_, _data_->_tmp4_, GEARY_EMAIL_FIELD_NONE, GEARY_IMAP_DB_FOLDER_LIST_FLAGS_NONE, _data_->_tmp5_, geary_imap_engine_list_email_by_id_replay_local_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = geary_imap_db_folder_fetch_email_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		_data_->email = _data_->_tmp6_;
		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_->_tmp7_ = _data_->email;
		_data_->_tmp8_ = geary_email_get_id (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = geary_imap_db_email_identifier_get_uid (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp9_, GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier));
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = _g_object_ref0 (_data_->_tmp11_);
		_g_object_unref0 (_data_->self->priv->initial_uid);
		_data_->self->priv->initial_uid = _data_->_tmp12_;
		_g_object_unref0 (_data_->email);
	}
	_data_->local_flags = geary_imap_db_folder_list_flags_from_folder_flags (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->flags) | GEARY_IMAP_DB_FOLDER_LIST_FLAGS_PARTIAL_OK;
	_data_->_tmp13_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->owner;
	_data_->_tmp14_ = geary_imap_engine_minimal_folder_get_local_folder (_data_->_tmp13_);
	_data_->_tmp15_ = _data_->_tmp14_;
	_data_->_tmp16_ = _data_->self->priv->initial_id;
	_data_->_tmp17_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->cancellable;
	_data_->_state_ = 2;
	geary_imap_db_folder_list_email_by_id_async (_data_->_tmp15_, _data_->_tmp16_, _data_->self->priv->count, G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->required_fields, _data_->local_flags, _data_->_tmp17_, geary_imap_engine_list_email_by_id_replay_local_async_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp18_ = geary_imap_db_folder_list_email_by_id_finish (_data_->_tmp15_, _data_->_res_, &_data_->_inner_error0_);
	_data_->list = _data_->_tmp18_;
	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_->_tmp19_ = gee_array_list_new (GEARY_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data_->fulfilled = _data_->_tmp19_;
	_data_->_tmp20_ = _data_->list;
	if (_data_->_tmp20_ != NULL) {
		{
			_data_->_tmp21_ = _data_->list;
			_data_->_email_list = _data_->_tmp21_;
			_data_->_tmp22_ = _data_->_email_list;
			_data_->_tmp23_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp22_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp24_ = _data_->_tmp23_;
			_data_->_email_size = _data_->_tmp24_;
			_data_->_email_index = -1;
			while (TRUE) {
				_data_->_email_index = _data_->_email_index + 1;
				_data_->_tmp25_ = _data_->_email_index;
				_data_->_tmp26_ = _data_->_email_size;
				if (!(_data_->_tmp25_ < _data_->_tmp26_)) {
					break;
				}
				_data_->_tmp27_ = _data_->_email_list;
				_data_->_tmp28_ = gee_list_get (_data_->_tmp27_, _data_->_email_index);
				_data_->_vala1_email = (GearyEmail*) _data_->_tmp28_;
				_data_->_tmp29_ = _data_->_vala1_email;
				_data_->_tmp30_ = geary_email_get_fields (_data_->_tmp29_);
				_data_->_tmp31_ = _data_->_tmp30_;
				if (geary_email_field_fulfills (_data_->_tmp31_, G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->required_fields)) {
					_data_->_tmp32_ = _data_->fulfilled;
					_data_->_tmp33_ = _data_->_vala1_email;
					gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp32_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _data_->_tmp33_);
				} else {
					_data_->_tmp34_ = _data_->_vala1_email;
					_data_->_tmp35_ = geary_email_get_id (_data_->_tmp34_);
					_data_->_tmp36_ = _data_->_tmp35_;
					_data_->_tmp37_ = geary_imap_db_email_identifier_get_uid (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp36_, GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier));
					_data_->_tmp38_ = _data_->_tmp37_;
					_data_->_tmp39_ = _g_object_ref0 (_data_->_tmp38_);
					_data_->uid = _data_->_tmp39_;
					_data_->_tmp40_ = _data_->uid;
					_data_->_tmp41_ = _data_->_vala1_email;
					_data_->_tmp42_ = geary_email_get_fields (_data_->_tmp41_);
					_data_->_tmp43_ = _data_->_tmp42_;
					geary_imap_engine_abstract_list_email_add_unfulfilled_fields (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail), _data_->_tmp40_, geary_email_field_clear (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->required_fields, _data_->_tmp43_));
					_g_object_unref0 (_data_->uid);
				}
				_g_object_unref0 (_data_->_vala1_email);
			}
		}
	}
	_data_->_tmp44_ = _data_->fulfilled;
	_data_->_tmp45_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp44_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
	_data_->_tmp46_ = _data_->_tmp45_;
	_data_->self->priv->fulfilled_count = _data_->_tmp46_;
	if (_data_->self->priv->fulfilled_count > 0) {
		_data_->_tmp47_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->accumulator;
		_data_->_tmp48_ = _data_->fulfilled;
		gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp47_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp48_, GEE_TYPE_COLLECTION, GeeCollection));
	}
	_data_->finished = FALSE;
	if (geary_folder_list_flags_is_local_only (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->flags)) {
		_data_->finished = TRUE;
	} else {
		if (_data_->self->priv->count != G_MAXINT) {
			if (geary_imap_engine_abstract_list_email_get_unfulfilled_count (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)) == 0) {
				_data_->_tmp49_ = _data_->self->priv->fulfilled_count >= _data_->self->priv->count;
			} else {
				_data_->_tmp49_ = FALSE;
			}
			_data_->finished = _data_->_tmp49_;
		} else {
			if (!geary_folder_list_flags_is_newest_to_oldest (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->flags)) {
				_data_->_tmp50_ = geary_imap_engine_abstract_list_email_get_unfulfilled_count (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)) == 0;
			} else {
				_data_->_tmp50_ = FALSE;
			}
			_data_->finished = _data_->_tmp50_;
		}
	}
	if (_data_->finished) {
		_data_->_tmp51_ = GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_COMPLETED;
	} else {
		_data_->_tmp51_ = GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_CONTINUE;
	}
	_data_->result = _data_->_tmp51_;
	_g_object_unref0 (_data_->fulfilled);
	_g_object_unref0 (_data_->list);
	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_imap_engine_list_email_by_id_real_replay_remote_async_data_free (gpointer _data)
{
	GearyImapEngineListEmailByIdReplayRemoteAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->remote);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineListEmailByIdReplayRemoteAsyncData, _data_);
}

static void
geary_imap_engine_list_email_by_id_real_replay_remote_async (GearyImapEngineReplayOperation* base,
                                                             GearyImapFolderSession* remote,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	GearyImapEngineListEmailByID * self;
	GearyImapEngineListEmailByIdReplayRemoteAsyncData* _data_;
	GearyImapEngineListEmailByID* _tmp0_;
	GearyImapFolderSession* _tmp1_;
	g_return_if_fail (GEARY_IMAP_IS_FOLDER_SESSION (remote));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByID);
	_data_ = g_slice_new0 (GearyImapEngineListEmailByIdReplayRemoteAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_imap_engine_list_email_by_id_real_replay_remote_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (remote);
	_g_object_unref0 (_data_->remote);
	_data_->remote = _tmp1_;
	geary_imap_engine_list_email_by_id_real_replay_remote_async_co (_data_);
}

static void
geary_imap_engine_list_email_by_id_replay_remote_finish (GearyImapEngineReplayOperation* base,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	GearyImapEngineListEmailByIdReplayRemoteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_list_email_by_id_replay_remote_async_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_)
{
	GearyImapEngineListEmailByIdReplayRemoteAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_list_email_by_id_real_replay_remote_async_co (_data_);
}

static gboolean
geary_imap_engine_list_email_by_id_real_replay_remote_async_co (GearyImapEngineListEmailByIdReplayRemoteAsyncData* _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_->expansion_required = FALSE;
	_data_->_state_ = 1;
	geary_imap_engine_list_email_by_id_is_fully_expanded_async (_data_->self, _data_->remote, geary_imap_engine_list_email_by_id_replay_remote_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = geary_imap_engine_list_email_by_id_is_fully_expanded_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;
	}
	if (!_data_->_tmp0_) {
		if (geary_folder_list_flags_is_oldest_to_newest (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->flags)) {
			_data_->expansion_required = TRUE;
		} else {
			if (_data_->self->priv->count == G_MAXINT) {
				_data_->expansion_required = TRUE;
			} else {
				_data_->expansion_required = (_data_->self->priv->fulfilled_count + geary_imap_engine_abstract_list_email_get_unfulfilled_count (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail))) < _data_->self->priv->count;
			}
		}
	}
	if (_data_->expansion_required) {
		_data_->_tmp1_ = _data_->self->priv->initial_uid;
		_data_->_state_ = 2;
		geary_imap_engine_abstract_list_email_expand_vector_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail), _data_->remote, _data_->_tmp1_, _data_->self->priv->count, geary_imap_engine_list_email_by_id_replay_remote_async_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp2_ = geary_imap_engine_abstract_list_email_expand_vector_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail), _data_->_res_, &_data_->_inner_error0_);
		_data_->uids = _data_->_tmp2_;
		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_->_tmp3_ = _data_->uids;
		if (_data_->_tmp3_ != NULL) {
			_data_->_tmp4_ = _data_->uids;
			geary_imap_engine_abstract_list_email_add_many_unfulfilled_fields (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->required_fields);
		}
		_g_object_unref0 (_data_->uids);
	}
	_data_->_state_ = 3;
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_CLASS (geary_imap_engine_list_email_by_id_parent_class)->replay_remote_async (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->remote, geary_imap_engine_list_email_by_id_replay_remote_async_ready, _data_);
	return FALSE;
	_state_3:
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_CLASS (geary_imap_engine_list_email_by_id_parent_class)->replay_remote_finish (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _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;
	}
	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 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 gchar*
geary_imap_engine_list_email_by_id_real_describe_state (GearyImapEngineReplayOperation* base)
{
	GearyImapEngineListEmailByID * self;
	gchar* _tmp0_ = NULL;
	GearyImapDBEmailIdentifier* _tmp1_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByID);
	_tmp1_ = self->priv->initial_id;
	if (_tmp1_ != NULL) {
		GearyImapDBEmailIdentifier* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = self->priv->initial_id;
		_tmp3_ = geary_email_identifier_to_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_TYPE_EMAIL_IDENTIFIER, GearyEmailIdentifier));
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp3_;
	} else {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("(null)");
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp4_;
	}
	_tmp5_ = GEARY_IMAP_ENGINE_REPLAY_OPERATION_CLASS (geary_imap_engine_list_email_by_id_parent_class)->describe_state (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_tmp6_ = _tmp5_;
	_tmp7_ = bool_to_string (geary_folder_list_flags_is_including_id (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->flags));
	_tmp8_ = _tmp7_;
	_tmp9_ = bool_to_string (geary_folder_list_flags_is_newest_to_oldest (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->flags));
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strdup_printf ("%s initial_id=%s count=%u incl=%s newest_to_oldest=%s", _tmp6_, _tmp0_, (guint) self->priv->count, _tmp8_, _tmp10_);
	_tmp12_ = _tmp11_;
	_g_free0 (_tmp10_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	result = _tmp12_;
	_g_free0 (_tmp0_);
	return result;
}

static void
geary_imap_engine_list_email_by_id_is_fully_expanded_async_data_free (gpointer _data)
{
	GearyImapEngineListEmailByIdIsFullyExpandedAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->remote);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineListEmailByIdIsFullyExpandedAsyncData, _data_);
}

static void
geary_imap_engine_list_email_by_id_is_fully_expanded_async (GearyImapEngineListEmailByID* self,
                                                            GearyImapFolderSession* remote,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_)
{
	GearyImapEngineListEmailByIdIsFullyExpandedAsyncData* _data_;
	GearyImapEngineListEmailByID* _tmp0_;
	GearyImapFolderSession* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_LIST_EMAIL_BY_ID (self));
	g_return_if_fail (GEARY_IMAP_IS_FOLDER_SESSION (remote));
	_data_ = g_slice_new0 (GearyImapEngineListEmailByIdIsFullyExpandedAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_imap_engine_list_email_by_id_is_fully_expanded_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (remote);
	_g_object_unref0 (_data_->remote);
	_data_->remote = _tmp1_;
	geary_imap_engine_list_email_by_id_is_fully_expanded_async_co (_data_);
}

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

/**
     * Determines if the owning folder's vector is fully expanded.
     */
static void
geary_imap_engine_list_email_by_id_is_fully_expanded_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_)
{
	GearyImapEngineListEmailByIdIsFullyExpandedAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_list_email_by_id_is_fully_expanded_async_co (_data_);
}

static gboolean
geary_imap_engine_list_email_by_id_is_fully_expanded_async_co (GearyImapEngineListEmailByIdIsFullyExpandedAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = geary_imap_folder_session_get_folder (_data_->remote);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = geary_imap_folder_get_properties (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = geary_folder_properties_get_email_total (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->remote_count = _data_->_tmp5_;
	_data_->_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->owner;
	_data_->_tmp7_ = geary_imap_engine_minimal_folder_get_local_folder (_data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->cancellable;
	_data_->_state_ = 1;
	geary_imap_db_folder_get_email_count_async (_data_->_tmp8_, GEARY_IMAP_DB_FOLDER_LIST_FLAGS_INCLUDE_MARKED_FOR_REMOVE, _data_->_tmp9_, geary_imap_engine_list_email_by_id_is_fully_expanded_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->local_count_with_marked = geary_imap_db_folder_get_email_count_finish (_data_->_tmp8_, _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_->result = _data_->local_count_with_marked >= _data_->remote_count;
	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_imap_engine_list_email_by_id_class_init (GearyImapEngineListEmailByIDClass * klass,
                                               gpointer klass_data)
{
	geary_imap_engine_list_email_by_id_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineListEmailByID_private_offset);
	((GearyImapEngineReplayOperationClass *) klass)->replay_local_async = (void (*) (GearyImapEngineReplayOperation*, GAsyncReadyCallback, gpointer)) geary_imap_engine_list_email_by_id_real_replay_local_async;
	((GearyImapEngineReplayOperationClass *) klass)->replay_local_finish = (GearyImapEngineReplayOperationStatus (*) (GearyImapEngineReplayOperation*, GAsyncResult*, GError**)) geary_imap_engine_list_email_by_id_replay_local_finish;
	((GearyImapEngineReplayOperationClass *) klass)->replay_remote_async = (void (*) (GearyImapEngineReplayOperation*, GearyImapFolderSession*, GAsyncReadyCallback, gpointer)) geary_imap_engine_list_email_by_id_real_replay_remote_async;
	((GearyImapEngineReplayOperationClass *) klass)->replay_remote_finish = (void (*) (GearyImapEngineReplayOperation*, GAsyncResult*, GError**)) geary_imap_engine_list_email_by_id_replay_remote_finish;
	((GearyImapEngineReplayOperationClass *) klass)->describe_state = (gchar* (*) (GearyImapEngineReplayOperation*)) geary_imap_engine_list_email_by_id_real_describe_state;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_list_email_by_id_finalize;
}

static void
geary_imap_engine_list_email_by_id_instance_init (GearyImapEngineListEmailByID * self,
                                                  gpointer klass)
{
	self->priv = geary_imap_engine_list_email_by_id_get_instance_private (self);
	self->priv->fulfilled_count = 0;
	self->priv->initial_uid = NULL;
}

static void
geary_imap_engine_list_email_by_id_finalize (GObject * obj)
{
	GearyImapEngineListEmailByID * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByID);
	_g_object_unref0 (self->priv->initial_id);
	_g_object_unref0 (self->priv->initial_uid);
	G_OBJECT_CLASS (geary_imap_engine_list_email_by_id_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
geary_imap_engine_list_email_by_id_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineListEmailByIDClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_list_email_by_id_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineListEmailByID), 0, (GInstanceInitFunc) geary_imap_engine_list_email_by_id_instance_init, NULL };
	GType geary_imap_engine_list_email_by_id_type_id;
	geary_imap_engine_list_email_by_id_type_id = g_type_register_static (GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, "GearyImapEngineListEmailByID", &g_define_type_info, 0);
	GearyImapEngineListEmailByID_private_offset = g_type_add_instance_private (geary_imap_engine_list_email_by_id_type_id, sizeof (GearyImapEngineListEmailByIDPrivate));
	return geary_imap_engine_list_email_by_id_type_id;
}

GType
geary_imap_engine_list_email_by_id_get_type (void)
{
	static gsize geary_imap_engine_list_email_by_id_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_list_email_by_id_type_id__once)) {
		GType geary_imap_engine_list_email_by_id_type_id;
		geary_imap_engine_list_email_by_id_type_id = geary_imap_engine_list_email_by_id_get_type_once ();
		g_once_init_leave (&geary_imap_engine_list_email_by_id_type_id__once, geary_imap_engine_list_email_by_id_type_id);
	}
	return geary_imap_engine_list_email_by_id_type_id__once;
}

