|
|
|
@ -140,7 +140,7 @@ ImapConnection.prototype.connect = function(loginCb) {
|
|
|
|
|
if (err)
|
|
|
|
|
return loginCb(err);
|
|
|
|
|
// Next, get the list of available namespaces if supported (RFC2342)
|
|
|
|
|
if (!checkedNS && self._supports('NAMESPACE')) {
|
|
|
|
|
if (!checkedNS && self._serverSupports('NAMESPACE')) {
|
|
|
|
|
// Re-enter this function after we've obtained the available
|
|
|
|
|
// namespaces
|
|
|
|
|
checkedNS = true;
|
|
|
|
@ -519,7 +519,8 @@ ImapConnection.prototype.connect = function(loginCb) {
|
|
|
|
|
self._state.requests.shift();
|
|
|
|
|
if (self._state.requests.length === 0
|
|
|
|
|
&& recentCmd !== 'LOGOUT') {
|
|
|
|
|
if (self._state.status === STATES.BOXSELECTED && self._supports('IDLE')) {
|
|
|
|
|
if (self._state.status === STATES.BOXSELECTED
|
|
|
|
|
&& self._serverSupports('IDLE')) {
|
|
|
|
|
// According to RFC 2177, we should re-IDLE at least every 29
|
|
|
|
|
// minutes to avoid disconnection by the server
|
|
|
|
|
self._send('IDLE', undefined, true);
|
|
|
|
@ -530,7 +531,7 @@ ImapConnection.prototype.connect = function(loginCb) {
|
|
|
|
|
self._state.ext.idle.timeWaited += self._state.tmoKeepalive;
|
|
|
|
|
if (self._state.ext.idle.timeWaited >= self._state.ext.idle.MAX_WAIT)
|
|
|
|
|
self._send('IDLE', undefined, true); // restart IDLE
|
|
|
|
|
} else if (!self._supports('IDLE'))
|
|
|
|
|
} else if (!self._serverSupports('IDLE'))
|
|
|
|
|
self._noop();
|
|
|
|
|
}
|
|
|
|
|
}, self._state.tmoKeepalive);
|
|
|
|
@ -607,7 +608,7 @@ ImapConnection.prototype.getBoxes = function(namespace, cb) {
|
|
|
|
|
cb = arguments[arguments.length - 1];
|
|
|
|
|
if (arguments.length !== 2)
|
|
|
|
|
namespace = '';
|
|
|
|
|
this._send((!this._supports('XLIST') ? 'LIST' : 'XLIST')
|
|
|
|
|
this._send((!this._serverSupports('XLIST') ? 'LIST' : 'XLIST')
|
|
|
|
|
+ ' "' + utils.escape(namespace) + '" "*"', cb);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -774,7 +775,7 @@ ImapConnection.prototype._fetch = function(which, uids, options) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// always fetch GMail-specific bits of information when on GMail
|
|
|
|
|
if (this._supports('X-GM-EXT-1'))
|
|
|
|
|
if (this._serverSupports('X-GM-EXT-1'))
|
|
|
|
|
extensions = 'X-GM-THRID X-GM-MSGID X-GM-LABELS ';
|
|
|
|
|
|
|
|
|
|
var cmd = which;
|
|
|
|
@ -948,7 +949,7 @@ ImapConnection.prototype._fnTmrConn = function(loginCb) {
|
|
|
|
|
this._state.conn.destroy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImapConnection.prototype._supports = function(capability) {
|
|
|
|
|
ImapConnection.prototype._serverSupports = function(capability) {
|
|
|
|
|
return (this.capabilities.indexOf(capability) > -1);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -1010,10 +1011,10 @@ ImapConnection.prototype._login = function(cb) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (this._state.status === STATES.NOAUTH) {
|
|
|
|
|
if (this._supports('LOGINDISABLED'))
|
|
|
|
|
if (this._serverSupports('LOGINDISABLED'))
|
|
|
|
|
return cb(new Error('Logging in is disabled on this server'));
|
|
|
|
|
|
|
|
|
|
if (this._supports('AUTH=XOAUTH') && 'xoauth' in this._options) {
|
|
|
|
|
if (this._serverSupports('AUTH=XOAUTH') && 'xoauth' in this._options) {
|
|
|
|
|
this._send('AUTHENTICATE XOAUTH ' + utils.escape(this._options.xoauth),
|
|
|
|
|
fnReturn);
|
|
|
|
|
} else if (this._options.username !== undefined
|
|
|
|
|