rename is* connection properties

fork
Brian White 12 years ago
parent 2d0772ac56
commit 1a1d51c42a

@ -98,8 +98,8 @@ function ImapConnection(options) {
this.delimiter = undefined; this.delimiter = undefined;
this.namespaces = { personal: [], other: [], shared: [] }; this.namespaces = { personal: [], other: [], shared: [] };
this.capabilities = []; this.capabilities = [];
this.isConnected = false; this.connected = false;
this.isAuthenticated = false; this.authenticated = false;
} }
inherits(ImapConnection, EventEmitter); inherits(ImapConnection, EventEmitter);
@ -121,6 +121,7 @@ ImapConnection.prototype.connect = function(loginCb) {
// TODO: support STARTTLS // TODO: support STARTTLS
state.conn.cleartext = utils.setSecure(state.conn); state.conn.cleartext = utils.setSecure(state.conn);
state.conn.on('secure', function() { state.conn.on('secure', function() {
state.connected = true;
self.debug&&self.debug('[connection] Secure connection made.'); self.debug&&self.debug('[connection] Secure connection made.');
}); });
} else } else
@ -128,16 +129,16 @@ ImapConnection.prototype.connect = function(loginCb) {
state.conn.on('connect', function() { state.conn.on('connect', function() {
clearTimeout(state.tmrConn); clearTimeout(state.tmrConn);
state.isConnected = true; state.connected = true;
state.isAuthenticated = false; state.authenticated = false;
self.debug&&self.debug('[connection] Connected to host.'); self.debug&&self.debug('[connection] Connected to host.');
state.conn.cleartext.write(''); state.conn.cleartext.write('');
state.status = STATES.NOAUTH; state.status = STATES.NOAUTH;
}); });
state.conn.on('end', function() { state.conn.on('end', function() {
state.isConnected = false; state.connected = false;
state.isAuthenticated = false; state.authenticated = false;
self.debug&&self.debug('[connection] FIN packet received. Disconnecting...'); self.debug&&self.debug('[connection] FIN packet received. Disconnecting...');
self.emit('end'); self.emit('end');
}); });
@ -155,8 +156,8 @@ ImapConnection.prototype.connect = function(loginCb) {
state.conn.on('close', function(had_error) { state.conn.on('close', function(had_error) {
self._reset(); self._reset();
requests = state.requests; requests = state.requests;
state.isConnected = false; state.connected = false;
state.isAuthenticated = false; state.authenticated = false;
self.debug&&self.debug('[connection] Connection closed.'); self.debug&&self.debug('[connection] Connection closed.');
self.emit('close', had_error); self.emit('close', had_error);
}); });
@ -523,7 +524,7 @@ ImapConnection.prototype.connect = function(loginCb) {
break; break;
case 'PREAUTH': case 'PREAUTH':
state.status = STATES.AUTH; state.status = STATES.AUTH;
state.isAuthenticated = true; state.authenticated = true;
if (state.numCapRecvs === 0) if (state.numCapRecvs === 0)
state.numCapRecvs = 1; state.numCapRecvs = 1;
break; break;
@ -671,7 +672,7 @@ ImapConnection.prototype.connect = function(loginCb) {
}; };
ImapConnection.prototype.isAuthenticated = function() { ImapConnection.prototype.isAuthenticated = function() {
return this._state.status >= STATES.AUTH; return this.authenticated;
}; };
ImapConnection.prototype.logout = function(cb) { ImapConnection.prototype.logout = function(cb) {
@ -1347,7 +1348,7 @@ ImapConnection.prototype._login = function(cb) {
fnReturn = function(err) { fnReturn = function(err) {
if (!err) { if (!err) {
self._state.status = STATES.AUTH; self._state.status = STATES.AUTH;
self._state.isAuthenticated = true; self._state.authenticated = true;
if (self._state.numCapRecvs !== 2) { if (self._state.numCapRecvs !== 2) {
// fetch post-auth server capabilities if they were not // fetch post-auth server capabilities if they were not
// automatically provided after login // automatically provided after login

Loading…
Cancel
Save