Make GenericAccount's local and remote properties internal.
This allows removing MinimalFolder's copy of the account's Imap.Account since it can access it from the account, and will allow the remote to instance to change as the server becomes available/unavailable. * src/engine/imap-engine/imap-engine-generic-account.vala (GenericAccount): Make both remote and local properties internally accessible. * src/engine/imap-engine/imap-engine-minimal-folder.vala (MinimalFolder): Remove remote property and ctor arg, update call sites to access it from via GenericAccount instead. Update subclasses and ctor call sites.
This commit is contained in:
parent
ac7a405fc7
commit
59a52bde3e
15 changed files with 72 additions and 78 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Geary.EmailIdentifier> email_ids,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
yield GmailFolder.true_remove_email_async(this, email_ids, cancellable);
|
||||
|
|
|
|||
|
|
@ -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<Geary.EmailIdentifier> email_ids,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
yield GmailFolder.true_remove_email_async(this, email_ids, cancellable);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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<Geary.EmailIdentifier> email_ids,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright 2016 Software Freedom Conservancy Inc.
|
||||
* Copyright 2017 Michael Gratton <mike@vee.net>
|
||||
* Copyright 2017-2018 Michael Gratton <mike@vee.net>.
|
||||
*
|
||||
* 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<FolderPath, MinimalFolder> 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
|
||||
|
|
|
|||
|
|
@ -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<Geary.EmailIdentifier> email_ids,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
/* Copyright 2016 Software Freedom Conservancy Inc.
|
||||
/*
|
||||
* Copyright 2016 Software Freedom Conservancy Inc.
|
||||
* Copyright 2018 Michael Gratton <mike@vee.net>
|
||||
*
|
||||
* 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<Geary.Imap.MailboxAttribute>())
|
||||
|
|
@ -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<Geary.Email>? 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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue