зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 92251. Full Rewrite of the way we manage and report errors during a message send or save. R=varada, SR=bienvenu
This commit is contained in:
Родитель
fe7e6cc3e7
Коммит
b36a5a5122
Двоичные данные
mailnews/compose/macbuild/msgCompose.mcp
Двоичные данные
mailnews/compose/macbuild/msgCompose.mcp
Двоичный файл не отображается.
Двоичные данные
mailnews/compose/macbuild/msgComposeIDL.mcp
Двоичные данные
mailnews/compose/macbuild/msgComposeIDL.mcp
Двоичный файл не отображается.
|
@ -42,6 +42,7 @@ XPIDLSRCS = \
|
|||
nsIMsgSendLaterListener.idl \
|
||||
nsIMsgSend.idl \
|
||||
nsIMsgSendLater.idl \
|
||||
nsIMsgSendReport.idl \
|
||||
nsIMsgDraft.idl \
|
||||
nsIMsgRecipientArray.idl \
|
||||
nsISmtpServer.idl \
|
||||
|
|
|
@ -33,6 +33,7 @@ XPIDLSRCS = \
|
|||
.\nsIMsgSendLaterListener.idl \
|
||||
.\nsIMsgSend.idl \
|
||||
.\nsIMsgSendLater.idl \
|
||||
.\nsIMsgSendReport.idl \
|
||||
.\nsIMsgRecipientArray.idl \
|
||||
.\nsIMsgDraft.idl \
|
||||
.\nsISmtpServer.idl \
|
||||
|
|
|
@ -162,6 +162,9 @@ interface nsIMsgCompose : nsISupports {
|
|||
*/
|
||||
void ResetNodeEventHandlers(in nsIDOMNode node);
|
||||
|
||||
/* Retreive the message send object */
|
||||
readonly attribute nsIMsgSend messageSend;
|
||||
|
||||
/* ... */
|
||||
attribute nsIEditorShell editor;
|
||||
|
||||
|
@ -209,11 +212,8 @@ interface nsIMsgCompose : nsISupports {
|
|||
[noscript] void notifyStateListeners(in TStateListenerNotification aNotificationType, in nsresult aResult);
|
||||
|
||||
/* Retreive the progress object */
|
||||
[noscript] nsIMsgProgress getProgress();
|
||||
readonly attribute nsIMsgProgress progress;
|
||||
|
||||
/* Retreive the message send object */
|
||||
[noscript] nsIMsgSend getMessageSend();
|
||||
|
||||
/* Retreive the external send listener */
|
||||
nsIMsgSendListener getExternalSendListener();
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "nsIMsgSendListener.idl"
|
||||
#include "nsIEditorShell.idl"
|
||||
#include "nsIMsgProgress.idl"
|
||||
#include "nsIMsgSendReport.idl"
|
||||
#include "domstubs.idl"
|
||||
#include "nsIPrompt.idl"
|
||||
#include "MailNewsTypes2.idl"
|
||||
|
@ -203,11 +204,14 @@ interface nsIMsgSend : nsISupports
|
|||
void abort();
|
||||
|
||||
/* Report a send failure */
|
||||
void fail(in nsresult failure_code, in wstring error_msg);
|
||||
nsresult fail(in nsresult failure_code, in wstring error_msg);
|
||||
|
||||
/* Disable UI notification (alert message) */
|
||||
void setGUINotificationState(in PRBool aEnableFlag);
|
||||
|
||||
/* retreive the last send process report*/
|
||||
readonly attribute nsIMsgSendReport sendReport;
|
||||
|
||||
/* methods for send listener ... */
|
||||
[noscript] void notifyListenerOnStartSending(in string aMsgID, in unsigned long aMsgSize);
|
||||
[noscript] void notifyListenerOnProgress(in string aMsgID, in unsigned long aProgress, in unsigned long aProgressMax);
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- Mode: idl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIPrompt.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(2247c280-7f7f-11d5-9daa-994d49414e7c)]
|
||||
interface nsIMsgProcessReport : nsISupports {
|
||||
|
||||
attribute boolean proceeded;
|
||||
attribute nsresult error;
|
||||
attribute wstring message;
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
[scriptable, uuid(2247c281-7f7f-11d5-9daa-994d49414e7c)]
|
||||
interface nsIMsgSendReport : nsISupports {
|
||||
|
||||
const long process_Current = -1;
|
||||
const long process_BuildMessage = 0;
|
||||
const long process_NNTP = 1;
|
||||
const long process_SMTP = 2;
|
||||
const long process_Copy = 3;
|
||||
const long process_FCC = 4;
|
||||
|
||||
attribute long deliveryMode; /* see nsMsgDeliverMode in nsIMsgSend.idl for valid value */
|
||||
attribute long currentProcess;
|
||||
|
||||
void reset();
|
||||
|
||||
void setProceeded(in long process, in boolean proceeded);
|
||||
void setError(in long process, in nsresult error, in boolean overwriteError);
|
||||
void setMessage(in long process, in wstring message, in boolean overwriteMessage);
|
||||
|
||||
nsIMsgProcessReport getProcessReport(in long process);
|
||||
|
||||
/* Display Report will ananlyze data collected during the send and will show the most appropriate error.
|
||||
Also it will return the error code. In case of no error or if the error has been canceld, it will return
|
||||
NS_OK.
|
||||
*/
|
||||
nsresult displayReport(in nsIPrompt prompt, in boolean showErrorOnly, in boolean dontShowReportTwice);
|
||||
};
|
|
@ -71,14 +71,11 @@ var progressListener = {
|
|||
|
||||
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
|
||||
{
|
||||
|
||||
var overallProgress = aCurTotalProgress;
|
||||
|
||||
// Calculate percentage.
|
||||
var percent;
|
||||
if ( aMaxTotalProgress != "-1" )
|
||||
if ( aMaxTotalProgress > 0 )
|
||||
{
|
||||
percent = parseInt( (overallProgress*100)/aMaxTotalProgress + .5 );
|
||||
percent = parseInt( (aCurTotalProgress*100)/aMaxTotalProgress + .5 );
|
||||
if ( percent > 100 )
|
||||
percent = 100;
|
||||
|
||||
|
@ -86,19 +83,19 @@ var progressListener = {
|
|||
|
||||
// Advance progress meter.
|
||||
dialog.progress.setAttribute( "value", percent );
|
||||
|
||||
// Update percentage label on progress meter.
|
||||
var percentMsg = getString( "progressText" );
|
||||
percentMsg = replaceInsert( percentMsg, 1, percent );
|
||||
dialog.progressText.setAttribute("value", percentMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
percent = "??";
|
||||
|
||||
// Progress meter should be barber-pole in this case.
|
||||
dialog.progress.setAttribute( "mode", "undetermined" );
|
||||
// Update percentage label on progress meter.
|
||||
dialog.progressText.setAttribute("value", "");
|
||||
}
|
||||
|
||||
// Update percentage label on progress meter.
|
||||
var percentMsg = getString( "progressText" );
|
||||
percentMsg = replaceInsert( percentMsg, 1, percent );
|
||||
dialog.progressText.setAttribute("value", percentMsg);
|
||||
},
|
||||
|
||||
onLocationChange: function(aWebProgress, aRequest, aLocation)
|
||||
|
|
|
@ -22,16 +22,16 @@
|
|||
# The following are used by the compose back end
|
||||
#
|
||||
## @name NS_MSG_UNABLE_TO_OPEN_FILE
|
||||
12500=Unable to open the file %.200s. Check the file name and try again.
|
||||
12500=Unable to open the file %P0%.
|
||||
|
||||
## @name NS_MSG_UNABLE_TO_OPEN_TMP_FILE
|
||||
12501=Unable to open the temporary file %.200s. Check your 'Temporary Directory' setting and try again.
|
||||
12501=Unable to open the temporary file %P0%. Check your 'Temporary Directory' setting.
|
||||
|
||||
## @name NS_MSG_UNABLE_TO_SAVE_TEMPLATE
|
||||
12502=Unable to save your message as template. Please verify that your Mail preferences are correct and try again.
|
||||
12502=Unable to save your message as template.
|
||||
|
||||
## @name NS_MSG_UNABLE_TO_SAVE_DRAFT
|
||||
12503=Unable to save your message as draft. Please verify that your Mail preferences are correct and try again.
|
||||
12503=Unable to save your message as draft.
|
||||
|
||||
## @name NS_MSG_LOAD_ATTACHMNTS
|
||||
12504=Loading attachments...
|
||||
|
@ -52,7 +52,7 @@
|
|||
12509=Assembling message...
|
||||
|
||||
## @name NS_MSG_NO_SENDER
|
||||
12510=No sender was specified. Please fill in your email address in the Mail and Newsgroup preferences.
|
||||
12510=No sender was specified. Please fill in your email address in the Mail/News account settings.
|
||||
|
||||
## @name NS_MSG_NO_RECIPIENTS
|
||||
12511=No recipients were specified. Please enter a recipient or newsgroup in the addressing area.
|
||||
|
@ -61,7 +61,7 @@
|
|||
12512=Error writing temporary file.
|
||||
|
||||
## @name NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER
|
||||
12513=An error occurred sending mail: Unable to connect to the SMTP server. The server may be down or may be incorrectly configured. Please verify that your Mail preferences are correct and try again.
|
||||
12513=An error occurred sending mail: Unable to connect to the SMTP server. The server may be down or may be incorrectly configured. Please verify that your Mail/News account settings are correct and try again.
|
||||
|
||||
## @name NS_ERROR_SENDING_FROM_COMMAND
|
||||
12514=An error occurred while sending mail. The mail server responded: %s. Please verify that your email address is correct in your Mail preferences and try again.
|
||||
|
@ -75,9 +75,6 @@
|
|||
## @name NS_ERROR_SENDING_MESSAGE
|
||||
12517=An error occurred while sending mail. The mail server responded: %s. Please check the message and try again.
|
||||
|
||||
## @name NS_ERROR_SERVER_ERROR
|
||||
12518=An error occurred sending mail: SMTP server error. The server responded: %s. Contact your mail administrator for assistance.
|
||||
|
||||
## @name NS_ERROR_QUEUED_DELIVERY_FAILED
|
||||
12519=An error occurred delivering unsent messages.
|
||||
|
||||
|
@ -97,7 +94,7 @@
|
|||
12524=An error occurred sending mail: SMTP server error. The server responded: %s Contact your mail administrator for assistance.
|
||||
|
||||
## @name NS_MSG_UNABLE_TO_SEND_LATER
|
||||
12525=Unable to save your message in order to send it later. Please verify that your Mail preferences are correct and try again.
|
||||
12525=Unable to save your message in order to send it later.
|
||||
|
||||
## @name NS_ERROR_COMMUNICATIONS_ERROR
|
||||
12526=A communications error occurred: %d. Please try again.
|
||||
|
@ -118,7 +115,7 @@
|
|||
12531=Attachment error.
|
||||
|
||||
## @name NS_MSG_FAILED_COPY_OPERATION
|
||||
12532=Your Send operation was successful, but copying the message to your Sent folder failed. Would you like to return to the compose window?
|
||||
12532=Your Send operation was successful, but copying the message to your Sent folder failed.
|
||||
|
||||
## @name NS_MSG_ASSEMBLING_MESSAGE
|
||||
12534=Assembling mail information...
|
||||
|
@ -173,6 +170,27 @@ noIdentities=You don't have any email identities yet. Create one with the Accou
|
|||
## @name NS_MSG_CANCELLING
|
||||
12555=Cancelling...
|
||||
|
||||
## @name NS_MSG_SEND_ERROR_TITLE
|
||||
12556=Send Message Error
|
||||
|
||||
## @name NS_MSG_SENDLATER_ERROR_TITLE
|
||||
12557=Send Later Error
|
||||
|
||||
## @name NS_MSG_SAVE_DRAFT_TITLE
|
||||
12558=Save Draft Error
|
||||
|
||||
## @name NS_MSG_SAVE_TEMPLATE_TITLE
|
||||
12559=Save Template Error
|
||||
|
||||
## @name NS_ERROR_SEND_FAILED_BUT_NNTP_OK
|
||||
12560=Your message has been posted to the newsgroup but has not been sent to other recipient.
|
||||
|
||||
## @name NS_MSG_ASK_TO_COMEBACK_TO_COMPOSE
|
||||
12561=Would you like to return to the compose window?
|
||||
|
||||
## @name NS_MSG_GENERIC_FAILURE_EXPLANATION
|
||||
12562=Please verify that your Mail/News account settings are correct and try again.
|
||||
|
||||
## Strings use for the save message dialog shown when the user close a message compose window
|
||||
saveDlogTitle=Save Message
|
||||
saveDlogMessage=Message has not been Sent. Do you want to save the message in the Drafts Folder?
|
||||
|
|
|
@ -37,6 +37,7 @@ CPPSRCS = \
|
|||
nsSmtpProtocol.cpp \
|
||||
nsMsgSend.cpp \
|
||||
nsMsgSendPart.cpp \
|
||||
nsMsgSendReport.cpp \
|
||||
nsSmtpService.cpp \
|
||||
nsMsgCreate.cpp \
|
||||
nsMsgCopy.cpp \
|
||||
|
@ -83,6 +84,8 @@ EXPORTS = \
|
|||
nsMsgRecipientArray.h \
|
||||
nsURLFetcher.h \
|
||||
nsMsgSend.h \
|
||||
nsMsgSendReport.h \
|
||||
nsMsgSimulateError.h \
|
||||
nsSmtpServer.h \
|
||||
nsSmtpDataSource.h \
|
||||
nsSmtpDelegateFactory.h \
|
||||
|
|
|
@ -35,6 +35,8 @@ EXPORTS= nsSmtpUrl.h \
|
|||
nsMsgCompUtils.h \
|
||||
nsMsgDeliveryListener.h \
|
||||
nsMsgSend.h \
|
||||
nsMsgSendReport.h \
|
||||
nsMsgSimulateError.h \
|
||||
nsMsgAttachmentHandler.h \
|
||||
nsMsgComposeService.h \
|
||||
nsMsgComposeParams.h \
|
||||
|
@ -61,6 +63,7 @@ CPP_OBJS= .\$(OBJDIR)\nsMsgCompFields.obj \
|
|||
.\$(OBJDIR)\nsSmtpProtocol.obj \
|
||||
.\$(OBJDIR)\nsMsgSend.obj \
|
||||
.\$(OBJDIR)\nsMsgSendPart.obj \
|
||||
.\$(OBJDIR)\nsMsgSendReport.obj \
|
||||
.\$(OBJDIR)\nsSmtpService.obj \
|
||||
.\$(OBJDIR)\nsMsgComposeService.obj \
|
||||
.\$(OBJDIR)\nsMsgComposeParams.obj \
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "nsMsgPrompts.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
|
@ -461,18 +463,31 @@ nsMsgAttachmentHandler::SnarfMsgAttachment(nsMsgCompFields *compFields)
|
|||
m_override_type = PL_strdup(MESSAGE_RFC822);
|
||||
if (!mFileSpec)
|
||||
{
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto done;
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsCOMPtr<nsIOutputStream> outputStream;
|
||||
NS_FileSpecToIFile(mFileSpec, getter_AddRefs(localFile));
|
||||
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), localFile, -1, 00600);
|
||||
if (NS_FAILED(rv) || !outputStream)
|
||||
if (NS_FAILED(rv) || !outputStream || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_3))
|
||||
{
|
||||
rv = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||
goto done;
|
||||
if (m_mime_delivery_state)
|
||||
{
|
||||
nsCOMPtr<nsIMsgSendReport> sendReport;
|
||||
m_mime_delivery_state->GetSendReport(getter_AddRefs(sendReport));
|
||||
if (sendReport)
|
||||
{
|
||||
nsAutoString error_msg;
|
||||
nsAutoString path;
|
||||
mFileSpec->GetNativePathString(path);
|
||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||
sendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||
}
|
||||
}
|
||||
rv = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||
goto done;
|
||||
}
|
||||
mOutFile = do_QueryInterface(outputStream);
|
||||
|
||||
|
@ -564,8 +579,21 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
|||
nsCOMPtr<nsIOutputStream> outputStream;
|
||||
NS_FileSpecToIFile(mFileSpec, getter_AddRefs(localFile));
|
||||
status = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), localFile, -1, 00600);
|
||||
if (NS_FAILED(status) || !outputStream)
|
||||
if (NS_FAILED(status) || !outputStream || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_3))
|
||||
{
|
||||
if (m_mime_delivery_state)
|
||||
{
|
||||
nsCOMPtr<nsIMsgSendReport> sendReport;
|
||||
m_mime_delivery_state->GetSendReport(getter_AddRefs(sendReport));
|
||||
if (sendReport)
|
||||
{
|
||||
nsAutoString error_msg;
|
||||
nsAutoString path;
|
||||
mFileSpec->GetNativePathString(path);
|
||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||
sendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||
}
|
||||
}
|
||||
delete mFileSpec;
|
||||
mFileSpec = nsnull;
|
||||
return NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||
|
@ -742,7 +770,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
|||
// we got the encode data, so call the next stream to write it to the disk.
|
||||
//
|
||||
if (obj->fileStream->write(obj->buff, count) != count)
|
||||
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||
status = NS_MSG_ERROR_WRITING_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -966,7 +994,8 @@ nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg)
|
|||
{
|
||||
status = NS_ERROR_ABORT;
|
||||
m_mime_delivery_state->SetStatus(status);
|
||||
m_mime_delivery_state->Fail(status, 0);
|
||||
nsresult ignoreMe;
|
||||
m_mime_delivery_state->Fail(status, nsnull, &ignoreMe);
|
||||
m_mime_delivery_state->NotifyListenerOnStopSending(nsnull, status, 0, nsnull);
|
||||
SetMimeDeliveryState(nsnull);
|
||||
return status;
|
||||
|
@ -1089,7 +1118,8 @@ nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg)
|
|||
int status = next->SnarfAttachment(mCompFields);
|
||||
if (NS_FAILED(status))
|
||||
{
|
||||
m_mime_delivery_state->Fail(status, 0);
|
||||
nsresult ignoreMe;
|
||||
m_mime_delivery_state->Fail(status, nsnull, &ignoreMe);
|
||||
m_mime_delivery_state->NotifyListenerOnStopSending(nsnull, status, 0, nsnull);
|
||||
SetMimeDeliveryState(nsnull);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -1105,7 +1135,8 @@ nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg)
|
|||
// the exit routine and terminating the delivery.
|
||||
if (NS_FAILED(status))
|
||||
{
|
||||
m_mime_delivery_state->Fail(status, aMsg);
|
||||
nsresult ignoreMe;
|
||||
m_mime_delivery_state->Fail(status, aMsg, &ignoreMe);
|
||||
m_mime_delivery_state->NotifyListenerOnStopSending(nsnull, status, aMsg, nsnull);
|
||||
SetMimeDeliveryState(nsnull);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -1115,7 +1146,8 @@ nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg)
|
|||
status = m_mime_delivery_state->GatherMimeAttachments ();
|
||||
if (NS_FAILED(status))
|
||||
{
|
||||
m_mime_delivery_state->Fail(status, aMsg);
|
||||
nsresult ignoreMe;
|
||||
m_mime_delivery_state->Fail(status, aMsg, &ignoreMe);
|
||||
m_mime_delivery_state->NotifyListenerOnStopSending(nsnull, status, aMsg, nsnull);
|
||||
SetMimeDeliveryState(nsnull);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -1128,7 +1160,8 @@ nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg)
|
|||
// then report that error and continue
|
||||
if (NS_FAILED(status))
|
||||
{
|
||||
m_mime_delivery_state->Fail(status, aMsg);
|
||||
nsresult ignoreMe;
|
||||
m_mime_delivery_state->Fail(status, aMsg, &ignoreMe);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsNetCID.h"
|
||||
#include "nsMsgPrompts.h"
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
||||
|
@ -164,11 +165,12 @@ nsresult mime_sanity_check_fields (
|
|||
followup_to++;
|
||||
|
||||
/* #### sanity check other_random_headers for newline conventions */
|
||||
if (!from || !*from)
|
||||
if (!from || !*from || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_6))
|
||||
return NS_MSG_NO_SENDER;
|
||||
else
|
||||
if ((!to || !*to) && (!cc || !*cc) &&
|
||||
(!bcc || !*bcc) && (!newsgroups || !*newsgroups))
|
||||
if (((!to || !*to) && (!cc || !*cc) &&
|
||||
(!bcc || !*bcc) && (!newsgroups || !*newsgroups)) ||
|
||||
CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_7))
|
||||
return NS_MSG_NO_RECIPIENTS;
|
||||
else
|
||||
return NS_OK;
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
#include "nsImapCore.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
// Defines....
|
||||
static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
||||
|
@ -864,6 +865,7 @@ nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide
|
|||
char *outCString = nsnull;
|
||||
rv = nsMsgI18NSaveAsCharset(contentType, m_compFields->GetCharacterSet(),
|
||||
msgBody.get(), &outCString);
|
||||
SET_SIMULATED_ERROR(SIMULATED_SEND_ERROR_14, rv, NS_ERROR_UENC_NOMAPPING);
|
||||
if (NS_SUCCEEDED(rv) && nsnull != outCString)
|
||||
{
|
||||
// body contains multilingual data, confirm send to the user
|
||||
|
@ -920,26 +922,36 @@ nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide
|
|||
rv = _SendMsg(deliverMode, identity, entityConversionDone);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
if (rv != NS_ERROR_BUT_DONT_SHOW_ALERT)
|
||||
if (NS_FAILED(nsMsgDisplayMessageByID(prompt, rv)))
|
||||
nsCOMPtr<nsIMsgSendReport> sendReport;
|
||||
if (mMsgSend)
|
||||
mMsgSend->GetSendReport(getter_AddRefs(sendReport));
|
||||
if (sendReport)
|
||||
{
|
||||
nsresult theError;
|
||||
sendReport->DisplayReport(prompt, PR_TRUE, PR_TRUE, &theError);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If we come here it's because we got an error before we could intialize a
|
||||
send report! Let's try our best...
|
||||
*/
|
||||
switch (deliverMode)
|
||||
{
|
||||
/* If we come here it's because we have an unknown error and we need to warm the user
|
||||
Let's try our best...
|
||||
*/
|
||||
switch (deliverMode)
|
||||
{
|
||||
case nsIMsgCompDeliverMode::SaveAsDraft:
|
||||
nsMsgDisplayMessageByID(prompt, NS_MSG_UNABLE_TO_SAVE_DRAFT);
|
||||
break;
|
||||
case nsIMsgCompDeliverMode::SaveAsTemplate:
|
||||
nsMsgDisplayMessageByID(prompt, NS_MSG_UNABLE_TO_SAVE_TEMPLATE);
|
||||
break;
|
||||
case nsIMsgCompDeliverMode::Later:
|
||||
nsMsgDisplayMessageByID(prompt, NS_MSG_UNABLE_TO_SEND_LATER);
|
||||
break;
|
||||
case nsIMsgCompDeliverMode::SaveAsDraft:
|
||||
nsMsgDisplayMessageByID(prompt, NS_MSG_UNABLE_TO_SAVE_DRAFT);
|
||||
break;
|
||||
case nsIMsgCompDeliverMode::SaveAsTemplate:
|
||||
nsMsgDisplayMessageByID(prompt, NS_MSG_UNABLE_TO_SAVE_TEMPLATE);
|
||||
break;
|
||||
|
||||
default:
|
||||
nsMsgDisplayMessageByID(prompt, NS_ERROR_SEND_FAILED);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
nsMsgDisplayMessageByID(prompt, NS_ERROR_SEND_FAILED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (progress)
|
||||
progress->CloseProgressDialog(PR_TRUE);
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
#define NS_MSG_UNABLE_TO_SAVE_DRAFT NS_MSG_GENERATE_FAILURE(12503)
|
||||
#define NS_MSG_LOAD_ATTACHMNTS NS_MSG_GENERATE_SUCCESS(12504)
|
||||
#define NS_MSG_LOAD_ATTACHMNT NS_MSG_GENERATE_SUCCESS(12505)
|
||||
#define NS_MSG_COULDNT_OPEN_FCC_FOLDER NS_MSG_GENERATE_FAILURE(12506)
|
||||
#define NS_MSG_COULDNT_OPEN_FCC_FOLDER NS_MSG_GENERATE_FAILURE(12506)
|
||||
#define NS_MSG_CANT_POST_TO_MULTIPLE_NEWS_HOSTS NS_MSG_GENERATE_FAILURE(12507)
|
||||
#define NS_MSG_ASSEMB_DONE_MSG NS_MSG_GENERATE_SUCCESS(12508)
|
||||
#define NS_MSG_ASSEMBLING_MSG NS_MSG_GENERATE_SUCCESS(12509)
|
||||
|
@ -64,24 +64,23 @@ private:
|
|||
#define NS_ERROR_SENDING_RCPT_COMMAND NS_MSG_GENERATE_FAILURE(12515)
|
||||
#define NS_ERROR_SENDING_DATA_COMMAND NS_MSG_GENERATE_FAILURE(12516)
|
||||
#define NS_ERROR_SENDING_MESSAGE NS_MSG_GENERATE_FAILURE(12517)
|
||||
#define NS_ERROR_SERVER_ERROR NS_MSG_GENERATE_FAILURE(12518)
|
||||
#define NS_ERROR_QUEUED_DELIVERY_FAILED NS_MSG_GENERATE_FAILURE(12519)
|
||||
#define NS_ERROR_SEND_FAILED NS_MSG_GENERATE_FAILURE(12520)
|
||||
#define SMTP_DELIV_MAIL NS_MSG_GENERATE_SUCCESS(12521)
|
||||
#define SMTP_MESSAGE_SENT_WAITING_MAIL_REPLY NS_MSG_GENERATE_SUCCESS(12522)
|
||||
#define SMTP_PROGRESS_MAILSENT NS_MSG_GENERATE_SUCCESS(12523)
|
||||
#define NS_ERROR_SMTP_SERVER_ERROR NS_MSG_GENERATE_FAILURE(12524)
|
||||
#define NS_MSG_UNABLE_TO_SEND_LATER NS_MSG_GENERATE_FAILURE(12525)
|
||||
#define NS_ERROR_COMMUNICATIONS_ERROR NS_MSG_GENERATE_FAILURE(12526)
|
||||
#define NS_ERROR_BUT_DONT_SHOW_ALERT NS_MSG_GENERATE_FAILURE(12527)
|
||||
#define NS_ERROR_TCP_READ_ERROR NS_MSG_GENERATE_FAILURE(12528)
|
||||
#define NS_MSG_UNABLE_TO_SEND_LATER NS_MSG_GENERATE_FAILURE(12525)
|
||||
#define NS_ERROR_COMMUNICATIONS_ERROR NS_MSG_GENERATE_FAILURE(12526)
|
||||
#define NS_ERROR_BUT_DONT_SHOW_ALERT NS_MSG_GENERATE_FAILURE(12527)
|
||||
#define NS_ERROR_TCP_READ_ERROR NS_MSG_GENERATE_FAILURE(12528)
|
||||
#define NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS NS_MSG_GENERATE_FAILURE(12529)
|
||||
#define NS_ERROR_SMTP_PASSWORD_UNDEFINED NS_MSG_GENERATE_FAILURE(12530)
|
||||
#define NS_ERROR_SMTP_PASSWORD_UNDEFINED NS_MSG_GENERATE_FAILURE(12530)
|
||||
#define NS_ERROR_MIME_MPART_ATTACHMENT_ERROR NS_MSG_GENERATE_FAILURE(12531)
|
||||
#define NS_MSG_FAILED_COPY_OPERATION NS_MSG_GENERATE_FAILURE(12532)
|
||||
#define NS_MSG_FAILED_COPY_OPERATION NS_MSG_GENERATE_FAILURE(12532)
|
||||
|
||||
// For message sending operations...
|
||||
#define NS_MSG_ASSEMBLING_MESSAGE NS_MSG_GENERATE_SUCCESS(12534)
|
||||
#define NS_MSG_ASSEMBLING_MESSAGE NS_MSG_GENERATE_SUCCESS(12534)
|
||||
#define NS_MSG_GATHERING_ATTACHMENT NS_MSG_GENERATE_SUCCESS(12535)
|
||||
#define NS_MSG_CREATING_MESSAGE NS_MSG_GENERATE_SUCCESS(12536)
|
||||
#define NS_MSG_FAILURE_ON_OBJ_EMBED NS_MSG_GENERATE_FAILURE(12537)
|
||||
|
@ -90,14 +89,13 @@ private:
|
|||
#define NS_MSG_START_COPY_MESSAGE_FAILED NS_MSG_GENERATE_FAILURE(12540)
|
||||
#define NS_MSG_LARGE_MESSAGE_WARNING NS_MSG_GENERATE_FAILURE(12541)
|
||||
|
||||
#define NS_SMTP_PASSWORD_PROMPT_TITLE NS_MSG_GENERATE_SUCCESS(12542)
|
||||
#define NS_SMTP_PASSWORD_PROMPT NS_MSG_GENERATE_SUCCESS(12543)
|
||||
#define NS_SMTP_CONNECTING_TO_SERVER NS_MSG_GENERATE_SUCCESS(12545)
|
||||
#define NS_SMTP_USERNAME_PASSWORD_PROMPT NS_MSG_GENERATE_SUCCESS(12546)
|
||||
#define NS_SMTP_PASSWORD_PROMPT_TITLE NS_MSG_GENERATE_SUCCESS(12542)
|
||||
#define NS_SMTP_PASSWORD_PROMPT NS_MSG_GENERATE_SUCCESS(12543)
|
||||
#define NS_SMTP_CONNECTING_TO_SERVER NS_MSG_GENERATE_SUCCESS(12545)
|
||||
#define NS_SMTP_USERNAME_PASSWORD_PROMPT NS_MSG_GENERATE_SUCCESS(12546)
|
||||
|
||||
#define NS_MSG_SENDING_MESSAGE NS_MSG_GENERATE_SUCCESS(12550)
|
||||
#define NS_MSG_POSTING_MESSAGE NS_MSG_GENERATE_SUCCESS(12551)
|
||||
#define NS_MSG_ATTACHMENT_TYPE_MISMATCH NS_MSG_GENERATE_FAILURE(12552)
|
||||
|
||||
#define NS_MSG_MULTILINGUAL_SEND NS_MSG_GENERATE_SUCCESS(12553)
|
||||
|
||||
|
@ -105,5 +103,14 @@ private:
|
|||
|
||||
#define NS_MSG_CANCELLING NS_MSG_GENERATE_SUCCESS(12555)
|
||||
|
||||
// For message sending report...
|
||||
#define NS_MSG_SEND_ERROR_TITLE NS_MSG_GENERATE_SUCCESS(12556)
|
||||
#define NS_MSG_SENDLATER_ERROR_TITLE NS_MSG_GENERATE_SUCCESS(12557)
|
||||
#define NS_MSG_SAVE_DRAFT_TITLE NS_MSG_GENERATE_SUCCESS(12558)
|
||||
#define NS_MSG_SAVE_TEMPLATE_TITLE NS_MSG_GENERATE_SUCCESS(12559)
|
||||
#define NS_ERROR_SEND_FAILED_BUT_NNTP_OK NS_MSG_GENERATE_FAILURE(12560)
|
||||
#define NS_MSG_ASK_TO_COMEBACK_TO_COMPOSE NS_MSG_GENERATE_SUCCESS(12561)
|
||||
#define NS_MSG_GENERIC_FAILURE_EXPLANATION NS_MSG_GENERATE_SUCCESS(12562)
|
||||
|
||||
|
||||
#endif /* _nsMsgComposeStringBundle_H_ */
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "prcmon.h"
|
||||
#include "nsIMsgImapMailFolder.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
@ -201,7 +202,7 @@ nsMsgCopy::StartCopyOperation(nsIMsgIdentity *aUserIdentity,
|
|||
rv = GetUnsentMessagesFolder(aUserIdentity, getter_AddRefs(dstFolder), &waitForUrl);
|
||||
isDraft = PR_FALSE;
|
||||
if (!dstFolder || NS_FAILED(rv)) {
|
||||
return NS_MSG_UNABLE_TO_SEND_LATER;
|
||||
return NS_MSG_UNABLE_TO_SEND_LATER;
|
||||
}
|
||||
}
|
||||
else if (aMode == nsIMsgSend::nsMsgSaveAsDraft) // SaveAsDraft (Drafts)
|
||||
|
@ -209,15 +210,15 @@ nsMsgCopy::StartCopyOperation(nsIMsgIdentity *aUserIdentity,
|
|||
rv = GetDraftsFolder(aUserIdentity, getter_AddRefs(dstFolder), &waitForUrl);
|
||||
isDraft = PR_TRUE;
|
||||
if (!dstFolder || NS_FAILED(rv)) {
|
||||
return NS_MSG_UNABLE_TO_SAVE_DRAFT;
|
||||
return NS_MSG_UNABLE_TO_SAVE_DRAFT;
|
||||
}
|
||||
}
|
||||
else if (aMode == nsIMsgSend::nsMsgSaveAsTemplate) // SaveAsTemplate (Templates)
|
||||
{
|
||||
rv = GetTemplatesFolder(aUserIdentity, getter_AddRefs(dstFolder), &waitForUrl);
|
||||
isDraft = PR_FALSE;
|
||||
if (!dstFolder || NS_FAILED(rv)) {
|
||||
return NS_MSG_UNABLE_TO_SAVE_TEMPLATE;
|
||||
if (!dstFolder || NS_FAILED(rv) || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_5)) {
|
||||
return NS_MSG_UNABLE_TO_SAVE_TEMPLATE;
|
||||
}
|
||||
}
|
||||
else // SaveInSentFolder (Sent) - nsMsgDeliverNow
|
||||
|
@ -225,7 +226,7 @@ nsMsgCopy::StartCopyOperation(nsIMsgIdentity *aUserIdentity,
|
|||
rv = GetSentFolder(aUserIdentity, getter_AddRefs(dstFolder), &waitForUrl);
|
||||
isDraft = PR_FALSE;
|
||||
if (!dstFolder || NS_FAILED(rv)) {
|
||||
return NS_MSG_COULDNT_OPEN_FCC_FOLDER;
|
||||
return NS_MSG_COULDNT_OPEN_FCC_FOLDER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -411,6 +412,8 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
RETURN_SIMULATED_ERROR(SIMULATED_SEND_ERROR_5, NS_ERROR_FAILURE)
|
||||
|
||||
if (!msgFolder) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!aFolderURI || (PL_strlen(aFolderURI) == 0)) {
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsMsgPrompts.h"
|
||||
|
||||
#include "nsMsgCopy.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsMsgPrompts.h"
|
||||
#include "nsIMsgStringService.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
@ -30,7 +31,7 @@
|
|||
#include "nsMsgCompCID.h"
|
||||
|
||||
nsresult
|
||||
nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID)
|
||||
nsMsgBuildErrorMessageByID(PRInt32 msgID, nsString& retval, nsString* param0, nsString* param1)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -40,13 +41,41 @@ nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID)
|
|||
if (composebundle)
|
||||
{
|
||||
composebundle->GetStringByID(msgID, getter_Copies(msg));
|
||||
rv = nsMsgDisplayMessageByString(aPrompt, msg);
|
||||
retval = msg;
|
||||
|
||||
nsString target;
|
||||
if (param0)
|
||||
{
|
||||
target.AssignWithConversion("%P0%");
|
||||
retval.ReplaceSubstring(target, *param0);
|
||||
}
|
||||
if (param1)
|
||||
{
|
||||
target.AssignWithConversion("%P1%");
|
||||
retval.ReplaceSubstring(target, *param1);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDisplayMessageByString(nsIPrompt * aPrompt, const PRUnichar * msg)
|
||||
nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID, const PRUnichar * windowTitle)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIMsgStringService> composebundle (do_GetService(NS_MSG_COMPOSESTRINGSERVICE_CONTRACTID, &rv));
|
||||
nsXPIDLString msg;
|
||||
|
||||
if (composebundle)
|
||||
{
|
||||
composebundle->GetStringByID(msgID, getter_Copies(msg));
|
||||
rv = nsMsgDisplayMessageByString(aPrompt, msg, windowTitle);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDisplayMessageByString(nsIPrompt * aPrompt, const PRUnichar * msg, const PRUnichar * windowTitle)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrompt> prompt = aPrompt;
|
||||
|
@ -62,12 +91,12 @@ nsMsgDisplayMessageByString(nsIPrompt * aPrompt, const PRUnichar * msg)
|
|||
}
|
||||
|
||||
if (prompt)
|
||||
rv = prompt->Alert(nsnull, msg);
|
||||
rv = prompt->Alert(windowTitle, msg);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer)
|
||||
nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer, const PRUnichar * windowTitle)
|
||||
{
|
||||
nsCOMPtr<nsIMsgStringService> composebundle (do_GetService(NS_MSG_COMPOSESTRINGSERVICE_CONTRACTID));
|
||||
nsXPIDLString msg;
|
||||
|
@ -75,14 +104,14 @@ nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer)
|
|||
if (composebundle)
|
||||
{
|
||||
composebundle->GetStringByID(msgID, getter_Copies(msg));
|
||||
nsMsgAskBooleanQuestionByString(aPrompt, msg, answer);
|
||||
nsMsgAskBooleanQuestionByString(aPrompt, msg, answer, windowTitle);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBool *answer)
|
||||
nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBool *answer, const PRUnichar * windowTitle)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 result;
|
||||
|
@ -100,7 +129,7 @@ nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBo
|
|||
|
||||
if (dialog)
|
||||
{
|
||||
rv = dialog->Confirm(nsnull, msg, &result);
|
||||
rv = dialog->Confirm(windowTitle, msg, &result);
|
||||
if (result == 1)
|
||||
*answer = PR_TRUE;
|
||||
else
|
||||
|
|
|
@ -23,11 +23,16 @@
|
|||
#ifndef _nsMsgPrompts_H_
|
||||
#define _nsMsgPrompts_H_
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIPrompt;
|
||||
|
||||
nsresult nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID);
|
||||
nsresult nsMsgDisplayMessageByString(nsIPrompt * aPrompt, const PRUnichar * msg);
|
||||
nsresult nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer);
|
||||
nsresult nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBool *answer);
|
||||
nsresult nsMsgBuildErrorMessageByID(PRInt32 msgID, nsString& retval, nsString* param0 = nsnull, nsString* param1 = nsnull);
|
||||
nsresult nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID, const PRUnichar * windowTitle = nsnull);
|
||||
nsresult nsMsgDisplayMessageByString(nsIPrompt * aPrompt, const PRUnichar * msg, const PRUnichar * windowTitle = nsnull);
|
||||
nsresult nsMsgAskBooleanQuestionByID(nsIPrompt * aPrompt, PRInt32 msgID, PRBool *answer, const PRUnichar * windowTitle = nsnull);
|
||||
nsresult nsMsgAskBooleanQuestionByString(nsIPrompt * aPrompt, const PRUnichar * msg, PRBool *answer, const PRUnichar * windowTitle = nsnull);
|
||||
|
||||
#endif /* _nsMsgPrompts_H_ */
|
||||
|
|
|
@ -75,6 +75,8 @@
|
|||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIDocumentEncoder.h" // for editor output flags
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsMsgSendReport.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
|
||||
// use these macros to define a class IID for our component. Our object currently
|
||||
|
@ -189,6 +191,8 @@ nsMsgComposeAndSend::nsMsgComposeAndSend() :
|
|||
mCompFieldLocalAttachments = 0;
|
||||
mCompFieldRemoteAttachments = 0;
|
||||
mMessageWarningSize = 0;
|
||||
|
||||
NS_NEWXPCOM(mSendReport, nsMsgSendReport);
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -198,6 +202,7 @@ nsMsgComposeAndSend::~nsMsgComposeAndSend()
|
|||
#if defined(DEBUG_ducarroz)
|
||||
printf("DISPOSE nsMsgComposeAndSend: %x\n", this);
|
||||
#endif
|
||||
mSendReport = nsnull;
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
@ -567,6 +572,14 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
|||
nsOutputFileStream tempfile(*mHTMLFileSpec, kDefaultMode, 00600);
|
||||
if (! tempfile.is_open())
|
||||
{
|
||||
if (mSendReport)
|
||||
{
|
||||
nsAutoString error_msg;
|
||||
nsAutoString path;
|
||||
mHTMLFileSpec->GetNativePathString(path);
|
||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||
}
|
||||
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||
goto FAIL;
|
||||
}
|
||||
|
@ -638,11 +651,17 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
|||
goto FAILMEM;
|
||||
|
||||
mOutputFile = new nsOutputFileStream(*mTempFileSpec, kDefaultMode, 00600);
|
||||
if (! mOutputFile->is_open())
|
||||
if (! mOutputFile->is_open() || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_4))
|
||||
{
|
||||
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||
if (mGUINotificationEnabled)
|
||||
nsMsgDisplayMessageByID(promptObject, NS_MSG_UNABLE_TO_OPEN_TMP_FILE);
|
||||
if (mSendReport)
|
||||
{
|
||||
nsAutoString error_msg;
|
||||
nsAutoString path;
|
||||
mTempFileSpec->GetNativePathString(path);
|
||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||
}
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1110,8 @@ FAIL:
|
|||
if (status < 0)
|
||||
{
|
||||
m_status = status;
|
||||
Fail (status, nsnull);
|
||||
nsresult ignoreMe;
|
||||
Fail (status, nsnull, &ignoreMe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1214,7 +1234,7 @@ mime_write_message_body(nsIMsgSend *state, char *buf, PRInt32 size)
|
|||
|
||||
nsOutputFileStream * output;
|
||||
state->GetOutputStream(&output);
|
||||
if (!output)
|
||||
if (!output || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_9))
|
||||
return NS_MSG_ERROR_WRITING_FILE;
|
||||
|
||||
if (PRInt32(output->write(buf, size)) < size)
|
||||
|
@ -1512,7 +1532,7 @@ nsMsgComposeAndSend::ProcessMultipartRelated(PRInt32 *aMailboxCount, PRInt32 *aN
|
|||
// what we got before. It always should, BUT If it doesn't,
|
||||
// we will have memory problems and we should just return
|
||||
// with an error.
|
||||
if (multipartCount != mMultipartRelatedAttachmentCount) {
|
||||
if ((multipartCount != mMultipartRelatedAttachmentCount) || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_17)) {
|
||||
return NS_ERROR_MIME_MPART_ATTACHMENT_ERROR;
|
||||
}
|
||||
|
||||
|
@ -2682,6 +2702,10 @@ nsMsgComposeAndSend::Init(
|
|||
// Tell the user we are assembling the message...
|
||||
mComposeBundle->GetStringByID(NS_MSG_ASSEMBLING_MESSAGE, getter_Copies(msg));
|
||||
SetStatusMessage( msg );
|
||||
if (mSendReport)
|
||||
mSendReport->SetCurrentProcess(nsIMsgSendReport::process_BuildMessage);
|
||||
|
||||
RETURN_SIMULATED_ERROR(SIMULATED_SEND_ERROR_1, NS_ERROR_FAILURE);
|
||||
|
||||
//
|
||||
// The Init() method should initialize a send operation for full
|
||||
|
@ -2845,7 +2869,8 @@ nsMsgComposeAndSend::DeliverMessage()
|
|||
// if this is a mongo email...we should have a way to warn the user that
|
||||
// they are about to do something they may not want to do.
|
||||
//
|
||||
if ( (mMessageWarningSize > 0) && (mTempFileSpec->GetFileSize() > mMessageWarningSize) && (mGUINotificationEnabled))
|
||||
if (((mMessageWarningSize > 0) && (mTempFileSpec->GetFileSize() > mMessageWarningSize) && (mGUINotificationEnabled)) ||
|
||||
CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_15))
|
||||
{
|
||||
PRBool abortTheSend = PR_FALSE;
|
||||
|
||||
|
@ -2864,7 +2889,8 @@ nsMsgComposeAndSend::DeliverMessage()
|
|||
nsMsgAskBooleanQuestionByString(prompt, printfString, &abortTheSend);
|
||||
if (!abortTheSend)
|
||||
{
|
||||
Fail(NS_ERROR_BUT_DONT_SHOW_ALERT, printfString);
|
||||
nsresult ignoreMe;
|
||||
Fail(NS_ERROR_BUT_DONT_SHOW_ALERT, printfString, &ignoreMe);
|
||||
PR_FREEIF(printfString);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2924,6 +2950,9 @@ nsMsgComposeAndSend::DeliverFileAsMail()
|
|||
(mCompFields->GetBcc() ? PL_strlen (mCompFields->GetBcc()) + 10 : 0) +
|
||||
10);
|
||||
|
||||
if (mSendReport)
|
||||
mSendReport->SetCurrentProcess(nsIMsgSendReport::process_SMTP);
|
||||
|
||||
nsCOMPtr<nsIPrompt> promptObject;
|
||||
GetDefaultPrompt(getter_AddRefs(promptObject));
|
||||
|
||||
|
@ -2932,7 +2961,8 @@ nsMsgComposeAndSend::DeliverFileAsMail()
|
|||
nsXPIDLString eMsg;
|
||||
mComposeBundle->GetStringByID(NS_ERROR_OUT_OF_MEMORY, getter_Copies(eMsg));
|
||||
|
||||
Fail(NS_ERROR_OUT_OF_MEMORY, eMsg);
|
||||
nsresult ignoreMe;
|
||||
Fail(NS_ERROR_OUT_OF_MEMORY, eMsg, &ignoreMe);
|
||||
NotifyListenerOnStopSending(nsnull, NS_ERROR_OUT_OF_MEMORY, nsnull, nsnull);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -3001,11 +3031,7 @@ nsMsgComposeAndSend::DeliverFileAsMail()
|
|||
nsMsgDeliveryListener * aListener = new nsMsgDeliveryListener(SendDeliveryCallback, nsMailDelivery, this);
|
||||
nsCOMPtr<nsIUrlListener> uriListener = do_QueryInterface(aListener);
|
||||
if (!uriListener)
|
||||
{
|
||||
if (mGUINotificationEnabled)
|
||||
nsMsgDisplayMessageByID(promptObject, NS_ERROR_SENDING_MESSAGE);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Note: Don't do a SetMsgComposeAndSendObject since we are in the same thread, and
|
||||
// using callbacks for notification
|
||||
|
@ -3020,8 +3046,8 @@ nsMsgComposeAndSend::DeliverFileAsMail()
|
|||
// to the top most mail window...after all, that's where we are going to be sending status
|
||||
// update information too....
|
||||
|
||||
nsCOMPtr<nsIInterfaceRequestor> callbacks;
|
||||
GetNotificationCallbacks(getter_AddRefs(callbacks));
|
||||
nsCOMPtr<nsIInterfaceRequestor> callbacks;
|
||||
GetNotificationCallbacks(getter_AddRefs(callbacks));
|
||||
|
||||
// Tell the user we are sending the message!
|
||||
nsXPIDLString msg;
|
||||
|
@ -3044,6 +3070,10 @@ nsMsgComposeAndSend::DeliverFileAsNews()
|
|||
nsresult rv = NS_OK;
|
||||
if (!(mCompFields->GetNewsgroups()))
|
||||
return rv;
|
||||
|
||||
if (mSendReport)
|
||||
mSendReport->SetCurrentProcess(nsIMsgSendReport::process_NNTP);
|
||||
|
||||
nsCOMPtr<nsIPrompt> promptObject;
|
||||
GetDefaultPrompt(getter_AddRefs(promptObject));
|
||||
|
||||
|
@ -3054,11 +3084,7 @@ nsMsgComposeAndSend::DeliverFileAsNews()
|
|||
nsMsgDeliveryListener * aListener = new nsMsgDeliveryListener(SendDeliveryCallback, nsNewsDelivery, this);
|
||||
nsCOMPtr<nsIUrlListener> uriListener = do_QueryInterface(aListener);
|
||||
if (!uriListener)
|
||||
{
|
||||
if (mGUINotificationEnabled)
|
||||
nsMsgDisplayMessageByID(promptObject, NS_ERROR_SENDING_MESSAGE);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Note: Don't do a SetMsgComposeAndSendObject since we are in the same thread, and
|
||||
// using callbacks for notification
|
||||
|
@ -3096,31 +3122,27 @@ nsMsgComposeAndSend::DeliverFileAsNews()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgComposeAndSend::Fail(nsresult failure_code, const PRUnichar * error_msg)
|
||||
nsMsgComposeAndSend::Fail(nsresult failure_code, const PRUnichar * error_msg, nsresult *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = failure_code;
|
||||
|
||||
if (NS_FAILED(failure_code))
|
||||
{
|
||||
// in certain cases, we've already shown the alert
|
||||
// and we don't need to show another alert here.
|
||||
if (failure_code != NS_ERROR_BUT_DONT_SHOW_ALERT && failure_code != NS_ERROR_ABORT)
|
||||
if (mGUINotificationEnabled)
|
||||
{
|
||||
if (mLastErrorReported == NS_OK) //Avoid to report several time a failure error!
|
||||
{
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
GetDefaultPrompt(getter_AddRefs(prompt));
|
||||
|
||||
if (!error_msg)
|
||||
{
|
||||
if (NS_FAILED(nsMsgDisplayMessageByID(prompt, failure_code)))
|
||||
nsMsgDisplayMessageByID(prompt, NS_ERROR_SEND_FAILED);
|
||||
}
|
||||
else
|
||||
nsMsgDisplayMessageByString(prompt, error_msg);
|
||||
|
||||
mLastErrorReported = failure_code;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
GetDefaultPrompt(getter_AddRefs(prompt));
|
||||
|
||||
if (mSendReport)
|
||||
{
|
||||
mSendReport->SetError(nsIMsgSendReport::process_Current, failure_code, PR_FALSE);
|
||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg, PR_FALSE);
|
||||
mSendReport->DisplayReport(prompt, PR_TRUE, PR_TRUE, _retval);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (failure_code != NS_ERROR_BUT_DONT_SHOW_ALERT)
|
||||
nsMsgDisplayMessageByID(prompt, NS_ERROR_SEND_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_attachments_done_callback)
|
||||
|
@ -3154,7 +3176,7 @@ nsMsgComposeAndSend::DoDeliveryExitProcessing(nsIURI * aUri, nsresult aExitCode,
|
|||
nsXPIDLString eMsg;
|
||||
mComposeBundle->GetStringByID(aExitCode, getter_Copies(eMsg));
|
||||
|
||||
Fail(aExitCode, eMsg);
|
||||
Fail(aExitCode, eMsg, &aExitCode);
|
||||
NotifyListenerOnStopSending(nsnull, aExitCode, nsnull, nsnull);
|
||||
return;
|
||||
}
|
||||
|
@ -3243,6 +3265,9 @@ nsMsgComposeAndSend::DoFcc()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mSendReport)
|
||||
mSendReport->SetCurrentProcess(nsIMsgSendReport::process_Copy);
|
||||
|
||||
//
|
||||
// If we are here, then we need to save off the FCC file to save and
|
||||
// start the copy operation. MimeDoFCC() will take care of all of this
|
||||
|
@ -3392,6 +3417,9 @@ nsMsgComposeAndSend::NotifyListenerOnStopCopy(nsresult aStatus)
|
|||
//
|
||||
if ( NS_SUCCEEDED(aStatus) && (mNeedToPerformSecondFCC) )
|
||||
{
|
||||
if (mSendReport)
|
||||
mSendReport->SetCurrentProcess(nsIMsgSendReport::process_FCC);
|
||||
|
||||
mNeedToPerformSecondFCC = PR_FALSE;
|
||||
|
||||
const char *fcc2 = mCompFields->GetFcc2();
|
||||
|
@ -3403,26 +3431,7 @@ nsMsgComposeAndSend::NotifyListenerOnStopCopy(nsresult aStatus)
|
|||
fcc2,
|
||||
mCompFields->GetNewspostUrl());
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
//
|
||||
// If we hit here, the copy operation FAILED and we should at least tell the
|
||||
// user that it did fail but the send operation has already succeeded.
|
||||
//
|
||||
PRBool oopsGiveMeBackTheComposeWindow = PR_FALSE;
|
||||
|
||||
nsXPIDLString eMsg;
|
||||
mComposeBundle->GetStringByID(NS_MSG_FAILED_COPY_OPERATION, getter_Copies(eMsg));
|
||||
Fail(NS_ERROR_BUT_DONT_SHOW_ALERT, eMsg);
|
||||
|
||||
if (mGUINotificationEnabled)
|
||||
{
|
||||
nsMsgAskBooleanQuestionByString(prompt, eMsg, &oopsGiveMeBackTheComposeWindow);
|
||||
if (!oopsGiveMeBackTheComposeWindow)
|
||||
aStatus = NS_OK;
|
||||
else
|
||||
aStatus = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
Fail(rv, nsnull, &aStatus);
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3434,31 +3443,7 @@ nsMsgComposeAndSend::NotifyListenerOnStopCopy(nsresult aStatus)
|
|||
// user that it did fail but the send operation has already succeeded. This only if
|
||||
// we are sending the message and not just saving it!
|
||||
|
||||
if ( m_deliver_mode != nsMsgSaveAsDraft && m_deliver_mode != nsMsgSaveAsTemplate )
|
||||
{
|
||||
PRBool oopsGiveMeBackTheComposeWindow = PR_FALSE;
|
||||
|
||||
nsXPIDLString eMsg;
|
||||
mComposeBundle->GetStringByID(NS_MSG_FAILED_COPY_OPERATION, getter_Copies(eMsg));
|
||||
Fail(NS_ERROR_BUT_DONT_SHOW_ALERT, eMsg);
|
||||
|
||||
if (mGUINotificationEnabled)
|
||||
{
|
||||
nsMsgAskBooleanQuestionByString(prompt, eMsg, &oopsGiveMeBackTheComposeWindow);
|
||||
if (!oopsGiveMeBackTheComposeWindow)
|
||||
aStatus = NS_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsXPIDLString eMsg;
|
||||
if (m_deliver_mode == nsMsgSaveAsTemplate)
|
||||
mComposeBundle->GetStringByID(NS_MSG_UNABLE_TO_SAVE_TEMPLATE, getter_Copies(eMsg));
|
||||
else
|
||||
mComposeBundle->GetStringByID(NS_MSG_UNABLE_TO_SAVE_DRAFT, getter_Copies(eMsg));
|
||||
Fail(aStatus, eMsg);
|
||||
aStatus = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
}
|
||||
Fail(aStatus, nsnull, &aStatus);
|
||||
}
|
||||
|
||||
// If we are here, its real cleanup time!
|
||||
|
@ -3529,6 +3514,11 @@ nsMsgComposeAndSend::CreateAndSendMessage(
|
|||
)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
/* First thing to do is to reset the send errors report */
|
||||
mSendReport->Reset();
|
||||
mSendReport->SetDeliveryMode(mode);
|
||||
|
||||
mParentWindow = parentWindow;
|
||||
mSendProgress = progress;
|
||||
|
@ -3551,10 +3541,10 @@ nsMsgComposeAndSend::CreateAndSendMessage(
|
|||
attachments, preloaded_attachments,
|
||||
password);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NS_OK;
|
||||
else
|
||||
return rv;
|
||||
if (NS_FAILED(rv) && mSendReport)
|
||||
mSendReport->SetError(nsIMsgSendReport::process_Current, rv, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -3572,6 +3562,10 @@ nsMsgComposeAndSend::SendMessageFile(
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
/* First thing to do is to reset the send errors report */
|
||||
mSendReport->Reset();
|
||||
mSendReport->SetDeliveryMode(mode);
|
||||
|
||||
if (!fields)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
|
@ -3615,10 +3609,13 @@ nsMsgComposeAndSend::SendMessageFile(
|
|||
nsnull, nsnull,
|
||||
password);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return DeliverMessage();
|
||||
else
|
||||
return rv;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = DeliverMessage();
|
||||
|
||||
if (NS_FAILED(rv) && mSendReport)
|
||||
mSendReport->SetError(nsIMsgSendReport::process_Current, rv, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsMsgAttachmentData *
|
||||
|
@ -3767,6 +3764,8 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
|||
mSendProgress->GetProcessCanceledByUser(&canceled);
|
||||
if (canceled)
|
||||
return NS_ERROR_ABORT;
|
||||
else
|
||||
mSendProgress->OnProgressChange(nsnull, nsnull, 0, 0, 0, -1);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -3796,23 +3795,16 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
|||
delete tFileSpec;
|
||||
if (! tempOutfile.is_open())
|
||||
{
|
||||
// Need to determine what type of operation failed and set status accordingly.
|
||||
switch (mode)
|
||||
if (mSendReport)
|
||||
{
|
||||
case nsMsgQueueForLater:
|
||||
status = NS_MSG_UNABLE_TO_SEND_LATER;
|
||||
break;
|
||||
case nsMsgSaveAsDraft:
|
||||
status = NS_MSG_UNABLE_TO_SAVE_DRAFT;
|
||||
break;
|
||||
case nsMsgSaveAsTemplate:
|
||||
status = NS_MSG_UNABLE_TO_SAVE_TEMPLATE;
|
||||
break;
|
||||
case nsMsgDeliverNow:
|
||||
default:
|
||||
status = NS_MSG_COULDNT_OPEN_FCC_FOLDER;
|
||||
break;
|
||||
nsAutoString error_msg;
|
||||
nsAutoString path;
|
||||
tFileSpec->GetNativePathString(path);
|
||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||
}
|
||||
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||
|
||||
NS_RELEASE(mCopyFileSpec);
|
||||
return status;
|
||||
}
|
||||
|
@ -3821,8 +3813,16 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
|||
// Get our files ready...
|
||||
//
|
||||
nsInputFileStream inputFile(*input_file);
|
||||
if (!inputFile.is_open())
|
||||
if (!inputFile.is_open() || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_2))
|
||||
{
|
||||
if (mSendReport)
|
||||
{
|
||||
nsAutoString error_msg;
|
||||
nsAutoString path;
|
||||
input_file->GetNativePathString(path);
|
||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_FILE, error_msg, &path, nsnull);
|
||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||
}
|
||||
status = NS_MSG_UNABLE_TO_OPEN_FILE;
|
||||
goto FAIL;
|
||||
}
|
||||
|
@ -4211,6 +4211,16 @@ nsMsgComposeAndSend::SetGUINotificationState(PRBool aEnableFlag)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIMsgSendReport sendReport; */
|
||||
NS_IMETHODIMP
|
||||
nsMsgComposeAndSend::GetSendReport(nsIMsgSendReport * *aSendReport)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSendReport);
|
||||
*aSendReport = mSendReport;
|
||||
NS_IF_ADDREF(*aSendReport);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgComposeAndSend::Abort()
|
||||
{
|
||||
PRUint32 i;
|
||||
|
|
|
@ -384,7 +384,8 @@ private:
|
|||
// will set m_attachment1_body & m_attachment1_body_length;
|
||||
nsresult EnsureLineBreaks(const char *body, PRUint32 body_len);
|
||||
|
||||
nsCString mSmtpPassword; // store the smtp Password use during a send
|
||||
nsCOMPtr<nsIMsgSendReport> mSendReport;
|
||||
nsCString mSmtpPassword; // store the smtp Password use during a send
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsISmtpUrl.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "prlog.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
|
@ -60,26 +61,6 @@ static NS_DEFINE_CID(kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
|
|||
static NS_DEFINE_CID(kMsgSendCID, NS_MSGSEND_CID);
|
||||
static NS_DEFINE_CID(kISupportsArrayCID, NS_SUPPORTSARRAY_CID);
|
||||
|
||||
//
|
||||
// This function will be used by the factory to generate the
|
||||
// nsMsgComposeAndSend Object....
|
||||
//
|
||||
nsresult NS_NewMsgSendLater(const nsIID &aIID, void ** aInstancePtrResult)
|
||||
{
|
||||
/* note this new macro for assertions...they can take a string describing the assertion */
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
|
||||
if (nsnull != aInstancePtrResult)
|
||||
{
|
||||
nsMsgSendLater *pSendLater = new nsMsgSendLater();
|
||||
if (pSendLater)
|
||||
return pSendLater->QueryInterface(NS_GET_IID(nsIMsgSendLater), aInstancePtrResult);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsMsgSendLater, nsIMsgSendLater, nsIStreamListener)
|
||||
|
||||
nsMsgSendLater::nsMsgSendLater()
|
||||
|
@ -154,6 +135,7 @@ nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult s
|
|||
|
||||
// See if we succeeded on reading the message from the message store?
|
||||
//
|
||||
SET_SIMULATED_ERROR(SIMULATED_SEND_ERROR_13, status, NS_ERROR_FAILURE);
|
||||
if (NS_SUCCEEDED(status))
|
||||
{
|
||||
// Now, so some analysis on the identity for this particular message!
|
||||
|
@ -421,8 +403,20 @@ SendOperationListener::OnStopSending(const char *aMsgID, nsresult aStatus, const
|
|||
}
|
||||
else
|
||||
{
|
||||
// shame we can't get access to a prompt interface from here...=(
|
||||
nsMsgDisplayMessageByID(nsnull, NS_ERROR_SEND_FAILED);
|
||||
/*TODO
|
||||
if (mSendReport)
|
||||
{
|
||||
// shame we can't get access to a prompt interface from here...=(
|
||||
mSendReport->SetError(nsIMsgSendReport::process_Current, aStatus, PR_FALSE);
|
||||
mSendReport->DisplayReport(nsnull, PR_TRUE, PR_TRUE, &aStatus);
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
// shame we can't get access to a prompt interface from here...=(
|
||||
if (aStatus != NS_ERROR_BUT_DONT_SHOW_ALERT && aStatus != NS_ERROR_ABORT)
|
||||
nsMsgDisplayMessageByID(nsnull, NS_ERROR_SEND_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
// Regardless, we will still keep trying to send the rest...
|
||||
|
|
|
@ -0,0 +1,422 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jean-Francois Ducarroz <ducarroz@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsMsgSendReport.h"
|
||||
|
||||
#include "msgCore.h"
|
||||
#include "nsIMsgCompose.h"
|
||||
#include "nsMsgComposeStringBundle.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsMsgPrompts.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMsgProcessReport, nsIMsgProcessReport)
|
||||
|
||||
nsMsgProcessReport::nsMsgProcessReport()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
Reset();
|
||||
}
|
||||
|
||||
nsMsgProcessReport::~nsMsgProcessReport()
|
||||
{
|
||||
}
|
||||
|
||||
/* attribute boolean proceeded; */
|
||||
NS_IMETHODIMP nsMsgProcessReport::GetProceeded(PRBool *aProceeded)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProceeded);
|
||||
*aProceeded = mProceeded;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsMsgProcessReport::SetProceeded(PRBool aProceeded)
|
||||
{
|
||||
mProceeded = aProceeded;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsresult error; */
|
||||
NS_IMETHODIMP nsMsgProcessReport::GetError(nsresult *aError)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aError);
|
||||
*aError = mError;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsMsgProcessReport::SetError(nsresult aError)
|
||||
{
|
||||
mError = aError;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring message; */
|
||||
NS_IMETHODIMP nsMsgProcessReport::GetMessage(PRUnichar * *aMessage)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMessage);
|
||||
*aMessage = mMessage.ToNewUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsMsgProcessReport::SetMessage(const PRUnichar * aMessage)
|
||||
{
|
||||
mMessage = aMessage;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void Reset (); */
|
||||
NS_IMETHODIMP nsMsgProcessReport::Reset()
|
||||
{
|
||||
mProceeded = PR_FALSE;
|
||||
mError = NS_OK;
|
||||
mMessage.AssignWithConversion("");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMsgSendReport, nsIMsgSendReport)
|
||||
|
||||
nsMsgSendReport::nsMsgSendReport()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i <= SEND_LAST_PROCESS; i ++)
|
||||
NS_NEWXPCOM(mProcessReport[i], nsMsgProcessReport);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
nsMsgSendReport::~nsMsgSendReport()
|
||||
{
|
||||
PRUint32 i;
|
||||
for (i = 0; i <= SEND_LAST_PROCESS; i ++)
|
||||
mProcessReport[i] = nsnull;
|
||||
}
|
||||
|
||||
/* attribute long currentProcess; */
|
||||
NS_IMETHODIMP nsMsgSendReport::GetCurrentProcess(PRInt32 *aCurrentProcess)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCurrentProcess);
|
||||
*aCurrentProcess = mCurrentProcess;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsMsgSendReport::SetCurrentProcess(PRInt32 aCurrentProcess)
|
||||
{
|
||||
if (aCurrentProcess < 0 || aCurrentProcess > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
mCurrentProcess = aCurrentProcess;
|
||||
if (mProcessReport[mCurrentProcess])
|
||||
mProcessReport[mCurrentProcess]->SetProceeded(PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute long deliveryMode; */
|
||||
NS_IMETHODIMP nsMsgSendReport::GetDeliveryMode(PRInt32 *aDeliveryMode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDeliveryMode);
|
||||
*aDeliveryMode = mDeliveryMode;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsMsgSendReport::SetDeliveryMode(PRInt32 aDeliveryMode)
|
||||
{
|
||||
mDeliveryMode = aDeliveryMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void Reset (); */
|
||||
NS_IMETHODIMP nsMsgSendReport::Reset()
|
||||
{
|
||||
PRUint32 i;
|
||||
for (i = 0; i <= SEND_LAST_PROCESS; i ++)
|
||||
if (mProcessReport[i])
|
||||
mProcessReport[i]->Reset();
|
||||
|
||||
mCurrentProcess = 0;
|
||||
mDeliveryMode = 0;
|
||||
mAlreadyDisplayReport = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setProceeded (in long process, in boolean proceeded); */
|
||||
NS_IMETHODIMP nsMsgSendReport::SetProceeded(PRInt32 process, PRBool proceeded)
|
||||
{
|
||||
if (process < process_Current || process > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
if (!mProcessReport[process])
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mProcessReport[process]->SetProceeded(proceeded);
|
||||
}
|
||||
|
||||
/* void setError (in long process, in nsresult error, in boolean overwriteError); */
|
||||
NS_IMETHODIMP nsMsgSendReport::SetError(PRInt32 process, nsresult newError, PRBool overwriteError)
|
||||
{
|
||||
if (process < process_Current || process > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
if (!mProcessReport[process])
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult currError = NS_OK;
|
||||
mProcessReport[process]->GetError(&currError);
|
||||
if (overwriteError || currError == NS_OK)
|
||||
return mProcessReport[process]->SetError(newError);
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setMessage (in long process, in wstring message, in boolean overwriteMessage); */
|
||||
NS_IMETHODIMP nsMsgSendReport::SetMessage(PRInt32 process, const PRUnichar *message, PRBool overwriteMessage)
|
||||
{
|
||||
if (process < process_Current || process > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
if (!mProcessReport[process])
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsXPIDLString currMessage;
|
||||
mProcessReport[process]->GetMessage(getter_Copies(currMessage));
|
||||
if (overwriteMessage || (!currMessage) || (const char *)currMessage[0] == 0)
|
||||
return mProcessReport[process]->SetMessage(message);
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIMsgProcessReport getProcessReport (in long process); */
|
||||
NS_IMETHODIMP nsMsgSendReport::GetProcessReport(PRInt32 process, nsIMsgProcessReport **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (process < process_Current || process > SEND_LAST_PROCESS)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
if (process == process_Current)
|
||||
process = mCurrentProcess;
|
||||
|
||||
*_retval = mProcessReport[process];
|
||||
NS_IF_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsresult displayReport (in nsIPrompt prompt, in boolean showErrorOnly, in boolean dontShowReportTwice); */
|
||||
NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showErrorOnly, PRBool dontShowReportTwice, nsresult *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult currError = NS_OK;
|
||||
mProcessReport[mCurrentProcess]->GetError(&currError);
|
||||
*_retval = currError;
|
||||
|
||||
if (dontShowReportTwice && mAlreadyDisplayReport)
|
||||
return NS_OK;
|
||||
|
||||
if (showErrorOnly && NS_SUCCEEDED(currError))
|
||||
return NS_OK;
|
||||
|
||||
nsXPIDLString currMessage;
|
||||
mProcessReport[mCurrentProcess]->GetMessage(getter_Copies(currMessage));
|
||||
|
||||
|
||||
nsCOMPtr<nsIMsgStringService> composebundle (do_GetService(NS_MSG_COMPOSESTRINGSERVICE_CONTRACTID));
|
||||
if (!composebundle)
|
||||
{
|
||||
//TODO need to display a generic hardcoded message
|
||||
mAlreadyDisplayReport = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXPIDLString dialogTitle;
|
||||
nsXPIDLString dialogMessage;
|
||||
|
||||
if (NS_SUCCEEDED(currError))
|
||||
{
|
||||
//TODO display a success error message
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//Do we have an explanation of the error? if no, try to build one...
|
||||
if (currMessage.IsEmpty())
|
||||
{
|
||||
switch (currError)
|
||||
{
|
||||
case NS_ERROR_SEND_FAILED:
|
||||
case NS_ERROR_SEND_FAILED_BUT_NNTP_OK:
|
||||
case NS_MSG_FAILED_COPY_OPERATION:
|
||||
case NS_MSG_UNABLE_TO_SEND_LATER:
|
||||
case NS_MSG_UNABLE_TO_SAVE_DRAFT:
|
||||
case NS_MSG_UNABLE_TO_SAVE_TEMPLATE:
|
||||
//Ignore, don't need to repeat ourself.
|
||||
break;
|
||||
default:
|
||||
nsAutoString errorMsg;
|
||||
nsMsgBuildErrorMessageByID(currError, errorMsg);
|
||||
|
||||
if (! errorMsg.IsEmpty())
|
||||
currMessage.Adopt(errorMsg.ToNewUnicode());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mDeliveryMode == nsIMsgCompDeliverMode::Now)
|
||||
{
|
||||
// SMTP is taking care of it's own error message and will return NS_ERROR_BUT_DONT_SHOW_ALERT as error code.
|
||||
// In that case, we must not show an alert ourself.
|
||||
if (currError == NS_ERROR_BUT_DONT_SHOW_ALERT)
|
||||
{
|
||||
mAlreadyDisplayReport = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
composebundle->GetStringByID(NS_MSG_SEND_ERROR_TITLE, getter_Copies(dialogTitle));
|
||||
|
||||
PRInt32 preStrId = NS_ERROR_SEND_FAILED;
|
||||
PRBool askToGoBackToCompose = PR_FALSE;
|
||||
switch (mCurrentProcess)
|
||||
{
|
||||
case process_BuildMessage :
|
||||
preStrId = NS_ERROR_SEND_FAILED;
|
||||
askToGoBackToCompose = PR_FALSE;
|
||||
break;
|
||||
case process_NNTP :
|
||||
preStrId = NS_ERROR_SEND_FAILED;
|
||||
askToGoBackToCompose = PR_FALSE;
|
||||
break;
|
||||
case process_SMTP :
|
||||
PRBool nntpProceeded;
|
||||
mProcessReport[process_NNTP]->GetProceeded(&nntpProceeded);
|
||||
if (nntpProceeded)
|
||||
preStrId = NS_ERROR_SEND_FAILED_BUT_NNTP_OK;
|
||||
else
|
||||
preStrId = NS_ERROR_SEND_FAILED;
|
||||
askToGoBackToCompose = PR_FALSE;
|
||||
break;
|
||||
case process_Copy:
|
||||
preStrId = NS_MSG_FAILED_COPY_OPERATION;
|
||||
askToGoBackToCompose = PR_TRUE;
|
||||
break;
|
||||
case process_FCC:
|
||||
preStrId = NS_MSG_FAILED_COPY_OPERATION;
|
||||
askToGoBackToCompose = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
composebundle->GetStringByID(preStrId, getter_Copies(dialogMessage));
|
||||
|
||||
//Do we already have an error message?
|
||||
if (!askToGoBackToCompose && currMessage.IsEmpty())
|
||||
{
|
||||
//we don't have an error description but we can put a generic explanation
|
||||
composebundle->GetStringByID(NS_MSG_GENERIC_FAILURE_EXPLANATION, getter_Copies(currMessage));
|
||||
}
|
||||
|
||||
if (!currMessage.IsEmpty())
|
||||
{
|
||||
nsAutoString temp((const PRUnichar *)dialogMessage); // Because of bug 74726, we cannot use directly an XPIDLString
|
||||
if (! dialogMessage.IsEmpty())
|
||||
temp.Append(NS_LITERAL_STRING("\n"));
|
||||
temp.Append(currMessage);
|
||||
dialogMessage.Adopt(temp.ToNewUnicode());
|
||||
}
|
||||
|
||||
if (askToGoBackToCompose)
|
||||
{
|
||||
PRBool oopsGiveMeBackTheComposeWindow = PR_TRUE;
|
||||
nsXPIDLString text1;
|
||||
composebundle->GetStringByID(NS_MSG_ASK_TO_COMEBACK_TO_COMPOSE, getter_Copies(text1));
|
||||
nsAutoString temp((const PRUnichar *)dialogMessage); // Because of bug 74726, we cannot use directly an XPIDLString
|
||||
if (! dialogMessage.IsEmpty())
|
||||
temp.Append(NS_LITERAL_STRING("\n"));
|
||||
temp.Append(text1);
|
||||
dialogMessage.Adopt(temp.ToNewUnicode());
|
||||
nsMsgAskBooleanQuestionByString(prompt, dialogMessage, &oopsGiveMeBackTheComposeWindow, dialogTitle);
|
||||
if (!oopsGiveMeBackTheComposeWindow)
|
||||
*_retval = NS_OK;
|
||||
}
|
||||
else
|
||||
nsMsgDisplayMessageByString(prompt, dialogMessage, dialogTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 titleID;
|
||||
PRInt32 preStrId;
|
||||
|
||||
switch (mDeliveryMode)
|
||||
{
|
||||
case nsIMsgCompDeliverMode::Later:
|
||||
titleID = NS_MSG_SENDLATER_ERROR_TITLE;
|
||||
preStrId = NS_MSG_UNABLE_TO_SEND_LATER;
|
||||
break;
|
||||
|
||||
case nsIMsgCompDeliverMode::SaveAsDraft:
|
||||
titleID = NS_MSG_SAVE_DRAFT_TITLE;
|
||||
preStrId = NS_MSG_UNABLE_TO_SAVE_DRAFT;
|
||||
break;
|
||||
|
||||
case nsIMsgCompDeliverMode::SaveAsTemplate:
|
||||
titleID = NS_MSG_SAVE_TEMPLATE_TITLE;
|
||||
preStrId = NS_MSG_UNABLE_TO_SAVE_TEMPLATE;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* This should never happend! */
|
||||
titleID = NS_MSG_SEND_ERROR_TITLE;
|
||||
preStrId = NS_ERROR_SEND_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
composebundle->GetStringByID(titleID, getter_Copies(dialogTitle));
|
||||
composebundle->GetStringByID(preStrId, getter_Copies(dialogMessage));
|
||||
|
||||
//Do we have an error message...
|
||||
if (currMessage.IsEmpty())
|
||||
{
|
||||
//we don't have an error description but we can put a generic explanation
|
||||
composebundle->GetStringByID(NS_MSG_GENERIC_FAILURE_EXPLANATION, getter_Copies(currMessage));
|
||||
}
|
||||
|
||||
if (!currMessage.IsEmpty())
|
||||
{
|
||||
nsAutoString temp((const PRUnichar *)dialogMessage); // Because of bug 74726, we cannot use directly an XPIDLString
|
||||
if (! dialogMessage.IsEmpty())
|
||||
temp.Append(NS_LITERAL_STRING("\n"));
|
||||
temp.Append(currMessage);
|
||||
dialogMessage.Adopt(temp.ToNewUnicode());
|
||||
}
|
||||
|
||||
nsMsgDisplayMessageByString(prompt, dialogMessage, dialogTitle);
|
||||
}
|
||||
|
||||
mAlreadyDisplayReport = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jean-Francois Ducarroz <ducarroz@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef __nsMsgSendReport_h__
|
||||
#define __nsMsgSendReport_h__
|
||||
|
||||
#include "nsIMsgSendReport.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsMsgProcessReport : public nsIMsgProcessReport
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMSGPROCESSREPORT
|
||||
|
||||
nsMsgProcessReport();
|
||||
virtual ~nsMsgProcessReport();
|
||||
|
||||
private:
|
||||
PRBool mProceeded;
|
||||
nsresult mError;
|
||||
nsString mMessage;
|
||||
};
|
||||
|
||||
|
||||
class nsMsgSendReport : public nsIMsgSendReport
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMSGSENDREPORT
|
||||
|
||||
nsMsgSendReport();
|
||||
virtual ~nsMsgSendReport();
|
||||
|
||||
private:
|
||||
#define SEND_LAST_PROCESS process_FCC
|
||||
nsCOMPtr<nsIMsgProcessReport> mProcessReport[SEND_LAST_PROCESS + 1];
|
||||
PRInt32 mDeliveryMode;
|
||||
PRInt32 mCurrentProcess;
|
||||
PRBool mAlreadyDisplayReport;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,73 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jean-Francois Ducarroz <ducarroz@netscape.com>
|
||||
*/
|
||||
|
||||
#define SIMULATE_ERROR 0
|
||||
|
||||
#if (SIMULATE_ERROR)
|
||||
extern long SIMULATED_SEND_ERROR_ID;
|
||||
|
||||
enum
|
||||
{
|
||||
SIMULATED_SEND_ERROR_1 = 1, // Failure during the initialization
|
||||
SIMULATED_SEND_ERROR_2, // Failure while openning message to copy
|
||||
SIMULATED_SEND_ERROR_3, // Failure while opening a temp file for attachment handling
|
||||
SIMULATED_SEND_ERROR_4, // Failure while opening a temp file for converting to plain text a part. JFD: IMPORTANT TO TEST THIS CASE!
|
||||
SIMULATED_SEND_ERROR_5, // Failure while Locate a Message Folder
|
||||
SIMULATED_SEND_ERROR_6, // Simulate no sender
|
||||
SIMULATED_SEND_ERROR_7, // Simulate no recipient - nsMsgSend
|
||||
SIMULATED_SEND_ERROR_8, // Simulate no recipient - inside smtp
|
||||
SIMULATED_SEND_ERROR_9, // Simulate failure in mime_write_message_body
|
||||
SIMULATED_SEND_ERROR_10, // Simulate SMTP logging error
|
||||
SIMULATED_SEND_ERROR_11, // Simulate SMTP protocol error (1)
|
||||
SIMULATED_SEND_ERROR_12, // Simulate SMTP protocol error (2)
|
||||
SIMULATED_SEND_ERROR_13, // Simulate Sent unsent messages error
|
||||
SIMULATED_SEND_ERROR_14, // Simulate charset conversion error (plaintext only)
|
||||
SIMULATED_SEND_ERROR_15, // Simulate large message warning
|
||||
SIMULATED_SEND_ERROR_16, // Failure getting user email address in smtp
|
||||
SIMULATED_SEND_ERROR_17, // Failure while retreiving multipart related object
|
||||
|
||||
SIMULATED_SEND_ERROR_EOL
|
||||
};
|
||||
|
||||
//JFD: last error simulated is NS_ERROR_BUT_DONT_SHOW_ALERT
|
||||
|
||||
long SIMULATED_SEND_ERROR_ID = 0;
|
||||
|
||||
#define SET_SIMULATED_ERROR(id, var, err) \
|
||||
if (SIMULATED_SEND_ERROR_ID == id) \
|
||||
var = err;
|
||||
|
||||
#define RETURN_SIMULATED_ERROR(id, err) \
|
||||
if (SIMULATED_SEND_ERROR_ID == id) \
|
||||
return err;
|
||||
|
||||
#define CHECK_SIMULATED_ERROR(id) \
|
||||
(SIMULATED_SEND_ERROR_ID == id)
|
||||
|
||||
#else
|
||||
|
||||
#define SET_SIMULATED_ERROR(id, var, err)
|
||||
#define RETURN_SIMULATED_ERROR(id, err)
|
||||
#define CHECK_SIMULATED_ERROR(id) (0)
|
||||
|
||||
#endif
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsEscape.h"
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
#include "nsISSLSocketControl.h"
|
||||
/* sigh, cmtcmn.h, included from nsIPSMSocketInfo.h, includes windows.h, which includes winuser.h,
|
||||
|
@ -548,7 +549,7 @@ PRInt32 nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, PRUint32
|
|||
* we don't care
|
||||
*/
|
||||
|
||||
if(!((const char *)emailAddress))
|
||||
if(!((const char *)emailAddress) || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_16))
|
||||
{
|
||||
m_urlErrorState = NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS;
|
||||
return(NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS);
|
||||
|
@ -911,7 +912,7 @@ PRInt32 nsSmtpProtocol::AuthLoginPassword()
|
|||
PRInt32 passwordLength = nsCRT::strlen((const char *) origPassword);
|
||||
if (!(const char*) origPassword || passwordLength == 0)
|
||||
return NS_ERROR_SMTP_PASSWORD_UNDEFINED;
|
||||
password.Assign((const char*) origPassword);
|
||||
password.Assign((const char*) origPassword);
|
||||
}
|
||||
else
|
||||
password.Assign(mLogonCookie);
|
||||
|
@ -955,7 +956,7 @@ PRInt32 nsSmtpProtocol::SendMailResponse()
|
|||
PRInt32 status = 0;
|
||||
nsCAutoString buffer;
|
||||
|
||||
if(m_responseCode != 250)
|
||||
if(m_responseCode != 250 || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_11))
|
||||
{
|
||||
nsresult rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_FROM_COMMAND, (const char*)m_responseText);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
|
@ -1018,11 +1019,11 @@ PRInt32 nsSmtpProtocol::SendRecipientResponse()
|
|||
|
||||
if(m_responseCode != 250 && m_responseCode != 251)
|
||||
{
|
||||
nsresult rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_RCPT_COMMAND, (const char*)m_responseText);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
nsresult rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_RCPT_COMMAND, (const char*)m_responseText);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_SENDING_RCPT_COMMAND);
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_SENDING_RCPT_COMMAND);
|
||||
}
|
||||
|
||||
if(m_addressesLeft > 0)
|
||||
|
@ -1049,28 +1050,28 @@ PRInt32 nsSmtpProtocol::SendRecipientResponse()
|
|||
|
||||
PRInt32 nsSmtpProtocol::SendData(nsIURI *url, const char *dataBuffer, PRBool aSuppressLogging)
|
||||
{
|
||||
if (!dataBuffer) return -1;
|
||||
if (!dataBuffer) return -1;
|
||||
|
||||
if (!aSuppressLogging) {
|
||||
PR_LOG(SMTPLogModule, PR_LOG_ALWAYS, ("SMTP Send: %s", dataBuffer));
|
||||
} else {
|
||||
PR_LOG(SMTPLogModule, PR_LOG_ALWAYS, ("Logging suppressed for this command (it probably contained authentication information)"));
|
||||
}
|
||||
return nsMsgAsyncWriteProtocol::SendData(url, dataBuffer);
|
||||
if (!aSuppressLogging) {
|
||||
PR_LOG(SMTPLogModule, PR_LOG_ALWAYS, ("SMTP Send: %s", dataBuffer));
|
||||
} else {
|
||||
PR_LOG(SMTPLogModule, PR_LOG_ALWAYS, ("Logging suppressed for this command (it probably contained authentication information)"));
|
||||
}
|
||||
return nsMsgAsyncWriteProtocol::SendData(url, dataBuffer);
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsSmtpProtocol::SendDataResponse()
|
||||
{
|
||||
PRInt32 status = 0;
|
||||
char * command=0;
|
||||
PRInt32 status = 0;
|
||||
char * command=0;
|
||||
|
||||
if((m_responseCode != 354) && (m_responseCode != 250)) {
|
||||
nsresult rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_DATA_COMMAND, (const char*)m_responseText);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
if((m_responseCode != 354) && (m_responseCode != 250)) {
|
||||
nsresult rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_DATA_COMMAND, (const char*)m_responseText);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_SENDING_DATA_COMMAND);
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_SENDING_DATA_COMMAND);
|
||||
}
|
||||
#ifdef UNREADY_CODE
|
||||
#ifdef XP_UNIX
|
||||
|
@ -1207,15 +1208,15 @@ PRInt32 nsSmtpProtocol::SendPostData()
|
|||
PRInt32 nsSmtpProtocol::SendMessageResponse()
|
||||
{
|
||||
|
||||
if((m_responseCode != 354) && (m_responseCode != 250)) {
|
||||
nsresult rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_MESSAGE, (const char*)m_responseText);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
if(((m_responseCode != 354) && (m_responseCode != 250)) || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_12)) {
|
||||
nsresult rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_MESSAGE, (const char*)m_responseText);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
|
||||
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_SENDING_MESSAGE);
|
||||
m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
|
||||
return(NS_ERROR_SENDING_MESSAGE);
|
||||
}
|
||||
|
||||
UpdateStatus(SMTP_PROGRESS_MAILSENT);
|
||||
UpdateStatus(SMTP_PROGRESS_MAILSENT);
|
||||
|
||||
/* else */
|
||||
nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningURL);
|
||||
|
@ -1304,7 +1305,7 @@ nsresult nsSmtpProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer )
|
|||
PR_FREEIF (addrs1);
|
||||
}
|
||||
|
||||
if (m_addressesLeft == 0 || addrs2 == nsnull) // hmm no addresses to send message to...
|
||||
if (m_addressesLeft == 0 || addrs2 == nsnull || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_8)) // hmm no addresses to send message to...
|
||||
{
|
||||
m_nextState = SMTP_ERROR_DONE;
|
||||
ClearFlag(SMTP_PAUSE_FOR_READ);
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsMsgComposeStringBundle.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
|
||||
typedef struct _findServerByKeyEntry {
|
||||
const char *key;
|
||||
|
@ -128,7 +129,7 @@ nsresult nsSmtpService::SendMailMessage(nsIFileSpec * aFilePath,
|
|||
smtpServer->GetHostname(getter_Copies(smtpHostName));
|
||||
smtpServer->GetUsername(getter_Copies(smtpUserName));
|
||||
|
||||
if ((const char*)smtpHostName && (const char*)smtpHostName[0] != 0)
|
||||
if ((const char*)smtpHostName && (const char*)smtpHostName[0] != 0 && !CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_10))
|
||||
{
|
||||
rv = NS_MsgBuildSmtpUrl(aFilePath, smtpHostName, smtpUserName,
|
||||
aRecipients, aSenderIdentity, aUrlListener, aStatusFeedback,
|
||||
|
|
Загрузка…
Ссылка в новой задаче