nsIMsgIdentity *identity = nsnull; rv = nsComponentManager::CreateInstance(kMsgIdentityCID, nsnull, nsIMsgIdentity::GetIID(), (void **)&identity);  if (NS_SUCCEEDED(rv)) rv = identity->SetKey(identityKey); #ifdef DEBUG_alecf else printf("\tcouldn't create %s's identity\n",identityKey); #endif  PR_FREEIF(identityKey); if (NS_SUCCEEDED(rv)) rv = addIdentity(identity);  return rv;
return Init();
nsMsgAccount::SetKey(char *accountKey){  if (!accountKey) return NS_ERROR_NULL_POINTER;  nsresult rv=NS_OK;  // need the prefs service to do anything  if (!m_prefs)    rv = nsServiceManager::GetService(kPrefServiceCID,                                      nsIPref::GetIID(),                                      (nsISupports**)&m_prefs);  if (NS_FAILED(rv)) return rv;  m_accountKey = PL_strdup(accountKey);  // we should make this be created lazily like incoming servers are  //  // Load Identities  //  // ex) mail.account.myaccount.identities = "joe-home,joe-work"  char *identitiesKeyPref = PR_smprintf("mail.account.%s.identities",                                        accountKey);  char *identityKey = nsnull;  rv = m_prefs->CopyCharPref(identitiesKeyPref, &identityKey);  PR_FREEIF(identitiesKeyPref);#ifdef DEBUG_alecf  printf("%s's identities: %s\n", accountKey, identityKey);#endif    // XXX todo: iterate through identities. for now, assume just one  nsIMsgIdentity *identity = nsnull;  rv = nsComponentManager::CreateInstance(kMsgIdentityCID,                                          nsnull,                                          nsIMsgIdentity::GetIID(),                                          (void **)&identity);  if (NS_SUCCEEDED(rv))    rv = identity->SetKey(identityKey);#ifdef DEBUG_alecf  else    printf("\tcouldn't create %s's identity\n",identityKey);#endif  PR_FREEIF(identityKey);  if (NS_SUCCEEDED(rv))    rv = addIdentity(identity);  return rv;}