1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.geronimo.javamail.store.imap.connection;
19
20 import java.util.List;
21
22 import javax.mail.Flags;
23 import javax.mail.Folder;
24 import javax.mail.MessagingException;
25
26 import org.apache.geronimo.javamail.store.imap.connection.IMAPResponseTokenizer.Token;
27
28
29
30
31
32 public class IMAPMailboxStatus {
33
34 public Flags availableFlags = null;
35
36 public Flags permanentFlags = null;
37
38 public int mode = Folder.READ_WRITE;
39
40
41 public int messages = -1;
42
43 public int recentMessages = -1;
44
45 public int unseenMessages = -1;
46
47
48 public long uidNext = -1L;
49
50 public long uidValidity = -1L;
51
52 public IMAPMailboxStatus() {
53 }
54
55
56
57
58
59
60
61
62
63
64
65 public void mergeStatus(IMAPStatusResponse source) throws MessagingException {
66
67 if (source.messages != -1) {
68 messages = source.messages;
69 }
70 if (source.uidNext != -1L) {
71 uidNext = source.uidNext;
72 }
73 if (source.uidValidity != -1L) {
74 uidValidity = source.uidValidity;
75 }
76 if (source.recentMessages != -1) {
77 recentMessages = source.recentMessages;
78 }
79 if (source.unseenMessages != -1) {
80 unseenMessages = source.unseenMessages;
81 }
82 }
83
84
85
86
87
88
89
90
91
92 public void mergeFlags(IMAPFlagsResponse response) throws MessagingException {
93 if (response != null) {
94 availableFlags = response.getFlags();
95 }
96 }
97
98
99 public void mergeSizeResponses(List responses) throws MessagingException
100 {
101 for (int i = 0; i < responses.size(); i++) {
102 mergeStatus((IMAPSizeResponse)responses.get(i));
103 }
104 }
105
106
107 public void mergeOkResponses(List responses) throws MessagingException {
108 for (int i = 0; i < responses.size(); i++) {
109 mergeStatus((IMAPOkResponse)responses.get(i));
110 }
111 }
112
113
114
115
116
117
118
119
120
121
122
123 public void mergeStatus(IMAPSizeResponse source) throws MessagingException {
124 if (source != null) {
125 String name = source.getKeyword();
126
127
128 if (source.isKeyword("EXISTS")) {
129 messages = source.getSize();
130 }
131
132 else if (source.isKeyword("RECENT")) {
133 recentMessages = source.getSize();
134 }
135 }
136 }
137
138
139
140
141
142
143
144
145
146
147
148
149
150 public void mergeStatus(IMAPOkResponse source) throws MessagingException {
151 if (source != null) {
152 String name = source.getKeyword();
153
154
155 if (source.isKeyword("UIDVALIDITY")) {
156 List arguments = source.getStatus();
157 uidValidity = ((Token)arguments.get(0)).getLong();
158 }
159
160 if (source.isKeyword("UIDNEXT")) {
161 List arguments = source.getStatus();
162 uidNext = ((Token)arguments.get(0)).getLong();
163 }
164
165 else if (source.isKeyword("UNSEEN")) {
166 List arguments = source.getStatus();
167 uidValidity = ((Token)arguments.get(0)).getInteger();
168 }
169 }
170 }
171
172
173
174
175
176
177
178
179
180
181
182 public void mergeStatus(IMAPPermanentFlagsResponse source) throws MessagingException {
183 if (source != null) {
184
185 permanentFlags = source.flags;
186 }
187 }
188 }