server->SetHostName((char *)hostname);
nsMsgAccountManager::MigrateNewsAccount(nsIMsgIdentity *identity, const char *hostname, nsFileSpec & newsrcfile, nsFileSpec & newsHostsDir){  	nsresult rv;	nsFileSpec thisNewsHostsDir = newsHostsDir;    if (!identity) return NS_ERROR_NULL_POINTER;	if (!hostname) return NS_ERROR_NULL_POINTER;    // create the account	nsCOMPtr<nsIMsgAccount> account;    rv = CreateAccount(getter_AddRefs(account));	if (NS_FAILED(rv)) return rv;    // create the server	nsCOMPtr<nsIMsgIncomingServer> server;    rv = CreateIncomingServer("nntp", getter_AddRefs(server));	if (NS_FAILED(rv)) return rv;	// now upgrade all the prefs	server->SetType("nntp");    server->SetHostName((char *)hostname);    // we only need to do this once    if (!m_alreadySetNntpDefaultLocalPath) {      nsCOMPtr <nsIFileSpec>nntpRootDir;      rv = NS_NewFileSpecWithSpec(newsHostsDir, getter_AddRefs(nntpRootDir));      if (NS_FAILED(rv)) return rv;            // set the default local path for "nntp"      rv = server->SetDefaultLocalPath(nntpRootDir);      if (NS_FAILED(rv)) return rv;      // set the newsrc root for "nntp"      // we really want <profile>/News or /home/sspitzer/      // not <profile>/News/news.rc or /home/sspitzer/.newsrc-news      nsFileSpec newsrcFileDir;      newsrcfile.GetParent(newsrcFileDir);      if (NS_FAILED(rv)) return rv;            nsCOMPtr <nsIFileSpec>newsrcRootDir;      rv = NS_NewFileSpecWithSpec(newsrcFileDir, getter_AddRefs(newsrcRootDir));      if (NS_FAILED(rv)) return rv;                  nsCOMPtr<nsINntpIncomingServer> nntpServer;      nntpServer = do_QueryInterface(server, &rv);      if (NS_FAILED(rv)) return rv;      rv = nntpServer->SetNewsrcRootPath(newsrcRootDir);      if (NS_FAILED(rv)) return rv;      m_alreadySetNntpDefaultLocalPath = PR_TRUE;    }        // create the identity    nsCOMPtr<nsIMsgIdentity> copied_identity;    rv = CreateIdentity(getter_AddRefs(copied_identity));	if (NS_FAILED(rv)) return rv;    // make this new identity to copy of the identity    // that we created out of the 4.x prefs	rv = CopyIdentity(identity,copied_identity);	if (NS_FAILED(rv)) return rv;    rv = SetNewsCcAndFccValues(copied_identity);    if (NS_FAILED(rv)) return rv;    // hook them together	account->SetIncomingServer(server);	account->AddIdentity(copied_identity);	    rv = MigrateOldNntpPrefs(server, hostname, newsrcfile);    if (NS_FAILED(rv)) return rv;			// 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);		thisNewsHostsDir += (const char *) alteredHost;    nsCOMPtr <nsIFileSpec> newsDir;    PRBool dirExists;	rv = NS_NewFileSpecWithSpec(thisNewsHostsDir, getter_AddRefs(newsDir));	if (NS_FAILED(rv)) return rv;    // set the local path for this "nntp" server    rv = server->SetLocalPath(newsDir);    if (NS_FAILED(rv)) return rv;    	rv = newsDir->Exists(&dirExists);	if (!dirExists) {		newsDir->CreateDir();	}	return NS_OK;}