Add uidvalidity event and make uidvalidity, uidnext, etc consistently an integer

fork
Brian White 12 years ago
parent 4242f2be3c
commit 8376ee1559

@ -195,7 +195,7 @@ node-imap exposes one object: **ImapConnection**.
* _Box_ is an object representing the currently open mailbox, and has the following properties:
* **name** - <_string_> - The name of this mailbox.
* **readOnly** - <_boolean_> - True if this mailbox was opened in read-only mode.
* **validity** - <_string_> - A number that can be used to determine if UIDs in this mailbox have changed since the last time this mailbox was opened.
* **validity** - <_integer_> - A 32-bit number that can be used to determine if UIDs in this mailbox have changed since the last time this mailbox was opened. It is possible for this to change during a session, in which case a 'uidvalidity' event will be emitted on the ImapConnection instance.
* **permFlags** - <_array_> - A list of flags that can be permanently added/removed to/from messages in this mailbox.
* **messages** - <_object_> Contains various message counts for this mailbox:
* **total** - <_integer_> - Total number of messages in this mailbox.
@ -203,7 +203,7 @@ node-imap exposes one object: **ImapConnection**.
* _ImapMessage_ is an object representing an email message. It consists of:
* Properties:
* **seqno** - <_integer_> - This message's sequence number. This number changes when messages with smaller sequence numbers are deleted for example (see the ImapConnection's 'deleted' event). This value is **always** available immediately.
* **uid** - <_integer_> - An ID that uniquely identifies this message within its mailbox.
* **uid** - <_integer_> - A 32-bit ID that uniquely identifies this message within its mailbox.
* **flags** - <_array_> - A list of flags currently set on this message.
* **date** - <_string_> - The internal server date for the message (always represented in GMT?)
* **headers** - <_object_> - The headers of the message (header => values), **if headers were requested when calling fetch().** Note: Header values are always arrays for consistency.
@ -326,6 +326,8 @@ ImapConnection Events
* **msgupdate**(<_ImapMessage_>msg) - Fires when a message's flags have changed, generally from another IMAP connection's session. With that in mind, the only available ImapMessage properties in this case will almost always only be 'seqno' and 'flags' (no 'data' or 'end' events will be emitted on the object).
* **uidvalidity**(<_integer_>uidvalidity) - Fires when the UID validity value has changed for the currently open mailbox. Any UIDs previously stored for this mailbox are now invalidated.
* **close**(<_boolean_>hadError) - Fires when the connection is completely closed.
* **end**() - Fires when the connection is ended.

@ -409,11 +409,11 @@ ImapConnection.prototype.connect = function(loginCb) {
m.mailbox = parsers.convStr(m.mailbox, indata.literals);
var ret = {
name: m.mailbox,
uidvalidity: undefined,
uidvalidity: 0,
messages: {
total: undefined,
new: undefined,
unseen: undefined
total: 0,
new: 0,
unseen: 0
}
};
if (m.attributes) {
@ -470,9 +470,9 @@ ImapConnection.prototype.connect = function(loginCb) {
if (m = /^UNSEEN (\d+)/i.exec(code))
state.box.messages.unseen = parseInt(m[1], 10);
else if (m = /^UIDVALIDITY (\d+)/i.exec(code))
state.box.uidvalidity = m[1];
state.box.uidvalidity = parseInt(m[1], 10);
else if (m = /^UIDNEXT (\d+)/i.exec(code))
state.box.uidnext = m[1];
state.box.uidnext = parseInt(m[1], 10);
else if (m = /^PERMANENTFLAGS \((.*)\)/i.exec(code)) {
var idx, permFlags, keywords;
state.box.permFlags = permFlags = m[1].split(' ');
@ -489,6 +489,11 @@ ImapConnection.prototype.connect = function(loginCb) {
return f.substr(1);
});
}
} else if (state.status === STATES.BOXSELECTED) {
if (m = /^UIDVALIDITY (\d+)/i.exec(code)) {
state.box.uidvalidity = parseInt(m[1], 10);
self.emit('uidvalidity', state.box.uidvalidity);
}
}
break;
case 'PREAUTH':

Loading…
Cancel
Save