[geary/wip/181-special-folder-dupes: 3/7] Ensure accounts don't accidentially create multiple inbox-type folders
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/181-special-folder-dupes: 3/7] Ensure accounts don't accidentially create multiple inbox-type folders
- Date: Mon, 14 Jan 2019 05:28:13 +0000 (UTC)
commit b0f85b3af8daf0521fcd2303b66b963c667a1ad8
Author: Michael Gratton <mike vee net>
Date: Mon Jan 14 11:17:19 2019 +1100
Ensure accounts don't accidentially create multiple inbox-type folders
.../gmail/imap-engine-gmail-account.vala | 33 ++++++++++++--------
.../other/imap-engine-other-account.vala | 14 ++++++---
.../outlook/imap-engine-outlook-account.vala | 35 ++++++++++++----------
3 files changed, 50 insertions(+), 32 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 0857352c..52127abc 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-account.vala
@@ -1,7 +1,9 @@
-/* Copyright 2016 Software Freedom Conservancy Inc.
+/*
+ * Copyright 2016 Software Freedom Conservancy Inc.
+ * Copyright 2019 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.
+ * (version 2.1 or later). See the COPYING file in this distribution.
*/
private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount {
@@ -44,26 +46,31 @@ private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount {
}
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();
+ 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();
+ // There can be only one Inbox
+ if (type == SpecialFolderType.INBOX) {
+ type = SpecialFolderType.NONE;
+ }
+ }
- switch (special_folder_type) {
+ switch (type) {
case SpecialFolderType.ALL_MAIL:
- return new GmailAllMailFolder(this, local_folder, special_folder_type);
+ return new GmailAllMailFolder(this, local_folder, type);
case SpecialFolderType.DRAFTS:
- return new GmailDraftsFolder(this, local_folder, special_folder_type);
+ return new GmailDraftsFolder(this, local_folder, type);
case SpecialFolderType.SPAM:
case SpecialFolderType.TRASH:
- return new GmailSpamTrashFolder(this, local_folder, special_folder_type);
+ return new GmailSpamTrashFolder(this, local_folder, type);
default:
- return new GmailFolder(this, local_folder, special_folder_type);
+ return new GmailFolder(this, local_folder, type);
}
}
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 e3eb94a6..7e5d496f 100644
--- a/src/engine/imap-engine/other/imap-engine-other-account.vala
+++ b/src/engine/imap-engine/other/imap-engine-other-account.vala
@@ -1,8 +1,9 @@
/*
* Copyright 2016 Software Freedom Conservancy Inc.
+ * Copyright 2019 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.
+ * (version 2.1 or later). See the COPYING file in this distribution.
*/
private class Geary.ImapEngine.OtherAccount : Geary.ImapEngine.GenericAccount {
@@ -15,12 +16,17 @@ private class Geary.ImapEngine.OtherAccount : Geary.ImapEngine.GenericAccount {
}
protected override MinimalFolder new_folder(ImapDB.Folder local_folder) {
- Geary.FolderPath path = local_folder.get_path();
+ FolderPath path = local_folder.get_path();
SpecialFolderType type;
- if (Imap.MailboxSpecifier.folder_path_is_inbox(path))
+ if (Imap.MailboxSpecifier.folder_path_is_inbox(path)) {
type = SpecialFolderType.INBOX;
- else
+ } else {
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 OtherFolder(this, 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 2c09c3e5..8d7e162d 100644
--- a/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
+++ b/src/engine/imap-engine/outlook/imap-engine-outlook-account.vala
@@ -1,7 +1,9 @@
-/* Copyright 2016 Software Freedom Conservancy Inc.
+/*
+ * Copyright 2016 Software Freedom Conservancy Inc.
+ * Copyright 2019 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.
+ * (version 2.1 or later). See the COPYING file in this distribution.
*/
private class Geary.ImapEngine.OutlookAccount : Geary.ImapEngine.GenericAccount {
@@ -32,19 +34,22 @@ private class Geary.ImapEngine.OutlookAccount : Geary.ImapEngine.GenericAccount
}
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, local_folder, special_folder_type);
-
- return new OutlookFolder(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 {
+ type = local_folder.get_properties().attrs.get_special_folder_type();
+ // There can be only one Inbox
+ if (type == SpecialFolderType.INBOX) {
+ type = SpecialFolderType.NONE;
+ }
+ }
+
+ if (type == Geary.SpecialFolderType.DRAFTS)
+ return new OutlookDraftsFolder(this, local_folder, type);
+
+ return new OutlookFolder(this, local_folder, type);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]