NS_ADDREF(*aIncomingServer);
NS_IF_ADDREF(*aIncomingServer);
nsMsgAccount::GetIncomingServer(nsIMsgIncomingServer * *aIncomingServer){  if (!aIncomingServer) return NS_ERROR_NULL_POINTER;  nsresult rv;  // need to call SetKey() first!  if (!m_accountKey) return NS_ERROR_NOT_INITIALIZED;    // create the incoming server lazily  if (!m_incomingServer) {    // from here, load mail.account.myaccount.server    // and             mail.account.myaccount.identities    // to load and create the appropriate objects        //    // Load the incoming server    //    // ex) mail.account.myaccount.server = "myserver"    char *serverKeyPref = PR_smprintf("mail.account.%s.server", m_accountKey);    char *serverKey;    rv = m_prefs->CopyCharPref(serverKeyPref, &serverKey);    PR_FREEIF(serverKeyPref);    // the server pref doesn't exist    if (NS_FAILED(rv)) return rv;    #ifdef DEBUG_alecf    printf("\t%s's server: %s\n", m_accountKey, serverKey);#endif        // ask the prefs what kind of server this is and use it to    // create a ProgID for it    // ex) mail.server.myserver.type = imap    char *serverTypePref = PR_smprintf("mail.server.%s.type", serverKey);    char *serverType;    rv = m_prefs->CopyCharPref(serverTypePref, &serverType);    PR_FREEIF(serverTypePref);    // the server type doesn't exist!    if (NS_FAILED(rv)) return rv;    #ifdef DEBUG_alecf    if (NS_FAILED(rv)) {      printf("\tCould not read pref %s\n", serverTypePref);    } else {      printf("\t%s's   type: %s\n", m_accountKey, serverType);    }#endif        char *serverTypeProgID =      PR_smprintf("component://netscape/messenger/server&type=%s", serverType);        PR_FREEIF(serverType);        nsIMsgIncomingServer *server;    rv = nsComponentManager::CreateInstance(serverTypeProgID,                                            nsnull,                                            nsIMsgIncomingServer::GetIID(),                                            (void **)&server);    PR_FREEIF(serverTypeProgID);    #ifdef DEBUG_alecf    if (NS_SUCCEEDED(rv)) {      printf("Created a %s server\n", serverType);    } else {      printf("Could not create a %s server\n", serverType);    }#endif        if (NS_SUCCEEDED(rv))      rv = server->SetKey(serverKey);        if (NS_SUCCEEDED(rv))      rv = SetIncomingServer(server);    PR_FREEIF(serverKey);  }    if (!m_incomingServer) return NS_ERROR_UNEXPECTED;    *aIncomingServer = m_incomingServer;  NS_ADDREF(*aIncomingServer);  return NS_OK;}