support for IMAP ID extension (RFC 2971)

fork
Dominik Gehl 11 years ago
parent 37778d8747
commit b697dfe66d

@ -306,6 +306,15 @@ Connection.prototype.getBoxes = function(namespace, cb) {
this._enqueue('LIST "' + namespace + '" "*"', cb);
};
Connection.prototype.id = function(identification, cb) {
if (!this.serverSupports('ID'))
throw new Error('Server does not support ID');
cmd = '';
for (var k in identification)
cmd += '"' + k + '" "' + identification[k] + '"';
return this._enqueue('ID (' + cmd + ')', cb);
}
Connection.prototype.openBox = function(name, readOnly, cb) {
if (this.state !== 'authenticated')
throw new Error('Not authenticated');
@ -1093,6 +1102,8 @@ Connection.prototype._resUntagged = function(info) {
this._sock.end();
else if (type === 'namespace')
this.namespaces = info.text;
else if (type === 'id')
this._curReq.cbargs.push(info.text);
else if (type === 'capability')
this._caps = info.text.map(function(v) { return v.toUpperCase(); });
else if (type === 'preauth')

@ -14,7 +14,7 @@ var CH_LF = 10,
RE_SEQNO = /^\* (\d+)/,
RE_LISTCONTENT = /^\((.*)\)$/,
RE_LITERAL = /\{(\d+)\}$/,
RE_UNTAGGED = /^\* (?:(OK|NO|BAD|BYE|FLAGS|LIST|LSUB|SEARCH|STATUS|CAPABILITY|NAMESPACE|PREAUTH|SORT|THREAD|ESEARCH|QUOTA|QUOTAROOT)|(\d+) (EXPUNGE|FETCH|RECENT|EXISTS))(?: (?:\[([^\]]+)\] )?(.+))?$/i,
RE_UNTAGGED = /^\* (?:(OK|NO|BAD|BYE|FLAGS|ID|LIST|LSUB|SEARCH|STATUS|CAPABILITY|NAMESPACE|PREAUTH|SORT|THREAD|ESEARCH|QUOTA|QUOTAROOT)|(\d+) (EXPUNGE|FETCH|RECENT|EXISTS))(?: (?:\[([^\]]+)\] )?(.+))?$/i,
RE_TAGGED = /^A(\d+) (OK|NO|BAD) (?:\[([^\]]+)\] )?(.+)$/i,
RE_CONTINUE = /^\+(?: (?:\[([^\]]+)\] )?(.+))?$/i,
RE_CRLF = /\r\n/g,
@ -249,6 +249,8 @@ Parser.prototype._resUntagged = function() {
val = [];
} else if (type === 'list' || type === 'lsub')
val = parseBoxList(m[5], this._literals);
else if (type === 'id')
val = parseId(m[5], this._literals);
else if (type === 'status')
val = parseStatus(m[5], this._literals);
else if (type === 'fetch')
@ -329,6 +331,17 @@ function parseESearch(text, literals) {
return attrs;
}
function parseId(text, literals) {
var r = parseExpr(text, literals),
id = {};
for (var i = 0, len = r[0].length; i < len; i += 2) {
id[r[0][i].toLowerCase()] = r[0][i + 1]
}
return id;
}
function parseQuota(text, literals) {
var r = parseExpr(text, literals),
resources = {};

Loading…
Cancel
Save