attribute did not show right for POP3.
Showing
2 changed files
with
31 additions
and
38 deletions
... | @@ -138,7 +138,7 @@ attribute_set_seen (attribute_t attr) | ... | @@ -138,7 +138,7 @@ attribute_set_seen (attribute_t attr) |
138 | if (attr->_set_flags) | 138 | if (attr->_set_flags) |
139 | status = attr->_set_flags (attr, MU_ATTRIBUTE_SEEN); | 139 | status = attr->_set_flags (attr, MU_ATTRIBUTE_SEEN); |
140 | attr->flags |= MU_ATTRIBUTE_SEEN; | 140 | attr->flags |= MU_ATTRIBUTE_SEEN; |
141 | return 0; | 141 | return status; |
142 | } | 142 | } |
143 | 143 | ||
144 | int | 144 | int |
... | @@ -150,7 +150,7 @@ attribute_set_answered (attribute_t attr) | ... | @@ -150,7 +150,7 @@ attribute_set_answered (attribute_t attr) |
150 | if (attr->_set_flags) | 150 | if (attr->_set_flags) |
151 | status = attr->_set_flags (attr, MU_ATTRIBUTE_ANSWERED); | 151 | status = attr->_set_flags (attr, MU_ATTRIBUTE_ANSWERED); |
152 | attr->flags |= MU_ATTRIBUTE_ANSWERED; | 152 | attr->flags |= MU_ATTRIBUTE_ANSWERED; |
153 | return 0; | 153 | return status; |
154 | } | 154 | } |
155 | 155 | ||
156 | int | 156 | int |
... | @@ -162,7 +162,7 @@ attribute_set_flagged (attribute_t attr) | ... | @@ -162,7 +162,7 @@ attribute_set_flagged (attribute_t attr) |
162 | if (attr->_set_flags) | 162 | if (attr->_set_flags) |
163 | status = attr->_set_flags (attr, MU_ATTRIBUTE_FLAGGED); | 163 | status = attr->_set_flags (attr, MU_ATTRIBUTE_FLAGGED); |
164 | attr->flags |= MU_ATTRIBUTE_FLAGGED; | 164 | attr->flags |= MU_ATTRIBUTE_FLAGGED; |
165 | return 0; | 165 | return status; |
166 | } | 166 | } |
167 | 167 | ||
168 | int | 168 | int |
... | @@ -174,7 +174,7 @@ attribute_set_read (attribute_t attr) | ... | @@ -174,7 +174,7 @@ attribute_set_read (attribute_t attr) |
174 | if (attr->_set_flags) | 174 | if (attr->_set_flags) |
175 | status = attr->_set_flags (attr, MU_ATTRIBUTE_READ); | 175 | status = attr->_set_flags (attr, MU_ATTRIBUTE_READ); |
176 | attr->flags |= MU_ATTRIBUTE_READ; | 176 | attr->flags |= MU_ATTRIBUTE_READ; |
177 | return 0; | 177 | return status; |
178 | } | 178 | } |
179 | 179 | ||
180 | int | 180 | int |
... | @@ -198,7 +198,7 @@ attribute_set_draft (attribute_t attr) | ... | @@ -198,7 +198,7 @@ attribute_set_draft (attribute_t attr) |
198 | if (attr->_set_flags) | 198 | if (attr->_set_flags) |
199 | status = attr->_set_flags (attr, MU_ATTRIBUTE_DRAFT); | 199 | status = attr->_set_flags (attr, MU_ATTRIBUTE_DRAFT); |
200 | attr->flags |= MU_ATTRIBUTE_DRAFT; | 200 | attr->flags |= MU_ATTRIBUTE_DRAFT; |
201 | return 0; | 201 | return status; |
202 | } | 202 | } |
203 | 203 | ||
204 | int | 204 | int |
... | @@ -209,15 +209,15 @@ attribute_set_recent (attribute_t attr) | ... | @@ -209,15 +209,15 @@ attribute_set_recent (attribute_t attr) |
209 | return EINVAL; | 209 | return EINVAL; |
210 | if (attr->_unset_flags) | 210 | if (attr->_unset_flags) |
211 | { | 211 | { |
212 | status = attr->_unset_flags (attr, MU_ATTRIBUTE_READ); | 212 | status |= attr->_unset_flags (attr, MU_ATTRIBUTE_READ); |
213 | status = attr->_unset_flags (attr, MU_ATTRIBUTE_SEEN); | 213 | status |= attr->_unset_flags (attr, MU_ATTRIBUTE_SEEN); |
214 | } | 214 | } |
215 | if (attr == NULL) | 215 | if (attr == NULL) |
216 | { | 216 | { |
217 | attr->flags &= ~MU_ATTRIBUTE_READ; | 217 | attr->flags &= ~MU_ATTRIBUTE_READ; |
218 | attr->flags &= ~MU_ATTRIBUTE_SEEN; | 218 | attr->flags &= ~MU_ATTRIBUTE_SEEN; |
219 | } | 219 | } |
220 | return 0; | 220 | return status; |
221 | } | 221 | } |
222 | 222 | ||
223 | int | 223 | int |
... | @@ -231,77 +231,70 @@ attribute_is_userflag (attribute_t attr, int flag) | ... | @@ -231,77 +231,70 @@ attribute_is_userflag (attribute_t attr, int flag) |
231 | int | 231 | int |
232 | attribute_is_seen (attribute_t attr) | 232 | attribute_is_seen (attribute_t attr) |
233 | { | 233 | { |
234 | int status = 0; | ||
235 | if (attr == NULL) | 234 | if (attr == NULL) |
236 | return 0; | 235 | return 0; |
237 | if (attr->_get_flags) | 236 | if (attr->_get_flags) |
238 | status = attr->_get_flags (attr, &(attr->flags)); | 237 | attr->_get_flags (attr, &(attr->flags)); |
239 | return attr->flags & MU_ATTRIBUTE_SEEN; | 238 | return attr->flags & MU_ATTRIBUTE_SEEN; |
240 | } | 239 | } |
241 | 240 | ||
242 | int | 241 | int |
243 | attribute_is_answered (attribute_t attr) | 242 | attribute_is_answered (attribute_t attr) |
244 | { | 243 | { |
245 | int status = 0; | ||
246 | if (attr == NULL) | 244 | if (attr == NULL) |
247 | return 0; | 245 | return 0; |
248 | if (attr->_get_flags) | 246 | if (attr->_get_flags) |
249 | status = attr->_get_flags (attr, &(attr->flags)); | 247 | attr->_get_flags (attr, &(attr->flags)); |
250 | return attr->flags & MU_ATTRIBUTE_ANSWERED; | 248 | return attr->flags & MU_ATTRIBUTE_ANSWERED; |
251 | } | 249 | } |
252 | 250 | ||
253 | int | 251 | int |
254 | attribute_is_flagged (attribute_t attr) | 252 | attribute_is_flagged (attribute_t attr) |
255 | { | 253 | { |
256 | int status = 0; | ||
257 | if (attr == NULL) | 254 | if (attr == NULL) |
258 | return 0; | 255 | return 0; |
259 | if (attr->_get_flags) | 256 | if (attr->_get_flags) |
260 | status = attr->_get_flags (attr, &(attr->flags)); | 257 | attr->_get_flags (attr, &(attr->flags)); |
261 | return attr->flags & MU_ATTRIBUTE_FLAGGED; | 258 | return attr->flags & MU_ATTRIBUTE_FLAGGED; |
262 | } | 259 | } |
263 | 260 | ||
264 | int | 261 | int |
265 | attribute_is_read (attribute_t attr) | 262 | attribute_is_read (attribute_t attr) |
266 | { | 263 | { |
267 | int status = 0; | ||
268 | if (attr == NULL) | 264 | if (attr == NULL) |
269 | return 0; | 265 | return 0; |
270 | if (attr->_get_flags) | 266 | if (attr->_get_flags) |
271 | status = attr->_get_flags (attr, &(attr->flags)); | 267 | attr->_get_flags (attr, &(attr->flags)); |
272 | return attr->flags & MU_ATTRIBUTE_READ; | 268 | return attr->flags & MU_ATTRIBUTE_READ; |
273 | } | 269 | } |
274 | 270 | ||
275 | int | 271 | int |
276 | attribute_is_deleted (attribute_t attr) | 272 | attribute_is_deleted (attribute_t attr) |
277 | { | 273 | { |
278 | int status = 0; | ||
279 | if (attr == NULL) | 274 | if (attr == NULL) |
280 | return 0; | 275 | return 0; |
281 | if (attr->_get_flags) | 276 | if (attr->_get_flags) |
282 | status = attr->_get_flags (attr, &(attr->flags)); | 277 | attr->_get_flags (attr, &(attr->flags)); |
283 | return attr->flags & MU_ATTRIBUTE_DELETED; | 278 | return attr->flags & MU_ATTRIBUTE_DELETED; |
284 | } | 279 | } |
285 | 280 | ||
286 | int | 281 | int |
287 | attribute_is_draft (attribute_t attr) | 282 | attribute_is_draft (attribute_t attr) |
288 | { | 283 | { |
289 | int status = 0; | ||
290 | if (attr == NULL) | 284 | if (attr == NULL) |
291 | return 0; | 285 | return 0; |
292 | if (attr->_get_flags) | 286 | if (attr->_get_flags) |
293 | status = attr->_get_flags (attr, &(attr->flags)); | 287 | attr->_get_flags (attr, &(attr->flags)); |
294 | return attr->flags & MU_ATTRIBUTE_DRAFT; | 288 | return attr->flags & MU_ATTRIBUTE_DRAFT; |
295 | } | 289 | } |
296 | 290 | ||
297 | int | 291 | int |
298 | attribute_is_recent (attribute_t attr) | 292 | attribute_is_recent (attribute_t attr) |
299 | { | 293 | { |
300 | int status = 0; | ||
301 | if (attr == NULL) | 294 | if (attr == NULL) |
302 | return 0; | 295 | return 0; |
303 | if (attr->_get_flags) | 296 | if (attr->_get_flags) |
304 | status = attr->_get_flags (attr, &(attr->flags)); | 297 | attr->_get_flags (attr, &(attr->flags)); |
305 | /* something is recent when it is not read and not seen. */ | 298 | /* something is recent when it is not read and not seen. */ |
306 | return (attr->flags == 0 | 299 | return (attr->flags == 0 |
307 | || ! ((attr->flags & MU_ATTRIBUTE_SEEN) | 300 | || ! ((attr->flags & MU_ATTRIBUTE_SEEN) |
... | @@ -437,17 +430,20 @@ string_to_flags (const char *buffer, int *pflags) | ... | @@ -437,17 +430,20 @@ string_to_flags (const char *buffer, int *pflags) |
437 | sep++; | 430 | sep++; |
438 | } | 431 | } |
439 | else | 432 | else |
440 | return EINVAL; | 433 | sep = buffer; |
441 | 434 | ||
442 | while (*sep == ' ') sep++; /* glob spaces */ | 435 | while (*sep) |
443 | if (strchr (sep, 'R') != NULL || strchr (sep, 'r') != NULL) | 436 | { |
444 | *pflags |= MU_ATTRIBUTE_READ; | 437 | if (strchr (sep, 'R') != NULL || strchr (sep, 'r') != NULL) |
445 | if (strchr (sep, 'O') != NULL || strchr (sep, 'o') != NULL) | 438 | *pflags |= MU_ATTRIBUTE_READ; |
446 | *pflags |= MU_ATTRIBUTE_SEEN; | 439 | if (strchr (sep, 'O') != NULL || strchr (sep, 'o') != NULL) |
447 | if (strchr (sep, 'A') != NULL || strchr (sep, 'a') != NULL) | 440 | *pflags |= MU_ATTRIBUTE_SEEN; |
448 | *pflags |= MU_ATTRIBUTE_ANSWERED; | 441 | if (strchr (sep, 'A') != NULL || strchr (sep, 'a') != NULL) |
449 | if (strchr (sep, 'F') != NULL || strchr (sep, 'f') != NULL) | 442 | *pflags |= MU_ATTRIBUTE_ANSWERED; |
450 | *pflags |= MU_ATTRIBUTE_FLAGGED; | 443 | if (strchr (sep, 'F') != NULL || strchr (sep, 'f') != NULL) |
444 | *pflags |= MU_ATTRIBUTE_FLAGGED; | ||
445 | sep++; | ||
446 | } | ||
451 | return 0; | 447 | return 0; |
452 | } | 448 | } |
453 | 449 | ... | ... |
... | @@ -1034,17 +1034,14 @@ pop_attr_flags (attribute_t attr, int *pflags) | ... | @@ -1034,17 +1034,14 @@ pop_attr_flags (attribute_t attr, int *pflags) |
1034 | pop_message_t mpm = message_get_owner (msg); | 1034 | pop_message_t mpm = message_get_owner (msg); |
1035 | char hdr_status[64]; | 1035 | char hdr_status[64]; |
1036 | header_t header = NULL; | 1036 | header_t header = NULL; |
1037 | int err; | ||
1038 | 1037 | ||
1039 | if (mpm == NULL) | 1038 | if (mpm == NULL) |
1040 | return EINVAL; | 1039 | return EINVAL; |
1041 | hdr_status[0] = '\0'; | 1040 | hdr_status[0] = '\0'; |
1042 | message_get_header (mpm->message, &header); | 1041 | message_get_header (mpm->message, &header); |
1043 | err = header_get_value (header, "Status", | 1042 | header_get_value (header, "Status", hdr_status, sizeof (hdr_status), NULL); |
1044 | hdr_status, sizeof (hdr_status), NULL); | 1043 | string_to_flags (hdr_status, pflags); |
1045 | if (err != 0) | 1044 | return 0; |
1046 | err = string_to_flags (hdr_status, pflags); | ||
1047 | return err; | ||
1048 | } | 1045 | } |
1049 | 1046 | ||
1050 | /* stub to call from body object. */ | 1047 | /* stub to call from body object. */ | ... | ... |
-
Please register or sign in to post a comment