So within the last few minutes i figured out why i was seeing wrong results when processing the flags for a message. Originally i was getting the flags as part of the message header using an IMAP command like this:
UID FETCH [message uid here] (FLAGS BODY[HEADER])
And it did return the flags, but not accurate ones. In the case of GMail, for every message, regardless of its read/unread status in the UI, the \Seen flag would be returned. This coupled with the fact that the default value for the Seen flag in the Message was true, resulted in every message appearing as though it is new. Not cool.
The solution was to request the message flags separate from the header like this:
UID FETCH [message uid here] FLAGS
Sending this command returns the correct flags, or in the case of a new message, no flags. The only drawback to his approach is the fact that another roundtrip to the server must be performed for each message, minor additional overhead, but additional overhead nonetheless.
Now that the new message detection code is working i can implement a nice quick method of checking for new messages with appropriate callbacks and whatnot. Follow me on twitter @Atmospherian to get updates when i check-in the code.

Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 