fix IDLE after connection if there is nothing yet to do and other misc changes

fork
Brian White 12 years ago
parent 4e61905378
commit b5dca62d5b

@ -164,15 +164,17 @@ ImapConnection.prototype.connect = function(loginCb) {
state.conn.on('ready', function() {
var checkedNS = false;
var redo = function(err) {
if (err)
var reentry = function(err) {
if (err) {
state.conn.destroy();
return loginCb(err);
}
// Next, get the list of available namespaces if supported (RFC2342)
if (!checkedNS && self._serverSupports('NAMESPACE')) {
// Re-enter this function after we've obtained the available
// namespaces
checkedNS = true;
return self._send('NAMESPACE', redo);
return self._send('NAMESPACE', reentry);
}
// Lastly, get the top-level mailbox hierarchy delimiter used by the
// server
@ -185,9 +187,9 @@ ImapConnection.prototype.connect = function(loginCb) {
if (state.status !== STATES.AUTH) {
// First get pre-auth capabilities, including server-supported auth
// mechanisms
self._login(redo);
self._login(reentry);
} else
redo();
reentry();
});
});
@ -617,13 +619,13 @@ ImapConnection.prototype.connect = function(loginCb) {
args.unshift([]);
}
args.unshift(err);
requests[0].callback.apply({}, args);
requests[0].callback.apply(self, args);
}
var recentCmd = requests[0].cmdstr;
requests.shift();
if (requests.length === 0 && recentCmd !== 'LOGOUT') {
if (state.status === STATES.BOXSELECTED && self._serverSupports('IDLE')) {
if (state.status >= STATES.AUTH && 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);
@ -766,7 +768,7 @@ ImapConnection.prototype.renameBox = function(oldname, newname, cb) {
ImapConnection.prototype.append = function(data, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
options = undefined;
}
options = options || {};
if (!options.mailbox) {

Loading…
Cancel
Save