Add archive support for all IMAP accounts
https://bugzilla.gnome.org/show_bug.cgi?id=713986
This commit is contained in:
parent
f48652a140
commit
51ecfe0d9e
6 changed files with 44 additions and 6 deletions
|
|
@ -68,6 +68,7 @@ public class FolderList.FolderEntry : FolderList.AbstractFolderEntry, Sidebar.In
|
|||
return "task-due-symbolic";
|
||||
|
||||
case Geary.SpecialFolderType.ALL_MAIL:
|
||||
case Geary.SpecialFolderType.ARCHIVE:
|
||||
return "mail-archive-symbolic";
|
||||
|
||||
case Geary.SpecialFolderType.SPAM:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public class Geary.AccountInformation : BaseObject {
|
|||
private const string SENT_MAIL_FOLDER_KEY = "sent_mail_folder";
|
||||
private const string SPAM_FOLDER_KEY = "spam_folder";
|
||||
private const string TRASH_FOLDER_KEY = "trash_folder";
|
||||
private const string ARCHIVE_FOLDER_KEY = "archive_folder";
|
||||
private const string SAVE_DRAFTS_KEY = "save_drafts";
|
||||
private const string USE_EMAIL_SIGNATURE_KEY = "use_email_signature";
|
||||
private const string EMAIL_SIGNATURE_KEY = "email_signature";
|
||||
|
|
@ -134,6 +135,7 @@ public class Geary.AccountInformation : BaseObject {
|
|||
public Geary.FolderPath? sent_mail_folder_path { get; set; default = null; }
|
||||
public Geary.FolderPath? spam_folder_path { get; set; default = null; }
|
||||
public Geary.FolderPath? trash_folder_path { get; set; default = null; }
|
||||
public Geary.FolderPath? archive_folder_path { get; set; default = null; }
|
||||
|
||||
public Geary.Credentials imap_credentials { get; set; default = new Geary.Credentials(null, null); }
|
||||
public bool imap_remember_password { get; set; default = true; }
|
||||
|
|
@ -239,6 +241,8 @@ public class Geary.AccountInformation : BaseObject {
|
|||
key_file, GROUP, SPAM_FOLDER_KEY));
|
||||
trash_folder_path = build_folder_path(get_string_list_value(
|
||||
key_file, GROUP, TRASH_FOLDER_KEY));
|
||||
archive_folder_path = build_folder_path(get_string_list_value(
|
||||
key_file, GROUP, ARCHIVE_FOLDER_KEY));
|
||||
|
||||
save_drafts = get_bool_value(key_file, GROUP, SAVE_DRAFTS_KEY, true);
|
||||
}
|
||||
|
|
@ -302,6 +306,7 @@ public class Geary.AccountInformation : BaseObject {
|
|||
sent_mail_folder_path = from.sent_mail_folder_path;
|
||||
spam_folder_path = from.spam_folder_path;
|
||||
trash_folder_path = from.trash_folder_path;
|
||||
archive_folder_path = from.archive_folder_path;
|
||||
save_drafts = from.save_drafts;
|
||||
use_email_signature = from.use_email_signature;
|
||||
email_signature = from.email_signature;
|
||||
|
|
@ -380,6 +385,9 @@ public class Geary.AccountInformation : BaseObject {
|
|||
|
||||
case Geary.SpecialFolderType.TRASH:
|
||||
return trash_folder_path;
|
||||
|
||||
case Geary.SpecialFolderType.ARCHIVE:
|
||||
return archive_folder_path;
|
||||
|
||||
default:
|
||||
assert_not_reached();
|
||||
|
|
@ -409,6 +417,10 @@ public class Geary.AccountInformation : BaseObject {
|
|||
case Geary.SpecialFolderType.TRASH:
|
||||
trash_folder_path = path;
|
||||
break;
|
||||
|
||||
case Geary.SpecialFolderType.ARCHIVE:
|
||||
archive_folder_path = path;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached();
|
||||
|
|
@ -833,6 +845,8 @@ public class Geary.AccountInformation : BaseObject {
|
|||
? spam_folder_path.as_list().to_array() : new string[] {}));
|
||||
key_file.set_string_list(GROUP, TRASH_FOLDER_KEY, (trash_folder_path != null
|
||||
? trash_folder_path.as_list().to_array() : new string[] {}));
|
||||
key_file.set_string_list(GROUP, ARCHIVE_FOLDER_KEY, (archive_folder_path != null
|
||||
? archive_folder_path.as_list().to_array() : new string[] {}));
|
||||
|
||||
key_file.set_boolean(GROUP, SAVE_DRAFTS_KEY, save_drafts);
|
||||
|
||||
|
|
|
|||
|
|
@ -588,6 +588,11 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
// names for the Trash folder, leaving in the English names as well. The first in the list
|
||||
// will be the default, so please add the most common localized name to the front.
|
||||
_("Trash | Rubbish | Rubbish Bin"));
|
||||
mailbox_search_names.set(Geary.SpecialFolderType.ARCHIVE,
|
||||
// List of folder names to match for Archive, separated by |. Please add localized common
|
||||
// names for the Trash folder, leaving in the English names as well. The first in the list
|
||||
// will be the default, so please add the most common localized name to the front.
|
||||
_("Archive | Archives"));
|
||||
|
||||
Gee.HashMap<Geary.SpecialFolderType, Gee.ArrayList<string>> compiled
|
||||
= new Gee.HashMap<Geary.SpecialFolderType, Gee.ArrayList<string>>();
|
||||
|
|
@ -671,6 +676,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
case Geary.SpecialFolderType.SENT:
|
||||
case Geary.SpecialFolderType.SPAM:
|
||||
case Geary.SpecialFolderType.TRASH:
|
||||
case Geary.SpecialFolderType.ARCHIVE:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -690,6 +696,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
Geary.SpecialFolderType.SENT,
|
||||
Geary.SpecialFolderType.SPAM,
|
||||
Geary.SpecialFolderType.TRASH,
|
||||
Geary.SpecialFolderType.ARCHIVE,
|
||||
};
|
||||
foreach (Geary.SpecialFolderType special in required)
|
||||
yield ensure_special_folder_async(special, cancellable);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
private class Geary.ImapEngine.OtherAccount : Geary.ImapEngine.GenericAccount {
|
||||
public OtherAccount(string name, AccountInformation account_information,
|
||||
Imap.Account remote, ImapDB.Account local) {
|
||||
base (name, account_information, false, remote, local);
|
||||
base (name, account_information, true, remote, local);
|
||||
}
|
||||
|
||||
protected override MinimalFolder new_folder(Geary.FolderPath path, Imap.Account remote_account,
|
||||
|
|
|
|||
|
|
@ -4,10 +4,27 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
private class Geary.ImapEngine.OtherFolder : GenericFolder {
|
||||
private class Geary.ImapEngine.OtherFolder : GenericFolder, FolderSupport.Archive {
|
||||
public OtherFolder(OtherAccount account, Imap.Account remote, ImapDB.Account local,
|
||||
ImapDB.Folder local_folder, SpecialFolderType special_folder_type) {
|
||||
base (account, remote, local, local_folder, special_folder_type);
|
||||
}
|
||||
}
|
||||
|
||||
public async Geary.Revokable? archive_email_async(Gee.List<Geary.EmailIdentifier> email_ids,
|
||||
Cancellable? cancellable = null) throws Error {
|
||||
Geary.Folder? archive_folder = null;
|
||||
try {
|
||||
archive_folder = yield account.get_required_special_folder_async(Geary.SpecialFolderType.ARCHIVE, cancellable);
|
||||
} catch (Error e) {
|
||||
debug("Error looking up archive folder in %s: %s", account.to_string(), e.message);
|
||||
}
|
||||
|
||||
if (archive_folder == null) {
|
||||
debug("Can't archive email because no archive folder was found in %s", account.to_string());
|
||||
} else {
|
||||
return yield move_email_async(email_ids, archive_folder.path, cancellable);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,9 +86,8 @@ public class Geary.Imap.MailboxAttributes : Geary.Imap.Flags {
|
|||
if (contains(MailboxAttribute.SPECIAL_FOLDER_ALL))
|
||||
return Geary.SpecialFolderType.ALL_MAIL;
|
||||
|
||||
// TODO: Convert into SpecialFolderType.ARCHIVE (to support services that have an Archive
|
||||
// folder that isn't an All Mail folder, i.e. Outlook.com):
|
||||
// http://redmine.yorba.org/issues/7492
|
||||
if (contains(MailboxAttribute.SPECIAL_FOLDER_ARCHIVE))
|
||||
return Geary.SpecialFolderType.ARCHIVE;
|
||||
|
||||
if (contains(MailboxAttribute.SPECIAL_FOLDER_FLAGGED))
|
||||
return Geary.SpecialFolderType.FLAGGED;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue