diff --git a/experiment.js b/experiment.js index 69c75c0..83b6bec 100644 --- a/experiment.js +++ b/experiment.js @@ -7,25 +7,29 @@ var exp_logout = class extends ExtensionCommon.ExtensionAPI { exp_logout: { async exp_logout(identities) { if( identities != null && identities.length > 0 ) { - var acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); - var accounts = acctMgr.accounts; - for (var i = 0; i < accounts.length; i++) { - var account = accounts[i]; - if( account != null && account.identities != null && account.incomingServer != null ) { - for (var j = 0; j < account.identities.length; j++) { - var id = account.identities[j]; - if( id != null ) { - for (var k = 0; k < identities.length; k++) { - var id2logout = identities[k].id; - if( id2logout == id.key ) { - account.incomingServer.forgetPassword(); - account.incomingServer.forgetSessionPassword(); - account.incomingServer.closeCachedConnections(); - var smtpService=Components.classes['@mozilla.org/messengercompose/smtp;1'].getService(Components.interfaces.nsISmtpService); - if( smtpService != null ) { - var smtpServer=smtpService.getServerByKey(id.smtpServerKey); - if( smtpServer != null ) { - smtpServer.forgetPassword(); + var acctMgr = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); + if( acctMgr != null ) { + var accounts = acctMgr.accounts; + if( accounts != null && accounts.length > 0 ) { + for (var i = 0; i < accounts.length; i++) { + var account = accounts[i]; + if( account != null && account.identities != null && account.incomingServer != null ) { + for (var j = 0; j < account.identities.length; j++) { + var id = account.identities[j]; + if( id != null ) { + for (var k = 0; k < identities.length; k++) { + var id2logout = identities[k].id; + if( id2logout == id.key ) { + account.incomingServer.forgetPassword(); + account.incomingServer.forgetSessionPassword(); + account.incomingServer.closeCachedConnections(); + var smtpService=Components.classes['@mozilla.org/messengercompose/smtp;1'].getService(Components.interfaces.nsISmtpService); + if( smtpService != null ) { + var smtpServer=smtpService.getServerByKey(id.smtpServerKey); + if( smtpServer != null ) { + smtpServer.forgetPassword(); + } + } } } } @@ -33,7 +37,7 @@ var exp_logout = class extends ExtensionCommon.ExtensionAPI { } } } - } + } } } }