我正在开发一个附加组件,它需要使用其主机名和用户名创建帐户列表。我可以做到这一点,nsIMsgAccountManager
但是当我使用手动设置创建新帐户时,主机名显示给我默认的 imap 服务器名称,即imap.googlemail.com
即使我已将其更改为192.168.0.25
. 理想情况下,我应该得到主机名,192.168.0.25
但它给了我imap.googlemail.com
. 这是我使用的代码:
var originalAccounts = PrefValue("mail.accountmanager.accounts");
var allServers = accountManager.allServers;
var accounts = originalAccounts.split(",");
var flagFirstItemIsSelected=false;
for (var i = 0; i < accounts.length; ++i) {
for (var ii=0; ii < allServers.Count(); ii++) {
var currentServer = allServers.GetElementAt(ii).QueryInterface(Components.interfaces.nsIMsgIncomingServer);
var type = currentServer.type;
alert(accounts[i]);
if ( accounts[i] == accountManager.FindAccountForServer(currentServer).key) {
// if (type == "none" || type == "pop3" || type == "imap" || type == "rss") {
if(type != "none")
{
if((currentServer.username.toLowerCase().search("Yahoo".toLowerCase()))==-1&&(currentServer.username.toLowerCase().search("Gmail".toLowerCase()))==-1&&(currentServer.username.toLowerCase().search("Rediffmail".toLowerCase()))==-1)
{
var theListitem = accountList.appendItem("[" + type + "] - " + currentServer.prettyName, accounts[i]);
if(flagFirstItemIsSelected==false)
{
//accountList.selectItem( theListitem );
flagFirstItemIsSelected=true;
}
theListitem.setAttribute("class", "folderMenuItem listitem-iconic")
theListitem.setAttribute("ServerType",type);
theListitem.setAttribute("IsServer",true);
theListitem.setAttribute("IsSecure",currentServer.isSecure);
theListitem.setAttribute("onclick","listClicked()");
}
}
}
}
}
请任何人告诉我我错在哪里。