1/* Copyright 2016 Software Freedom Conservancy Inc. 2 * 3 * This software is licensed under the GNU Lesser General Public License 4 * (version 2.1 or later). See the COPYING file in this distribution. 5 */ 6 7/** 8 * A collection of {@link MessageFlag}s. 9 * 10 * @see StoreCommand 11 * @see FetchCommand 12 * @see FetchedData 13 */ 14 15public class Geary.Imap.MessageFlags : Geary.Imap.Flags { 16 public MessageFlags(Gee.Collection<MessageFlag> flags) { 17 base (flags); 18 } 19 20 /** 21 * Create {@link MessageFlags} from a {@link ListParameter} of flag strings. 22 */ 23 public static MessageFlags from_list(ListParameter listp) throws ImapError { 24 Gee.Collection<MessageFlag> list = new Gee.ArrayList<MessageFlag>(); 25 for (int ctr = 0; ctr < listp.size; ctr++) 26 list.add(new MessageFlag(listp.get_as_string(ctr).ascii)); 27 28 return new MessageFlags(list); 29 } 30 31 /** 32 * Create {@link MessageFlags} from a flat string of space-delimited flags. 33 */ 34 public static MessageFlags deserialize(string? str) { 35 if (String.is_empty(str)) 36 return new MessageFlags(new Gee.ArrayList<MessageFlag>()); 37 38 string[] tokens = str.split(" "); 39 40 Gee.Collection<MessageFlag> flags = new Gee.ArrayList<MessageFlag>(); 41 foreach (string token in tokens) 42 flags.add(new MessageFlag(token)); 43 44 return new MessageFlags(flags); 45 } 46 47 internal void add(MessageFlag flag) { 48 list.add(flag); 49 } 50 51 internal void remove(MessageFlag flag) { 52 list.remove(flag); 53 } 54} 55 56