[geary/wip/remote-retry: 7/7] Remove Geary.Future
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/remote-retry: 7/7] Remove Geary.Future
- Date: Tue, 20 Jan 2015 22:45:25 +0000 (UTC)
commit 48536ac5f7ed8aeafae0e03f4852265d32f60c83
Author: Jim Nelson <jim yorba org>
Date: Tue Jan 20 14:43:28 2015 -0800
Remove Geary.Future
Although I like what a Future can do for us as far as notifying of
completion and returning values, (a) it's adding too much complication
to an already-complicated branch and (b) the API should be overhauled
to support Futures; in particular, the API could be completely
non-async, requiring the caller to block on the Future if they want
Error notification or the result value, and even then could consider
using signals instead.
src/CMakeLists.txt | 1 -
src/engine/api/geary-folder-supports-archive.vala | 6 +-
src/engine/api/geary-folder-supports-copy.vala | 6 +-
src/engine/api/geary-folder-supports-create.vala | 14 +--
src/engine/api/geary-folder-supports-empty.vala | 6 +-
src/engine/api/geary-folder-supports-mark.vala | 6 +-
src/engine/api/geary-folder-supports-move.vala | 6 +-
src/engine/api/geary-folder-supports-remove.vala | 6 +-
src/engine/api/geary-folder.vala | 6 +-
src/engine/api/geary-future.vala | 108 --------------------
src/engine/api/geary-search-folder.vala | 6 +-
src/engine/imap-db/outbox/smtp-outbox-folder.vala | 6 +-
.../gmail/imap-engine-gmail-all-mail-folder.vala | 4 +-
.../gmail/imap-engine-gmail-drafts-folder.vala | 4 +-
.../gmail/imap-engine-gmail-folder.vala | 25 ++---
.../gmail/imap-engine-gmail-search-folder.vala | 4 +-
.../gmail/imap-engine-gmail-spam-trash-folder.vala | 8 +-
.../imap-engine/imap-engine-generic-folder.vala | 14 ++--
.../imap-engine/imap-engine-minimal-folder.vala | 60 ++++-------
.../imap-engine/imap-engine-replay-operation.vala | 61 +----------
.../imap-engine/imap-engine-replay-queue.vala | 6 -
.../replay-ops/imap-engine-create-email.vala | 7 +-
.../replay-ops/imap-engine-fetch-email.vala | 7 +-
23 files changed, 70 insertions(+), 307 deletions(-)
---
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d6ad70b..5f0abb5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,7 +33,6 @@ engine/api/geary-folder-supports-empty.vala
engine/api/geary-folder-supports-mark.vala
engine/api/geary-folder-supports-move.vala
engine/api/geary-folder-supports-remove.vala
-engine/api/geary-future.vala
engine/api/geary-logging.vala
engine/api/geary-named-flag.vala
engine/api/geary-named-flags.vala
diff --git a/src/engine/api/geary-folder-supports-archive.vala
b/src/engine/api/geary-folder-supports-archive.vala
index 7bb51df..52578ef 100644
--- a/src/engine/api/geary-folder-supports-archive.vala
+++ b/src/engine/api/geary-folder-supports-archive.vala
@@ -17,13 +17,9 @@ public interface Geary.FolderSupport.Archive : Geary.Folder {
/**
* Archives the specified emails from the folder.
*
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
- *
* The { link Geary.Folder} must be opened prior to attempting this operation.
*/
- public abstract async Geary.Future archive_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public abstract async void archive_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error;
}
diff --git a/src/engine/api/geary-folder-supports-copy.vala b/src/engine/api/geary-folder-supports-copy.vala
index 861efb7..351a16a 100644
--- a/src/engine/api/geary-folder-supports-copy.vala
+++ b/src/engine/api/geary-folder-supports-copy.vala
@@ -19,13 +19,9 @@ public interface Geary.FolderSupport.Copy : Geary.Folder {
* If the destination is this { link Folder}, the operation will not make a copy of the message
* but will return success.
*
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
- *
* The Folder must be opened prior to attempting this operation.
*/
- public abstract async Geary.Future copy_email_async(Gee.List<Geary.EmailIdentifier> to_copy,
+ public abstract async void copy_email_async(Gee.List<Geary.EmailIdentifier> to_copy,
Geary.FolderPath destination, Cancellable? cancellable = null) throws Error;
}
diff --git a/src/engine/api/geary-folder-supports-create.vala
b/src/engine/api/geary-folder-supports-create.vala
index 8da9695..f1b5235 100644
--- a/src/engine/api/geary-folder-supports-create.vala
+++ b/src/engine/api/geary-folder-supports-create.vala
@@ -17,6 +17,8 @@ public interface Geary.FolderSupport.Create : Geary.Folder {
/**
* Creates (appends) the message to this folder.
*
+ * The Folder must be opened prior to attempting this operation.
+ *
* The optional { link EmailFlags} allows for those flags to be set when saved. Some Folders
* may ignore those flags (i.e. Outbox) if not applicable.
*
@@ -24,17 +26,9 @@ public interface Geary.FolderSupport.Create : Geary.Folder {
* Like EmailFlags, this is optional if not applicable.
*
* If an id is passed, this will replace the existing message by deleting it after the new
- * message is created. The new message's ID is returned in the { link Future}.
- *
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
- *
- * The Folder must be opened prior to attempting this operation.
- *
- * @returns A Future whose result Value is the created { link EmailIdentifier}.
+ * message is created. The new message's ID is returned.
*/
- public abstract async Geary.Future create_email_async(Geary.RFC822.Message rfc822, EmailFlags? flags,
+ public abstract async Geary.EmailIdentifier? create_email_async(Geary.RFC822.Message rfc822, EmailFlags?
flags,
DateTime? date_received, Geary.EmailIdentifier? id, Cancellable? cancellable = null) throws Error;
}
diff --git a/src/engine/api/geary-folder-supports-empty.vala b/src/engine/api/geary-folder-supports-empty.vala
index d58f467..69f1e48 100644
--- a/src/engine/api/geary-folder-supports-empty.vala
+++ b/src/engine/api/geary-folder-supports-empty.vala
@@ -19,11 +19,7 @@
public interface Geary.FolderSupport.Empty : Geary.Folder {
/**
* Removes all email from the folder.
- *
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
*/
- public abstract async Geary.Future empty_folder_async(Cancellable? cancellable = null) throws Error;
+ public abstract async void empty_folder_async(Cancellable? cancellable = null) throws Error;
}
diff --git a/src/engine/api/geary-folder-supports-mark.vala b/src/engine/api/geary-folder-supports-mark.vala
index 83b0e50..5b1be59 100644
--- a/src/engine/api/geary-folder-supports-mark.vala
+++ b/src/engine/api/geary-folder-supports-mark.vala
@@ -13,13 +13,9 @@ public interface Geary.FolderSupport.Mark : Geary.Folder {
/**
* Adds and removes flags from a list of messages.
*
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
- *
* The { link Geary.Folder} must be opened prior to attempting this operation.
*/
- public abstract async Geary.Future mark_email_async(Gee.List<Geary.EmailIdentifier> to_mark,
+ public abstract async void mark_email_async(Gee.List<Geary.EmailIdentifier> to_mark,
Geary.EmailFlags? flags_to_add, Geary.EmailFlags? flags_to_remove,
Cancellable? cancellable = null) throws Error;
}
diff --git a/src/engine/api/geary-folder-supports-move.vala b/src/engine/api/geary-folder-supports-move.vala
index 244c4d5..58ededf 100644
--- a/src/engine/api/geary-folder-supports-move.vala
+++ b/src/engine/api/geary-folder-supports-move.vala
@@ -18,13 +18,9 @@ public interface Geary.FolderSupport.Move : Geary.Folder {
* If the destination is this { link Folder}, the operation will not move the message in any
* way but will return success.
*
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
- *
* The { link Geary.Folder} must be opened prior to attempting this operation.
*/
- public abstract async Geary.Future move_email_async(Gee.List<Geary.EmailIdentifier> to_move,
+ public abstract async void move_email_async(Gee.List<Geary.EmailIdentifier> to_move,
Geary.FolderPath destination, Cancellable? cancellable = null) throws Error;
}
diff --git a/src/engine/api/geary-folder-supports-remove.vala
b/src/engine/api/geary-folder-supports-remove.vala
index 76dc57d..11d1b40 100644
--- a/src/engine/api/geary-folder-supports-remove.vala
+++ b/src/engine/api/geary-folder-supports-remove.vala
@@ -23,13 +23,9 @@ public interface Geary.FolderSupport.Remove : Geary.Folder {
/**
* Removes the specified emails from the folder.
*
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
- *
* The { link Geary.Folder} must be opened prior to attempting this operation.
*/
- public abstract async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public abstract async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error;
}
diff --git a/src/engine/api/geary-folder.vala b/src/engine/api/geary-folder.vala
index b1c7c3d..8f76fb3 100644
--- a/src/engine/api/geary-folder.vala
+++ b/src/engine/api/geary-folder.vala
@@ -537,13 +537,9 @@ public abstract class Geary.Folder : BaseObject {
* force waiting for the server to connect. Unlike the list variants, if in the OPENING state
* and the message is not found locally, EngineError.NOT_FOUND is thrown.
*
- * The method throws an Error if there's an issue with initiating the operation. The
- * { link Future} throws an Error if there's an issue with ''completing'' the operation, which
- * may occur after this call has completed.
- *
* The Folder must be opened prior to attempting this operation.
*/
- public abstract async Geary.Future fetch_email_async(Geary.EmailIdentifier email_id,
+ public abstract async Geary.Email fetch_email_async(Geary.EmailIdentifier email_id,
Geary.Email.Field required_fields, ListFlags flags, Cancellable? cancellable = null) throws Error;
/**
diff --git a/src/engine/api/geary-search-folder.vala b/src/engine/api/geary-search-folder.vala
index e1bfb9c..c064a62 100644
--- a/src/engine/api/geary-search-folder.vala
+++ b/src/engine/api/geary-search-folder.vala
@@ -380,12 +380,12 @@ public class Geary.SearchFolder : Geary.AbstractLocalFolder, Geary.FolderSupport
return yield account.local_fetch_email_async(id, required_fields, cancellable);
}
- public virtual async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public virtual async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
Gee.MultiMap<Geary.EmailIdentifier, Geary.FolderPath>? ids_to_folders
= yield account.get_containing_folders_async(email_ids, cancellable);
if (ids_to_folders == null)
- return null;
+ return;
Gee.MultiMap<Geary.FolderPath, Geary.EmailIdentifier> folders_to_ids
= Geary.Collection.reverse_multi_map<Geary.EmailIdentifier, Geary.FolderPath>(ids_to_folders);
@@ -424,8 +424,6 @@ public class Geary.SearchFolder : Geary.AbstractLocalFolder, Geary.FolderSupport
}
}
}
-
- return null;
}
/**
diff --git a/src/engine/imap-db/outbox/smtp-outbox-folder.vala
b/src/engine/imap-db/outbox/smtp-outbox-folder.vala
index 6a8e0b4..745967b 100644
--- a/src/engine/imap-db/outbox/smtp-outbox-folder.vala
+++ b/src/engine/imap-db/outbox/smtp-outbox-folder.vala
@@ -386,7 +386,7 @@ private class Geary.SmtpOutboxFolder : Geary.AbstractLocalFolder, Geary.FolderSu
return row.outbox_id;
}
- public virtual async Geary.EmailIdentifier create_email_async(Geary.RFC822.Message rfc822, EmailFlags?
flags,
+ public virtual async Geary.EmailIdentifier? create_email_async(Geary.RFC822.Message rfc822, EmailFlags?
flags,
DateTime? date_received, Geary.EmailIdentifier? id = null, Cancellable? cancellable = null) throws
Error {
check_open();
@@ -552,13 +552,11 @@ private class Geary.SmtpOutboxFolder : Geary.AbstractLocalFolder, Geary.FolderSu
notify_email_flags_changed(changed_map);
}
- public virtual async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public virtual async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
check_open();
yield internal_remove_email_async(email_ids, cancellable);
-
- return null;
}
// Like remove_email_async(), but can be called even when the folder isn't open
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-all-mail-folder.vala
b/src/engine/imap-engine/gmail/imap-engine-gmail-all-mail-folder.vala
index 3c42875..ce46e75 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-all-mail-folder.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-all-mail-folder.vala
@@ -14,8 +14,8 @@ private class Geary.ImapEngine.GmailAllMailFolder : MinimalFolder, FolderSupport
base (account, remote, local, local_folder, special_folder_type);
}
- public async Geary.Future? remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
- return yield GmailFolder.true_remove_email_async(this, email_ids, cancellable);
+ yield GmailFolder.true_remove_email_async(this, email_ids, cancellable);
}
}
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-drafts-folder.vala
b/src/engine/imap-engine/gmail/imap-engine-gmail-drafts-folder.vala
index a814549..57ea1df 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-drafts-folder.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-drafts-folder.vala
@@ -22,8 +22,8 @@ private class Geary.ImapEngine.GmailDraftsFolder : MinimalFolder, FolderSupport.
return yield base.create_email_async(rfc822, flags, date_received, id, cancellable);
}
- public async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
- return yield GmailFolder.true_remove_email_async(this, email_ids, cancellable);
+ yield GmailFolder.true_remove_email_async(this, email_ids, cancellable);
}
}
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
b/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
index 2dd85f6..16e5529 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
@@ -11,20 +11,20 @@ private class Geary.ImapEngine.GmailFolder : MinimalFolder, FolderSupport.Archiv
base (account, remote, local, local_folder, special_folder_type);
}
- public new async Geary.EmailIdentifier create_email_async(
+ public new async Geary.EmailIdentifier? create_email_async(
RFC822.Message rfc822, Geary.EmailFlags? flags, DateTime? date_received,
Geary.EmailIdentifier? id, Cancellable? cancellable = null) throws Error {
return yield base.create_email_async(rfc822, flags, date_received, id, cancellable);
}
- public async Geary.Future archive_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public async void archive_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
- return yield expunge_email_async(email_ids, cancellable);
+ yield expunge_email_async(email_ids, cancellable);
}
- public async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
- return yield true_remove_email_async(this, email_ids, cancellable);
+ yield true_remove_email_async(this, email_ids, cancellable);
}
/**
@@ -36,7 +36,7 @@ private class Geary.ImapEngine.GmailFolder : MinimalFolder, FolderSupport.Archiv
* no connection (or the connection dies) there's no record that Geary needs to perform the
* final remove when a connection is reestablished.
*/
- public static async Geary.Future true_remove_email_async(MinimalFolder folder,
+ public static async void true_remove_email_async(MinimalFolder folder,
Gee.List<Geary.EmailIdentifier> email_ids, Cancellable? cancellable) throws Error {
// Get path to Trash folder
Geary.Folder? trash = folder.account.get_special_folder(SpecialFolderType.TRASH);
@@ -45,19 +45,14 @@ private class Geary.ImapEngine.GmailFolder : MinimalFolder, FolderSupport.Archiv
// Copy to Trash, collect UIDs (note that copying to Trash is like a move; the copied
// messages are removed from all labels)
- Gee.Set<Imap.UID>? uids;
- Geary.Future? future = yield folder.copy_email_uids_async(email_ids, trash.path, out uids,
- cancellable);
-
- if (future != null)
- uids = (Gee.Set<Imap.UID>?) yield future.wait_for_fulfillment_async(cancellable);
-
+ Gee.Set<Imap.UID>? uids = yield folder.copy_email_uids_async(email_ids, trash.path, cancellable);
if (uids == null || uids.size == 0) {
debug("%s: Can't true-remove %d emails, no COPYUIDs returned", folder.to_string(),
email_ids.size);
- return null;
+ return;
}
+
// For speed reasons, use a detached Imap.Folder object to delete moved emails; this is a
// separate connection and is not synchronized with the database, but also avoids a full
// folder normalization, which can be a heavyweight operation
@@ -78,8 +73,6 @@ private class Geary.ImapEngine.GmailFolder : MinimalFolder, FolderSupport.Archiv
debug("%s: Successfully true-removed %d/%d emails", folder.to_string(), uids.size,
email_ids.size);
-
- return null;
}
}
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala
b/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala
index a35de63..18aecee 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-search-folder.vala
@@ -17,7 +17,7 @@ public class Geary.ImapEngine.GmailSearchFolder : Geary.SearchFolder {
}
- public override async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public override async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
Geary.Folder? trash_folder = null;
try {
@@ -34,7 +34,5 @@ public class Geary.ImapEngine.GmailSearchFolder : Geary.SearchFolder {
// to fully trash the message.
yield email_store.copy_email_async(email_ids, trash_folder.path, cancellable);
}
-
- return null;
}
}
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-spam-trash-folder.vala
b/src/engine/imap-engine/gmail/imap-engine-gmail-spam-trash-folder.vala
index e99446e..e9bb552 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-spam-trash-folder.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-spam-trash-folder.vala
@@ -16,13 +16,13 @@ private class Geary.ImapEngine.GmailSpamTrashFolder : MinimalFolder, FolderSuppo
base (account, remote, local, local_folder, special_folder_type);
}
- public async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
- return yield expunge_email_async(email_ids, cancellable);
+ yield expunge_email_async(email_ids, cancellable);
}
- public async Geary.Future empty_folder_async(Cancellable? cancellable = null) throws Error {
- return yield expunge_all_async(cancellable);
+ public async void empty_folder_async(Cancellable? cancellable = null) throws Error {
+ yield expunge_all_async(cancellable);
}
}
diff --git a/src/engine/imap-engine/imap-engine-generic-folder.vala
b/src/engine/imap-engine/imap-engine-generic-folder.vala
index 48f2c57..fb1d328 100644
--- a/src/engine/imap-engine/imap-engine-generic-folder.vala
+++ b/src/engine/imap-engine/imap-engine-generic-folder.vala
@@ -11,18 +11,18 @@ private class Geary.ImapEngine.GenericFolder : MinimalFolder, Geary.FolderSuppor
base (account, remote, local, local_folder, special_folder_type);
}
- public async Geary.Future remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ public async void remove_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable = null) throws Error {
- return yield expunge_email_async(email_ids, cancellable);
+ yield expunge_email_async(email_ids, cancellable);
}
- public async Geary.Future empty_folder_async(Cancellable? cancellable = null) throws Error {
- return yield expunge_all_async(cancellable);
+ public async void empty_folder_async(Cancellable? cancellable = null) throws Error {
+ yield expunge_all_async(cancellable);
}
- public new async Geary.Future create_email_async(RFC822.Message rfc822, Geary.EmailFlags? flags,
- DateTime? date_received, Geary.EmailIdentifier? id, Cancellable? cancellable = null)
- throws Error {
+ public new async Geary.EmailIdentifier? create_email_async(RFC822.Message rfc822,
+ Geary.EmailFlags? flags, DateTime? date_received, Geary.EmailIdentifier? id,
+ Cancellable? cancellable = null) throws Error {
return yield base.create_email_async(rfc822, flags, date_received, id, cancellable);
}
}
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index 8f251b2..98a657b 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -1278,7 +1278,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Helper function for child classes dealing with the delete/archive question. This method will
// mark the message as deleted and expunge it.
- protected async Geary.Future expunge_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
+ protected async void expunge_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
Cancellable? cancellable) throws Error {
check_open("expunge_email_async");
check_ids("expunge_email_async", email_ids);
@@ -1287,16 +1287,16 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
cancellable);
replay_queue.schedule(remove);
- return yield remove.wait_for_ready_async(cancellable);
+ yield remove.wait_for_ready_async(cancellable);
}
- protected async Geary.Future expunge_all_async(Cancellable? cancellable = null) throws Error {
+ protected async void expunge_all_async(Cancellable? cancellable = null) throws Error {
check_open("expunge_all_async");
EmptyFolder empty_folder = new EmptyFolder(this, cancellable);
replay_queue.schedule(empty_folder);
- return yield empty_folder.wait_for_ready_async(cancellable);
+ yield empty_folder.wait_for_ready_async(cancellable);
}
private void check_open(string method) throws EngineError {
@@ -1321,7 +1321,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
check_id(method, id);
}
- public virtual async Geary.Future mark_email_async(Gee.List<Geary.EmailIdentifier> to_mark,
+ public virtual async void mark_email_async(Gee.List<Geary.EmailIdentifier> to_mark,
Geary.EmailFlags? flags_to_add, Geary.EmailFlags? flags_to_remove,
Cancellable? cancellable = null) throws Error {
check_open("mark_email_async");
@@ -1329,60 +1329,47 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
MarkEmail mark = new MarkEmail(this, to_mark, flags_to_add, flags_to_remove, cancellable);
replay_queue.schedule(mark);
- return yield mark.wait_for_ready_async(cancellable);
+ yield mark.wait_for_ready_async(cancellable);
}
- public virtual async Geary.Future copy_email_async(Gee.List<Geary.EmailIdentifier> to_copy,
+ public virtual async void copy_email_async(Gee.List<Geary.EmailIdentifier> to_copy,
Geary.FolderPath destination, Cancellable? cancellable = null) throws Error {
- return yield copy_email_uids_async(to_copy, destination, null, cancellable);
+ yield copy_email_uids_async(to_copy, destination, cancellable);
}
/**
* Returns the destination folder's UIDs for the copied messages.
- *
- * If returned Future is non-null, must wait for Future to fulfill to get destination UIDs.
*/
- public async Geary.Future copy_email_uids_async(Gee.List<Geary.EmailIdentifier> to_copy,
- Geary.FolderPath destination, out Gee.Set<Imap.UID>? destination_uids,
- Cancellable? cancellable = null) throws Error {
+ public async Gee.Set<Imap.UID>? copy_email_uids_async(Gee.List<Geary.EmailIdentifier> to_copy,
+ Geary.FolderPath destination, Cancellable? cancellable = null) throws Error {
check_open("copy_email_uids_async");
check_ids("copy_email_uids_async", to_copy);
// watch for copying to this folder, which is treated as a no-op
- if (destination.equal_to(path)) {
- destination_uids = null;
-
- // FIX
+ if (destination.equal_to(path))
return null;
- }
CopyEmail copy = new CopyEmail(this, (Gee.List<ImapDB.EmailIdentifier>) to_copy, destination);
replay_queue.schedule(copy);
- Geary.Future future = yield copy.wait_for_ready_async(cancellable);
+ yield copy.wait_for_ready_async(cancellable);
- // TODO: Fix
- if (future != null)
- destination_uids = copy.destination_uids.size > 0 ? copy.destination_uids : null;
- else
- destination_uids = null;
-
- return future;
+ return copy.destination_uids.size > 0 ? copy.destination_uids : null;
}
- public virtual async Geary.Future move_email_async(Gee.List<Geary.EmailIdentifier> to_move,
+ public virtual async void move_email_async(Gee.List<Geary.EmailIdentifier> to_move,
Geary.FolderPath destination, Cancellable? cancellable = null) throws Error {
check_open("move_email_async");
check_ids("move_email_async", to_move);
// watch for moving to this folder, which is treated as a no-op
if (destination.equal_to(path))
- return null;
+ return;
MoveEmail move = new MoveEmail(this, (Gee.List<ImapDB.EmailIdentifier>) to_move, destination);
replay_queue.schedule(move);
- return yield move.wait_for_ready_async(cancellable);
+ yield move.wait_for_ready_async(cancellable);
}
private void on_email_flags_changed(Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> changed) {
@@ -1423,10 +1410,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
replay_queue.schedule(op);
- // Unlike the list operations, need to wait on the future because ServerSearchEmail will
- // retry until completed
- Geary.Future future = yield op.wait_for_ready_async(cancellable);
- yield future.wait_for_fulfillment_async(cancellable);
+ 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;
@@ -1443,23 +1427,21 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
return earliest_id;
}
- protected async Geary.Future create_email_async(RFC822.Message rfc822, Geary.EmailFlags? flags,
- DateTime? date_received, Geary.EmailIdentifier? id, out Geary.EmailIdentifier? created_id,
+ protected async Geary.EmailIdentifier? create_email_async(RFC822.Message rfc822,
+ Geary.EmailFlags? flags, DateTime? date_received, Geary.EmailIdentifier? id,
Cancellable? cancellable = null) throws Error {
check_open("create_email_async");
if (id != null)
check_id("create_email_async", id);
Error? cancel_error = null;
- Geary.Future? future = null;
Geary.EmailIdentifier? ret = null;
try {
CreateEmail create = new CreateEmail(this, rfc822, flags, date_received, cancellable);
replay_queue.schedule(create);
+ yield create.wait_for_ready_async(cancellable);
- future = yield create.wait_for_ready_async(cancellable);
- if (future != null)
- ret = (Geary.EmailIdentifier?) yield future.wait_for_fulfillment_async(cancellable);
+ ret = create.created_id;
} catch (Error e) {
if (e is IOError.CANCELLED)
cancel_error = e;
diff --git a/src/engine/imap-engine/imap-engine-replay-operation.vala
b/src/engine/imap-engine/imap-engine-replay-operation.vala
index 8d11766..0f20bf0 100644
--- a/src/engine/imap-engine/imap-engine-replay-operation.vala
+++ b/src/engine/imap-engine/imap-engine-replay-operation.vala
@@ -46,14 +46,12 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
public bool notified { get { return semaphore.is_passed(); } }
private Nonblocking.Semaphore semaphore = new Nonblocking.Semaphore();
- private Geary.Future future;
public ReplayOperation(string name, Scope scope, OnError on_remote_error = OnError.THROW) {
this.name = name;
opnum = next_opnum++;
this.scope = scope;
this.on_remote_error = on_remote_error;
- future = new Geary.Future(name);
}
/**
@@ -104,10 +102,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
/**
* See Scope for conditions where this method will be called.
*
- * This result is used to fulfill the { link Future} that is ultimately returned by to the
- * caller. It will be ignored if the call throws an Error or returns anything other than
- * Status.COMPLETED.
- *
* Returns:
* COMPLETED: the operation has completed and no further calls should be made.
* CONTINUE: The local operation has completed and the remote portion must be executed as
@@ -121,10 +115,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
/**
* See Scope for conditions where this method will be called.
*
- * This result is used to fulfill the { link Future} that is ultimately returned by to the
- * caller. It will be ignored if the call throws an Error or returns anything other than
- * Status.COMPLETED.
- *
* Returns:
* COMPLETED: the operation has completed and no further calls should be made.
* CONTINUE: Treated as COMPLETED.
@@ -135,19 +125,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
public abstract async Status replay_remote_async() throws Error;
/**
- * Returns the final result of the operation as a Value.
- *
- * This result is used to fulfill the { link Future} that is ultimately returned by to the
- * caller. It will be ignored if the call throws an Error or returns anything other than
- * Status.COMPLETED.
- *
- * Default implementation returns null.
- */
- protected virtual Value? get_operation_result() {
- return null;
- }
-
- /**
* See Scope, replay_local_async(), and replay_remote_async() for conditions for this where this
* will be called.
*/
@@ -156,32 +133,17 @@ 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.
- *
- * TODO: Always return a Future and require returning results to be fetched from the Future.
- * Child classes must supply a fulfill_future() override method that does the right thing for
- * the operation. Or...they just know to do it.
- *
- * Returns a Semaphore if the operation is retrying. The Semaphore will be triggered when the
- * retry completes or errors out.
*/
- public async Geary.Future 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);
- return future;
+ if (err != null)
+ throw err;
}
- // Can only be called once, although must be called after notify_retrying() has been called and
- // the operation is complete
+ // Can only be called once
internal void notify_ready(Error? err) {
- if (err != null)
- future.fulfill(null, err);
- else
- future.fulfill(get_operation_result(), null);
-
- // if original call has already been completed and is merely waiting for the future, our
- // work is done
- if (semaphore.is_passed())
- return;
+ assert(!semaphore.is_passed());
this.err = err;
@@ -192,19 +154,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
}
}
- // Can only be called once, although notify_ready() may be called after calling this.
- internal void notify_retrying() {
- assert(!semaphore.is_passed());
-
- // Complete the original call but let the caller wait on the Future (if necessary) to get
- // the final result
- try {
- semaphore.notify();
- } catch (Error notify_err) {
- debug("Unable to notify replay operation as retrying: [%s] %s", name, notify_err.message);
- }
- }
-
public abstract string describe_state();
public string to_string() {
diff --git a/src/engine/imap-engine/imap-engine-replay-queue.vala
b/src/engine/imap-engine/imap-engine-replay-queue.vala
index 7939396..34ca427 100644
--- a/src/engine/imap-engine/imap-engine-replay-queue.vala
+++ b/src/engine/imap-engine/imap-engine-replay-queue.vala
@@ -504,12 +504,6 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
debug("Schedule op retry %s on %s: remote_retry_count=%d", op.to_string(),
to_string(), op.remote_retry_count);
- // if this is the first retry, complete the waiting async caller but allow
- // them to wait later or be signaled when completed ... this returns to the
- // original caller a Future they can use to be notified of final results
- if (op.remote_retry_count == 0)
- op.notify_retrying();
-
// use the retry count to sort the command at the top of the queue and
// take another go at it ... the Folder will disconnect and reconnect due
// to the hard error and wait_for_open_async() will block this command until
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 3f2ab1a..bb8974b 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
@@ -5,7 +5,8 @@
*/
private class Geary.ImapEngine.CreateEmail : Geary.ImapEngine.SendReplayOperation {
- private Geary.EmailIdentifier? created_id = null;
+ public Geary.EmailIdentifier? created_id { get; private set; default = null; }
+
private MinimalFolder engine;
private RFC822.Message rfc822;
private Geary.EmailFlags? flags;
@@ -69,8 +70,4 @@ private class Geary.ImapEngine.CreateEmail : Geary.ImapEngine.SendReplayOperatio
return ReplayOperation.Status.COMPLETED;
}
-
- protected override Value? get_operation_result() {
- return created_id;
- }
}
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
b/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
index e0cd438..133d8a5 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-fetch-email.vala
@@ -5,6 +5,8 @@
*/
private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation {
+ public Email? email = null;
+
private MinimalFolder engine;
private ImapDB.EmailIdentifier id;
private Email.Field required_fields;
@@ -13,7 +15,6 @@ private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation
private Cancellable? cancellable;
private Imap.UID? uid = null;
private bool remote_removed = false;
- private Geary.Email? email = null;
public FetchEmail(MinimalFolder engine, ImapDB.EmailIdentifier id, Email.Field required_fields,
Folder.ListFlags flags, Cancellable? cancellable) {
@@ -124,10 +125,6 @@ private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation
return ReplayOperation.Status.COMPLETED;
}
- protected override Value? get_operation_result() {
- return email;
- }
-
public override async void backout_local_async() throws Error {
// read-only
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]