nsMsgAccountManager::MigrateImapAccount(nsIMsgIdentity *identity, const char *hostname)
nsMsgAccountManager::MigrateImapAccount(nsIMsgIdentity *identity, const char *hostAndPort)
nsMsgAccountManager::MigrateImapAccount(nsIMsgIdentity *identity, const char *hostname){  nsresult rv;  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("imap", getter_AddRefs(server));  if (NS_FAILED(rv)) return rv;  server->SetType("imap");  server->SetHostName((char *)hostname);    // 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 = SetMailCcAndFccValues(copied_identity);  if (NS_FAILED(rv)) return rv;      // hook them together  account->SetIncomingServer(server);  account->AddIdentity(copied_identity);  // 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;    rv = MigrateOldImapPrefs(server, hostname);  if (NS_FAILED(rv)) return rv;    nsCOMPtr <nsIFileSpec> imapMailDir;  nsFileSpec dir;  PRBool dirExists;  char *imap_directory_value = nsnull;  // if they used -installer, this pref will point to where their files got copied  rv = m_prefs->CopyCharPref(PREF_IMAP_DIRECTORY, &imap_directory_value);  // if the "mail.imap.root_dir" pref is set, use that.  if (NS_SUCCEEDED(rv) && imap_directory_value && (PL_strlen(imap_directory_value) > 0)) {    dir = imap_directory_value;    PR_FREEIF(imap_directory_value);  }  else {    dir = profileDir;      // we want <profile>/ImapMail, not <profile>    dir += NEW_IMAPMAIL_DIR_NAME;    if (!dir.Exists()) {      dir.CreateDir();    }  }  rv = NS_NewFileSpecWithSpec(dir, getter_AddRefs(imapMailDir));  if (NS_FAILED(rv)) return rv;  // we only need to do this once  if (!m_alreadySetImapDefaultLocalPath) {    // set the default local path for "imap"    rv = server->SetDefaultLocalPath(imapMailDir);    if (NS_FAILED(rv)) return rv;    m_alreadySetImapDefaultLocalPath = PR_TRUE;  }    // we want .../ImapMail/<hostname>, not .../ImapMail  rv = imapMailDir->AppendRelativeUnixPath(hostname);  if (NS_FAILED(rv)) return rv;  // set the local path for this "imap" server  rv = server->SetLocalPath(imapMailDir);  if (NS_FAILED(rv)) return rv;     rv = imapMailDir->Exists(&dirExists);  if (!dirExists) {    imapMailDir->CreateDir();  }    return NS_OK;}