4
4
* (version 2.1 or later). See the COPYING file in this distribution.
7
public class Geary.Imap.FolderProperties {
8
// messages can be updated a variety of ways, so it's available as a public set
9
public int messages { get; set; }
7
public class Geary.Imap.FolderProperties : Geary.FolderProperties {
9
* -1 if the Folder was not opened via SELECT or EXAMINE.
11
public int select_examine_messages { get; private set; }
13
* -1 if the FolderProperties were not obtained via a STATUS command
15
public int status_messages { get; private set; }
16
public int unseen { get; private set; }
10
17
public int recent { get; private set; }
11
public int unseen { get; private set; }
12
18
public UIDValidity? uid_validity { get; private set; }
13
19
public UID? uid_next { get; private set; }
14
20
public MailboxAttributes attrs { get; private set; }
15
public Trillian supports_children { get; private set; }
16
public Trillian has_children { get; private set; }
17
public Trillian is_openable { get; private set; }
22
// Note that unseen from SELECT/EXAMINE is the *position* of the first unseen message,
23
// not the total unseen count, so it should not be passed in here, but rather the unseen
24
// count from a STATUS command
19
25
public FolderProperties(int messages, int recent, int unseen, UIDValidity? uid_validity,
20
26
UID? uid_next, MailboxAttributes attrs) {
21
this.messages = messages;
27
base (messages, unseen, Trillian.UNKNOWN, Trillian.UNKNOWN, Trillian.UNKNOWN);
29
select_examine_messages = messages;
22
31
this.recent = recent;
23
32
this.unseen = unseen;
24
33
this.uid_validity = uid_validity;
31
40
public FolderProperties.status(StatusResults status, MailboxAttributes attrs) {
32
messages = status.messages;
41
base (status.messages, status.unseen, Trillian.UNKNOWN, Trillian.UNKNOWN, Trillian.UNKNOWN);
43
select_examine_messages = -1;
44
status_messages = status.messages;
33
45
recent = status.recent;
34
46
unseen = status.unseen;
35
47
uid_validity = status.uid_validity;
55
* Use with FolderProperties of the *same folder* seen at different times (i.e. after SELECTing
56
* versus data stored locally). Only compares fields that suggest the contents of the folder
59
* Note that this is *not* concerned with message flags changing.
61
public Trillian have_contents_changed(Geary.Imap.FolderProperties other) {
62
// UIDNEXT changes indicate messages have been added, but not if they've been removed
63
if (uid_next != null && other.uid_next != null && !uid_next.equals(other.uid_next))
66
// Gmail includes Chat messages in STATUS results but not in SELECT/EXAMINE
67
// results, so message count comparison has to be from the same origin ... use SELECT/EXAMINE
68
// first, as it's more authoritative in many ways
70
// TODO: If this continues to work, it might be worthwhile to change the result of this
72
if (select_examine_messages >= 0 && other.select_examine_messages >= 0
73
&& select_examine_messages != other.select_examine_messages) {
77
if (status_messages >= 0 && other.status_messages >= 0 && status_messages != other.status_messages) {
81
return Trillian.FALSE;
42
84
private void init_flags() {
43
85
supports_children = Trillian.from_boolean(!attrs.contains(MailboxAttribute.NO_INFERIORS));
44
87
// \HasNoChildren & \HasChildren are optional attributes (could check for CHILDREN extension,
45
88
// but unnecessary here)
46
89
if (attrs.contains(MailboxAttribute.HAS_NO_CHILDREN))
49
92
has_children = Trillian.TRUE;
51
94
has_children = Trillian.UNKNOWN;
52
96
is_openable = Trillian.from_boolean(!attrs.contains(MailboxAttribute.NO_SELECT));
99
public void set_status_message_count(int messages, bool force) {
103
status_messages = messages;
105
// select/examine more authoritative than status, unless the caller knows otherwise
106
if (force || (select_examine_messages < 0))
107
email_total = messages;
110
public void set_select_examine_message_count(int messages) {
114
select_examine_messages = messages;
116
// select/examine more authoritative than status
117
email_total = messages;