geary/src/engine/api/geary-special-folder.vala
Eric Gregory 6963063fd5 Send outgoing messages via Outbox folder: Closes #4569
Squashed commit of many patches that merged Eric's outbox patch
as well as additional changes to upgrade the database rather than
require it be wiped and some refactoring suggested by the Outbox
implementation.  Also updated Outbox to be fully atomic via
Transactions.
2012-06-13 11:54:20 -07:00

64 lines
1.7 KiB
Vala

/* Copyright 2011-2012 Yorba Foundation
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
public enum Geary.SpecialFolderType {
INBOX,
DRAFTS,
SENT,
FLAGGED,
ALL_MAIL,
SPAM,
TRASH,
OUTBOX
}
public class Geary.SpecialFolder : Object {
public SpecialFolderType folder_type { get; private set; }
public string name { get; private set; }
public Geary.FolderPath path { get; private set; }
public int ordering { get; private set; }
public SpecialFolder(SpecialFolderType folder_type, string name, FolderPath path, int ordering) {
this.folder_type = folder_type;
this.name = name;
this.path = path;
this.ordering = ordering;
}
}
public class Geary.SpecialFolderMap : Object {
private Gee.HashMap<SpecialFolderType, SpecialFolder> map = new Gee.HashMap<SpecialFolderType,
SpecialFolder>();
public SpecialFolderMap() {
}
public void set_folder(SpecialFolder special_folder) {
map.set(special_folder.folder_type, special_folder);
}
public SpecialFolder? get_folder(SpecialFolderType folder_type) {
return map.get(folder_type);
}
public SpecialFolder? get_folder_by_path(FolderPath path) {
foreach (SpecialFolder folder in map.values) {
if (folder.path == path) {
return folder;
}
}
return null;
}
public Gee.Set<SpecialFolderType> get_supported_types() {
return map.keys.read_only_view;
}
public Gee.Collection<SpecialFolder> get_all() {
return map.values.read_only_view;
}
}