Port Bug #234186 --> Messages with mail server identity should not be sent through newsserver

to thunderbird

Patch by Christian Eyrich
This commit is contained in:
scott%scott-macgregor.org 2004-04-27 07:02:48 +00:00
parent b52c6a4485
commit c17f954b0c
2 changed files with 95 additions and 64 deletions

View File

@ -59,6 +59,8 @@ pref("editor.singleLine.pasteNewlines", 4); // substitute commas for new lines
// to avoid the height of the header area from changing when headers are present / not present // to avoid the height of the header area from changing when headers are present / not present
pref("mailnews.headers.minNumHeaders", 0); // 0 means we ignore this pref pref("mailnews.headers.minNumHeaders", 0); // 0 means we ignore this pref
pref("mail.compose.dontWarnMail2Newsgroup", false);
pref("messenger.throbber.url","chrome://messenger-region/locale/region.properties"); pref("messenger.throbber.url","chrome://messenger-region/locale/region.properties");
pref("mailnews.release_notes.url","chrome://messenger-region/locale/region.properties"); pref("mailnews.release_notes.url","chrome://messenger-region/locale/region.properties");
pref("mailnews.hints_and_tips.url","chrome://messenger-region/locale/region.properties"); pref("mailnews.hints_and_tips.url","chrome://messenger-region/locale/region.properties");

View File

@ -1626,9 +1626,9 @@ function GenericSendMessage( msgType )
if (gMsgCompose != null) if (gMsgCompose != null)
{ {
var msgCompFields = gMsgCompose.compFields; var msgCompFields = gMsgCompose.compFields;
if (msgCompFields) if (msgCompFields)
{ {
Recipients2CompFields(msgCompFields); Recipients2CompFields(msgCompFields);
var subject = document.getElementById("msgSubject").value; var subject = document.getElementById("msgSubject").value;
msgCompFields.subject = subject; msgCompFields.subject = subject;
@ -1637,9 +1637,10 @@ function GenericSendMessage( msgType )
if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later) if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later)
{ {
//Do we need to check the spelling? //Do we need to check the spelling?
if (sPrefs.getBoolPref("mail.SpellCheckBeforeSend")){ if (sPrefs.getBoolPref("mail.SpellCheckBeforeSend"))
//We disable spellcheck for the following -subject line, attachment pane, identity and addressing widget {
//therefore we need to explicitly focus on the mail body when we have to do a spellcheck. //We disable spellcheck for the following -subject line, attachment pane, identity and addressing widget
//therefore we need to explicitly focus on the mail body when we have to do a spellcheck.
window.content.focus(); window.content.focus();
window.cancelSendMessage = false; window.cancelSendMessage = false;
try { try {
@ -1649,66 +1650,95 @@ function GenericSendMessage( msgType )
catch(ex){} catch(ex){}
if(window.cancelSendMessage) if(window.cancelSendMessage)
return; return;
} }
//Check if we have a subject, else ask user for confirmation //Check if we have a subject, else ask user for confirmation
if (subject == "") if (subject == "")
{ {
if (gPromptService) if (gPromptService)
{ {
var result = {value:sComposeMsgsBundle.getString("defaultSubject")}; var result = {value:sComposeMsgsBundle.getString("defaultSubject")};
if (gPromptService.prompt( if (gPromptService.prompt(
window, window,
sComposeMsgsBundle.getString("subjectDlogTitle"), sComposeMsgsBundle.getString("subjectDlogTitle"),
sComposeMsgsBundle.getString("subjectDlogMessage"), sComposeMsgsBundle.getString("subjectDlogMessage"),
result, result,
null, null,
{value:0} {value:0}))
)) {
{ msgCompFields.subject = result.value;
msgCompFields.subject = result.value; var subjectInputElem = document.getElementById("msgSubject");
var subjectInputElem = document.getElementById("msgSubject"); subjectInputElem.value = result.value;
subjectInputElem.value = result.value; }
} else
else return;
return;
} }
} }
// Before sending the message, check what to do with HTML message, eventually abort. // check if the user tries to send a message to a newsgroup through a mail account
var convert = DetermineConvertibility(); var currentAccountKey = getCurrentAccountKey();
var action = DetermineHTMLAction(convert); var account = gAccountManager.getAccount(currentAccountKey);
if (action == nsIMsgCompSendFormat.AskUser) var servertype = account.incomingServer.type;
{
var recommAction = convert == nsIMsgCompConvertible.No if (servertype != "nntp" && msgCompFields.newsgroups != "")
? nsIMsgCompSendFormat.AskUser {
: nsIMsgCompSendFormat.PlainText; // default to ask user if the pref is not set
var result2 = {action:recommAction, var dontAskAgain = sPrefs.getBoolPref("mail.compose.dontWarnMail2Newsgroup");
convertible:convert,
abort:false}; if (!dontAskAgain)
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul", {
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen", var checkbox = {value:false};
result2); var okToProceed = gPromptService.confirmCheck(window,
if (result2.abort) sComposeMsgsBundle.getString("subjectDlogTitle"),
return; sComposeMsgsBundle.getString("recipientDlogMessage"),
action = result2.action; sComposeMsgsBundle.getString("CheckMsg"), checkbox);
}
switch (action) if (!okToProceed)
{ return;
case nsIMsgCompSendFormat.PlainText:
msgCompFields.forcePlainText = true; if (checkbox.value)
msgCompFields.useMultipartAlternative = false; sPrefs.setBoolPref(kDontAskAgainPref, true);
break; }
case nsIMsgCompSendFormat.HTML:
msgCompFields.forcePlainText = false; // remove newsgroups to prevent news_p to be set
msgCompFields.useMultipartAlternative = false; // in nsMsgComposeAndSend::DeliverMessage()
break; msgCompFields.newsgroups = "";
case nsIMsgCompSendFormat.Both: }
msgCompFields.forcePlainText = false;
msgCompFields.useMultipartAlternative = true; // Before sending the message, check what to do with HTML message, eventually abort.
break; var convert = DetermineConvertibility();
default: dump("\###SendMessage Error: invalid action value\n"); return; var action = DetermineHTMLAction(convert);
} if (action == nsIMsgCompSendFormat.AskUser)
{
var recommAction = convert == nsIMsgCompConvertible.No
? nsIMsgCompSendFormat.AskUser
: nsIMsgCompSendFormat.PlainText;
var result2 = {action:recommAction,
convertible:convert,
abort:false};
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul",
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen",
result2);
if (result2.abort)
return;
action = result2.action;
}
switch (action)
{
case nsIMsgCompSendFormat.PlainText:
msgCompFields.forcePlainText = true;
msgCompFields.useMultipartAlternative = false;
break;
case nsIMsgCompSendFormat.HTML:
msgCompFields.forcePlainText = false;
msgCompFields.useMultipartAlternative = false;
break;
case nsIMsgCompSendFormat.Both:
msgCompFields.forcePlainText = false;
msgCompFields.useMultipartAlternative = true;
break;
default: dump("\###SendMessage Error: invalid action value\n"); return;
}
} }
// hook for extra compose pre-processing // hook for extra compose pre-processing
@ -1755,8 +1785,7 @@ function GenericSendMessage( msgType )
gSendOrSaveOperationInProgress = true; gSendOrSaveOperationInProgress = true;
} }
msgWindow.SetDOMWindow(window); msgWindow.SetDOMWindow(window);
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), currentAccountKey, msgWindow, progress);
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), getCurrentAccountKey(), msgWindow, progress);
} }
catch (ex) { catch (ex) {
dump("failed to SendMsg: " + ex + "\n"); dump("failed to SendMsg: " + ex + "\n");