AddAccount(account);
nsMsgAccountManager::MigrateNewsAccount(nsIMsgIdentity *identity, const char *hostname, const char *newsrcfile, PRInt32 accountNum){  	nsresult rv;		if (!newsrcfile) return NS_ERROR_NULL_POINTER;	if (!hostname) return NS_ERROR_NULL_POINTER;	if (accountNum < 1) return NS_ERROR_FAILURE;		nsCOMPtr<nsIMsgAccount> account;	nsCOMPtr<nsIMsgIncomingServer> server;		rv = nsComponentManager::CreateInstance(kMsgAccountCID,		nsnull,		nsCOMTypeInfo<nsIMsgAccount>::GetIID(),		getter_AddRefs(account));	if (NS_FAILED(rv)) return rv;		rv = nsComponentManager::CreateInstance(NS_MSGINCOMINGSERVER_PROGID_PREFIX "nntp",		nsnull,		nsCOMTypeInfo<nsIMsgIncomingServer>::GetIID(),		getter_AddRefs(server));	if (NS_FAILED(rv)) return rv;	char accountStr[BUF_STR_LEN];	char serverStr[BUF_STR_LEN];	char identityStr[BUF_STR_LEN];	PR_snprintf(accountStr,BUF_STR_LEN,"account%d",accountNum);#ifdef DEBUG_ACCOUNTMANAGER	printf("account str = %s\n",accountStr);#endif	account->SetKey(accountStr);	PR_snprintf(serverStr,BUF_STR_LEN,"server%d",accountNum);#ifdef DEBUG_ACCOUNTMANAGER	printf("server str = %s\n",serverStr);#endif	server->SetKey(serverStr);		account->SetIncomingServer(server);	nsCOMPtr<nsIMsgIdentity> copied_identity;	rv = nsComponentManager::CreateInstance(kMsgIdentityCID,						    nsnull,						    nsCOMTypeInfo<nsIMsgIdentity>::GetIID(),						    getter_AddRefs(copied_identity));	if (NS_FAILED(rv)) return rv;	PR_snprintf(identityStr,BUF_STR_LEN,"identity%d",accountNum);	copied_identity->SetKey(identityStr);	rv = CopyIdentity(identity,copied_identity);	if (NS_FAILED(rv)) return rv;	account->AddIdentity(copied_identity);		// adds account to the hash table.	AddAccount(account);		// now upgrade all the prefs	nsFileSpec profileDir;		NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv);	if (NS_FAILED(rv)) return NS_ERROR_FAILURE;		rv = profile->GetCurrentProfileDir(&profileDir);	if (NS_FAILED(rv)) return NS_ERROR_FAILURE;		// some of this ought to be moved out into the NNTP implementation	nsCOMPtr<nsINntpIncomingServer> nntpServer;	nntpServer = do_QueryInterface(server, &rv);	if (NS_FAILED(rv)) {		return rv;	}		server->SetType("nntp");	server->SetHostName((char *)hostname);#ifdef SUPPORT_SNEWS	char *oldstr = nsnull;		// we don't handle nntp servers that accept username / passwords yet	char prefName[BUF_STR_LEN];	PR_snprintf(prefName, BUF_STR_LEN, "???nntp.server.%s.userName",hostname);	rv = m_prefs->CopyCharPref(prefName, &oldstr);	if (NS_SUCCEEDED(rv)) {		server->SetUsername(oldstr);		PR_FREEIF(oldstr);		oldstr = nsnull;	}#ifdef CAN_UPGRADE_4x_PASSWORDS	// upgrade the password	PR_snprintf(prefName, BUF_STR_LEN, "???nntp.server.%s.password",hostname);	rv = m_prefs->CopyCharPref(prefName, &oldstr);	if (NS_SUCCEEDED(rv)) {		server->SetPassword("enter your clear text password here");		PR_FREEIF(oldstr);		oldstr = nsnull;	}#else	rv = SetPasswordForServer(server);	if (NS_FAILED(rv)) return rv;#endif /* CAN_UPGRADE_4x_PASSWORDS */#endif /* SUPPORT_SNEWS */			// create the directory structure for this pop account	// under <profile dir>/News/host-<hostname>	nsCOMPtr <nsIFileSpec> newsDir;	nsFileSpec dir(profileDir);	PRBool dirExists;		// turn profileDir into the News dir.	dir += "News";	if (!dir.Exists()) {		dir.CreateDir();	}	// can't do dir += "host-"; dir += hostname; 	// because += on a nsFileSpec inserts a separator	// so we'd end up with host-/<hostname> and not host-<hostname>	nsCAutoString alteredHost ((const char *) "host-");	alteredHost += hostname;	NS_MsgHashIfNecessary(alteredHost);		dir += (const char *) alteredHost;	rv = NS_NewFileSpecWithSpec(dir, getter_AddRefs(newsDir));	if (NS_FAILED(rv)) return rv;	char *str = nsnull;	newsDir->GetNativePath(&str);		if (str && *str) {		server->SetLocalPath(str);		PR_FREEIF(str);		str = nsnull;	}		rv = newsDir->Exists(&dirExists);	if (NS_FAILED(rv)) return NS_ERROR_FAILURE;		if (!dirExists) {		newsDir->CreateDir();	}		nntpServer->SetNewsrcFilePath((char *)newsrcfile);	return NS_OK;}