[geary/wip/713878-lazy] Remove lazy_list_* operations and support code: Bug #713878



commit a07c9f25506d5bb0db6cdc9d00a7ddc62767e76a
Author: Jim Nelson <jim yorba org>
Date:   Thu Oct 23 18:28:14 2014 -0700

    Remove lazy_list_* operations and support code: Bug #713878
    
    The lazy_list_* operations outlived their purpose long ago and now
    merely represent dead interfaces and unused code paths.
    
    While at it, the Status.FAILED ReplayOperation status was removed, as
    it's only use was by CreateEmailOperation, and even then it was being
    inappropriately.

 src/engine/abstract/geary-abstract-folder.vala     |   41 --------
 src/engine/api/geary-folder.vala                   |   34 +------
 .../imap-engine/imap-engine-minimal-folder.vala    |  103 ++++----------------
 .../imap-engine/imap-engine-replay-operation.vala  |   21 ++---
 .../imap-engine/imap-engine-replay-queue.vala      |   43 +++-----
 .../imap-engine-abstract-list-email.vala           |   32 ++----
 .../replay-ops/imap-engine-create-email.vala       |    3 -
 .../replay-ops/imap-engine-list-email-by-id.vala   |   20 +---
 .../imap-engine-list-email-by-sparse-id.vala       |   20 +---
 .../imap-engine-server-search-email.vala           |    4 +-
 10 files changed, 70 insertions(+), 251 deletions(-)
---
diff --git a/src/engine/abstract/geary-abstract-folder.vala b/src/engine/abstract/geary-abstract-folder.vala
index 8a5dc68..aeed7cd 100644
--- a/src/engine/abstract/geary-abstract-folder.vala
+++ b/src/engine/abstract/geary-abstract-folder.vala
@@ -104,51 +104,10 @@ public abstract class Geary.AbstractFolder : BaseObject, Geary.Folder {
         int count, Geary.Email.Field required_fields, Folder.ListFlags flags, Cancellable? cancellable = 
null)
         throws Error;
     
-    public virtual void lazy_list_email_by_id(Geary.EmailIdentifier? initial_id, int count,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb, Cancellable? 
cancellable = null) {
-        do_lazy_list_email_by_id_async.begin(initial_id, count, required_fields, flags, cb,
-            cancellable);
-    }
-    
-    private async void do_lazy_list_email_by_id_async(Geary.EmailIdentifier? initial_id, int count,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb, Cancellable? 
cancellable) {
-        try {
-            Gee.List<Geary.Email>? list = yield list_email_by_id_async(initial_id, count,
-                required_fields, flags, cancellable);
-            if (list != null && list.size > 0)
-                cb(list, null);
-            
-            cb(null, null);
-        } catch (Error err) {
-            cb(null, err);
-        }
-    }
-    
     public abstract async Gee.List<Geary.Email>? list_email_by_sparse_id_async(
         Gee.Collection<Geary.EmailIdentifier> ids, Geary.Email.Field required_fields, Folder.ListFlags flags,
         Cancellable? cancellable = null) throws Error;
     
-    public virtual void lazy_list_email_by_sparse_id(Gee.Collection<Geary.EmailIdentifier> ids,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb,
-        Cancellable? cancellable = null) {
-        do_lazy_list_email_by_sparse_id_async.begin(ids, required_fields, flags, cb, cancellable);
-    }
-    
-    private async void do_lazy_list_email_by_sparse_id_async(Gee.Collection<Geary.EmailIdentifier> ids,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb,
-        Cancellable? cancellable) {
-        try {
-            Gee.List<Geary.Email>? list = yield list_email_by_sparse_id_async(ids,
-                required_fields, flags, cancellable);
-            if (list != null && list.size > 0)
-                cb(list, null);
-            
-            cb(null, null);
-        } catch (Error err) {
-            cb(null, err);
-        }
-    }
-    
     public abstract async Gee.Map<Geary.EmailIdentifier, Geary.Email.Field>? list_local_email_fields_async(
         Gee.Collection<Geary.EmailIdentifier> ids, Cancellable? cancellable = null) throws Error;
     
diff --git a/src/engine/api/geary-folder.vala b/src/engine/api/geary-folder.vala
index 683c513..69c6d30 100644
--- a/src/engine/api/geary-folder.vala
+++ b/src/engine/api/geary-folder.vala
@@ -4,8 +4,6 @@
  * (version 2.1 or later).  See the COPYING file in this distribution.
  */
 
-public delegate void Geary.EmailCallback(Gee.List<Geary.Email>? emails, Error? err);
-
 public interface Geary.Folder : BaseObject {
     public enum OpenState {
         CLOSED,
@@ -100,8 +98,7 @@ public interface Geary.Folder : BaseObject {
          */
         FORCE_UPDATE,
         /**
-         * Include the provided EmailIdentifier (only respected by { link list_email_by_id_async} and
-         * { link lazy_list_email_by_id}).
+         * Include the provided EmailIdentifier (only respected by { link list_email_by_id_async}.
          */
         INCLUDING_ID,
         /**
@@ -431,25 +428,12 @@ public interface Geary.Folder : BaseObject {
         throws Error;
     
     /**
-     * Similar in contract to lazy_list_email_async(), but uses Geary.EmailIdentifier rather than
-     * positional addressing, much like list_email_by_id_async().  See that method for more
-     * information on its contract and how the count and flags parameters work.
-     *
-     * Like the other "lazy" methods, this method will call EmailCallback while the operation is
-     * processing.  This method does not block.
-     *
-     * The Folder must be opened prior to attempting this operation.
-     */
-    public abstract void lazy_list_email_by_id(Geary.EmailIdentifier? initial_id, int count,
-        Geary.Email.Field required_fields, ListFlags flags, EmailCallback cb, Cancellable? cancellable = 
null);
-    
-    /**
      * Similar in contract to { link list_email_by_id_async}, but uses a list of
      * { link Geary.EmailIdentifier}s rather than a range.
      *
      * Any Gee.Collection is accepted for EmailIdentifiers, but the returned list will only contain
      * one email for each requested; duplicates are ignored.  ListFlags.INCLUDING_ID is ignored
-     * for this call and { link lazy_list_email_by_sparse_id}.
+     * for this call.
      *
      * The Folder must be opened prior to attempting this operation.
      */
@@ -458,20 +442,6 @@ public interface Geary.Folder : BaseObject {
         Cancellable? cancellable = null) throws Error;
     
     /**
-     * See { link list_email_by_id_async} and { link list_email_by_sparse_id_async}
-     * for more information on { link EmailIdentifier}s and how the flags and callback parameter
-     * works.
-     *
-     * Like the other "lazy" method, this method will call EmailCallback while the operation is
-     * processing.  This method does not block.
-     *
-     * The Folder must be opened prior to attempting this operation.
-     */
-    public abstract void lazy_list_email_by_sparse_id(Gee.Collection<Geary.EmailIdentifier> ids,
-        Geary.Email.Field required_fields, ListFlags flags, EmailCallback cb,
-        Cancellable? cancellable = null);
-    
-    /**
      * Returns the locally available Geary.Email.Field fields for the specified emails.  If a
      * list or fetch operation occurs on the emails that specifies a field not returned here,
      * the Engine will either have to go out to the remote server to get it, or (if
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala 
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index ceb9f2c..af8750f 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -1114,110 +1114,49 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
     }
     
     //
-    // list_email_by_id variants
+    // list email variants
     //
     
     public override async Gee.List<Geary.Email>? list_email_by_id_async(Geary.EmailIdentifier? initial_id,
         int count, Geary.Email.Field required_fields, Folder.ListFlags flags,
         Cancellable? cancellable = null) throws Error {
-        Gee.List<Geary.Email> accumulator = new Gee.ArrayList<Geary.Email>();
-        yield do_list_email_by_id_async("list_email_by_id_async", initial_id, count, required_fields,
-            flags, accumulator, null, cancellable);
-        
-        return !accumulator.is_empty ? accumulator : null;
-    }
-    
-    public override void lazy_list_email_by_id(Geary.EmailIdentifier? initial_id, int count,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb,
-        Cancellable? cancellable = null) {
-        do_lazy_list_email_by_id_async.begin(initial_id, count, required_fields, flags, cb, cancellable);
-    }
-    
-    private async void do_lazy_list_email_by_id_async(Geary.EmailIdentifier? initial_id, int count,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb, Cancellable? 
cancellable) {
-        try {
-            yield do_list_email_by_id_async("lazy_list_email_by_id", initial_id, count, required_fields,
-                flags, null, cb, cancellable);
-        } catch (Error err) {
-            cb(null, err);
-        }
-    }
-    
-    private async void do_list_email_by_id_async(string method, Geary.EmailIdentifier? initial_id,
-        int count, Geary.Email.Field required_fields, Folder.ListFlags flags,
-        Gee.List<Geary.Email>? accumulator, EmailCallback? cb, Cancellable? cancellable) throws Error {
-        check_open(method);
-        check_flags(method, flags);
+        check_open("list_email_by_id_async");
+        check_flags("list_email_by_id_async", flags);
         if (initial_id != null)
-            check_id(method, initial_id);
+            check_id("list_email_by_id_async", initial_id);
         
-        if (count == 0) {
-            // signal finished
-            if (cb != null)
-                cb(null, null);
-            
-            return;
-        }
+        if (count == 0)
+            return null;
         
         // Schedule list operation and wait for completion.
         ListEmailByID op = new ListEmailByID(this, (ImapDB.EmailIdentifier) initial_id, count,
-            required_fields, flags, accumulator, cb, cancellable);
+            required_fields, flags, cancellable);
         replay_queue.schedule(op);
         
         yield op.wait_for_ready_async(cancellable);
+        
+        return !op.accumulator.is_empty ? op.accumulator : null;
     }
     
-    //
-    // list_email_by_sparse_id variants
-    //
-    
     public async override Gee.List<Geary.Email>? list_email_by_sparse_id_async(
         Gee.Collection<Geary.EmailIdentifier> ids, Geary.Email.Field required_fields, Folder.ListFlags flags,
         Cancellable? cancellable = null) throws Error {
-        Gee.ArrayList<Geary.Email> accumulator = new Gee.ArrayList<Geary.Email>();
-        yield do_list_email_by_sparse_id_async("list_email_by_sparse_id_async", ids, required_fields,
-            flags, accumulator, null, cancellable);
+        check_open("list_email_by_sparse_id_async");
+        check_flags("list_email_by_sparse_id_async", flags);
+        check_ids("list_email_by_sparse_id_async", ids);
         
-        return (accumulator.size > 0) ? accumulator : null;
-    }
-    
-    public override void lazy_list_email_by_sparse_id(Gee.Collection<Geary.EmailIdentifier> ids,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb, Cancellable? 
cancellable = null) {
-        do_lazy_list_email_by_sparse_id_async.begin(ids, required_fields, flags, cb, cancellable);
-    }
-    
-    private async void do_lazy_list_email_by_sparse_id_async(Gee.Collection<Geary.EmailIdentifier> ids,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, EmailCallback cb, Cancellable? 
cancellable) {
-        try {
-            yield do_list_email_by_sparse_id_async("lazy_list_email_by_sparse_id", ids, required_fields,
-                flags, null, cb, cancellable);
-        } catch (Error err) {
-            cb(null, err);
-        }
-    }
-    
-    private async void do_list_email_by_sparse_id_async(string method,
-        Gee.Collection<Geary.EmailIdentifier> ids, Geary.Email.Field required_fields, Folder.ListFlags flags,
-        Gee.List<Geary.Email>? accumulator, EmailCallback? cb, Cancellable? cancellable = null) throws Error 
{
-        check_open(method);
-        check_flags(method, flags);
-        check_ids(method, ids);
-        
-        if (ids.size == 0) {
-            // signal finished
-            if (cb != null)
-                cb(null, null);
-            
-            return;
-        }
+        if (ids.size == 0)
+            return null;
         
         // Schedule list operation and wait for completion.
         // TODO: Break up requests to avoid hogging the queue
         ListEmailBySparseID op = new ListEmailBySparseID(this, (Gee.Collection<ImapDB.EmailIdentifier>) ids,
-            required_fields, flags, accumulator, cb, cancellable);
+            required_fields, flags, cancellable);
         replay_queue.schedule(op);
         
         yield op.wait_for_ready_async(cancellable);
+        
+        return !op.accumulator.is_empty ? op.accumulator : null;
     }
     
     public override async Gee.Map<Geary.EmailIdentifier, Geary.Email.Field>? list_local_email_fields_async(
@@ -1356,21 +1295,19 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
         
         debug("%s: find_earliest_email_async: %s", to_string(), criteria.to_string());
         
-        Gee.List<Geary.Email> accumulator = new Gee.ArrayList<Geary.Email>();
         ServerSearchEmail op = new ServerSearchEmail(this, criteria, Geary.Email.Field.NONE,
-            accumulator, cancellable);
+            cancellable);
         
         // need to check again due to the yield in the above conditional block
         check_open("find_earliest_email_async.schedule operation");
         
         replay_queue.schedule(op);
         
-        if (!yield op.wait_for_ready_async(cancellable))
-            return null;
+        yield op.wait_for_ready_async(cancellable);
         
         // find earliest ID; because all Email comes from Folder, UID should always be present
         ImapDB.EmailIdentifier? earliest_id = null;
-        foreach (Geary.Email email in accumulator) {
+        foreach (Geary.Email email in op.accumulator) {
             ImapDB.EmailIdentifier email_id = (ImapDB.EmailIdentifier) email.id;
             
             if (earliest_id == null || email_id.uid.compare_to(earliest_id.uid) < 0)
diff --git a/src/engine/imap-engine/imap-engine-replay-operation.vala 
b/src/engine/imap-engine/imap-engine-replay-operation.vala
index 7b1ad33..0dd62e2 100644
--- a/src/engine/imap-engine/imap-engine-replay-operation.vala
+++ b/src/engine/imap-engine/imap-engine-replay-operation.vala
@@ -26,7 +26,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
     
     public enum Status {
         COMPLETED,
-        FAILED,
         CONTINUE
     }
     
@@ -36,7 +35,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
     public int opnum { get; private set; }
     public Scope scope { get; private set; }
     public Error? err { get; private set; default = null; }
-    public bool failed { get; private set; default = false; }
     public bool notified { get; private set; default = false; }
     
     private Nonblocking.Semaphore semaphore = new Nonblocking.Semaphore();
@@ -97,10 +95,11 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
      *
      * Returns:
      *   COMPLETED: the operation has completed and no further calls should be made.
-     *   FAILED: the operation has failed.  (An exception may be thrown for similar effect.)
-     *     backout_local_async() will *not* be executed.
      *   CONTINUE: The local operation has completed and the remote portion must be executed as
      *      well.  This is treated as COMPLETED if get_scope() returns LOCAL_ONLY.
+     *
+     * If Error thrown:
+     *   backout_local_async() will *not* be executed.
      */
     public abstract async Status replay_local_async() throws Error;
     
@@ -109,9 +108,10 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
      *
      * Returns:
      *   COMPLETED: the operation has completed and no further calls should be made.
-     *   FAILED: the operation has failed.  (An exception may be thrown for similar effect.)
-     *     backout_local_async() will be executed only if scope is LOCAL_AND_REMOTE.
      *   CONTINUE: Treated as COMPLETED.
+     *
+     * If Error thrown:
+     *   backout_local_async() will be executed only if scope is LOCAL_AND_REMOTE.
      */
     public abstract async Status replay_remote_async() throws Error;
     
@@ -123,23 +123,20 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
     
     /**
      * Completes when the operation has completed execution.  If the operation threw an error
-     * during execution, it will be thrown here.  If the operation failed, this returns false.
+     * during execution, it will be thrown here.
      */
-    public async bool wait_for_ready_async(Cancellable? cancellable = null) throws Error {
+    public async void wait_for_ready_async(Cancellable? cancellable = null) throws Error {
         yield semaphore.wait_async(cancellable);
         
         if (err != null)
             throw err;
-        
-        return failed;
     }
     
-    internal void notify_ready(bool failed, Error? err) {
+    internal void notify_ready(Error? err) {
         assert(!notified);
         
         notified = true;
         
-        this.failed = failed;
         this.err = err;
         
         try {
diff --git a/src/engine/imap-engine/imap-engine-replay-queue.vala 
b/src/engine/imap-engine/imap-engine-replay-queue.vala
index b01f1d8..e376774 100644
--- a/src/engine/imap-engine/imap-engine-replay-queue.vala
+++ b/src/engine/imap-engine/imap-engine-replay-queue.vala
@@ -84,14 +84,14 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
             op.to_string());
     }
     
-    public virtual signal void backing_out(ReplayOperation op, bool failed, Error? err) {
-        Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backout-out: %s failed=%s err=%s",
-            to_string(), op.to_string(), failed.to_string(), (err != null) ? err.message : "(null)");
+    public virtual signal void backing_out(ReplayOperation op, Error? err) {
+        Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backout-out: %s err=%s",
+            to_string(), op.to_string(), (err != null) ? err.message : "(null)");
     }
     
-    public virtual signal void backed_out(ReplayOperation op, bool failed, Error? err) {
-        Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backed-out: %s failed=%s err=%s",
-            to_string(), op.to_string(), failed.to_string(), (err != null) ? err.message : "(null)");
+    public virtual signal void backed_out(ReplayOperation op, Error? err) {
+        Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backed-out: %s err=%s",
+            to_string(), op.to_string(), (err != null) ? err.message : "(null)");
     }
     
     public virtual signal void backout_failed(ReplayOperation op, Error? backout_err) {
@@ -393,20 +393,14 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
                         case ReplayOperation.Status.COMPLETED:
                             // done
                             remote_enqueue = false;
-                            op.notify_ready(false, null);
+                            op.notify_ready(null);
                         break;
                         
                         case ReplayOperation.Status.CONTINUE:
                             // don't touch remote_enqueue; if already false, CONTINUE is treated as
                             // COMPLETED.
                             if (!remote_enqueue)
-                                op.notify_ready(false, null);
-                        break;
-                        
-                        case ReplayOperation.Status.FAILED:
-                            // done
-                            remote_enqueue = false;
-                            op.notify_ready(true, null);
+                                op.notify_ready(null);
                         break;
                         
                         default:
@@ -416,7 +410,7 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
                     debug("Replay local error for %s on %s: %s", op.to_string(), to_string(),
                         replay_err.message);
                     
-                    op.notify_ready(false, replay_err);
+                    op.notify_ready(replay_err);
                     remote_enqueue = false;
                 }
             }
@@ -436,7 +430,7 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
                 locally_executed(op, remote_enqueue);
             
             if (!remote_enqueue) {
-                if (!op.failed && op.err == null)
+                if (op.err == null)
                     completed(op);
                 else
                     failed(op);
@@ -487,11 +481,10 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
             
             remotely_executing(op);
             
-            ReplayOperation.Status status = ReplayOperation.Status.FAILED;
             Error? remote_err = null;
             if (folder_opened || is_close_op) {
                 try {
-                    status = yield op.replay_remote_async();
+                    yield op.replay_remote_async();
                 } catch (Error replay_err) {
                     debug("Replay remote error for %s on %s: %s", op.to_string(), to_string(),
                         replay_err.message);
@@ -502,16 +495,14 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
                 remote_err = new EngineError.SERVER_UNAVAILABLE("Folder %s not available", 
owner.to_string());
             }
             
-            bool has_failed = !is_close_op && (status == ReplayOperation.Status.FAILED);
-            
-            // COMPLETED == CONTINUE, only FAILED or exception of interest here
-            if (remote_err != null || has_failed) {
+            // COMPLETED == CONTINUE, only exception of interest here if not closing
+            if (remote_err != null && !is_close_op) {
                 try {
-                    backing_out(op, has_failed, remote_err);
+                    backing_out(op, remote_err);
                     
                     yield op.backout_local_async();
                     
-                    backed_out(op, has_failed, remote_err);
+                    backed_out(op, remote_err);
                 } catch (Error backout_err) {
                     backout_failed(op, backout_err);
                 }
@@ -519,11 +510,11 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
             
             // use the remote error (not the backout error) for the operation's completion
             // state
-            op.notify_ready(has_failed, remote_err);
+            op.notify_ready(remote_err);
             
             remotely_executed(op);
             
-            if (!op.failed && op.err == null)
+            if (op.err == null)
                 completed(op);
             else
                 failed(op);
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-abstract-list-email.vala 
b/src/engine/imap-engine/replay-ops/imap-engine-abstract-list-email.vala
index 1e76607..4f1a3e2 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-abstract-list-email.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-abstract-list-email.vala
@@ -53,24 +53,23 @@ private abstract class Geary.ImapEngine.AbstractListEmail : Geary.ImapEngine.Sen
         }
     }
     
+    // The accumulated Email from the list operation.  Should only be accessed once the operation
+    // has completed.
+    public Gee.List<Geary.Email> accumulator = new Gee.ArrayList<Geary.Email>();
+    
     protected MinimalFolder owner;
     protected Geary.Email.Field required_fields;
-    protected Gee.List<Geary.Email>? accumulator = null;
-    protected weak EmailCallback? cb;
     protected Cancellable? cancellable;
     protected Folder.ListFlags flags;
     
     private Gee.HashMap<Imap.UID, Geary.Email.Field> unfulfilled = new Gee.HashMap<Imap.UID, 
Geary.Email.Field>();
     
     public AbstractListEmail(string name, MinimalFolder owner, Geary.Email.Field required_fields,
-        Folder.ListFlags flags, Gee.List<Geary.Email>? accumulator, EmailCallback? cb,
-        Cancellable? cancellable) {
+        Folder.ListFlags flags, Cancellable? cancellable) {
         base(name);
         
         this.owner = owner;
         this.required_fields = required_fields;
-        this.accumulator = accumulator;
-        this.cb = cb;
         this.cancellable = cancellable;
         this.flags = flags;
     }
@@ -100,11 +99,9 @@ private abstract class Geary.ImapEngine.AbstractListEmail : Geary.ImapEngine.Sen
     public override void notify_remote_removed_ids(Gee.Collection<ImapDB.EmailIdentifier> ids) {
         // remove email already picked up from local store ... for email reported via the
         // callback, too late
-        if (accumulator != null) {
-            Collection.remove_if<Geary.Email>(accumulator, (email) => {
-                return ids.contains((ImapDB.EmailIdentifier) email.id);
-            });
-        }
+        Collection.remove_if<Geary.Email>(accumulator, (email) => {
+            return ids.contains((ImapDB.EmailIdentifier) email.id);
+        });
         
         // remove from unfulfilled list, as there's now nothing to fetch from the server
         // NOTE: Requires UID to work; this *should* always work, as the EmailIdentifier should
@@ -163,17 +160,8 @@ private abstract class Geary.ImapEngine.AbstractListEmail : Geary.ImapEngine.Sen
         }
         
         // report merged emails
-        if (result_list.size > 0) {
-            if (accumulator != null)
-                accumulator.add_all(result_list);
-            
-            if (cb != null)
-                cb(result_list, null);
-        }
-        
-        // done
-        if (cb != null)
-            cb(null, null);
+        if (result_list.size > 0)
+            accumulator.add_all(result_list);
         
         // signal
         if (created_ids.size > 0) {
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala 
b/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala
index b27170b..3104c4c 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala
@@ -50,9 +50,6 @@ private class Geary.ImapEngine.CreateEmail : Geary.ImapEngine.SendReplayOperatio
         // use IMAP APPEND command on remote folders, which doesn't require opening a folder
         created_id = yield engine.remote_folder.create_email_async(rfc822, flags, date_received);
         
-        if (created_id == null)
-            return ReplayOperation.Status.FAILED;
-        
         // If the user cancelled the operation, we need to wipe the new message to keep this
         // operation atomic.
         if (cancellable.is_cancelled()) {
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-id.vala 
b/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-id.vala
index bd3f3d1..af07b35 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-id.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-id.vala
@@ -11,9 +11,8 @@ private class Geary.ImapEngine.ListEmailByID : Geary.ImapEngine.AbstractListEmai
     private Imap.UID? initial_uid = null;
     
     public ListEmailByID(MinimalFolder owner, ImapDB.EmailIdentifier? initial_id, int count,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, Gee.List<Geary.Email>? accumulator,
-        EmailCallback? cb, Cancellable? cancellable) {
-        base ("ListEmailByID", owner, required_fields, flags, accumulator, cb, cancellable);
+        Geary.Email.Field required_fields, Folder.ListFlags flags, Cancellable? cancellable) {
+        base ("ListEmailByID", owner, required_fields, flags, cancellable);
         
         this.initial_id = initial_id;
         this.count = count;
@@ -61,13 +60,8 @@ private class Geary.ImapEngine.ListEmailByID : Geary.ImapEngine.AbstractListEmai
         
         // report fulfilled items
         fulfilled_count = fulfilled.size;
-        if (fulfilled_count > 0) {
-            if (accumulator != null)
-                accumulator.add_all(fulfilled);
-            
-            if (cb != null)
-                cb(fulfilled, null);
-        }
+        if (fulfilled_count > 0)
+            accumulator.add_all(fulfilled);
         
         // determine if everything was listed
         bool finished = false;
@@ -95,12 +89,8 @@ private class Geary.ImapEngine.ListEmailByID : Geary.ImapEngine.AbstractListEmai
         
         // local-only operations stop here; also, since the local store is normalized from the top
         // of the vector on down, if enough items came back fulfilled, then done
-        if (finished) {
-            if (cb != null)
-                cb(null, null);
-            
+        if (finished)
             return ReplayOperation.Status.COMPLETED;
-        }
         
         return ReplayOperation.Status.CONTINUE;
     }
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-sparse-id.vala 
b/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-sparse-id.vala
index c7e42d4..1ab0eb4 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-sparse-id.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-list-email-by-sparse-id.vala
@@ -8,9 +8,8 @@ private class Geary.ImapEngine.ListEmailBySparseID : Geary.ImapEngine.AbstractLi
     private Gee.HashSet<ImapDB.EmailIdentifier> ids = new Gee.HashSet<ImapDB.EmailIdentifier>();
     
     public ListEmailBySparseID(MinimalFolder owner, Gee.Collection<ImapDB.EmailIdentifier> ids,
-        Geary.Email.Field required_fields, Folder.ListFlags flags, Gee.List<Geary.Email>? accumulator,
-        EmailCallback cb, Cancellable? cancellable) {
-        base ("ListEmailBySparseID", owner, required_fields, flags, accumulator, cb, cancellable);
+        Geary.Email.Field required_fields, Folder.ListFlags flags, Cancellable? cancellable) {
+        base ("ListEmailBySparseID", owner, required_fields, flags, cancellable);
         
         this.ids.add_all(ids);
     }
@@ -62,20 +61,11 @@ private class Geary.ImapEngine.ListEmailBySparseID : Geary.ImapEngine.AbstractLi
             }
         }
         
-        if (fulfilled.size > 0) {
-            if (accumulator != null)
-                accumulator.add_all(fulfilled);
-            
-            if (cb != null)
-                cb(fulfilled, null);
-        }
+        if (fulfilled.size > 0)
+            accumulator.add_all(fulfilled);
         
-        if (flags.is_local_only() || get_unfulfilled_count() == 0) {
-            if (cb != null)
-                cb(null, null);
-            
+        if (flags.is_local_only() || get_unfulfilled_count() == 0)
             return ReplayOperation.Status.COMPLETED;
-        }
         
         return ReplayOperation.Status.CONTINUE;
     }
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-server-search-email.vala 
b/src/engine/imap-engine/replay-ops/imap-engine-server-search-email.vala
index 5a96e0c..5b1443d 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-server-search-email.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-server-search-email.vala
@@ -14,10 +14,10 @@ private class Geary.ImapEngine.ServerSearchEmail : Geary.ImapEngine.AbstractList
     private Imap.SearchCriteria criteria;
     
     public ServerSearchEmail(MinimalFolder owner, Imap.SearchCriteria criteria, Geary.Email.Field 
required_fields,
-        Gee.List<Geary.Email>? accumulator, Cancellable? cancellable) {
+        Cancellable? cancellable) {
         // OLDEST_TO_NEWEST used for vector expansion, if necessary
         base ("ServerSearchEmail", owner, required_fields, Geary.Folder.ListFlags.OLDEST_TO_NEWEST,
-            accumulator, null, cancellable);
+            cancellable);
         
         this.criteria = criteria;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]