From b6db40a7367beb830218230d55b369d813d1f62b Mon Sep 17 00:00:00 2001 From: "varada%netscape.com" Date: Fri, 11 May 2001 00:22:38 +0000 Subject: [PATCH] bug#55236 - fix for throwing save as draft dialog when send fails;r=ducarroz;sr=sspitzer --- mailnews/compose/public/nsIMsgCompose.idl | 6 +++--- .../resources/content/MsgComposeCommands.js | 13 ++++++++----- mailnews/compose/src/nsMsgCompose.cpp | 18 +++++++++--------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/mailnews/compose/public/nsIMsgCompose.idl b/mailnews/compose/public/nsIMsgCompose.idl index d3a0dd1cd537..d97453862b80 100644 --- a/mailnews/compose/public/nsIMsgCompose.idl +++ b/mailnews/compose/public/nsIMsgCompose.idl @@ -88,8 +88,8 @@ interface nsIMsgComposeStateListener : nsISupports { /* ... */ void NotifyComposeFieldsReady(); - void ComposeProcessDone(); - void SaveInFolderDone(in string folderName); + void ComposeProcessDone(in nsresult aResult); + void SaveInFolderDone(in string folderName); }; %{ C++ @@ -206,7 +206,7 @@ interface nsIMsgCompose : nsISupports { in nsStringRef aSignature, in boolean aQuoted, in boolean aHTMLEditor); /* Tell the doc state listeners that the doc state has changed */ - [noscript] void notifyStateListeners(in TStateListenerNotification aNotificationType); + [noscript] void notifyStateListeners(in TStateListenerNotification aNotificationType, in nsresult aResult); /* Retreive the progress object */ [noscript] nsIMsgProgress getProgress(); diff --git a/mailnews/compose/resources/content/MsgComposeCommands.js b/mailnews/compose/resources/content/MsgComposeCommands.js index 5058b007fb7a..3d63f3c5445f 100644 --- a/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mailnews/compose/resources/content/MsgComposeCommands.js @@ -80,10 +80,15 @@ var stateListener = { ComposeFieldsReady(); }, - ComposeProcessDone: function() { + ComposeProcessDone: function(aResult) { dump("\n RECEIVE ComposeProcessDone\n\n"); windowLocked = false; CommandUpdate_MsgCompose(); + if (aResult== Components.results.NS_OK) + { + contentChanged = false; + msgCompose.bodyModified = false; + } }, SaveInFolderDone: function(folderURI) { @@ -1084,8 +1089,8 @@ function GenericSendMessage( msgType ) // Before sending the message, check what to do with HTML message, eventually abort. var convert = DetermineConvertibility(); - var action = DetermineHTMLAction(convert); - if (action == msgCompSendFormat.AskUser) + var action = DetermineHTMLAction(convert); + if (action == msgCompSendFormat.AskUser) { var recommAction = convert == msgCompConvertible.No ? msgCompSendFormat.AskUser @@ -1128,8 +1133,6 @@ function GenericSendMessage( msgType ) sendOrSaveOperationInProgress = true; } msgCompose.SendMsg(msgType, getCurrentIdentity(), progress); - contentChanged = false; - msgCompose.bodyModified = false; } catch (ex) { dump("failed to SendMsg: " + ex + "\n"); diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 5f57e6860869..71e8bb5b5f12 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -657,7 +657,7 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide rv = NS_ERROR_NOT_INITIALIZED; if (NS_FAILED(rv)) - NotifyStateListeners(eComposeProcessDone); + NotifyStateListeners(eComposeProcessDone,rv); return rv; } @@ -1465,7 +1465,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns composeService->TimeStamp("done with mime. Lets update some UI element", PR_FALSE); #endif - compose->NotifyStateListeners(eComposeFieldsReady); + compose->NotifyStateListeners(eComposeFieldsReady,NS_OK); #ifdef MSGCOMP_TRACE_PERFORMANCE composeService->TimeStamp("addressing widget, windows title and focus are now set, time to insert the body", PR_FALSE); @@ -1816,7 +1816,7 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS { if (nsCRT::strcasecmp(fieldsFCC, "nocopy://") == 0) { - compose->NotifyStateListeners(eComposeProcessDone); + compose->NotifyStateListeners(eComposeProcessDone, NS_OK); if (progress) progress->CloseProgressDialog(PR_FALSE); compose->CloseWindow(); @@ -1825,7 +1825,7 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS } else { - compose->NotifyStateListeners(eComposeProcessDone); + compose->NotifyStateListeners(eComposeProcessDone, NS_OK); if (progress) progress->CloseProgressDialog(PR_FALSE); compose->CloseWindow(); // if we fail on the simple GetFcc call, close the window to be safe and avoid @@ -1844,7 +1844,7 @@ nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aS #ifdef NS_DEBUG printf("nsMsgComposeSendListener: the message send operation failed!\n"); #endif - compose->NotifyStateListeners(eComposeProcessDone); + compose->NotifyStateListeners(eComposeProcessDone,aStatus); if (progress) progress->CloseProgressDialog(PR_TRUE); } @@ -1899,7 +1899,7 @@ nsMsgComposeSendListener::OnStopCopy(nsresult aStatus) compose->GetProgress(getter_AddRefs(progress)); if (progress) progress->CloseProgressDialog(NS_FAILED(aStatus)); - compose->NotifyStateListeners(eComposeProcessDone); + compose->NotifyStateListeners(eComposeProcessDone,aStatus); if (NS_SUCCEEDED(aStatus)) { @@ -2147,7 +2147,7 @@ nsMsgDocumentStateListener::NotifyDocumentCreated(void) return compose->BuildQuotedMessageAndSignature(); else { - compose->NotifyStateListeners(eComposeFieldsReady); + compose->NotifyStateListeners(eComposeFieldsReady,NS_OK); return compose->BuildBodyMessageAndSignature(); } } @@ -2496,7 +2496,7 @@ nsMsgCompose::BuildBodyMessageAndSignature() return rv; } -nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotificationType) +nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotificationType, nsresult aResult) { if (!mStateListeners) return NS_OK; // maybe there just aren't any. @@ -2519,7 +2519,7 @@ nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotifica break; case eComposeProcessDone: - thisListener->ComposeProcessDone(); + thisListener->ComposeProcessDone(aResult); break; case eSaveInFolderDone: