@ -27,7 +27,8 @@ var CRLF = '\r\n',
// extension constants
// extension constants
var IDLE _NONE = 1 ,
var IDLE _NONE = 1 ,
IDLE _WAIT = 2 ,
IDLE _WAIT = 2 ,
IDLE _READY = 3 ;
IDLE _READY = 3 ,
IDLE _DONE = 4 ;
function ImapConnection ( options ) {
function ImapConnection ( options ) {
if ( ! ( this instanceof ImapConnection ) )
if ( ! ( this instanceof ImapConnection ) )
@ -1209,16 +1210,18 @@ ImapConnection.prototype._send = function(cmdstr, cb, bypass) {
cbargs : [ ]
cbargs : [ ]
} ) ;
} ) ;
}
}
if ( this . _state . ext . idle . state === IDLE _WAIT )
if ( this . _state . ext . idle . state === IDLE _WAIT ||
( this . _state . ext . idle . state == IDLE _DONE && cmdstr !== 'DONE' ) )
return ;
return ;
if ( ( cmdstr === undefined && this . _state . requests . length )
if ( ( cmdstr === undefined && this . _state . requests . length )
|| this . _state . requests . length === 1 || bypass ) {
|| this . _state . requests . length === 1 || bypass ) {
var prefix = '' ,
var prefix = '' ,
cmd = ( bypass ? cmdstr : this . _state . requests [ 0 ] . cmdstr ) ;
cmd = ( bypass ? cmdstr : this . _state . requests [ 0 ] . cmdstr ) ;
clearTimeout ( this . _state . tmrKeepalive ) ;
clearTimeout ( this . _state . tmrKeepalive ) ;
if ( this . _state . ext . idle . state === IDLE _READY && cmd !== 'DONE' )
if ( this . _state . ext . idle . state === IDLE _READY && cmd !== 'DONE' ) {
this . _state . ext . idle . state = IDLE _DONE ;
return this . _send ( 'DONE' , undefined , true ) ;
return this . _send ( 'DONE' , undefined , true ) ;
else if ( cmd === 'IDLE' ) {
} else if ( cmd === 'IDLE' ) {
// we use a different prefix to differentiate and disregard the tagged
// we use a different prefix to differentiate and disregard the tagged
// response the server will send us when we issue DONE
// response the server will send us when we issue DONE
prefix = 'IDLE ' ;
prefix = 'IDLE ' ;