mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Fix for bug 31693. Disable UI element when a Send/Save is in process. R=putterman
This commit is contained in:
parent
2c5ff8e18e
commit
aebd5a3190
@ -95,9 +95,9 @@ interface nsIMsgComposeStateListener : nsISupports
|
||||
{
|
||||
/* ... */
|
||||
void NotifyComposeFieldsReady();
|
||||
void SendAndSaveProcessDone();
|
||||
};
|
||||
|
||||
|
||||
[scriptable, uuid(4E606270-B588-11D2-8289-00805F2A0107)]
|
||||
interface nsIMsgCompose : nsISupports {
|
||||
|
||||
@ -118,15 +118,13 @@ interface nsIMsgCompose : nsISupports {
|
||||
|
||||
/* ... */
|
||||
void SendMsg(in MSG_DeliverMode deliverMode,
|
||||
in nsIMsgIdentity identity,
|
||||
in wstring callback);
|
||||
in nsIMsgIdentity identity);
|
||||
|
||||
/* ... */
|
||||
void SendMsgEx(in MSG_DeliverMode deliverMode,
|
||||
in nsIMsgIdentity identity,
|
||||
in wstring addrTo, in wstring addrCc, in wstring addrBcc,
|
||||
in wstring newsgroup, in wstring subject, in wstring body,
|
||||
in wstring callback);
|
||||
in wstring newsgroup, in wstring subject, in wstring body);
|
||||
|
||||
/* ... */
|
||||
void CloseWindow();
|
||||
|
@ -37,6 +37,7 @@ var msgCompose = null;
|
||||
var MAX_RECIPIENTS = 0;
|
||||
var currentAttachment = null;
|
||||
var documentLoaded = false;
|
||||
var windowLocked = false;
|
||||
var contentChanged = false;
|
||||
|
||||
var Bundle = srGetStrBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties");
|
||||
@ -65,9 +66,13 @@ if (prefs) {
|
||||
|
||||
var stateListener = {
|
||||
NotifyComposeFieldsReady: function() {
|
||||
// dump("\n RECEIVE NotifyComposeFieldsReady\n\n");
|
||||
documentLoaded = true;
|
||||
msgCompose.UnregisterStateListener(stateListener);
|
||||
},
|
||||
|
||||
SendAndSaveProcessDone: function() {
|
||||
dump("\n RECEIVE SaveAndSendProcessDone\n\n");
|
||||
windowLocked = false;
|
||||
CommandUpdate_MsgCompose();
|
||||
}
|
||||
};
|
||||
|
||||
@ -76,6 +81,92 @@ var currentMailSendCharset = null;
|
||||
var g_send_default_charset = null;
|
||||
var g_charsetTitle = null;
|
||||
|
||||
|
||||
var defaultController =
|
||||
{
|
||||
supportsCommand: function(command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case "cmd_sendNow":
|
||||
case "cmd_sendLater":
|
||||
case "cmd_saveDefault":
|
||||
case "cmd_saveAsDraft":
|
||||
case "cmd_saveAsTemplate":
|
||||
case "cmd_attachFile":
|
||||
case "cmd_selectAddress":
|
||||
return true;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
},
|
||||
|
||||
isCommandEnabled: function(command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case "cmd_sendNow":
|
||||
case "cmd_sendLater":
|
||||
case "cmd_saveDefault":
|
||||
case "cmd_saveAsDraft":
|
||||
case "cmd_saveAsTemplate":
|
||||
case "cmd_attachFile":
|
||||
case "cmd_selectAddress":
|
||||
return !windowLocked;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function(command)
|
||||
{
|
||||
dump("DefaultController:doCommand\n");
|
||||
/* Because disabled button still fire oncommand event, we need to test again!!! */
|
||||
if (defaultController.isCommandEnabled(command))
|
||||
switch (command)
|
||||
{
|
||||
case "cmd_sendNow" : SendMessage(); break;
|
||||
case "cmd_sendLater" : SendMessageLater(); break;
|
||||
case "cmd_saveDefault" : SaveAsDraft(); break; /* TEMPORARY: We should save either as file, as draft or template, depending of last save type */
|
||||
case "cmd_saveAsDraft" : SaveAsDraft(); break;
|
||||
case "cmd_saveAsTemplate" : SaveAsTemplate(); break;
|
||||
case "cmd_attachFile" : AttachFile(); break;
|
||||
case "cmd_selectAddress" : SelectAddress(); break;
|
||||
|
||||
default: return;
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function(event)
|
||||
{
|
||||
dump("DefaultController:onEvent\n");
|
||||
}
|
||||
}
|
||||
|
||||
function SetupCommandUpdateHandlers()
|
||||
{
|
||||
dump("SetupCommandUpdateHandlers\n");
|
||||
top.controllers.insertControllerAt(0, defaultController);
|
||||
}
|
||||
|
||||
function CommandUpdate_MsgCompose()
|
||||
{
|
||||
dump("CommandUpdate_MsgCompose\n");
|
||||
goUpdateCommand("cmd_sendNow");
|
||||
goUpdateCommand("cmd_sendLater");
|
||||
goUpdateCommand("cmd_saveDefault");
|
||||
goUpdateCommand("cmd_saveAsDraft");
|
||||
goUpdateCommand("cmd_saveAsTemplate");
|
||||
goUpdateCommand("cmd_attachFile");
|
||||
goUpdateCommand("cmd_selectAddress");
|
||||
}
|
||||
|
||||
function ToggleWindowLock()
|
||||
{
|
||||
windowLocked = !windowLocked;
|
||||
CommandUpdate_MsgCompose();
|
||||
}
|
||||
|
||||
function GetArgs()
|
||||
{
|
||||
var args = new Object();
|
||||
@ -304,6 +395,8 @@ function ComposeStartup()
|
||||
function ComposeLoad()
|
||||
{
|
||||
dump("\nComposeLoad from XUL\n");
|
||||
|
||||
SetupCommandUpdateHandlers();
|
||||
|
||||
verifyAccounts(); // this will do migration, if we need to.
|
||||
|
||||
@ -330,6 +423,7 @@ function ComposeUnload(calledFromExit)
|
||||
{
|
||||
dump("\nComposeUnload from XUL\n");
|
||||
|
||||
msgCompose.UnregisterStateListener(stateListener);
|
||||
if (msgCompose && msgComposeService)
|
||||
msgComposeService.DisposeCompose(msgCompose, false);
|
||||
//...and what's about the editor appcore, how can we release it?
|
||||
@ -552,12 +646,16 @@ function GenericSendMessage( msgType )
|
||||
}
|
||||
}
|
||||
try {
|
||||
windowLocked = true;
|
||||
CommandUpdate_MsgCompose();
|
||||
msgCompose.SendMsg(msgType, getCurrentIdentity(), null);
|
||||
contentChanged = false;
|
||||
msgCompose.bodyModified = false;
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to SendMsg\n");
|
||||
windowLocked = false;
|
||||
CommandUpdate_MsgCompose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,16 +72,21 @@ Rights Reserved.
|
||||
<script language="JavaScript" src="chrome://messenger/content/messengercompose/MsgComposeCommands.js"/>
|
||||
|
||||
<commands id="commands">
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
<commandset id="selectEditMenuItems"/>
|
||||
<commandset id="undoEditMenuItems"/>
|
||||
<commandset id="msgComposeCommandUpdate"
|
||||
commandupdater="true"
|
||||
events="focus,tree-select"
|
||||
oncommandupdate="CommandUpdate_MsgCompose()"
|
||||
/>
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
<commandset id="selectEditMenuItems"/>
|
||||
<commandset id="undoEditMenuItems"/>
|
||||
|
||||
<commandset id="composerMenuItems"/>
|
||||
<commandset id="composerEditMenuItems"/>
|
||||
<commandset id="composerSaveMenuItems"/>
|
||||
<commandset id="composerStyleMenuItems"/>
|
||||
<commandset id="composerTableMenuItems"/>
|
||||
<commandset id="composerListMenuItems"/>
|
||||
<commandset id="composerMenuItems"/>
|
||||
<commandset id="composerEditMenuItems"/>
|
||||
<commandset id="composerSaveMenuItems"/>
|
||||
<commandset id="composerStyleMenuItems"/>
|
||||
<commandset id="composerTableMenuItems"/>
|
||||
<commandset id="composerListMenuItems"/>
|
||||
</commands>
|
||||
|
||||
<broadcasterset id="broadcasterset">
|
||||
@ -89,10 +94,13 @@ Rights Reserved.
|
||||
<broadcaster id="cmd_newNavigator"/>
|
||||
<broadcaster id="cmd_newEditor"/>
|
||||
<broadcaster id="cmd_close" oncommand="if (ComposeCanClose()) CloseWindow()"/>
|
||||
<broadcaster id="cmd_attachFile" oncommand="AttachFile()"/>
|
||||
<broadcaster id="cmd_selectAddress" oncommand="SelectAddress()"/>
|
||||
<broadcaster id="cmd_sendNow" oncommand="SendMessage()"/>
|
||||
<broadcaster id="cmd_sendLater" oncommand="SendMessageLater()"/>
|
||||
<broadcaster id="cmd_saveDefault" oncommand="goDoCommand('cmd_saveDefault')"/>
|
||||
<broadcaster id="cmd_saveAsDraft" oncommand="goDoCommand('cmd_saveAsDraft')"/>
|
||||
<broadcaster id="cmd_saveAsTemplate" oncommand="goDoCommand('cmd_saveAsTemplate')"/>
|
||||
<broadcaster id="cmd_attachFile" oncommand="goDoCommand('cmd_attachFile')"/>
|
||||
<broadcaster id="cmd_selectAddress" oncommand="goDoCommand('cmd_selectAddress')"/>
|
||||
<broadcaster id="cmd_sendNow" oncommand="goDoCommand('cmd_sendNow')"/>
|
||||
<broadcaster id="cmd_sendLater" oncommand="goDoCommand('cmd_sendLater')"/>
|
||||
<broadcaster id="cmd_print" oncommand="nsCmd:BrowserPrint"/>
|
||||
<broadcaster id="cmd_quit"/>
|
||||
<!-- Edit Menu -->
|
||||
@ -124,7 +132,7 @@ Rights Reserved.
|
||||
<!-- File Menu -->
|
||||
<key id="key_newNavigator"/>
|
||||
<key id="key_close"/>
|
||||
<key id="key_save" xulkey="true" key="&saveCmd.key;" disabled="true"/>
|
||||
<key id="key_save" xulkey="true" key="&saveCmd.key;" observes="cmd_saveDefault"/>
|
||||
<!-- key id="key_attachFile" xulkey="true" key="&attachFileCmd.key;" observes="cmd_attachFile"/ -->
|
||||
<!-- key id="key_selectAddresses" xulkey="true" key="&selectAddressCmd.key;" observes="cmd_selectAddress"/ -->
|
||||
<!-- key id="key_sendNow" xulkey="true" keycode="&sendNowCmd.keycode;" observes="cmd_sendNow"/ -->
|
||||
@ -187,13 +195,13 @@ ACTUALLY, EVERY TIME YOU TYPE ANY OF THE KEY DEFINED HERE AFTER WITHOUT ANY OF T
|
||||
<menuseparator/>
|
||||
|
||||
<menuitem id="menu_close"/>
|
||||
<menuitem value="&saveCmd.label;" disabled="true" key="key_save"/>
|
||||
<menuitem value="&saveCmd.label;" key="key_save" observes="cmd_saveDefault"/>
|
||||
<menu value="&saveAsCmd.label;" accessKey="&saveAsCmd.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem value="&saveAsFileCmd.label;" disabled="true" accessKey="&saveAsFileCmd.accesskey;"/>
|
||||
<menuseparator/>
|
||||
<menuitem value="&saveAsDraftCmd.label;" accessKey="&saveAsDraftCmd.accesskey;" oncommand="SaveAsDraft()"/>
|
||||
<menuitem value="&saveAsTemplateCmd.label;" accessKey="&saveAsTemplateCmd.accesskey;" oncommand="SaveAsTemplate()"/>
|
||||
<menuitem value="&saveAsDraftCmd.label;" accessKey="&saveAsDraftCmd.accesskey;" observes="cmd_saveAsDraft"/>
|
||||
<menuitem value="&saveAsTemplateCmd.label;" accessKey="&saveAsTemplateCmd.accesskey;" observes="cmd_saveAsTemplate"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
@ -257,43 +265,7 @@ ACTUALLY, EVERY TIME YOU TYPE ANY OF THE KEY DEFINED HERE AFTER WITHOUT ANY OF T
|
||||
<menuseparator/>
|
||||
<menuitem value="&pageInfoCmd.label;" disabled="true" accesskey="&pageInfoCmd.accesskey;" cmd="nsCmd:ComposeNYI"/>
|
||||
<menuseparator/>
|
||||
<!-- Deprecated BEGIN
|
||||
<menu value="&dcharMenu.label;" oncreate="InitCharsetMenuCheckMark();">
|
||||
<menupopup>
|
||||
<menuitem id="ISO-8859-1" type="radio" name="charsetGroup" value="&dcharIso1Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id="ISO-8859-2" type="radio" name="charsetGroup" value="&dcharIso2Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id="ISO-8859-3" type="radio" name="charsetGroup" value="&dcharIso3Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id="ISO-8859-4" type="radio" name="charsetGroup" value="&dcharIso4Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id="ISO-8859-9" type="radio" name="charsetGroup" value="&dcharIso9Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id="ISO-8859-10" type="radio" name="charsetGroup" value="&dcharIso10Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id= "ISO-8859-14" type="radio" name="charsetGroup" value="&dcharIso14Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id="ISO-8859-15" type="radio" name="charsetGroup" value="&dcharIso15Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="ISO-2022-JP" type="radio" name="charsetGroup" value="&dcharJapanCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="BIG5" type="radio" name="charsetGroup" value="&dcharTradChiBigCmd.label;" oncommand="SetDocumentCharacterSet('Big5');"/>
|
||||
<menuitem id="GB2312" type="radio" name="charsetGroup" value="&dcharSimpChiGbCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="EUC-KR" type="radio" name="charsetGroup" value="&dcharKoreanCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="UTF-8" type="radio" name="charsetGroup" value="&dcharUtf8Cmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="KOI8-R" type="radio" name="charsetGroup" value="&dcharRusCmd.label; " oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuitem id="KOI8-U" type="radio" name="charsetGroup" value="&dcharUkrCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="ISO-8859-7" type="radio" name="charsetGroup" value="&dcharIsoGreekCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="VISCII" type="radio" name="charsetGroup" value="&dcharVietViCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="TIS-620" type="radio" name="charsetGroup" value="&dcharThaiCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem id="ARMSCII-8" type="radio" name="charsetGroup" value="&dcharArmCmd.label;" oncommand="SetDocumentCharacterSet(this.id);"/>
|
||||
<menuseparator />
|
||||
<menuitem value="&dcharDEFAULT.label;" oncommand="SetDefaultMailSendCharacterSet();"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
END of Deprecated -->
|
||||
<menu id = "maileditCharsetMenu" />
|
||||
<menu id = "maileditCharsetMenu" />
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
@ -402,15 +374,15 @@ END of Deprecated -->
|
||||
</menubar>
|
||||
<toolbar class="toolbar-primary" id="composeToolbar" persist="collapsed">
|
||||
<box id="toolbar_button_box">
|
||||
<button class="button-toolbar-2 top" id="button-send" value="&sendButton.label;" tooltip="aTooltip" tooltiptext="&sendButton.tooltip;" onclick="SendMessage()"/>
|
||||
<button class="button-toolbar-2 top" id="button-send" value="&sendButton.label;" tooltip="aTooltip" tooltiptext="&sendButton.tooltip;" observes="cmd_sendNow"/>
|
||||
<toolbarseparator/>
|
||||
<button class="button-toolbar-2 top" id="button-address" value="&addressButton.label;" tooltip="aTooltip" tooltiptext="&addressButton.tooltip;" onclick="SelectAddress()"/>
|
||||
<button class="button-toolbar-2 top" id="button-attach" value="&attachButton.label;" tooltip="aTooltip" tooltiptext="&attachButton.tooltip;" onclick="AttachFile()"/>
|
||||
<button class="button-toolbar-2 top" id="button-quote" disabled="true" value=""eButton.label;" tooltip="aTooltip" tooltiptext=""eButton.tooltip;" onclick="QuoteMessage()"/>
|
||||
<button class="button-toolbar-2 top" id="button-address" value="&addressButton.label;" tooltip="aTooltip" tooltiptext="&addressButton.tooltip;" observes="cmd_selectAddress"/>
|
||||
<button class="button-toolbar-2 top" id="button-attach" value="&attachButton.label;" tooltip="aTooltip" tooltiptext="&attachButton.tooltip;" observes="cmd_attachFile"/>
|
||||
<button class="button-toolbar-2 top" id="button-quote" disabled="true" value=""eButton.label;" tooltip="aTooltip" tooltiptext=""eButton.tooltip;" onclick="if (this.getAttribute('disabled') != 'true') QuoteMessage()"/>
|
||||
<button class="button-toolbar-2 top" id="spellingButton" value="&spellingButton.label;" observes="cmd_spelling"/>
|
||||
<toolbarseparator/>
|
||||
<button class="button-toolbar-2 top" id="button-save" value="&saveButton.label;" tooltip="aTooltip" tooltiptext="&saveButton.tooltip;" onclick="SaveAsDraft()"/>
|
||||
<button class="button-toolbar-2 top" id="button-stop" disabled="true" value="&stopButton.label;" tooltip="aTooltip" tooltiptext="&stopButton.tooltip;" onclick="Stop()"/>
|
||||
<button class="button-toolbar-2 top" id="button-save" value="&saveButton.label;" tooltip="aTooltip" tooltiptext="&saveButton.tooltip;" observes="cmd_saveDefault"/>
|
||||
<button class="button-toolbar-2 top" id="button-stop" disabled="true" value="&stopButton.label;" tooltip="aTooltip" tooltiptext="&stopButton.tooltip;" onclick="if (this.getAttribute('disabled') != 'true') Stop()"/>
|
||||
<spring flex="100%"/>
|
||||
</box>
|
||||
<button class="plain" id="navigator-throbber" oncommand='goClickThrobber("compose.throbber.url")'>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<!-- File menu items -->
|
||||
<!ENTITY newMessage.label "New Message">
|
||||
<!ENTITY newMessage.accesskey "n">
|
||||
<!ENTITY saveCmd.label ".Save">
|
||||
<!ENTITY saveCmd.label "Save">
|
||||
<!ENTITY saveCmd.key "S">
|
||||
<!ENTITY saveAsCmd.label "Save As">
|
||||
<!ENTITY saveAsCmd.accesskey "s">
|
||||
|
@ -465,9 +465,7 @@ nsresult nsMsgCompose::UnregisterStateListener(nsIMsgComposeStateListener *state
|
||||
return mStateListeners->RemoveElement(iSupports);
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode,
|
||||
nsIMsgIdentity *identity,
|
||||
const PRUnichar *callback)
|
||||
nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -596,7 +594,7 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode,
|
||||
nsnull, // const struct nsMsgAttachmentData *attachments,
|
||||
nsnull, // const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
nsnull, // nsMsgSendPart *relatedPart,
|
||||
tArray, listeners); // listener array
|
||||
tArray, listeners); // listener array
|
||||
|
||||
// Cleanup converted body...
|
||||
if (newBody)
|
||||
@ -612,17 +610,6 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode,
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
/*TODO, don't close the window but just hide it, we will close it later when we receive a call back from the BE
|
||||
if (nsnull != mScriptContext) {
|
||||
const char* url = "";
|
||||
PRBool isUndefined = PR_FALSE;
|
||||
nsString rVal;
|
||||
|
||||
mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined);
|
||||
CloseWindow();
|
||||
}
|
||||
else // If we don't have a JS callback, then close the window by default!
|
||||
*/
|
||||
// rhp:
|
||||
// We shouldn't close the window if we are just saving a draft or a template
|
||||
// so do this check
|
||||
@ -630,13 +617,14 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode,
|
||||
(deliverMode != nsIMsgSend::nsMsgSaveAsTemplate) )
|
||||
ShowWindow(PR_FALSE);
|
||||
}
|
||||
else
|
||||
NotifyStateListeners(eSaveAndSendProcessDone);
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
|
||||
nsIMsgIdentity *identity,
|
||||
const PRUnichar *callback)
|
||||
nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -695,7 +683,7 @@ nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
|
||||
}
|
||||
}
|
||||
|
||||
rv = _SendMsg(deliverMode, identity, callback);
|
||||
rv = _SendMsg(deliverMode, identity);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
ShowWindow(PR_TRUE);
|
||||
@ -712,8 +700,7 @@ nsMsgCompose::SendMsgEx(MSG_DeliverMode deliverMode,
|
||||
nsIMsgIdentity *identity,
|
||||
const PRUnichar *addrTo, const PRUnichar *addrCc,
|
||||
const PRUnichar *addrBcc, const PRUnichar *newsgroup,
|
||||
const PRUnichar *subject, const PRUnichar *body,
|
||||
const PRUnichar *callback)
|
||||
const PRUnichar *subject, const PRUnichar *body)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -791,7 +778,7 @@ nsMsgCompose::SendMsgEx(MSG_DeliverMode deliverMode,
|
||||
m_compFields->SetBody(bodyCStr);
|
||||
}
|
||||
|
||||
rv = _SendMsg(deliverMode, identity, callback);
|
||||
rv = _SendMsg(deliverMode, identity);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_NOT_INITIALIZED;
|
||||
@ -799,7 +786,7 @@ nsMsgCompose::SendMsgEx(MSG_DeliverMode deliverMode,
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
ShowWindow(PR_TRUE);
|
||||
if (rv != NS_ERROR_BUT_DONT_SHOW_ALERT)
|
||||
if (rv != NS_ERROR_BUT_DONT_SHOW_ALERT)
|
||||
nsMsgDisplayMessageByID(rv);
|
||||
}
|
||||
return rv;
|
||||
@ -1708,13 +1695,19 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
|
||||
{
|
||||
if (fieldsFCC && *fieldsFCC)
|
||||
{
|
||||
if (nsCRT::strcasecmp(fieldsFCC, "nocopy://") == 0)
|
||||
if (nsCRT::strcasecmp(fieldsFCC, "nocopy://") == 0)
|
||||
{
|
||||
mComposeObj->NotifyStateListeners(nsMsgCompose::eSaveAndSendProcessDone);
|
||||
mComposeObj->CloseWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mComposeObj->NotifyStateListeners(nsMsgCompose::eSaveAndSendProcessDone);
|
||||
mComposeObj->CloseWindow(); // if we fail on the simple GetFcc call, close the window to be safe and avoid
|
||||
// windows hanging around to prevent the app from exiting.
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(compFields);
|
||||
}
|
||||
@ -1723,6 +1716,7 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsMsgComposeSendListener: the message send operation failed!\n");
|
||||
#endif
|
||||
mComposeObj->NotifyStateListeners(nsMsgCompose::eSaveAndSendProcessDone);
|
||||
mComposeObj->ShowWindow(PR_TRUE);
|
||||
}
|
||||
}
|
||||
@ -1764,6 +1758,7 @@ nsMsgComposeSendListener::OnStopCopy(nsresult aStatus)
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsMsgComposeSendListener: Success on the message copy operation!\n");
|
||||
#endif
|
||||
mComposeObj->NotifyStateListeners(nsMsgCompose::eSaveAndSendProcessDone);
|
||||
// We should only close the window if we are done. Things like templates
|
||||
// and drafts aren't done so their windows should stay open
|
||||
if ( (mDeliverMode != nsIMsgSend::nsMsgSaveAsDraft) &&
|
||||
@ -1775,6 +1770,7 @@ nsMsgComposeSendListener::OnStopCopy(nsresult aStatus)
|
||||
#ifdef NS_DEBUG
|
||||
printf("nsMsgComposeSendListener: the message copy operation failed!\n");
|
||||
#endif
|
||||
mComposeObj->NotifyStateListeners(nsMsgCompose::eSaveAndSendProcessDone);
|
||||
mComposeObj->ShowWindow(PR_TRUE);
|
||||
}
|
||||
}
|
||||
@ -2161,27 +2157,30 @@ nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotifica
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint32 i;
|
||||
switch (aNotificationType)
|
||||
for (i = 0; i < numListeners;i++)
|
||||
{
|
||||
case eComposeFieldsReady:
|
||||
for (i = 0; i < numListeners;i++)
|
||||
nsCOMPtr<nsISupports> iSupports = getter_AddRefs(mStateListeners->ElementAt(i));
|
||||
nsCOMPtr<nsIMsgComposeStateListener> thisListener = do_QueryInterface(iSupports);
|
||||
if (thisListener)
|
||||
{
|
||||
switch (aNotificationType)
|
||||
{
|
||||
nsCOMPtr<nsISupports> iSupports = getter_AddRefs(mStateListeners->ElementAt(i));
|
||||
nsCOMPtr<nsIMsgComposeStateListener> thisListener = do_QueryInterface(iSupports);
|
||||
if (thisListener)
|
||||
{
|
||||
rv = thisListener->NotifyComposeFieldsReady();
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
}
|
||||
case eComposeFieldsReady:
|
||||
thisListener->NotifyComposeFieldsReady();
|
||||
break;
|
||||
|
||||
case eSaveAndSendProcessDone:
|
||||
thisListener->SendAndSaveProcessDone();
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_NOTREACHED("Unknown notification");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_NOTREACHED("Unknown notification");
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::AttachmentPrettyName(const PRUnichar* url, PRUnichar** _retval)
|
||||
|
@ -89,13 +89,14 @@ class nsMsgCompose : public nsIMsgCompose
|
||||
}
|
||||
|
||||
private:
|
||||
nsresult _SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const PRUnichar *callback);
|
||||
nsresult _SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity);
|
||||
nsresult CreateMessage(const PRUnichar * originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgCompFields* compFields);
|
||||
void CleanUpRecipients(nsString& recipients);
|
||||
nsresult GetABDirectories(nsString& filePath, nsStringArray* directoriesArray, PRBool searchSubDirectory);
|
||||
|
||||
typedef enum {
|
||||
eComposeFieldsReady
|
||||
eComposeFieldsReady,
|
||||
eSaveAndSendProcessDone
|
||||
} TStateListenerNotification;
|
||||
|
||||
// tell the doc state listeners that the doc state has changed
|
||||
@ -124,8 +125,9 @@ class nsMsgCompose : public nsIMsgCompose
|
||||
MSG_ComposeType mType; //Message type
|
||||
nsCOMPtr<nsISupportsArray> mStateListeners; // contents are nsISupports
|
||||
|
||||
friend class QuotingOutputStreamListener;
|
||||
friend class QuotingOutputStreamListener;
|
||||
friend class nsMsgDocumentStateListener;
|
||||
friend class nsMsgComposeSendListener;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user