diff --git a/mailnews/compose/public/nsIMsgSendListener.idl b/mailnews/compose/public/nsIMsgSendListener.idl index 6123e9aa9794..3200ac3bfa92 100644 --- a/mailnews/compose/public/nsIMsgSendListener.idl +++ b/mailnews/compose/public/nsIMsgSendListener.idl @@ -80,4 +80,10 @@ interface nsIMsgSendListener : nsISupports { */ void onGetDraftFolderURI(in string aFolderURI); + /** + * Notify the observer when the user aborts the send without actually doing the send + * eg : by closing the compose window without Send. + */ + void onSendNotPerformed(in string aMsgID, in nsresult aStatus); + }; diff --git a/mailnews/compose/resources/content/MsgComposeCommands.js b/mailnews/compose/resources/content/MsgComposeCommands.js index bbd5242657fe..2cd3b45149f1 100644 --- a/mailnews/compose/resources/content/MsgComposeCommands.js +++ b/mailnews/compose/resources/content/MsgComposeCommands.js @@ -206,8 +206,19 @@ var stateListener = { SetContentAndBodyAsUnmodified(); if (gCloseWindowAfterSave) + { + // Notify the SendListener that Send has been aborted and Stopped + if (gMsgCompose) + { + var externalListener = gMsgCompose.getExternalSendListener(); + if (externalListener) + { + externalListener.onSendNotPerformed(null, Components.results.NS_ERROR_ABORT); + } + } MsgComposeCloseWindow(true); } + } gCloseWindowAfterSave = false; }, @@ -996,6 +1007,17 @@ function DoCommandClose() { var retVal; if ((retVal = ComposeCanClose())) { + + // Notify the SendListener that Send has been aborted and Stopped + if (gMsgCompose) + { + var externalListener = gMsgCompose.getExternalSendListener(); + if (externalListener) + { + externalListener.onSendNotPerformed(null, Components.results.NS_ERROR_ABORT); + } + } + MsgComposeCloseWindow(true); // at this point, we might be caching this window. // in which case, we don't want to close it diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 7775d8ad6d8e..71c152b36884 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -2284,6 +2284,29 @@ nsMsgComposeSendListener::OnStatus(const char *aMsgID, const PRUnichar *aMsg) return NS_OK; } +nsresult nsMsgComposeSendListener::OnSendNotPerformed(const char *aMsgID, nsresult aStatus) +{ + // since OnSendNotPerformed is called in the case where the user aborts the operation + // by closing the compose window, we need not do the stuff required + // for closing the windows. However we would need to do the other operations as below. + + nsresult rv = NS_OK; + + nsCOMPtrcompose = do_QueryReferent(mWeakComposeObj); + if (compose) + { + compose->NotifyStateListeners(eComposeProcessDone,aStatus); + + nsCOMPtr externalListener; + compose->GetExternalSendListener(getter_AddRefs(externalListener)); + if (externalListener) + externalListener->OnSendNotPerformed(aMsgID, aStatus) ; + } + + return rv ; +} + + nsresult nsMsgComposeSendListener::OnStopSending(const char *aMsgID, nsresult aStatus, const PRUnichar *aMsg, nsIFileSpec *returnFileSpec) { diff --git a/mailnews/compose/src/nsMsgSendLater.cpp b/mailnews/compose/src/nsMsgSendLater.cpp index 60ffb3b955e3..fdbe7b67dad1 100644 --- a/mailnews/compose/src/nsMsgSendLater.cpp +++ b/mailnews/compose/src/nsMsgSendLater.cpp @@ -376,6 +376,12 @@ SendOperationListener::OnStatus(const char *aMsgID, const PRUnichar *aMsg) return NS_OK; } + +nsresult +SendOperationListener::OnSendNotPerformed(const char *aMsgID, nsresult aStatus) +{ + return NS_OK; +} nsresult SendOperationListener::OnStopSending(const char *aMsgID, nsresult aStatus, const PRUnichar *aMsg, diff --git a/mailnews/import/eudora/src/nsEudoraCompose.cpp b/mailnews/import/eudora/src/nsEudoraCompose.cpp index 787b8081dec8..de7a0dd8f3bf 100644 --- a/mailnews/import/eudora/src/nsEudoraCompose.cpp +++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp @@ -124,6 +124,9 @@ public: return NS_OK; } + /* void OnSendNotPerformed */ + NS_IMETHOD OnSendNotPerformed(const char *aMsgID, nsresult aStatus) {return NS_OK;} + /* void OnGetDraftFolderURI (); */ NS_IMETHOD OnGetDraftFolderURI(const char *aFolderURI) {return NS_OK;} diff --git a/mailnews/import/outlook/src/nsOutlookCompose.cpp b/mailnews/import/outlook/src/nsOutlookCompose.cpp index 9a460b3ccf8a..1d5e0673bb4c 100644 --- a/mailnews/import/outlook/src/nsOutlookCompose.cpp +++ b/mailnews/import/outlook/src/nsOutlookCompose.cpp @@ -122,6 +122,9 @@ public: return NS_OK; } + /* void OnSendNotPerformed */ + NS_IMETHOD OnSendNotPerformed(const char *aMsgID, nsresult aStatus) {return NS_OK;} + /* void OnGetDraftFolderURI (); */ NS_IMETHOD OnGetDraftFolderURI(const char *aFolderURI) {return NS_OK;}