[geary/wip/iterate-723208: 3/3] Clean up SingleItem usage



commit ad12383bde4be67dc0ae64ba65b7304ada37274e
Author: Charles Lindsay <chaz yorba org>
Date:   Tue Jan 28 18:52:03 2014 -0800

    Clean up SingleItem usage

 .../conversation-list/conversation-list-view.vala  |    2 +-
 .../conversation-viewer/conversation-viewer.vala   |   11 +++++------
 src/engine/api/geary-named-flags.vala              |    4 ++--
 src/engine/app/app-email-store.vala                |    2 +-
 .../app/email-store/app-fetch-operation.vala       |    2 +-
 src/engine/imap-db/imap-db-folder.vala             |    4 ++--
 .../imap-engine/imap-engine-generic-account.vala   |    3 ++-
 .../imap-engine/imap-engine-generic-folder.vala    |    5 +++--
 .../replay-ops/imap-engine-create-email.vala       |    2 +-
 .../replay-ops/imap-engine-fetch-email.vala        |    7 ++++---
 src/engine/imap/api/imap-account.vala              |    2 +-
 src/engine/imap/api/imap-folder.vala               |    8 ++++----
 12 files changed, 27 insertions(+), 25 deletions(-)
---
diff --git a/src/client/conversation-list/conversation-list-view.vala 
b/src/client/conversation-list/conversation-list-view.vala
index 0350216..6bc2d91 100644
--- a/src/client/conversation-list/conversation-list-view.vala
+++ b/src/client/conversation-list/conversation-list-view.vala
@@ -170,7 +170,7 @@ public class ConversationListView : Gtk.TreeView {
             if (GearyApplication.instance.controller.get_selected_conversations().contains(conversation))
                 to_mark = GearyApplication.instance.controller.get_selected_conversations();
             else
-                to_mark = new Geary.Collection.SingleItem<Geary.App.Conversation>(conversation);
+                to_mark = Geary.iterate<Geary.App.Conversation>(conversation).to_array_list();
             
             if (read_clicked) {
                 // Read/unread.
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index c1ea5f9..1833076 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -1203,8 +1203,7 @@ public class ConversationViewer : Gtk.Box {
             if (message != null && !message.load_remote_images().is_certain()) {
                 Geary.EmailFlags flags = new Geary.EmailFlags();
                 flags.add(Geary.EmailFlags.LOAD_REMOTE_IMAGES);
-                mark_messages(new Geary.Collection.SingleItem<Geary.EmailIdentifier>(
-                    message.id), flags, null);
+                mark_messages(Geary.iterate<Geary.EmailIdentifier>(message.id).to_array_list(), flags, null);
             }
         }
     }
@@ -1418,14 +1417,14 @@ public class ConversationViewer : Gtk.Box {
     private void on_mark_read_message(Geary.Email message) {
         Geary.EmailFlags flags = new Geary.EmailFlags();
         flags.add(Geary.EmailFlags.UNREAD);
-        mark_messages(new Geary.Collection.SingleItem<Geary.EmailIdentifier>(message.id), null, flags);
+        mark_messages(Geary.iterate<Geary.EmailIdentifier>(message.id).to_array_list(), null, flags);
         mark_manual_read(message.id);
     }
 
     private void on_mark_unread_message(Geary.Email message) {
         Geary.EmailFlags flags = new Geary.EmailFlags();
         flags.add(Geary.EmailFlags.UNREAD);
-        mark_messages(new Geary.Collection.SingleItem<Geary.EmailIdentifier>(message.id), flags, null);
+        mark_messages(Geary.iterate<Geary.EmailIdentifier>(message.id).to_array_list(), flags, null);
         mark_manual_read(message.id);
     }
     
@@ -1475,13 +1474,13 @@ public class ConversationViewer : Gtk.Box {
     private void flag_message(Geary.Email email) {
         Geary.EmailFlags flags = new Geary.EmailFlags();
         flags.add(Geary.EmailFlags.FLAGGED);
-        mark_messages(new Geary.Collection.SingleItem<Geary.EmailIdentifier>(email.id), flags, null);
+        mark_messages(Geary.iterate<Geary.EmailIdentifier>(email.id).to_array_list(), flags, null);
     }
 
     private void unflag_message(Geary.Email email) {
         Geary.EmailFlags flags = new Geary.EmailFlags();
         flags.add(Geary.EmailFlags.FLAGGED);
-        mark_messages(new Geary.Collection.SingleItem<Geary.EmailIdentifier>(email.id), null, flags);
+        mark_messages(Geary.iterate<Geary.EmailIdentifier>(email.id).to_array_list(), null, flags);
     }
 
     private void show_attachment_menu(Geary.Email email, Geary.Attachment attachment) {
diff --git a/src/engine/api/geary-named-flags.vala b/src/engine/api/geary-named-flags.vala
index ed4e93e..2932d39 100644
--- a/src/engine/api/geary-named-flags.vala
+++ b/src/engine/api/geary-named-flags.vala
@@ -44,7 +44,7 @@ public class Geary.NamedFlags : BaseObject, Gee.Hashable<Geary.NamedFlags> {
     public virtual void add(NamedFlag flag) {
         if (!list.contains(flag)) {
             list.add(flag);
-            notify_added(new Collection.SingleItem<NamedFlag>(flag));
+            notify_added(Geary.iterate<NamedFlag>(flag).to_array_list());
         }
     }
     
@@ -60,7 +60,7 @@ public class Geary.NamedFlags : BaseObject, Gee.Hashable<Geary.NamedFlags> {
     public virtual bool remove(NamedFlag flag) {
         bool removed = list.remove(flag);
         if (removed)
-            notify_removed(new Collection.SingleItem<NamedFlag>(flag));
+            notify_removed(Geary.iterate<NamedFlag>(flag).to_array_list());
         
         return removed;
     }
diff --git a/src/engine/app/app-email-store.vala b/src/engine/app/app-email-store.vala
index b134d31..02288d0 100644
--- a/src/engine/app/app-email-store.vala
+++ b/src/engine/app/app-email-store.vala
@@ -80,7 +80,7 @@ public class Geary.App.EmailStore : BaseObject {
         Cancellable? cancellable = null) throws Error {
         FetchOperation op = new Geary.App.FetchOperation(required_fields, flags);
         yield do_folder_operation_async(op,
-            new Geary.Collection.SingleItem<Geary.EmailIdentifier>(email_id), cancellable);
+            Geary.iterate<Geary.EmailIdentifier>(email_id).to_array_list(), cancellable);
         
         if (op.result == null)
             throw new EngineError.NOT_FOUND("Couldn't fetch email ID %s", email_id.to_string());
diff --git a/src/engine/app/email-store/app-fetch-operation.vala 
b/src/engine/app/email-store/app-fetch-operation.vala
index b6df8c9..cb642a6 100644
--- a/src/engine/app/email-store/app-fetch-operation.vala
+++ b/src/engine/app/email-store/app-fetch-operation.vala
@@ -25,6 +25,6 @@ private class Geary.App.FetchOperation : Geary.App.AsyncFolderOperation {
         
         result = yield folder.fetch_email_async(
             id, required_fields, flags, cancellable);
-        return new Geary.Collection.SingleItem<Geary.EmailIdentifier>(id);
+        return Geary.iterate<Geary.EmailIdentifier>(id).to_array_list();
     }
 }
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index 9bbc11f..155dad4 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -876,8 +876,8 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
             }
             
             // Check to see if message is unread (this only affects non-marked emails.)
-            if (do_get_unread_count_for_ids(cx, new Geary.Collection.SingleItem
-                <ImapDB.EmailIdentifier>(id), cancellable) > 0) {
+            if (do_get_unread_count_for_ids(cx,
+                Geary.iterate<ImapDB.EmailIdentifier>(id).to_array_list(), cancellable) > 0) {
                 do_add_to_unread_count(cx, -1, cancellable);
                 was_unread = true;
             }
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 18e99af..8033f2c 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -209,7 +209,8 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
     }
     
     private GenericFolder build_folder(ImapDB.Folder local_folder) {
-        return Geary.Collection.get_first(build_folders(new 
Collection.SingleItem<ImapDB.Folder>(local_folder)));
+        return Geary.Collection.get_first(build_folders(
+            Geary.iterate<ImapDB.Folder>(local_folder).to_array_list()));
     }
 
     private Gee.Collection<GenericFolder> build_folders(Gee.Collection<ImapDB.Folder> local_folders) {
diff --git a/src/engine/imap-engine/imap-engine-generic-folder.vala 
b/src/engine/imap-engine/imap-engine-generic-folder.vala
index f0081a5..8203d27 100644
--- a/src/engine/imap-engine/imap-engine-generic-folder.vala
+++ b/src/engine/imap-engine/imap-engine-generic-folder.vala
@@ -914,7 +914,8 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
             }
             
             // Notify queued replay operations that the email has been removed (by EmailIdentifier)
-            replay_queue.notify_remote_removed_ids(new 
Collection.SingleItem<ImapDB.EmailIdentifier>(owned_id));
+            replay_queue.notify_remote_removed_ids(
+                Geary.iterate<ImapDB.EmailIdentifier>(owned_id).to_array_list());
         } else {
             debug("%s do_replay_removed_message: remote_position=%d unknown in local store "
                 + "(reported_remote_count=%d local_position=%d local_count=%d)",
@@ -942,7 +943,7 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
         
         // notify of change
         if (!marked && owned_id != null)
-            notify_email_removed(new Collection.SingleItem<Geary.EmailIdentifier>(owned_id));
+            notify_email_removed(Geary.iterate<Geary.EmailIdentifier>(owned_id).to_array_list());
         
         if (!marked)
             notify_email_count_changed(reported_remote_count, CountChangeReason.REMOVED);
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 6bb4741..4419aa0 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
@@ -65,7 +65,7 @@ private class Geary.ImapEngine.CreateEmail : Geary.ImapEngine.SendReplayOperatio
         // TODO: need to prevent gaps that may occur here
         Geary.Email created = new Geary.Email(created_id);
         Gee.Map<Geary.Email, bool> results = yield engine.local_folder.create_or_merge_email_async(
-            new Collection.SingleItem<Geary.Email>(created), cancellable);
+            Geary.iterate<Geary.Email>(created).to_array_list(), cancellable);
         if (results.size > 0)
             created_id = Collection.get_first<Geary.Email>(results.keys).id;
         else
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 cfad9fa..02c0970 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
@@ -102,12 +102,13 @@ private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation
         assert(email != null);
         
         Gee.Map<Geary.Email, bool> created_or_merged =
-            yield engine.local_folder.create_or_merge_email_async(new 
Collection.SingleItem<Geary.Email>(email),
-                cancellable);
+            yield engine.local_folder.create_or_merge_email_async(
+                Geary.iterate<Geary.Email>(email).to_array_list(), cancellable);
         
         // true means created
         if (created_or_merged.get(email)) {
-            Gee.Collection<Geary.EmailIdentifier> ids = new 
Collection.SingleItem<Geary.EmailIdentifier>(email.id);
+            Gee.Collection<Geary.EmailIdentifier> ids
+                = Geary.iterate<Geary.EmailIdentifier>(email.id).to_array_list();
             engine.notify_email_inserted(ids);
             engine.notify_email_locally_inserted(ids);
         }
diff --git a/src/engine/imap/api/imap-account.vala b/src/engine/imap/api/imap-account.vala
index 0cd39c4..274a012 100644
--- a/src/engine/imap/api/imap-account.vala
+++ b/src/engine/imap/api/imap-account.vala
@@ -342,7 +342,7 @@ private class Geary.Imap.Account : BaseObject {
         Gee.List<MailboxInformation>? list_results, Gee.List<StatusData>? status_results,
         Cancellable? cancellable) throws Error {
         Gee.Map<Command, StatusResponse> responses = yield send_multiple_async(
-            new Geary.Collection.SingleItem<Command>(cmd), list_results, status_results,
+            Geary.iterate<Command>(cmd).to_array_list(), list_results, status_results,
             cancellable);
         
         assert(responses.size == 1);
diff --git a/src/engine/imap/api/imap-folder.vala b/src/engine/imap/api/imap-folder.vala
index a38dc75..5660e5a 100644
--- a/src/engine/imap/api/imap-folder.vala
+++ b/src/engine/imap/api/imap-folder.vala
@@ -337,7 +337,7 @@ private class Geary.Imap.Folder : BaseObject {
         FetchCommand cmd = new FetchCommand.data_type(msg_set, FetchDataSpecifier.UID);
         
         Gee.HashMap<SequenceNumber, FetchedData>? fetched;
-        yield exec_commands_async(new Collection.SingleItem<Command>(cmd), out fetched, null,
+        yield exec_commands_async(Geary.iterate<Command>(cmd).to_array_list(), out fetched, null,
             cancellable);
         if (fetched == null || fetched.size == 0)
             return null;
@@ -550,9 +550,9 @@ private class Geary.Imap.Folder : BaseObject {
         
         CopyCommand cmd = new CopyCommand(msg_set,
             new MailboxSpecifier.from_folder_path(destination, null));
-        Gee.Collection<Command> cmds = new Collection.SingleItem<Command>(cmd);
         
-        yield exec_commands_async(cmds, null, null, cancellable);
+        yield exec_commands_async(Geary.iterate<Command>(cmd).to_array_list(), null,
+            null, cancellable);
     }
     
     // TODO: Support MOVE extension
@@ -897,7 +897,7 @@ private class Geary.Imap.Folder : BaseObject {
             msg_flags, internaldate, message.get_network_buffer(false));
         
         Gee.Map<Command, StatusResponse> responses = yield exec_commands_async(
-            new Collection.SingleItem<AppendCommand>(cmd), null, null, null);
+            Geary.iterate<AppendCommand>(cmd).to_array_list(), null, null, null);
         
         // Grab the response and parse out the UID, if available.
         StatusResponse response = responses.get(cmd);


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