nsCOMPtr<nsIPop3IncomingServer> pop3Server = do_QueryInterface(in, &rv); NS_ENSURE_SUCCESS(rv,rv); BYTE *pLeaveOnServer = nsOERegUtil::GetValueBytes( hKey, "Leave Mail On Server"); if (pLeaveOnServer) { pop3Server->SetLeaveMessagesOnServer(*pLeaveOnServer == 1 ? PR_TRUE : PR_FALSE); nsOERegUtil::FreeValueBytes(pLeaveOnServer); }
PRBool OESettings::DoPOP3Server( nsIMsgAccountManager *pMgr, HKEY hKey, char *pServerName, nsIMsgAccount **ppAccount){	if (ppAccount)		*ppAccount = nsnull;	BYTE *pBytes;	pBytes = nsOERegUtil::GetValueBytes( hKey, "POP3 User Name");	if (!pBytes)		return( PR_FALSE);	PRBool	result = PR_FALSE;	// I now have a user name/server name pair, find out if it already exists?	nsCOMPtr<nsIMsgIncomingServer>	in;	nsresult rv = pMgr->FindServer( (const char *)pBytes, pServerName, "pop3", getter_AddRefs( in));	if (NS_FAILED( rv) || (in == nsnull)) {		// Create the incoming server and an account for it?		rv = pMgr->CreateIncomingServer( (const char *)pBytes, pServerName, "pop3", getter_AddRefs( in));		if (NS_SUCCEEDED( rv) && in) {			rv = in->SetType( "pop3");			rv = in->SetHostName( pServerName);			rv = in->SetUsername( (char *)pBytes);			IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", pServerName, (char *)pBytes);			BYTE *pAccName = nsOERegUtil::GetValueBytes( hKey, "Account Name");			nsString	prettyName;			if (pAccName) {				prettyName.AssignWithConversion((const char *)pAccName);				nsOERegUtil::FreeValueBytes( pAccName);			}			else				prettyName.AssignWithConversion((const char *)pServerName);			PRUnichar *pretty = prettyName.ToNewUnicode();						IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty);			rv = in->SetPrettyName( pretty);			nsCRT::free( pretty);						// We have a server, create an account.			nsCOMPtr<nsIMsgAccount>	account;			rv = pMgr->CreateAccount( getter_AddRefs( account));			if (NS_SUCCEEDED( rv) && account) {				rv = account->SetIncomingServer( in);								IMPORT_LOG0( "Created a new account and set the incoming server to the POP3 server.\n");									// Fiddle with the identities				SetIdentities( pMgr, account, hKey);				result = PR_TRUE;				if (ppAccount)					account->QueryInterface( NS_GET_IID(nsIMsgAccount), (void **)ppAccount);			}						}	}	else		result = PR_TRUE;		nsOERegUtil::FreeValueBytes( pBytes);	return( result);}