rv = nsComponentManager::CreateInstance(kMsgAccountCID, nsnull, nsCOMTypeInfo<nsIMsgAccount>::GetIID(), getter_AddRefs(account));
rv = createKeyedAccount("account1", getter_AddRefs(account));
nsMsgAccountManager::MigratePopAccounts(nsIMsgIdentity *identity){  nsresult rv;    nsCOMPtr<nsIMsgAccount> account;  nsCOMPtr<nsIMsgIncomingServer> server;    rv = nsComponentManager::CreateInstance(kMsgAccountCID,                                          nsnull,                                          nsCOMTypeInfo<nsIMsgAccount>::GetIID(),                                          getter_AddRefs(account));  if (NS_FAILED(rv)) return 0;  rv = nsComponentManager::CreateInstance(NS_MSGINCOMINGSERVER_PROGID_PREFIX "pop3",                                          nsnull,                                          nsCOMTypeInfo<nsIMsgIncomingServer>::GetIID(),                                          getter_AddRefs(server));  if (NS_FAILED(rv)) return 0;  account->SetKey("account1");  server->SetKey("server1");    account->SetIncomingServer(server);  account->AddIdentity(identity);  // adds account to the hash table.  AddAccount(account);  // now upgrade all the prefs  char *oldstr = nsnull;  PRInt32 oldint;  PRBool oldbool;  nsFileSpec profileDir;    NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv);  if (NS_FAILED(rv)) return 0;    rv = profile->GetCurrentProfileDir(&profileDir);  if (NS_FAILED(rv)) return 0;    // pop stuff  // some of this ought to be moved out into the POP implementation  nsCOMPtr<nsIPop3IncomingServer> popServer;  popServer = do_QueryInterface(server, &rv);  if (NS_SUCCEEDED(rv)) {    server->SetType("pop3");	    rv = m_prefs->CopyCharPref("mail.pop_name", &oldstr);    if (NS_SUCCEEDED(rv)) {      server->SetUsername(oldstr);      PR_FREEIF(oldstr);      oldstr = nsnull;    }    #ifdef CAN_UPGRADE_4x_PASSWORDS    rv = m_prefs->CopyCharPref("mail.pop_password", &oldstr);    if (NS_SUCCEEDED(rv)) {      server->SetPassword(oldstr);      PR_FREEIF(oldstr);      oldstr = nsnull;    }#else    rv = SetPasswordForServer(server);    if (NS_FAILED(rv)) return rv;#endif /* CAN_UPGRADE_4x_PASSWORDS */    char *hostname=nsnull;    rv = m_prefs->CopyCharPref("network.hosts.pop_server", &hostname);    if (NS_SUCCEEDED(rv)) {      server->SetHostName(hostname);    }        rv = m_prefs->GetBoolPref("mail.check_new_mail", &oldbool);    if (NS_SUCCEEDED(rv)) {      server->SetDoBiff(oldbool);    }        rv = m_prefs->GetIntPref("mail.check_time", &oldint);    if (NS_SUCCEEDED(rv)) {      server->SetBiffMinutes(oldint);    }        // create the directory structure for this pop account    // under <profile dir>/Mail/<hostname>    nsCOMPtr <nsIFileSpec> mailDir;    nsFileSpec dir(profileDir);    PRBool dirExists;        // turn profileDir into the mail dir.    dir += "Mail";    if (!dir.Exists()) {      dir.CreateDir();    }    dir += hostname;    PR_FREEIF(hostname);        rv = NS_NewFileSpecWithSpec(dir, getter_AddRefs(mailDir));    if (NS_FAILED(rv)) return 0;        rv = mailDir->Exists(&dirExists);    if (NS_FAILED(rv)) return 0;        if (!dirExists) {      mailDir->CreateDir();    }        char *str = nsnull;    mailDir->GetNativePath(&str);        if (str && *str) {      server->SetLocalPath(str);      PR_FREEIF(str);      str = nsnull;    }        rv = mailDir->Exists(&dirExists);    if (NS_FAILED(rv)) return 0;        if (!dirExists) {      mailDir->CreateDir();    }        // create the files for the special folders.    // this needs to be i18N.    rv = createSpecialFile(dir,"Inbox");    if (NS_FAILED(rv)) return 0;        rv = createSpecialFile(dir,"Sent");    if (NS_FAILED(rv)) return 0;        rv = createSpecialFile(dir,"Trash");    if (NS_FAILED(rv)) return 0;        rv = createSpecialFile(dir,"Drafts");    if (NS_FAILED(rv)) return 0;        rv = createSpecialFile(dir,"Templates");    if (NS_FAILED(rv)) return 0;        rv = createSpecialFile(dir,"Unsent Message");    if (NS_FAILED(rv)) return 0;	    rv = m_prefs->GetBoolPref("mail.leave_on_server", &oldbool);    if (NS_SUCCEEDED(rv)) {      popServer->SetLeaveMessagesOnServer(oldbool);    }        rv = m_prefs->GetBoolPref("mail.delete_mail_left_on_server", &oldbool);    if (NS_SUCCEEDED(rv)) {      popServer->SetDeleteMailLeftOnServer(oldbool);    }  }    // one account created!  return 1;}