[geary/wip/778276-better-flag-updates: 15/25] Refactor GenericAccount::new_folder a bit to make it less verbose.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/778276-better-flag-updates: 15/25] Refactor GenericAccount::new_folder a bit to make it less verbose.
- Date: Mon, 18 Dec 2017 22:43:33 +0000 (UTC)
commit 382bd9c43e1a0e0779f6bb018a8ca9bfd62d8325
Author: Michael James Gratton <mike vee net>
Date: Thu Nov 23 16:35:44 2017 +1100
Refactor GenericAccount::new_folder a bit to make it less verbose.
.../gmail/imap-engine-gmail-account.vala | 20 ++++++++++----------
.../imap-engine/imap-engine-generic-account.vala | 10 +++++-----
.../other/imap-engine-other-account.vala | 9 ++++-----
.../outlook/imap-engine-outlook-account.vala | 14 +++++++-------
.../yahoo/imap-engine-yahoo-account.vala | 10 ++++------
5 files changed, 30 insertions(+), 33 deletions(-)
---
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 9dbf1cd..f4cafde 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
@@ -39,30 +39,30 @@ private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount {
return SUPPORTED_SPECIAL_FOLDERS;
}
- protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
- ImapDB.Account local_account, ImapDB.Folder local_folder) {
+ protected override MinimalFolder new_folder(ImapDB.Folder local_folder) {
+ Geary.FolderPath path = local_folder.get_path();
SpecialFolderType special_folder_type;
if (Imap.MailboxSpecifier.folder_path_is_inbox(path))
special_folder_type = SpecialFolderType.INBOX;
else
special_folder_type = local_folder.get_properties().attrs.get_special_folder_type();
-
+
switch (special_folder_type) {
case SpecialFolderType.ALL_MAIL:
- return new GmailAllMailFolder(this, remote_account, local_account, local_folder,
+ return new GmailAllMailFolder(this, this.remote, this.local, local_folder,
special_folder_type);
-
+
case SpecialFolderType.DRAFTS:
- return new GmailDraftsFolder(this, remote_account, local_account, local_folder,
+ return new GmailDraftsFolder(this, this.remote, this.local, local_folder,
special_folder_type);
-
+
case SpecialFolderType.SPAM:
case SpecialFolderType.TRASH:
- return new GmailSpamTrashFolder(this, remote_account, local_account, local_folder,
+ return new GmailSpamTrashFolder(this, this.remote, this.local, local_folder,
special_folder_type);
-
+
default:
- return new GmailFolder(this, remote_account, local_account, local_folder,
special_folder_type);
+ return new GmailFolder(this, this.remote, this.local, local_folder, special_folder_type);
}
}
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 653c356..2f4a3e0 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -19,8 +19,9 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
private static Geary.FolderPath? outbox_path = null;
private static Geary.FolderPath? search_path = null;
- private Imap.Account remote;
- private ImapDB.Account local;
+ protected Imap.Account remote { get; private set; }
+ protected ImapDB.Account local { get; private set; }
+
private bool open = false;
private Gee.HashMap<FolderPath, MinimalFolder> folder_map = new Gee.HashMap<
FolderPath, MinimalFolder>();
@@ -328,8 +329,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
// set using either the properties from the local folder or its path.
//
// This won't be called to build the Outbox or search folder, but for all others (including Inbox) it
will.
- protected abstract MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
- ImapDB.Account local_account, ImapDB.Folder local_folder);
+ protected abstract MinimalFolder new_folder(ImapDB.Folder local_folder);
// Subclasses with specific SearchFolder implementations should override
// this to return the correct subclass.
@@ -355,7 +355,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
}
foreach(ImapDB.Folder folder_to_build in folders_to_build) {
- MinimalFolder folder = new_folder(folder_to_build.get_path(), remote, local, folder_to_build);
+ MinimalFolder folder = new_folder(folder_to_build);
folder.report_problem.connect(notify_report_problem);
folder_map.set(folder.path, folder);
built_folders.add(folder);
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 3ff0cef..fb3467b 100644
--- a/src/engine/imap-engine/other/imap-engine-other-account.vala
+++ b/src/engine/imap-engine/other/imap-engine-other-account.vala
@@ -10,15 +10,14 @@ private class Geary.ImapEngine.OtherAccount : Geary.ImapEngine.GenericAccount {
base (name, account_information, remote, local);
}
- protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
- ImapDB.Account local_account, ImapDB.Folder local_folder) {
+ protected override MinimalFolder new_folder(ImapDB.Folder local_folder) {
+ Geary.FolderPath path = local_folder.get_path();
SpecialFolderType type;
if (Imap.MailboxSpecifier.folder_path_is_inbox(path))
type = SpecialFolderType.INBOX;
else
type = local_folder.get_properties().attrs.get_special_folder_type();
-
- return new OtherFolder(this, remote_account, local_account, local_folder, type);
+
+ return new OtherFolder(this, this.remote, this.local, local_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 06eab91..8602450 100644
--- a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
+++ b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
@@ -35,20 +35,20 @@ private class Geary.ImapEngine.OutlookAccount : Geary.ImapEngine.GenericAccount
base (name, account_information, remote, local);
}
- protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
- ImapDB.Account local_account, ImapDB.Folder local_folder) {
+ protected override MinimalFolder new_folder(ImapDB.Folder local_folder) {
// use the Folder's attributes to determine if it's a special folder type, unless it's
// INBOX; that's determined by name
+ Geary.FolderPath path = local_folder.get_path();
SpecialFolderType special_folder_type;
if (Imap.MailboxSpecifier.folder_path_is_inbox(path))
special_folder_type = SpecialFolderType.INBOX;
else
special_folder_type = local_folder.get_properties().attrs.get_special_folder_type();
-
+
if (special_folder_type == Geary.SpecialFolderType.DRAFTS)
- return new OutlookDraftsFolder(this, remote_account, local_account, local_folder,
special_folder_type);
-
- return new OutlookFolder(this, remote_account, local_account, local_folder, special_folder_type);
+ return new OutlookDraftsFolder(this, this.remote, this.local, local_folder, special_folder_type);
+
+ return new OutlookFolder(this, this.remote, this.local, 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 651a693..4ce20a3 100644
--- a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
+++ b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
@@ -37,13 +37,11 @@ private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount {
special_map.set(new Imap.FolderRoot("Trash"), Geary.SpecialFolderType.TRASH);
}
}
-
- protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
- ImapDB.Account local_account, ImapDB.Folder local_folder) {
+
+ protected override MinimalFolder new_folder(ImapDB.Folder local_folder) {
+ 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, remote_account, local_account, local_folder,
- special_folder_type);
+ return new YahooFolder(this, this.remote, this.local, local_folder, special_folder_type);
}
}
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]