зеркало из https://github.com/mozilla/pjs.git
Bug 410333: get rid of the send in utf-8 question-dialog, just silently switch to utf-8 if necessary
r=mnyromyr, sr=bienvenu
This commit is contained in:
Родитель
45c87e3a70
Коммит
7dd7dda77e
|
@ -1825,30 +1825,10 @@ function GenericSendMessage( msgType )
|
|||
msgType == nsIMsgCompDeliverMode.SaveAsTemplate)
|
||||
{
|
||||
var fallbackCharset = new Object;
|
||||
if (gPromptService &&
|
||||
!gMsgCompose.checkCharsetConversion(getCurrentIdentity(), fallbackCharset))
|
||||
{
|
||||
var dlgTitle = sComposeMsgsBundle.getString("initErrorDlogTitle");
|
||||
var dlgText = sComposeMsgsBundle.getString("12553"); // NS_ERROR_MSG_MULTILINGUAL_SEND
|
||||
var result3 = gPromptService.confirmEx(window, dlgTitle, dlgText,
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
|
||||
(gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1) +
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_2),
|
||||
sComposeMsgsBundle.getString('sendInUTF8'),
|
||||
null,
|
||||
sComposeMsgsBundle.getString('sendAnyway'), null, {value:0});
|
||||
switch(result3)
|
||||
{
|
||||
case 0:
|
||||
fallbackCharset.value = "UTF-8";
|
||||
break;
|
||||
case 1: // cancel
|
||||
return;
|
||||
case 2: // send anyway
|
||||
msgCompFields.needToCheckCharset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Check encoding, switch to UTF-8 if the default encoding doesn't fit.
|
||||
if (!gMsgCompose.checkCharsetConversion(getCurrentIdentity(), fallbackCharset))
|
||||
fallbackCharset.value = "UTF-8";
|
||||
|
||||
if (fallbackCharset &&
|
||||
fallbackCharset.value && fallbackCharset.value != "")
|
||||
gMsgCompose.SetDocumentCharset(fallbackCharset.value);
|
||||
|
@ -1864,7 +1844,7 @@ function GenericSendMessage( msgType )
|
|||
msgcomposeWindow.dispatchEvent(event);
|
||||
if (event.getPreventDefault())
|
||||
throw Components.results.NS_ERROR_ABORT;
|
||||
|
||||
|
||||
gAutoSaving = (msgType == nsIMsgCompDeliverMode.AutoSaveAsDraft);
|
||||
// disable the ui if we're not auto-saving
|
||||
if (!gAutoSaving)
|
||||
|
|
|
@ -171,12 +171,6 @@ noIdentities=You don't have any email identities yet. Create one with the Accou
|
|||
## @name NS_MSG_POSTING_MESSAGE
|
||||
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 (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.
|
||||
|
||||
|
|
|
@ -1802,30 +1802,10 @@ function GenericSendMessage( msgType )
|
|||
msgType == nsIMsgCompDeliverMode.SaveAsTemplate)
|
||||
{
|
||||
var fallbackCharset = new Object;
|
||||
if (gPromptService &&
|
||||
!gMsgCompose.checkCharsetConversion(getCurrentIdentity(), fallbackCharset))
|
||||
{
|
||||
var dlgTitle = sComposeMsgsBundle.getString("initErrorDlogTitle");
|
||||
var dlgText = sComposeMsgsBundle.getString("12553"); // NS_ERROR_MSG_MULTILINGUAL_SEND
|
||||
var result3 = gPromptService.confirmEx(window, dlgTitle, dlgText,
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
|
||||
(gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1) +
|
||||
(gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_2),
|
||||
sComposeMsgsBundle.getString('sendInUTF8'),
|
||||
null,
|
||||
sComposeMsgsBundle.getString('sendAnyway'), null, {value:0});
|
||||
switch(result3)
|
||||
{
|
||||
case 0:
|
||||
fallbackCharset.value = "UTF-8";
|
||||
break;
|
||||
case 1: // cancel
|
||||
return;
|
||||
case 2: // send anyway
|
||||
msgCompFields.needToCheckCharset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Check encoding, switch to UTF-8 if the default encoding doesn't fit.
|
||||
if (!gMsgCompose.checkCharsetConversion(getCurrentIdentity(), fallbackCharset))
|
||||
fallbackCharset.value = "UTF-8";
|
||||
|
||||
if (fallbackCharset &&
|
||||
fallbackCharset.value && fallbackCharset.value != "")
|
||||
gMsgCompose.SetDocumentCharset(fallbackCharset.value);
|
||||
|
|
|
@ -54,8 +54,6 @@
|
|||
#define NS_MSG_SENDING_MESSAGE 12550
|
||||
#define NS_MSG_POSTING_MESSAGE 12551
|
||||
|
||||
#define NS_ERROR_MSG_MULTILINGUAL_SEND NS_MSG_GENERATE_FAILURE(12553)
|
||||
|
||||
/* 12554 is taken by NS_ERROR_NNTP_NO_CROSS_POSTING. use 12555 as the next one */
|
||||
|
||||
#define NS_MSG_CANCELLING NS_MSG_GENERATE_SUCCESS(12555)
|
||||
|
|
|
@ -1083,24 +1083,14 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity
|
|||
isAsciiOnly = PR_FALSE;
|
||||
if (NS_SUCCEEDED(rv) && !outCString.IsEmpty())
|
||||
{
|
||||
// body contains characters outside the repertoire of the current
|
||||
// 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 the body contains characters outside the repertoire of the current
|
||||
// charset, just convert to UTF-8 and be done with it.
|
||||
if (NS_ERROR_UENC_NOMAPPING == rv && m_editor) {
|
||||
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 : // return to the editor
|
||||
return NS_ERROR_MSG_MULTILINGUAL_SEND;
|
||||
case 2 : // send anyway
|
||||
break;
|
||||
}
|
||||
CopyUTF16toUTF8(msgBody.get(), outCString);
|
||||
m_compFields->SetCharacterSet("UTF-8");
|
||||
}
|
||||
}
|
||||
// re-label to the fallback charset
|
||||
|
|
|
@ -142,59 +142,3 @@ 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<nsIPrompt> dialog = aPrompt;
|
||||
|
||||
if (!dialog)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
if (wwatch)
|
||||
wwatch->GetNewPrompter(0, getter_AddRefs(dialog));
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(dialog, 0);
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(bundleService, 0);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> composeBundle;
|
||||
bundleService->CreateBundle("chrome://messenger/locale/messengercompose/"
|
||||
"composeMsgs.properties",
|
||||
getter_AddRefs(composeBundle));
|
||||
NS_ENSURE_TRUE(composeBundle, 0);
|
||||
|
||||
nsString title;
|
||||
nsString msg;
|
||||
nsString sendInUTF8;
|
||||
nsString sendAnyway;
|
||||
|
||||
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(sendInUTF8));
|
||||
composeBundle->
|
||||
GetStringFromName(NS_LITERAL_STRING("sendAnyway").get(),
|
||||
getter_Copies(sendAnyway));
|
||||
|
||||
nsresult rv = dialog->
|
||||
ConfirmEx(title.get(), msg.get(),
|
||||
nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_0 +
|
||||
nsIPrompt::BUTTON_TITLE_CANCEL * nsIPrompt::BUTTON_POS_1 +
|
||||
nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_2 +
|
||||
nsIPrompt::BUTTON_POS_0_DEFAULT,
|
||||
sendInUTF8.get(), nsnull, sendAnyway.get(), nsnull, 0, &result);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, 0);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,5 @@ 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_ */
|
||||
|
|
|
@ -1832,20 +1832,9 @@ nsMsgComposeAndSend::GetBodyFromEditor()
|
|||
PRBool needToCheckCharset;
|
||||
mCompFields->GetNeedToCheckCharset(&needToCheckCharset);
|
||||
if (needToCheckCharset) {
|
||||
nsCOMPtr<nsIPrompt> 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 : // return to the editor
|
||||
Recycle(bodyText);
|
||||
return NS_ERROR_MSG_MULTILINGUAL_SEND;
|
||||
case 2 : // send anyway
|
||||
break;
|
||||
}
|
||||
// Just use UTF-8 and be done with it.
|
||||
CopyUTF16toUTF8(bodyText, outCString);
|
||||
mCompFields->SetCharacterSet("UTF-8");
|
||||
}
|
||||
}
|
||||
// re-label to the fallback charset
|
||||
|
|
|
@ -141,7 +141,7 @@ NS_IMETHODIMP nsMsgSendReport::SetCurrentProcess(PRInt32 aCurrentProcess)
|
|||
mCurrentProcess = aCurrentProcess;
|
||||
if (mProcessReport[mCurrentProcess])
|
||||
mProcessReport[mCurrentProcess]->SetProceeded(PR_TRUE);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -178,10 +178,10 @@ NS_IMETHODIMP nsMsgSendReport::SetProceeded(PRInt32 process, PRBool proceeded)
|
|||
{
|
||||
if (process < process_Current || process > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
|
||||
if (!mProcessReport[process])
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
|
@ -193,10 +193,10 @@ NS_IMETHODIMP nsMsgSendReport::SetError(PRInt32 process, nsresult newError, PRBo
|
|||
{
|
||||
if (process < process_Current || process > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
|
||||
if (!mProcessReport[process])
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
|
@ -213,10 +213,10 @@ NS_IMETHODIMP nsMsgSendReport::SetMessage(PRInt32 process, const PRUnichar *mess
|
|||
{
|
||||
if (process < process_Current || process > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
|
||||
if (!mProcessReport[process])
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
|
@ -237,7 +237,7 @@ NS_IMETHODIMP nsMsgSendReport::GetProcessReport(PRInt32 process, nsIMsgProcessRe
|
|||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
|
||||
NS_IF_ADDREF(*_retval = mProcessReport[process]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -250,13 +250,13 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError
|
|||
nsresult currError = NS_OK;
|
||||
mProcessReport[mCurrentProcess]->GetError(&currError);
|
||||
*_retval = currError;
|
||||
|
||||
|
||||
if (dontShowReportTwice && mAlreadyDisplayReport)
|
||||
return NS_OK;
|
||||
|
||||
|
||||
if (showErrorOnly && NS_SUCCEEDED(currError))
|
||||
return NS_OK;
|
||||
|
||||
|
||||
nsString currMessage;
|
||||
mProcessReport[mCurrentProcess]->GetMessage(getter_Copies(currMessage));
|
||||
|
||||
|
@ -280,7 +280,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError
|
|||
//TODO display a success error message
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//Do we have an explanation of the error? if no, try to build one...
|
||||
if (currMessage.IsEmpty())
|
||||
{
|
||||
|
@ -295,17 +295,12 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError
|
|||
case NS_MSG_UNABLE_TO_SAVE_TEMPLATE:
|
||||
//Ignore, don't need to repeat ourself.
|
||||
break;
|
||||
case NS_ERROR_MSG_MULTILINGUAL_SEND:
|
||||
// already displayed an alert, no additional message is needed
|
||||
// return to the compose window
|
||||
mAlreadyDisplayReport = PR_TRUE;
|
||||
return NS_OK;
|
||||
default:
|
||||
nsMsgBuildErrorMessageByID(currError, currMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mDeliveryMode == nsIMsgCompDeliverMode::Now || mDeliveryMode == nsIMsgCompDeliverMode::SendUnsent)
|
||||
{
|
||||
// SMTP is taking care of it's own error message and will return NS_ERROR_BUT_DONT_SHOW_ALERT as error code.
|
||||
|
@ -315,7 +310,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError
|
|||
mAlreadyDisplayReport = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
bundle->GetStringFromID(NS_MSG_SEND_ERROR_TITLE, getter_Copies(dialogTitle));
|
||||
|
||||
PRInt32 preStrId = NS_ERROR_SEND_FAILED;
|
||||
|
@ -356,7 +351,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError
|
|||
//we don't have an error description but we can put a generic explanation
|
||||
bundle->GetStringFromID(NS_MSG_GENERIC_FAILURE_EXPLANATION, getter_Copies(currMessage));
|
||||
}
|
||||
|
||||
|
||||
if (!currMessage.IsEmpty())
|
||||
{
|
||||
//Don't need to repeat ourself!
|
||||
|
@ -367,7 +362,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError
|
|||
dialogMessage.Append(currMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (askToGoBackToCompose)
|
||||
{
|
||||
PRBool oopsGiveMeBackTheComposeWindow = PR_TRUE;
|
||||
|
@ -432,7 +427,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError
|
|||
}
|
||||
nsMsgDisplayMessageByString(prompt, dialogMessage.get(), dialogTitle.get());
|
||||
}
|
||||
|
||||
|
||||
mAlreadyDisplayReport = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче