1/* 2 * Copyright 2016 Software Freedom Conservancy Inc. 3 * 4 * This software is licensed under the GNU Lesser General Public License 5 * (version 2.1 or later). See the COPYING file in this distribution. 6 */ 7 8private class Geary.ImapEngine.GenericFolder : MinimalFolder, 9 Geary.FolderSupport.Archive, 10 Geary.FolderSupport.Remove, 11 Geary.FolderSupport.Create, 12 Geary.FolderSupport.Empty { 13 14 public GenericFolder(GenericAccount account, 15 ImapDB.Folder local_folder, 16 Folder.SpecialUse use) { 17 base (account, local_folder, use); 18 } 19 20 public async Geary.Revokable? 21 archive_email_async(Gee.Collection<Geary.EmailIdentifier> email_ids, 22 GLib.Cancellable? cancellable = null) 23 throws GLib.Error { 24 Geary.Folder? archive_folder = null; 25 try { 26 archive_folder = yield account.get_required_special_folder_async( 27 Folder.SpecialUse.ARCHIVE, cancellable 28 ); 29 } catch (Error e) { 30 debug("Error looking up archive folder in %s: %s", account.to_string(), e.message); 31 } 32 33 if (archive_folder == null) { 34 debug("Can't archive email because no archive folder was found in %s", account.to_string()); 35 } else { 36 return yield move_email_async(email_ids, archive_folder.path, cancellable); 37 } 38 39 return null; 40 } 41 42 public async void 43 remove_email_async(Gee.Collection<Geary.EmailIdentifier> email_ids, 44 GLib.Cancellable? cancellable = null) 45 throws GLib.Error { 46 yield expunge_email_async(email_ids, cancellable); 47 } 48 49 public async void empty_folder_async(Cancellable? cancellable = null) throws Error { 50 yield expunge_all_async(cancellable); 51 } 52 53 public new async EmailIdentifier? 54 create_email_async(RFC822.Message rfc822, 55 EmailFlags? flags, 56 DateTime? date_received, 57 GLib.Cancellable? cancellable = null) 58 throws GLib.Error { 59 return yield base.create_email_async( 60 rfc822, flags, date_received, cancellable 61 ); 62 } 63} 64