@ -145,25 +145,32 @@ ImapConnection.prototype.connect = function(loginCb) {
} ) ;
} ) ;
state . conn . on ( 'ready' , function ( ) {
state . conn . on ( 'ready' , function ( ) {
// First get pre-auth capabilities, including server-supported auth
var checkedNS = false ;
// mechanisms
var redo = function ( err ) {
if ( err )
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 ) ;
}
// Lastly, get the top-level mailbox hierarchy delimiter used by the
// server
self . _send ( 'LIST "" ""' , loginCb ) ;
} ;
// First, get the supported (pre-auth or otherwise) capabilities:
self . _send ( 'CAPABILITY' , function ( ) {
self . _send ( 'CAPABILITY' , function ( ) {
// Next, attempt to login
// No need to attempt the login sequence if we're on a PREAUTH
var checkedNS = false ;
// connection.
self . _login ( function redo ( err ) {
if ( state . status != STATES . AUTH ) {
if ( err )
// First get pre-auth capabilities, including server-supported auth
return loginCb ( err ) ;
// mechanisms
// Next, get the list of available namespaces if supported (RFC2342)
self . _login ( redo ) ;
if ( ! checkedNS && self . _serverSupports ( 'NAMESPACE' ) ) {
} else {
// Re-enter this function after we've obtained the available
redo ( ) ;
// namespaces
} ;
checkedNS = true ;
return self . _send ( 'NAMESPACE' , redo ) ;
}
// Lastly, get the top-level mailbox hierarchy delimiter used by the
// server
self . _send ( 'LIST "" ""' , loginCb ) ;
} ) ;
} ) ;
} ) ;
} ) ;
} ) ;