[geary/wip/34-yahoo-fixes: 2/2] Don't hard-code special-use mailbox names for Yahoo accounts
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/34-yahoo-fixes: 2/2] Don't hard-code special-use mailbox names for Yahoo accounts
- Date: Sat, 2 Feb 2019 05:38:54 +0000 (UTC)
commit cd050baa0398f1e77d661ca23db24c8f9f1cda3a
Author: Michael Gratton <mike vee net>
Date: Sat Feb 2 16:37:12 2019 +1100
Don't hard-code special-use mailbox names for Yahoo accounts
Desipte Yahoo's IMAP CAPABILITIES not claiming to support SPECIAL-USE,
its LIST results actually include the appropriate flags, so just use
those.
.../yahoo/imap-engine-yahoo-account.vala | 46 +++++++++-------------
1 file changed, 18 insertions(+), 28 deletions(-)
---
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 cf0d6bc0..a754bff0 100644
--- a/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
+++ b/src/engine/imap-engine/yahoo/imap-engine-yahoo-account.vala
@@ -9,9 +9,6 @@
private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount {
- private static Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>? special_map = null;
-
-
public static void setup_service(ServiceInformation service) {
switch (service.protocol) {
case Protocol.IMAP:
@@ -34,33 +31,26 @@ private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount {
Endpoint incoming_remote,
Endpoint outgoing_remote) {
base(config, local, incoming_remote, outgoing_remote);
-
- if (special_map == null) {
- special_map = new Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>();
-
- FolderRoot root = this.local.imap_folder_root;
- special_map.set(
- this.local.imap_folder_root.inbox, Geary.SpecialFolderType.INBOX
- );
- special_map.set(
- root.get_child("Sent"), Geary.SpecialFolderType.SENT
- );
- special_map.set(
- root.get_child("Draft"), Geary.SpecialFolderType.DRAFTS
- );
- special_map.set(
- root.get_child("Bulk Mail"), Geary.SpecialFolderType.SPAM
- );
- special_map.set(
- root.get_child("Trash"), Geary.SpecialFolderType.TRASH
- );
- }
}
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, local_folder, special_folder_type);
+ FolderPath path = local_folder.get_path();
+ SpecialFolderType type;
+ if (Imap.MailboxSpecifier.folder_path_is_inbox(path)) {
+ type = SpecialFolderType.INBOX;
+ } else {
+ // Despite Yahoo not advertising that it supports
+ // SPECIAL-USE via its CAPABILITIES, it lists the
+ // appropriate attributes in LIST results anyway, so we
+ // can just consult that. :|
+ type = local_folder.get_properties().attrs.get_special_folder_type();
+ // There can be only one Inbox
+ if (type == SpecialFolderType.INBOX) {
+ type = SpecialFolderType.NONE;
+ }
+ }
+
+ return new YahooFolder(this, local_folder, type);
}
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]