void WMSettings::SetIdentities(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, nsIDOMDocument *xmlDoc, nsAutoString &inUserName, int32_t authMethodIncoming, bool isNNTP) { // Get the relevant information for an identity // BUG 470587. Don't set this: id->SetIdentityName(fullName); nsresult rv; nsAutoString value; nsCOMPtr<nsIMsgIdentity> id; rv = pMgr->CreateIdentity(getter_AddRefs(id)); if (id) { IMPORT_LOG0("Created identity and added to the account\n"); if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Display_Name" : "SMTP_Display_Name", value))) { id->SetFullName(value); IMPORT_LOG1("\tname: %S\n", value.get()); } if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Organization_Name" : "SMTP_Organization_Name", value))) { id->SetOrganization(value); } if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Email_Address" : "SMTP_Email_Address", value))) { id->SetEmail(NS_ConvertUTF16toUTF8(value)); IMPORT_LOG1("\temail: %S\n", value.get()); } if (NS_SUCCEEDED(nsWMUtils::GetValueForTag(xmlDoc, isNNTP ? "NNTP_Reply_To_Email_Address" : "SMTP_Reply_To_Email_Address", value))) { id->SetReplyTo(NS_ConvertUTF16toUTF8(value)); } // Windows users are used to top style quoting. id->SetReplyOnTop(isNNTP ? 0 : 1); pAcc->AddIdentity(id); } if (!isNNTP) // NNTP does not use SMTP in OE or TB SetSmtpServer(xmlDoc, id, inUserName, authMethodIncoming); }
void OESettings::SetIdentities(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, HKEY hKey, char *pIncomgUserName, PRInt32 authMethodIncoming, bool isNNTP) { // Get the relevant information for an identity char *pSmtpServer = (char *)nsOERegUtil::GetValueBytes(hKey, "SMTP Server"); char *pName = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Display Name" : "SMTP Display Name"); char *pEmail = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Email Address" : "SMTP Email Address"); char *pReply = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Reply To Email Address" : "SMTP Reply To Email Address"); char *pOrgName = (char *)nsOERegUtil::GetValueBytes(hKey, isNNTP ? "NNTP Organization Name" : "SMTP Organization Name"); nsresult rv; nsCOMPtr<nsIMsgIdentity> id; rv = pMgr->CreateIdentity(getter_AddRefs(id)); if (id) { nsAutoString fullName, organization; rv = nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), nsCString(pName), fullName); if (NS_SUCCEEDED(rv)) id->SetFullName(fullName); // BUG 470587. Don't set this: id->SetIdentityName(fullName); rv = nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), nsCString(pOrgName), organization); if (NS_SUCCEEDED(rv)) id->SetOrganization(organization); id->SetEmail(nsCString(pEmail)); if (pReply) id->SetReplyTo(nsCString(pReply)); // Outlook Express users are used to top style quoting. id->SetReplyOnTop(isNNTP ? 0 : 1); pAcc->AddIdentity(id); IMPORT_LOG0("Created identity and added to the account\n"); IMPORT_LOG1("\tname: %s\n", pName); IMPORT_LOG1("\temail: %s\n", pEmail); } if (!isNNTP) // NNTP does not use SMTP in OE or TB SetSmtpServer(pSmtpServer, hKey, id, pIncomgUserName, authMethodIncoming); nsOERegUtil::FreeValueBytes((BYTE *)pName); nsOERegUtil::FreeValueBytes((BYTE *)pSmtpServer); nsOERegUtil::FreeValueBytes((BYTE *)pEmail); nsOERegUtil::FreeValueBytes((BYTE *)pReply); }
void nsEudoraWin32::SetIdentities(nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, const char *userName, const char *serverName, char *pBuff) { nsCAutoString realName; nsCAutoString email; nsCAutoString server; DWORD valSize; nsresult rv; valSize = ::GetPrivateProfileString( pSection, "RealName", "", pBuff, kIniValueSize, pIniFile); if (valSize) realName = pBuff; valSize = ::GetPrivateProfileString( pSection, "SMTPServer", "", pBuff, kIniValueSize, pIniFile); if (valSize) server = pBuff; valSize = ::GetPrivateProfileString( pSection, "ReturnAddress", "", pBuff, kIniValueSize, pIniFile); if (valSize) email = pBuff; nsCOMPtr<nsIMsgIdentity> id; rv = accMgr->CreateIdentity( getter_AddRefs( id)); if (id) { nsAutoString fullName; fullName.Assign(NS_ConvertASCIItoUTF16(realName)); id->SetFullName(fullName); id->SetIdentityName(fullName); if (email.IsEmpty()) { email = userName; email += "@"; email += serverName; } id->SetEmail(email); acc->AddIdentity( id); IMPORT_LOG0( "Created identity and added to the account\n"); IMPORT_LOG1( "\tname: %s\n", realName.get()); IMPORT_LOG1( "\temail: %s\n", email.get()); } SetSmtpServer( accMgr, acc, server.get(), userName); }
void OutlookSettings::SetIdentities(nsIMsgAccountManager *aMgr, nsIMsgAccount *aAcc, nsIWindowsRegKey *aKey) { // Get the relevant information for an identity nsAutoString name; aKey->ReadStringValue(NS_LITERAL_STRING("SMTP Display Name"), name); nsAutoString server; aKey->ReadStringValue(NS_LITERAL_STRING("SMTP Server"), server); nsAutoString email; aKey->ReadStringValue(NS_LITERAL_STRING("SMTP Email Address"), email); nsAutoString reply; aKey->ReadStringValue(NS_LITERAL_STRING("SMTP Reply To Email Address"), reply); nsAutoString userName; aKey->ReadStringValue(NS_LITERAL_STRING("SMTP User Name"), userName); nsAutoString orgName; aKey->ReadStringValue(NS_LITERAL_STRING("SMTP Organization Name"), orgName); nsresult rv; nsCOMPtr<nsIMsgIdentity> id; if (!email.IsEmpty() && !name.IsEmpty() && !server.IsEmpty()) { // The default identity, nor any other identities matched, // create a new one and add it to the account. rv = aMgr->CreateIdentity(getter_AddRefs(id)); if (id) { id->SetFullName(name); id->SetIdentityName(name); id->SetOrganization(orgName); nsCAutoString nativeEmail; NS_CopyUnicodeToNative(email, nativeEmail); id->SetEmail(nativeEmail); if (!reply.IsEmpty()) { nsCAutoString nativeReply; NS_CopyUnicodeToNative(reply, nativeReply); id->SetReplyTo(nativeReply); } aAcc->AddIdentity(id); nsCAutoString nativeName; NS_CopyUnicodeToNative(name, nativeName); IMPORT_LOG0("Created identity and added to the account\n"); IMPORT_LOG1("\tname: %s\n", nativeName.get()); IMPORT_LOG1("\temail: %s\n", nativeEmail.get()); } } if (userName.IsEmpty()) { nsCOMPtr<nsIMsgIncomingServer> incomingServer; rv = aAcc->GetIncomingServer(getter_AddRefs(incomingServer)); if (NS_SUCCEEDED(rv) && incomingServer) { nsCAutoString nativeUserName; rv = incomingServer->GetUsername(nativeUserName); NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to get UserName from incomingServer"); NS_CopyNativeToUnicode(nativeUserName, userName); } } SetSmtpServer(aMgr, aAcc, id, server, userName); }
void OutlookSettings::SetIdentities(nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, HKEY hKey) { // Get the relevant information for an identity char *pName = (char *)nsOutlookRegUtil::GetValueBytes(hKey, "SMTP Display Name"); char *pServer = (char *)nsOutlookRegUtil::GetValueBytes(hKey, "SMTP Server"); char *pEmail = (char *)nsOutlookRegUtil::GetValueBytes(hKey, "SMTP Email Address"); char *pReply = (char *)nsOutlookRegUtil::GetValueBytes(hKey, "SMTP Reply To Email Address"); nsCString userName; userName.Adopt((char *)nsOutlookRegUtil::GetValueBytes(hKey, "SMTP User Name")); char *pOrgName = (char *)nsOutlookRegUtil::GetValueBytes(hKey, "SMTP Organization Name"); nsresult rv; if (pEmail && pName && pServer) { // The default identity, nor any other identities matched, // create a new one and add it to the account. nsCOMPtr<nsIMsgIdentity> id; rv = pMgr->CreateIdentity(getter_AddRefs(id)); if (id) { nsAutoString name, organization; rv = nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), nsDependentCString(pName), name); if (NS_SUCCEEDED(rv)) { id->SetFullName(name); id->SetIdentityName(name); } if (pOrgName) { rv = nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), nsDependentCString(pOrgName), organization); if (NS_SUCCEEDED(rv)) id->SetOrganization(organization); } id->SetEmail(nsDependentCString(pEmail)); if (pReply) id->SetReplyTo(nsDependentCString(pReply)); pAcc->AddIdentity(id); IMPORT_LOG0("Created identity and added to the account\n"); IMPORT_LOG1("\tname: %s\n", pName); IMPORT_LOG1("\temail: %s\n", pEmail); } } if (userName.IsEmpty()) { nsCOMPtr <nsIMsgIncomingServer> incomingServer; rv = pAcc->GetIncomingServer(getter_AddRefs(incomingServer)); if (NS_SUCCEEDED(rv) && incomingServer) rv = incomingServer->GetUsername(userName); NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to get UserName from incomingServer"); } SetSmtpServer(pMgr, pAcc, pServer, userName); nsOutlookRegUtil::FreeValueBytes((BYTE *)pName); nsOutlookRegUtil::FreeValueBytes((BYTE *)pServer); nsOutlookRegUtil::FreeValueBytes((BYTE *)pEmail); nsOutlookRegUtil::FreeValueBytes((BYTE *)pReply); }
void OESettings::SetIdentities(nsIMsgAccountManager *aMgr, nsIMsgAccount *pAcc, nsIWindowsRegKey *aKey, const nsString &aIncomgUserName, int32_t authMethodIncoming, bool isNNTP) { // Get the relevant information for an identity nsresult rv; nsAutoString name; rv = aKey->ReadStringValue(isNNTP ? NS_LITERAL_STRING("NNTP Display Name") : NS_LITERAL_STRING("SMTP Display Name"), name); nsAutoString email; rv = aKey->ReadStringValue(isNNTP ? NS_LITERAL_STRING("NNTP Email Address") : NS_LITERAL_STRING("SMTP Email Address"), email); nsAutoString reply; rv = aKey->ReadStringValue(isNNTP ? NS_LITERAL_STRING("NNTP Reply To Email Address") : NS_LITERAL_STRING("SMTP Reply To Email Address"), reply); nsAutoString orgName; rv = aKey->ReadStringValue(isNNTP ? NS_LITERAL_STRING("NNTP Organization Name") : NS_LITERAL_STRING("SMTP Organization Name"), orgName); nsCOMPtr<nsIMsgIdentity> id; rv = aMgr->CreateIdentity(getter_AddRefs(id)); if (NS_FAILED(rv)) return; id->SetFullName(name); //BUG 470587. Don't set this: id->SetIdentityName(fullName); id->SetOrganization(orgName); nsAutoCString nativeEmail; NS_CopyUnicodeToNative(email, nativeEmail); id->SetEmail(nativeEmail); if (!reply.IsEmpty()) { nsAutoCString nativeReply; NS_CopyUnicodeToNative(reply, nativeReply); id->SetReplyTo(nativeReply); } // Outlook Express users are used to top style quoting. id->SetReplyOnTop(isNNTP ? 0 : 1); pAcc->AddIdentity(id); nsAutoCString nativeName; NS_CopyUnicodeToNative(name, nativeName); IMPORT_LOG0("Created identity and added to the account\n"); IMPORT_LOG1("\tname: %s\n", nativeName.get()); IMPORT_LOG1("\temail: %s\n", nativeEmail.get()); if (isNNTP) // NNTP does not use SMTP in OE or TB return; nsAutoString smtpServer; rv = aKey->ReadStringValue(NS_LITERAL_STRING("SMTP Server"), smtpServer); SetSmtpServer(smtpServer, aKey, id, aIncomgUserName, authMethodIncoming); }