diff --git a/mozilla/mail/components/compose/content/MsgComposeCommands.js b/mozilla/mail/components/compose/content/MsgComposeCommands.js index ad57117617f..b5dfa6f9434 100644 --- a/mozilla/mail/components/compose/content/MsgComposeCommands.js +++ b/mozilla/mail/components/compose/content/MsgComposeCommands.js @@ -1822,9 +1822,24 @@ function GenericSendMessage( msgType ) { var dlgTitle = sComposeMsgsBundle.getString("initErrorDlogTitle"); var dlgText = sComposeMsgsBundle.getString("12553"); // NS_ERROR_MSG_MULTILINGUAL_SEND - if (!gPromptService.confirm(window, dlgTitle, dlgText)) - return; - fallbackCharset.value = "UTF-8"; + var result3 = gPromptService.confirmEx(window, dlgTitle, dlgText, + (gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) + + (gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_1) + + (gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_2), + sComposeMsgsBundle.getString('sendInUTF8'), + sComposeMsgsBundle.getString('sendAnyway'), + null, null, {value:0}); + switch(result3) + { + case 0: + fallbackCharset.value = "UTF-8"; + break; + case 1: // send anyway + msgCompFields.needToCheckCharset = false; + break; + case 2: // cancel + return; + } } if (fallbackCharset && fallbackCharset.value && fallbackCharset.value != "") diff --git a/mozilla/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties b/mozilla/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties index 168980f0b75..c68cd51b053 100644 --- a/mozilla/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties +++ b/mozilla/mail/locales/en-US/chrome/messenger/messengercompose/composeMsgs.properties @@ -184,7 +184,10 @@ noIdentities=You don't have any email identities yet. Create one with the Accou 12551=Posting message... ## @name NS_ERROR_MSG_MULTILINGUAL_SEND -12553=The message you composed contains characters not found in the selected Character Encoding. While you can choose a different Character Encoding, it is usually safe to use Unicode for mail. To send or save it as Unicode (UTF-8), click OK. To return to the Composer window where you can choose a different Character Encoding, click Cancel. +12553=The message you composed contains characters not found in the selected Character Encoding. While you can choose a different Character Encoding by returning to the composer window, it is usually safe to use Unicode (UTF-8) for mail. If you just send in the current Character Encoding, be aware that those not covered by the current Character Encoding will be turned to question marks and illegible by the recipient. + +sendInUTF8=Send in UTF-8 +sendAnyway=Send anyway ## @name NS_ERROR_NNTP_NO_CROSS_POSTING 12554=You can only send a message to one news server at a time. diff --git a/mozilla/mailnews/compose/public/nsIMsgCompFields.idl b/mozilla/mailnews/compose/public/nsIMsgCompFields.idl index fe52c870672..b8a6bc9bd83 100644 --- a/mozilla/mailnews/compose/public/nsIMsgCompFields.idl +++ b/mozilla/mailnews/compose/public/nsIMsgCompFields.idl @@ -41,7 +41,7 @@ #include "nsISupportsArray.idl" -[scriptable, uuid(3E89CAE3-BD2D-11d2-8293-000000000000)] +[scriptable, uuid(ABEFCAD2-47E9-4363-A3AA-8A76E7D96CE4)] interface nsIMsgCompFields : nsISupports { attribute AString from; @@ -108,6 +108,14 @@ interface nsIMsgCompFields : nsISupports { // Check if the composing mail headers can be converted to a mail charset. boolean checkCharsetConversion(out string fallbackCharset); + /** + * Indicates whether we need to check if the current |DocumentCharset| + * can represent all the characters in the message body. It should be + * initialized to true and set to false when 'Send Anyway' is selected + * by a user. (bug 249530) + */ + attribute boolean needToCheckCharset; + attribute nsISupports securityInfo; }; diff --git a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js index 6728360fd62..556fed0351a 100644 --- a/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mozilla/mailnews/compose/resources/content/MsgComposeCommands.js @@ -1770,9 +1770,24 @@ function GenericSendMessage( msgType ) { var dlgTitle = sComposeMsgsBundle.getString("initErrorDlogTitle"); var dlgText = sComposeMsgsBundle.getString("12553"); // NS_ERROR_MSG_MULTILINGUAL_SEND - if (!gPromptService.confirm(window, dlgTitle, dlgText)) - return; - fallbackCharset.value = "UTF-8"; + var result3 = gPromptService.confirmEx(window, dlgTitle, dlgText, + (gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) + + (gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_1) + + (gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_2), + sComposeMsgsBundle.getString('sendInUTF8'), + sComposeMsgsBundle.getString('sendAnyway'), + null, null, {value:0}); + switch(result3) + { + case 0: + fallbackCharset.value = "UTF-8"; + break; + case 1: // send anyway + msgCompFields.needToCheckCharset = false; + break; + case 2: // cancel + return; + } } if (fallbackCharset && fallbackCharset.value && fallbackCharset.value != "") diff --git a/mozilla/mailnews/compose/resources/locale/en-US/composeMsgs.properties b/mozilla/mailnews/compose/resources/locale/en-US/composeMsgs.properties index 2be3c2e0f5e..5f64f84aa65 100644 --- a/mozilla/mailnews/compose/resources/locale/en-US/composeMsgs.properties +++ b/mozilla/mailnews/compose/resources/locale/en-US/composeMsgs.properties @@ -184,7 +184,10 @@ noIdentities=You don't have any email identities yet. Create one with the Accou 12551=Posting message... ## @name NS_ERROR_MSG_MULTILINGUAL_SEND -12553=The message you composed contains characters not found in the selected Character Encoding. While you can choose a different Character Encoding, it is usually safe to use Unicode for mail. To send or save it as Unicode (UTF-8), click OK. To return to the Composer window where you can choose a different Character Encoding, click Cancel. +12553=The message you composed contains characters not found in the selected Character Encoding. While you can choose a different Character Encoding by returning to the composer window, it is usually safe to use Unicode (UTF-8) for mail. If you just send in the current Character Encoding, be aware that those not covered by the current Character Encoding will be turned to question marks and illegible by the recipient. + +sendInUTF8=Send in UTF-8 +sendAnyway=Send anyway ## @name NS_ERROR_NNTP_NO_CROSS_POSTING 12554=You can only send a message to one news server at a time. diff --git a/mozilla/mailnews/compose/src/nsMsgCompFields.cpp b/mozilla/mailnews/compose/src/nsMsgCompFields.cpp index 43d0b849f51..b6832468c81 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompFields.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompFields.cpp @@ -69,6 +69,7 @@ nsMsgCompFields::nsMsgCompFields() m_returnReceipt = PR_FALSE; m_receiptHeaderType = nsIMsgMdnGenerator::eDntType; m_bodyIsAsciiOnly = PR_FALSE; + m_needToCheckCharset = PR_TRUE; // Get the default charset from pref, use this as a mail charset. nsXPIDLString charset; @@ -777,3 +778,16 @@ NS_IMETHODIMP nsMsgCompFields::CheckCharsetConversion(char **fallbackCharset, PR return NS_OK; } + +NS_IMETHODIMP nsMsgCompFields::GetNeedToCheckCharset(PRBool *_retval) +{ + NS_ENSURE_ARG_POINTER(_retval); + *_retval = m_needToCheckCharset; + return NS_OK; +} + +NS_IMETHODIMP nsMsgCompFields::SetNeedToCheckCharset(PRBool aCheck) +{ + m_needToCheckCharset = aCheck; + return NS_OK; +} diff --git a/mozilla/mailnews/compose/src/nsMsgCompFields.h b/mozilla/mailnews/compose/src/nsMsgCompFields.h index 5aa8463a4d0..57733379428 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompFields.h +++ b/mozilla/mailnews/compose/src/nsMsgCompFields.h @@ -179,6 +179,7 @@ protected: PRBool m_bodyIsAsciiOnly; PRInt32 m_receiptHeaderType; /* receipt header type */ nsCString m_DefaultCharacterSet; + PRBool m_needToCheckCharset; nsCOMPtr mSecureCompFields; }; diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.cpp b/mozilla/mailnews/compose/src/nsMsgCompose.cpp index 686a2b78f98..55a18b9e154 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompose.cpp @@ -986,13 +986,22 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity // charset. ask whether to convert to UTF-8 or go back to reset // charset with a wider repertoire. (bug 233361) (if not mapi blind send) if (NS_ERROR_UENC_NOMAPPING == rv && m_editor) { - PRBool sendInUTF8; - rv = nsMsgAskBooleanQuestionByID(prompt, - NS_ERROR_MSG_MULTILINGUAL_SEND, &sendInUTF8); - if (!sendInUTF8) - return NS_ERROR_MSG_MULTILINGUAL_SEND; - CopyUTF16toUTF8(msgBody.get(), outCString); - m_compFields->SetCharacterSet("UTF-8"); + PRBool needToCheckCharset; + m_compFields->GetNeedToCheckCharset(&needToCheckCharset); + if (needToCheckCharset) { + PRInt32 answer = nsMsgAskAboutUncoveredCharacters(prompt); + switch (answer) { + case 0 : // convert to UTF-8 + CopyUTF16toUTF8(msgBody.get(), outCString); + m_compFields->SetCharacterSet("UTF-8"); + break; + case 1 : // send anyway + break; + case 2 : // return to the editor + default : + return NS_ERROR_MSG_MULTILINGUAL_SEND; + } + } } // re-label to the fallback charset else if (fallbackCharset) diff --git a/mozilla/mailnews/compose/src/nsMsgPrompts.cpp b/mozilla/mailnews/compose/src/nsMsgPrompts.cpp index 4fcad99be1b..c02060131eb 100644 --- a/mozilla/mailnews/compose/src/nsMsgPrompts.cpp +++ b/mozilla/mailnews/compose/src/nsMsgPrompts.cpp @@ -152,3 +152,59 @@ nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBo return NS_OK; } + +// returns 0 (send in UTF-8) in case of error +PRInt32 +nsMsgAskAboutUncoveredCharacters(nsIPrompt * aPrompt) +{ + PRInt32 result; + nsCOMPtr dialog = aPrompt; + + if (!dialog) + { + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); + if (wwatch) + wwatch->GetNewPrompter(0, getter_AddRefs(dialog)); + } + + NS_ENSURE_TRUE(dialog, 0); + + nsCOMPtr bundleService = + do_GetService(NS_STRINGBUNDLE_CONTRACTID); + NS_ENSURE_TRUE(bundleService, 0); + + nsCOMPtr composeBundle; + bundleService->CreateBundle("chrome://messenger/locale/messengercompose/" + "composeMsgs.properties", + getter_AddRefs(composeBundle)); + NS_ENSURE_TRUE(composeBundle, 0); + + nsXPIDLString title; + nsXPIDLString msg; + nsXPIDLString button0; + nsXPIDLString button1; + + composeBundle-> + GetStringFromName(NS_LITERAL_STRING("initErrorDlogTitle").get(), + getter_Copies(title)); + composeBundle-> + GetStringFromID(NS_ERROR_GET_CODE(NS_ERROR_MSG_MULTILINGUAL_SEND), + getter_Copies(msg)); + composeBundle-> + GetStringFromName(NS_LITERAL_STRING("sendInUTF8").get(), + getter_Copies(button0)); + composeBundle-> + GetStringFromName(NS_LITERAL_STRING("sendAnyway").get(), + getter_Copies(button1)); + + nsresult rv = dialog-> + ConfirmEx(title, msg, + nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_0 + + nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_1 + + nsIPrompt::BUTTON_TITLE_CANCEL * nsIPrompt::BUTTON_POS_2 + + nsIPrompt::BUTTON_POS_0_DEFAULT, + button0, button1, nsnull, nsnull, 0, &result); + + NS_ENSURE_SUCCESS(rv, 0); + return result; +} diff --git a/mozilla/mailnews/compose/src/nsMsgPrompts.h b/mozilla/mailnews/compose/src/nsMsgPrompts.h index f69cf5c58a3..e9e8858214a 100644 --- a/mozilla/mailnews/compose/src/nsMsgPrompts.h +++ b/mozilla/mailnews/compose/src/nsMsgPrompts.h @@ -49,5 +49,6 @@ nsresult nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID, const nsresult nsMsgDisplayMessageByString(nsIPrompt * aPrompt, const PRUnichar * msg, const PRUnichar * windowTitle = nsnull); nsresult nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer, const PRUnichar * windowTitle = nsnull); nsresult nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBool *answer, const PRUnichar * windowTitle = nsnull); +PRInt32 nsMsgAskAboutUncoveredCharacters(nsIPrompt * aPrompt); #endif /* _nsMsgPrompts_H_ */ diff --git a/mozilla/mailnews/compose/src/nsMsgSend.cpp b/mozilla/mailnews/compose/src/nsMsgSend.cpp index aebd44f4218..f7a6d051a1c 100644 --- a/mozilla/mailnews/compose/src/nsMsgSend.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSend.cpp @@ -1766,17 +1766,26 @@ nsMsgComposeAndSend::GetBodyFromEditor() getter_Copies(outCString), getter_Copies(fallbackCharset)); if (NS_ERROR_UENC_NOMAPPING == rv) { - PRBool sendInUTF8; - nsCOMPtr prompt; - GetDefaultPrompt(getter_AddRefs(prompt)); - rv = nsMsgAskBooleanQuestionByID(prompt, NS_ERROR_MSG_MULTILINGUAL_SEND, - &sendInUTF8); - if (!sendInUTF8) { - Recycle(bodyText); - return NS_ERROR_MSG_MULTILINGUAL_SEND; + PRBool needToCheckCharset; + mCompFields->GetNeedToCheckCharset(&needToCheckCharset); + printf("need to check charset=%d\n", needToCheckCharset); + if (needToCheckCharset) { + nsCOMPtr prompt; + GetDefaultPrompt(getter_AddRefs(prompt)); + PRInt32 answer = nsMsgAskAboutUncoveredCharacters(prompt); + switch (answer) { + case 0 : // convert to UTF-8 + CopyUTF16toUTF8(bodyText, outCString); + mCompFields->SetCharacterSet("UTF-8"); // tag as UTF-8 + break; + case 1 : // send anyway + break; + case 2 : // return to the editor + default : + Recycle(bodyText); + return NS_ERROR_MSG_MULTILINGUAL_SEND; + } } - CopyUTF16toUTF8(bodyText, outCString); - mCompFields->SetCharacterSet("UTF-8"); // tag as UTF-8 } // re-label to the fallback charset else if (fallbackCharset) @@ -2994,6 +3003,10 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields) mCompFields->SetSecurityInfo(secInfo); + PRBool needToCheckCharset; + fields->GetNeedToCheckCharset(&needToCheckCharset); + mCompFields->SetNeedToCheckCharset(needToCheckCharset); + // Check the fields for legitimacy... // if ( m_deliver_mode != nsMsgSaveAsDraft && m_deliver_mode != nsMsgSaveAsTemplate )