diff --git a/mozilla/mailnews/base/util/nsMsgProtocol.cpp b/mozilla/mailnews/base/util/nsMsgProtocol.cpp index 82ff3aa7d70..ab065654e71 100644 --- a/mozilla/mailnews/base/util/nsMsgProtocol.cpp +++ b/mozilla/mailnews/base/util/nsMsgProtocol.cpp @@ -877,6 +877,17 @@ nsMsgAsyncWriteProtocol::nsMsgAsyncWriteProtocol(nsIURI * aURL) : nsMsgProtocol( nsMsgAsyncWriteProtocol::~nsMsgAsyncWriteProtocol() {} +NS_IMETHODIMP nsMsgAsyncWriteProtocol::Cancel(nsresult status) +{ + if (m_request) + m_request->Cancel(status); + + if (m_WriteRequest) + m_WriteRequest->Cancel(status); + + return NS_OK; +} + nsresult nsMsgAsyncWriteProtocol::PostMessage(nsIURI* url, nsIFileSpec *fileSpec) { // convert the file spec into a nsIFile.... diff --git a/mozilla/mailnews/compose/public/nsIMsgSend.idl b/mozilla/mailnews/compose/public/nsIMsgSend.idl index 919f5ea0b0e..34c950c2840 100644 --- a/mozilla/mailnews/compose/public/nsIMsgSend.idl +++ b/mozilla/mailnews/compose/public/nsIMsgSend.idl @@ -47,7 +47,8 @@ class nsFileSpec; class nsOutputFileStream; %} -interface nsIURI; +interface nsIURI; +interface nsIRequest; interface nsIMsgDBHdr; interface nsIMsgHdr; interface nsIDocShell; @@ -233,6 +234,8 @@ interface nsIMsgSend : nsISupports [noscript] nsOutputFileStream getOutputStream(); + [noscript] attribute nsIRequest runningRequest; + [noscript] attribute nsresult status; }; diff --git a/mozilla/mailnews/compose/public/nsISmtpService.idl b/mozilla/mailnews/compose/public/nsISmtpService.idl index 81ed13bb9ac..fb1ded14c68 100644 --- a/mozilla/mailnews/compose/public/nsISmtpService.idl +++ b/mozilla/mailnews/compose/public/nsISmtpService.idl @@ -30,6 +30,7 @@ interface nsIMsgIdentity; interface nsIInterfaceRequestor; interface nsIFileSpec; interface nsIMsgStatusFeedback; +interface nsIRequest; [scriptable, uuid(FBAF0F10-CA9B-11d2-8063-006008128C4E)] interface nsISmtpService : nsISupports { @@ -58,7 +59,8 @@ interface nsISmtpService : nsISupports { in nsISmtpServer aServer, in nsIMsgStatusFeedback aStatusListener, in nsIInterfaceRequestor aNotificationCallbacks, - out nsIURI aURL); + out nsIURI aURL, + out nsIRequest aRequest); /** * A copy of the array of SMTP servers, as stored in the preferences diff --git a/mozilla/mailnews/compose/resources/content/sendProgress.xul b/mozilla/mailnews/compose/resources/content/sendProgress.xul index 5769b9f6ed4..71ceb8d920c 100644 --- a/mozilla/mailnews/compose/resources/content/sendProgress.xul +++ b/mozilla/mailnews/compose/resources/content/sendProgress.xul @@ -82,12 +82,10 @@ Contributor(s): - diff --git a/mozilla/mailnews/compose/src/nsMsgSend.cpp b/mozilla/mailnews/compose/src/nsMsgSend.cpp index b9b60227b6d..f2466c69b82 100644 --- a/mozilla/mailnews/compose/src/nsMsgSend.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSend.cpp @@ -74,6 +74,7 @@ #include "nsISmtpUrl.h" #include "nsIInterfaceRequestor.h" #include "nsIDocumentEncoder.h" // for editor output flags +#include "nsILoadGroup.h" // use these macros to define a class IID for our component. Our object currently @@ -2780,7 +2781,7 @@ SendDeliveryCallback(nsIURI *aUrl, nsresult aExitCode, nsMsgDeliveryType deliver aExitCode = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER; break; default: - if (! NS_IS_MSG_ERROR(aExitCode)) + if (aExitCode != NS_ERROR_ABORT && !NS_IS_MSG_ERROR(aExitCode)) aExitCode = NS_ERROR_SEND_FAILED; break; } @@ -2790,11 +2791,13 @@ SendDeliveryCallback(nsIURI *aUrl, nsresult aExitCode, nsMsgDeliveryType deliver else if (deliveryType == nsNewsDelivery) { if (NS_FAILED(aExitCode)) - if (! NS_IS_MSG_ERROR(aExitCode)) + if (aExitCode != NS_ERROR_ABORT && !NS_IS_MSG_ERROR(aExitCode)) aExitCode = NS_ERROR_SEND_FAILED; msgSend->DeliverAsNewsExit(aUrl, aExitCode); } + + msgSend->SetRunningRequest(nsnull); } return aExitCode; @@ -3025,7 +3028,7 @@ nsMsgComposeAndSend::DeliverFileAsMail() rv = smtpService->SendMailMessage(aFileSpec, buf, mUserIdentity, uriListener, nsnull, msgStatus, - callbacks, nsnull); + callbacks, nsnull, getter_AddRefs(mRunningRequest)); } PR_FREEIF(buf); // free the buf because we are done with it.... @@ -3081,7 +3084,8 @@ nsMsgComposeAndSend::DeliverFileAsNews() if (!msgWindow) return NS_ERROR_FAILURE; - rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mCompFields->GetNewspostUrl(), uriListener, msgWindow, nsnull); + rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mCompFields->GetNewspostUrl(), + uriListener, msgWindow, nsnull); if (NS_FAILED(rv)) return rv; } @@ -4223,6 +4227,13 @@ nsresult nsMsgComposeAndSend::Abort() rv = ma->Abort(); } } + + /* stop the current running url */ + if (mRunningRequest) + { + mRunningRequest->Cancel(NS_ERROR_ABORT); + mRunningRequest = nsnull; + } mAbortInProcess = PR_FALSE; return NS_OK; @@ -4277,6 +4288,21 @@ NS_IMETHODIMP nsMsgComposeAndSend::GetOutputStream(nsOutputFileStream * *_retval } +/* [noscript] attribute nsIURI runningURL; */ +NS_IMETHODIMP nsMsgComposeAndSend::GetRunningRequest(nsIRequest **request) +{ + NS_ENSURE_ARG(request); + *request = mRunningRequest; + NS_IF_ADDREF(*request); + return NS_OK; +} +NS_IMETHODIMP nsMsgComposeAndSend::SetRunningRequest(nsIRequest *request) +{ + mRunningRequest = request; + return NS_OK; +} + + NS_IMETHODIMP nsMsgComposeAndSend::GetStatus(nsresult *aStatus) { NS_ENSURE_ARG(aStatus); diff --git a/mozilla/mailnews/compose/src/nsMsgSend.h b/mozilla/mailnews/compose/src/nsMsgSend.h index 10b304485f0..d8fe8729a61 100644 --- a/mozilla/mailnews/compose/src/nsMsgSend.h +++ b/mozilla/mailnews/compose/src/nsMsgSend.h @@ -292,6 +292,7 @@ public: nsCOMPtr mSendProgress; nsCOMPtr mListener; + nsCOMPtr mRunningRequest; PRBool mSendMailAlso; nsIFileSpec *mReturnFileSpec; // a holder for file spec's to be returned to caller diff --git a/mozilla/mailnews/compose/src/nsSmtpService.cpp b/mozilla/mailnews/compose/src/nsSmtpService.cpp index e87c806a65f..4263e6f2406 100644 --- a/mozilla/mailnews/compose/src/nsSmtpService.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpService.cpp @@ -71,7 +71,7 @@ NS_MsgBuildSmtpUrl(nsIFileSpec * aFilePath, nsIInterfaceRequestor* aNotificationCallbacks, nsIURI ** aUrl); -nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer); +nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer, nsIRequest ** aRequest); nsSmtpService::nsSmtpService() : mSmtpServersLoaded(PR_FALSE) @@ -96,7 +96,8 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath, nsISmtpServer * aServer, nsIMsgStatusFeedback *aStatusFeedback, nsIInterfaceRequestor* aNotificationCallbacks, - nsIURI ** aURL) + nsIURI ** aURL, + nsIRequest ** aRequest) { nsIURI * urlToRun = nsnull; nsresult rv = NS_OK; @@ -134,7 +135,7 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath, nsCOMPtr smtpUrl = do_QueryInterface(urlToRun, &rv); if (NS_SUCCEEDED(rv)) smtpUrl->SetSmtpServer(smtpServer); - rv = NS_MsgLoadSmtpUrl(urlToRun, nsnull); + rv = NS_MsgLoadSmtpUrl(urlToRun, nsnull, aRequest); } if (aURL) // does the caller want a handle on the url? @@ -218,7 +219,7 @@ nsresult NS_MsgBuildSmtpUrl(nsIFileSpec * aFilePath, return rv; } -nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer) +nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer, nsIRequest ** aRequest) { // for now, assume the url is a news url and load it.... nsCOMPtr smtpUrl; @@ -232,13 +233,14 @@ nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer) smtpUrl = do_QueryInterface(aUrl); if (smtpUrl) { - // almost there...now create a nntp protocol instance to run the url in... + // almost there...now create a smtp protocol instance to run the url in... smtpProtocol = new nsSmtpProtocol(aUrl); if (smtpProtocol == nsnull) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(smtpProtocol); rv = smtpProtocol->LoadUrl(aUrl, aConsumer); // protocol will get destroyed when url is completed... + smtpProtocol->QueryInterface(NS_GET_IID(nsIRequest), (void **) aRequest); NS_RELEASE(smtpProtocol); }