nsGetMailboxServer(const char *username, const char *hostname, nsIMsgIncomingServer** aResult)
nsGetMailboxServer(char *username, char *hostname, nsIMsgIncomingServer** aResult)
nsGetMailboxServer(const char *username, const char *hostname, nsIMsgIncomingServer** aResult){  nsresult rv = NS_OK;  nsUnescape(NS_CONST_CAST(char*,username));  nsUnescape(NS_CONST_CAST(char*,hostname));  // retrieve the AccountManager  nsCOMPtr<nsIMsgAccountManager> accountManager =            do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);  if (NS_FAILED(rv)) return rv;  // find all local mail "no servers" matching the given hostname  nsCOMPtr<nsIMsgIncomingServer> none_server;  rv = accountManager->FindServer(username,                                  hostname,                                  "none",                                  getter_AddRefs(none_server));  if (NS_SUCCEEDED(rv)) {	 *aResult = none_server;	  NS_ADDREF(*aResult);	  return rv;  }#ifdef HAVE_MOVEMAIL  // find all movemail "servers" matching the given hostname  nsCOMPtr<nsIMsgIncomingServer> movemail_server;  rv = accountManager->FindServer(username,                                  hostname,                                  "movemail",                                  getter_AddRefs(movemail_server));  if (NS_SUCCEEDED(rv)) {	 *aResult = movemail_server;	  NS_ADDREF(*aResult);	  return rv;  }#endif /* HAVE_MOVEMAIL */  // if that fails, look for the pop hosts matching the given hostname  nsCOMPtr<nsIMsgIncomingServer> server;  if (NS_FAILED(rv))   {	  rv = accountManager->FindServer(username,                                    hostname,                                    "pop3",                                    getter_AddRefs(server));    // if we can't find a pop server, maybe it's a local message     // in an imap hiearchy. look for an imap server.    if (NS_FAILED(rv))     {	  rv = accountManager->FindServer(username,                                    hostname,                                    "imap",                                    getter_AddRefs(server));    }  }	if (NS_SUCCEEDED(rv))   {		*aResult = server;		NS_ADDREF(*aResult);		return rv;	}  // if you fail after looking at all "pop3", "movemail" and "none" servers, you fail.  return rv;}