diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala index bdebdedc..971b2cb9 100644 --- a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala +++ b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala @@ -49,21 +49,17 @@ private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount { switch (special_folder_type) { case SpecialFolderType.ALL_MAIL: - return new GmailAllMailFolder(this, this.remote, local_folder, - special_folder_type); + return new GmailAllMailFolder(this, local_folder, special_folder_type); case SpecialFolderType.DRAFTS: - return new GmailDraftsFolder(this, this.remote, local_folder, - special_folder_type); + return new GmailDraftsFolder(this, local_folder, special_folder_type); case SpecialFolderType.SPAM: case SpecialFolderType.TRASH: - return new GmailSpamTrashFolder(this, this.remote, local_folder, - special_folder_type); + return new GmailSpamTrashFolder(this, local_folder, special_folder_type); default: - return new GmailFolder(this, this.remote, local_folder, - special_folder_type); + return new GmailFolder(this, local_folder, special_folder_type); } } @@ -71,4 +67,3 @@ private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount { return new GmailSearchFolder(this); } } - 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 9f9fb8be..5612fcdd 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 @@ -9,11 +9,12 @@ */ private class Geary.ImapEngine.GmailAllMailFolder : MinimalFolder, FolderSupport.Remove { - public GmailAllMailFolder(GmailAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public GmailAllMailFolder(GmailAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base(account, local_folder, special_folder_type); } - + public async void remove_email_async(Gee.List email_ids, Cancellable? cancellable = null) throws Error { 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 7b56ab91..e72643ab 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 @@ -11,17 +11,18 @@ private class Geary.ImapEngine.GmailDraftsFolder : MinimalFolder, FolderSupport.Create, FolderSupport.Remove { - public GmailDraftsFolder(GmailAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public GmailDraftsFolder(GmailAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base (account, local_folder, special_folder_type); } - + 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 void remove_email_async(Gee.List email_ids, Cancellable? cancellable = null) throws Error { 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 cca2e00b..ccaa5820 100644 --- a/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala +++ b/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala @@ -6,11 +6,12 @@ private class Geary.ImapEngine.GmailFolder : MinimalFolder, FolderSupport.Archive, FolderSupport.Create, FolderSupport.Remove { - public GmailFolder(GmailAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public GmailFolder(GmailAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base (account, local_folder, special_folder_type); } - + 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 { 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 ec8461fb..aa6ce5d9 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 @@ -11,9 +11,10 @@ private class Geary.ImapEngine.GmailSpamTrashFolder : MinimalFolder, FolderSupport.Remove, FolderSupport.Empty { - public GmailSpamTrashFolder(GmailAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public GmailSpamTrashFolder(GmailAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base (account, local_folder, special_folder_type); } public async void remove_email_async(Gee.List email_ids, diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala b/src/engine/imap-engine/imap-engine-generic-account.vala index a48ecd97..03816c80 100644 --- a/src/engine/imap-engine/imap-engine-generic-account.vala +++ b/src/engine/imap-engine/imap-engine-generic-account.vala @@ -1,6 +1,6 @@ /* * Copyright 2016 Software Freedom Conservancy Inc. - * Copyright 2017 Michael Gratton + * Copyright 2017-2018 Michael Gratton . * * This software is licensed under the GNU Lesser General Public License * (version 2.1 or later). See the COPYING file in this distribution. @@ -24,8 +24,8 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account { private static Geary.FolderPath? outbox_path = null; private static Geary.FolderPath? search_path = null; - protected Imap.Account remote { get; private set; } - protected ImapDB.Account local { get; private set; } + internal Imap.Account remote { get; private set; } + internal ImapDB.Account local { get; private set; } private bool open = false; private Gee.HashMap folder_map = new Gee.HashMap< @@ -1085,24 +1085,19 @@ internal class Geary.ImapEngine.UpdateRemoteFolders : AccountOperation { internal class Geary.ImapEngine.RefreshFolderUnseen : FolderOperation { - private weak Imap.Account remote; - - internal RefreshFolderUnseen(MinimalFolder folder, - GenericAccount account, - Imap.Account remote) { + GenericAccount account) { base(account, folder); - this.remote = remote; } public override async void execute(Cancellable cancellable) throws Error { if (this.folder.get_open_state() == Geary.Folder.OpenState.CLOSED) { - Imap.Folder remote_folder = yield this.remote.fetch_folder_cached_async( - folder.path, - true, - cancellable - ); - + Imap.Folder remote_folder = + yield ((GenericAccount) this.account).remote.fetch_folder_cached_async( + folder.path, + true, + cancellable + ); // Although this is called when the folder is closed, we // can safely use local_folder since we are only using its diff --git a/src/engine/imap-engine/imap-engine-generic-folder.vala b/src/engine/imap-engine/imap-engine-generic-folder.vala index cd59b9bf..5f802ed7 100644 --- a/src/engine/imap-engine/imap-engine-generic-folder.vala +++ b/src/engine/imap-engine/imap-engine-generic-folder.vala @@ -10,9 +10,10 @@ private class Geary.ImapEngine.GenericFolder : MinimalFolder, Geary.FolderSupport.Create, Geary.FolderSupport.Empty { - public GenericFolder(GenericAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public GenericFolder(GenericAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base (account, local_folder, special_folder_type); } public async Geary.Revokable? archive_email_async(Gee.List email_ids, diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala b/src/engine/imap-engine/imap-engine-minimal-folder.vala index 4037c769..e85f7ef3 100644 --- a/src/engine/imap-engine/imap-engine-minimal-folder.vala +++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala @@ -1,4 +1,6 @@ -/* Copyright 2016 Software Freedom Conservancy Inc. +/* + * Copyright 2016 Software Freedom Conservancy Inc. + * Copyright 2018 Michael Gratton * * This software is licensed under the GNU Lesser General Public License * (version 2.1 or later). See the COPYING file in this distribution. @@ -61,9 +63,9 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport internal ReplayQueue replay_queue { get; private set; } private weak GenericAccount _account; - private Geary.AggregatedFolderProperties _properties = new Geary.AggregatedFolderProperties( - false, false); - private Imap.Account remote; + private Geary.AggregatedFolderProperties _properties = + new Geary.AggregatedFolderProperties(false, false); + private Folder.OpenFlags open_flags = OpenFlags.NONE; private int open_count = 0; private bool remote_opened = false; @@ -105,11 +107,9 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport public MinimalFolder(GenericAccount account, - Imap.Account remote, ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { this._account = account; - this.remote = remote; this.remote_open_timer = new TimeoutManager.seconds( FORCE_OPEN_REMOTE_TIMEOUT_SEC, () => { start_open_remote(); } ); @@ -565,7 +565,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport if (!yield remote_semaphore.wait_for_result_async(cancellable)) throw new EngineError.ALREADY_CLOSED("%s failed to open", to_string()); } - + public override async bool open_async(Geary.Folder.OpenFlags open_flags, Cancellable? cancellable = null) throws Error { if (open_count++ > 0) { @@ -577,12 +577,9 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport start_open_remote(); } - - debug("Not opening %s: already open", to_string()); - return false; } - + // first open gets to name the flags, but see note above this.open_flags = open_flags; @@ -612,7 +609,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport // second account Inbox they don't manipulate), no remote connection will ever be made, // meaning that folder normalization never happens and unsolicited notifications never // arrive - this.remote.ready.connect(on_remote_ready); + this._account.remote.ready.connect(on_remote_ready); if (open_flags.is_all_set(OpenFlags.NO_DELAY)) { start_open_remote(); } else { @@ -622,7 +619,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport } private void start_open_remote() { - if (!this.remote_opened && this.remote.is_ready) { + if (!this.remote_opened && this._account.remote.is_ready) { this.remote_opened = true; this.remote_open_timer.reset(); this.open_remote_async.begin(null); @@ -676,7 +673,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport debug("Fetching information for remote folder %s", to_string()); try { - opening_folder = yield this.remote.fetch_folder_cached_async( + opening_folder = yield this._account.remote.fetch_folder_cached_async( path, false, cancellable ); } catch (EngineError.NOT_FOUND err) { @@ -687,7 +684,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport // Use local STATUS data cache to be able to present // something to the user at least. XXX get the attrs // from somewhere for Bug 714775 - opening_folder = this.remote.new_selectable_folder( + opening_folder = this._account.remote.new_selectable_folder( path, local_status, new Imap.MailboxAttributes(new Gee.ArrayList()) @@ -1470,7 +1467,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport // we support IMAP CONDSTORE (Bug 713117). int chunk_size = FLAG_UPDATE_START_CHUNK; Geary.EmailIdentifier? lowest = null; - while (!this.open_cancellable.is_cancelled() && this.remote.is_ready) { + while (!this.open_cancellable.is_cancelled() && this._account.remote.is_ready) { Gee.List? list_local = yield list_email_by_id_async( lowest, chunk_size, Geary.Email.Field.FLAGS, @@ -1525,9 +1522,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport private void on_refresh_unseen() { // We queue an account operation since the folder itself is // closed and hence does not have a connection to use for it. - RefreshFolderUnseen op = new RefreshFolderUnseen( - this, this._account, this.remote - ); + RefreshFolderUnseen op = new RefreshFolderUnseen(this, this._account); try { this._account.queue_operation(op); } catch (Error err) { diff --git a/src/engine/imap-engine/other/imap-engine-other-account.vala b/src/engine/imap-engine/other/imap-engine-other-account.vala index 829ce2dd..4ee8097b 100644 --- a/src/engine/imap-engine/other/imap-engine-other-account.vala +++ b/src/engine/imap-engine/other/imap-engine-other-account.vala @@ -18,6 +18,6 @@ private class Geary.ImapEngine.OtherAccount : Geary.ImapEngine.GenericAccount { else type = local_folder.get_properties().attrs.get_special_folder_type(); - return new OtherFolder(this, this.remote, local_folder, type); + return new OtherFolder(this, local_folder, type); } } diff --git a/src/engine/imap-engine/other/imap-engine-other-folder.vala b/src/engine/imap-engine/other/imap-engine-other-folder.vala index 77d84ddf..25d85f0c 100644 --- a/src/engine/imap-engine/other/imap-engine-other-folder.vala +++ b/src/engine/imap-engine/other/imap-engine-other-folder.vala @@ -5,9 +5,10 @@ */ private class Geary.ImapEngine.OtherFolder : GenericFolder { - public OtherFolder(OtherAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public OtherFolder(OtherAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base (account, local_folder, special_folder_type); } } diff --git a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala index 6d68a002..d9a7f979 100644 --- a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala +++ b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala @@ -46,9 +46,9 @@ private class Geary.ImapEngine.OutlookAccount : Geary.ImapEngine.GenericAccount special_folder_type = local_folder.get_properties().attrs.get_special_folder_type(); if (special_folder_type == Geary.SpecialFolderType.DRAFTS) - return new OutlookDraftsFolder(this, this.remote, local_folder, special_folder_type); + return new OutlookDraftsFolder(this, local_folder, special_folder_type); - return new OutlookFolder(this, this.remote, local_folder, special_folder_type); + return new OutlookFolder(this, local_folder, special_folder_type); } } diff --git a/src/engine/imap-engine/outlook/imap-engine-outlook-drafts-folder.vala b/src/engine/imap-engine/outlook/imap-engine-outlook-drafts-folder.vala index 32186641..a6a8ebdc 100644 --- a/src/engine/imap-engine/outlook/imap-engine-outlook-drafts-folder.vala +++ b/src/engine/imap-engine/outlook/imap-engine-outlook-drafts-folder.vala @@ -12,8 +12,9 @@ * saved at all. */ private class Geary.ImapEngine.OutlookDraftsFolder : MinimalFolder { - public OutlookDraftsFolder(OutlookAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public OutlookDraftsFolder(OutlookAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base(account, local_folder, special_folder_type); } } diff --git a/src/engine/imap-engine/outlook/imap-engine-outlook-folder.vala b/src/engine/imap-engine/outlook/imap-engine-outlook-folder.vala index 4131fe8c..4bf46b01 100644 --- a/src/engine/imap-engine/outlook/imap-engine-outlook-folder.vala +++ b/src/engine/imap-engine/outlook/imap-engine-outlook-folder.vala @@ -5,8 +5,9 @@ */ private class Geary.ImapEngine.OutlookFolder : GenericFolder { - public OutlookFolder(OutlookAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public OutlookFolder(OutlookAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base(account, local_folder, special_folder_type); } } diff --git a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala index d7fd9592..49333a92 100644 --- a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala +++ b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala @@ -42,6 +42,6 @@ private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount { Geary.FolderPath path = local_folder.get_path(); SpecialFolderType special_folder_type = special_map.has_key(path) ? special_map.get(path) : Geary.SpecialFolderType.NONE; - return new YahooFolder(this, this.remote, local_folder, special_folder_type); + return new YahooFolder(this, local_folder, special_folder_type); } } diff --git a/src/engine/imap-engine/yahoo/imap-engine-yahoo-folder.vala b/src/engine/imap-engine/yahoo/imap-engine-yahoo-folder.vala index 5663faf6..dc8481ff 100644 --- a/src/engine/imap-engine/yahoo/imap-engine-yahoo-folder.vala +++ b/src/engine/imap-engine/yahoo/imap-engine-yahoo-folder.vala @@ -5,8 +5,9 @@ */ private class Geary.ImapEngine.YahooFolder : GenericFolder { - public YahooFolder(YahooAccount account, Imap.Account remote, - ImapDB.Folder local_folder, SpecialFolderType special_folder_type) { - base (account, remote, local_folder, special_folder_type); + public YahooFolder(YahooAccount account, + ImapDB.Folder local_folder, + SpecialFolderType special_folder_type) { + base (account, local_folder, special_folder_type); } }