|
|
|
@ -158,25 +158,32 @@ ImapConnection.prototype.connect = function(loginCb) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
state.conn.on('ready', function() {
|
|
|
|
|
// First get pre-auth capabilities, including server-supported auth
|
|
|
|
|
// mechanisms
|
|
|
|
|
var checkedNS = false;
|
|
|
|
|
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() {
|
|
|
|
|
// Next, attempt to login
|
|
|
|
|
var checkedNS = false;
|
|
|
|
|
self._login(function redo(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);
|
|
|
|
|
});
|
|
|
|
|
// No need to attempt the login sequence if we're on a PREAUTH
|
|
|
|
|
// connection.
|
|
|
|
|
if (state.status != STATES.AUTH) {
|
|
|
|
|
// First get pre-auth capabilities, including server-supported auth
|
|
|
|
|
// mechanisms
|
|
|
|
|
self._login(redo);
|
|
|
|
|
} else {
|
|
|
|
|
redo();
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|