~hkdb/geary/disco-3.34.1

« back to all changes in this revision

Viewing changes to src/engine/imap/message/imap-flag.vala

  • Committer: hkdb
  • Date: 2019-10-08 10:54:21 UTC
  • Revision ID: hkdb@3df.io-20191008105421-3dkwnpnhcamm77to
Tags: upstream-3.34.1-disco
ImportĀ upstreamĀ versionĀ 3.34.1-disco

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 generic IMAP message or mailbox flag.
 
9
 *
 
10
 * In IMAP, message and mailbox flags have similar syntax, which is encapsulated here.
 
11
 *
 
12
 * @see MessageFlag
 
13
 * @see MailboxAttribute
 
14
 */
 
15
 
 
16
public abstract class Geary.Imap.Flag : BaseObject, Gee.Hashable<Geary.Imap.Flag> {
 
17
    public string value { get; private set; }
 
18
 
 
19
    /**
 
20
     * Constructs a new flag.
 
21
     *
 
22
     * The given keyword must be an IMAP atom.
 
23
     */
 
24
    protected Flag(string name) {
 
25
        this.value = name;
 
26
    }
 
27
 
 
28
    public bool is_system() {
 
29
        return value[0] == '\\';
 
30
    }
 
31
 
 
32
    public bool equals_string(string value) {
 
33
        return Ascii.stri_equal(this.value, value);
 
34
    }
 
35
 
 
36
    public bool equal_to(Geary.Imap.Flag flag) {
 
37
        return (flag == this) ? true : flag.equals_string(value);
 
38
    }
 
39
 
 
40
    /**
 
41
     * Returns the {@link Flag} as an appropriate {@link Parameter}.
 
42
     */
 
43
    public StringParameter to_parameter() throws ImapError {
 
44
        return new UnquotedStringParameter(value);
 
45
    }
 
46
 
 
47
    public uint hash() {
 
48
        return Ascii.stri_hash(value);
 
49
    }
 
50
 
 
51
    public string to_string() {
 
52
        return value;
 
53
    }
 
54
}
 
55
 
 
56
 
 
57