зеркало из https://github.com/mozilla/pjs.git
Bug 355008: Convert most of nsMsgSend to nsIFile. r=bienvenu, sr=mscott
This commit is contained in:
Родитель
46891fef68
Коммит
244162b964
|
@ -44,22 +44,17 @@
|
||||||
|
|
||||||
interface nsIMsgCompFields;
|
interface nsIMsgCompFields;
|
||||||
interface nsIMsgIdentity;
|
interface nsIMsgIdentity;
|
||||||
|
interface nsIOutputStream;
|
||||||
%{C++
|
|
||||||
class nsOutputFileStream;
|
|
||||||
%}
|
|
||||||
|
|
||||||
[ptr] native nsOutputFileStream(nsOutputFileStream);
|
|
||||||
|
|
||||||
/* Security interface */
|
/* Security interface */
|
||||||
[noscript, uuid(ed899511-b473-4a93-ba02-d8cb90d58e1c)]
|
[noscript, uuid(245f2adc-410e-4bdb-91e2-a7bb42d61787)]
|
||||||
interface nsIMsgComposeSecure : nsISupports
|
interface nsIMsgComposeSecure : nsISupports
|
||||||
{
|
{
|
||||||
// requiresCryptoEncapsulation --> returns true if the current message send requires us to go through
|
// requiresCryptoEncapsulation --> returns true if the current message send requires us to go through
|
||||||
// some encryption work. In the case of false, you can disregard the compose secure object.
|
// some encryption work. In the case of false, you can disregard the compose secure object.
|
||||||
boolean requiresCryptoEncapsulation(in nsIMsgIdentity aIdentity, in nsIMsgCompFields aCompFields);
|
boolean requiresCryptoEncapsulation(in nsIMsgIdentity aIdentity, in nsIMsgCompFields aCompFields);
|
||||||
|
|
||||||
void beginCryptoEncapsulation(in nsOutputFileStream aStream, in string aRecipients, in nsIMsgCompFields aCompFields, in nsIMsgIdentity aIdentity, in nsIMsgSendReport sendReport, in boolean aIsDraft);
|
void beginCryptoEncapsulation(in nsIOutputStream aStream, in string aRecipients, in nsIMsgCompFields aCompFields, in nsIMsgIdentity aIdentity, in nsIMsgSendReport sendReport, in boolean aIsDraft);
|
||||||
void finishCryptoEncapsulation(in boolean aAbort, in nsIMsgSendReport sendReport);
|
void finishCryptoEncapsulation(in boolean aAbort, in nsIMsgSendReport sendReport);
|
||||||
void mimeCryptoWriteBlock(in string aBuf, in long aLen);
|
void mimeCryptoWriteBlock(in string aBuf, in long aLen);
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
class nsFileSpec;
|
class nsFileSpec;
|
||||||
class nsOutputFileStream;
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
interface nsIMsgProgress;
|
interface nsIMsgProgress;
|
||||||
|
@ -69,6 +68,8 @@ interface nsIMsgDBHdr;
|
||||||
interface nsIMsgHdr;
|
interface nsIMsgHdr;
|
||||||
interface nsIDocShell;
|
interface nsIDocShell;
|
||||||
interface nsIFileSpec;
|
interface nsIFileSpec;
|
||||||
|
interface nsIFile;
|
||||||
|
interface nsIOutputStream;
|
||||||
interface nsIMsgComposeSecure;
|
interface nsIMsgComposeSecure;
|
||||||
interface nsIMsgStatusFeedback;
|
interface nsIMsgStatusFeedback;
|
||||||
interface nsIEditor;
|
interface nsIEditor;
|
||||||
|
@ -162,10 +163,9 @@ typedef struct nsMsgAttachedFile
|
||||||
[ptr] native nsMsgAttachmentData(nsMsgAttachmentData);
|
[ptr] native nsMsgAttachmentData(nsMsgAttachmentData);
|
||||||
[ptr] native nsMsgAttachedFile(nsMsgAttachedFile);
|
[ptr] native nsMsgAttachedFile(nsMsgAttachedFile);
|
||||||
[ptr] native nsMsgAttachmentHandler(nsMsgAttachmentHandler);
|
[ptr] native nsMsgAttachmentHandler(nsMsgAttachmentHandler);
|
||||||
[ptr] native nsOutputFileStream(nsOutputFileStream);
|
|
||||||
[ptr] native nsCString(nsCString);
|
[ptr] native nsCString(nsCString);
|
||||||
|
|
||||||
[scriptable, uuid(39876de6-207f-43f4-99a7-d60f1c49ea48)]
|
[scriptable, uuid(7d3aad47-b742-42b8-b5af-0af65cd1b366)]
|
||||||
interface nsIMsgSend : nsISupports
|
interface nsIMsgSend : nsISupports
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -213,7 +213,7 @@ interface nsIMsgSend : nsISupports
|
||||||
void sendMessageFile(in nsIMsgIdentity aUserIdentity,
|
void sendMessageFile(in nsIMsgIdentity aUserIdentity,
|
||||||
in string aAccountKey,
|
in string aAccountKey,
|
||||||
in nsIMsgCompFields fields,
|
in nsIMsgCompFields fields,
|
||||||
in nsIFileSpec sendIFileSpec,
|
in nsIFile sendIFile,
|
||||||
in PRBool deleteSendFileOnCompletion,
|
in PRBool deleteSendFileOnCompletion,
|
||||||
in PRBool digest_p,
|
in PRBool digest_p,
|
||||||
in nsMsgDeliverMode mode,
|
in nsMsgDeliverMode mode,
|
||||||
|
@ -265,9 +265,9 @@ interface nsIMsgSend : nsISupports
|
||||||
|
|
||||||
[noscript] nsIMsgProgress getProgress();
|
[noscript] nsIMsgProgress getProgress();
|
||||||
|
|
||||||
[noscript] nsOutputFileStream getOutputStream();
|
nsIOutputStream getOutputStream();
|
||||||
|
|
||||||
[noscript] attribute nsIRequest runningRequest;
|
[noscript] attribute nsIRequest runningRequest;
|
||||||
|
|
||||||
[noscript] attribute nsresult status;
|
[noscript] attribute nsresult status;
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,29 @@ NS_IMETHODIMP nsMsgCompUtils::GetMsgMimeConformToStandard(PRBool *_retval)
|
||||||
//
|
//
|
||||||
#define TPATH_LEN 1024
|
#define TPATH_LEN 1024
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create a file for the a unique temp file
|
||||||
|
// on the local machine. Caller must free memory
|
||||||
|
//
|
||||||
|
nsresult
|
||||||
|
nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile)
|
||||||
|
{
|
||||||
|
if ((!tFileName) || (!*tFileName))
|
||||||
|
tFileName = "nsmail.tmp";
|
||||||
|
|
||||||
|
nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR,
|
||||||
|
tFileName,
|
||||||
|
tFile);
|
||||||
|
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = (*tFile)->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
NS_RELEASE(*tFile);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a file spec for the a unique temp file
|
// Create a file spec for the a unique temp file
|
||||||
// on the local machine. Caller must free memory
|
// on the local machine. Caller must free memory
|
||||||
|
|
|
@ -72,6 +72,7 @@ PR_BEGIN_EXTERN_C
|
||||||
// in as a template
|
// in as a template
|
||||||
//
|
//
|
||||||
nsFileSpec *nsMsgCreateTempFileSpec(const char *tFileName);
|
nsFileSpec *nsMsgCreateTempFileSpec(const char *tFileName);
|
||||||
|
nsresult nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile);
|
||||||
char *nsMsgCreateTempFileName(const char *tFileName);
|
char *nsMsgCreateTempFileName(const char *tFileName);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include "nsIMsgCopyServiceListener.h"
|
#include "nsIMsgCopyServiceListener.h"
|
||||||
#include "nsIFileSpec.h"
|
#include "nsIFileSpec.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
|
#include "nsNetUtil.h"
|
||||||
#include "nsIFileURL.h"
|
#include "nsIFileURL.h"
|
||||||
#include "nsMsgCopy.h"
|
#include "nsMsgCopy.h"
|
||||||
#include "nsXPIDLString.h"
|
#include "nsXPIDLString.h"
|
||||||
|
@ -77,7 +78,6 @@
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
#include "nsMsgCompCID.h"
|
#include "nsMsgCompCID.h"
|
||||||
#include "nsIFileSpec.h"
|
|
||||||
#include "nsIAbAddressCollecter.h"
|
#include "nsIAbAddressCollecter.h"
|
||||||
#include "nsAbBaseCID.h"
|
#include "nsAbBaseCID.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
@ -268,11 +268,11 @@ nsMsgComposeAndSend::nsMsgComposeAndSend() :
|
||||||
mOriginalHTMLBody = nsnull;
|
mOriginalHTMLBody = nsnull;
|
||||||
|
|
||||||
// These are for temp file creation and return
|
// These are for temp file creation and return
|
||||||
mReturnFileSpec = nsnull;
|
mReturnFile = nsnull;
|
||||||
mTempFileSpec = nsnull;
|
mTempFile = nsnull;
|
||||||
mHTMLFileSpec = nsnull;
|
mHTMLFile = nsnull;
|
||||||
mCopyFileSpec = nsnull;
|
mCopyFile = nsnull;
|
||||||
mCopyFileSpec2 = nsnull;
|
mCopyFile2 = nsnull;
|
||||||
mCopyObj = nsnull;
|
mCopyObj = nsnull;
|
||||||
mNeedToPerformSecondFCC = PR_FALSE;
|
mNeedToPerformSecondFCC = PR_FALSE;
|
||||||
|
|
||||||
|
@ -379,50 +379,39 @@ nsMsgComposeAndSend::Clear()
|
||||||
m_plaintext = nsnull;
|
m_plaintext = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHTMLFileSpec)
|
if (mHTMLFile)
|
||||||
{
|
{
|
||||||
mHTMLFileSpec->Delete(PR_FALSE);
|
mHTMLFile->Remove(PR_FALSE);
|
||||||
delete mHTMLFileSpec;
|
mHTMLFile = nsnull;
|
||||||
mHTMLFileSpec= nsnull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOutputFile)
|
if (mOutputFile)
|
||||||
{
|
mOutputFile = nsnull;
|
||||||
delete mOutputFile;
|
|
||||||
mOutputFile = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mCopyFileSpec)
|
if (mCopyFile)
|
||||||
{
|
{
|
||||||
nsFileSpec aFileSpec;
|
mCopyFile->Remove(PR_FALSE);
|
||||||
mCopyFileSpec->GetFileSpec(&aFileSpec);
|
|
||||||
if (aFileSpec.Valid())
|
|
||||||
aFileSpec.Delete(PR_FALSE);
|
|
||||||
|
|
||||||
// jt -- *don't* use delete someone may still holding the nsIFileSpec
|
// jt -- *don't* use delete someone may still holding the nsIFile
|
||||||
// pointer
|
// pointer
|
||||||
NS_IF_RELEASE(mCopyFileSpec);
|
mCopyFile = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCopyFileSpec2)
|
if (mCopyFile2)
|
||||||
{
|
{
|
||||||
nsFileSpec aFileSpec;
|
mCopyFile2->Remove(PR_FALSE);
|
||||||
mCopyFileSpec2->GetFileSpec(&aFileSpec);
|
|
||||||
if (aFileSpec.Valid())
|
|
||||||
aFileSpec.Delete(PR_FALSE);
|
|
||||||
|
|
||||||
// jt -- *don't* use delete someone may still holding the nsIFileSpec
|
// jt -- *don't* use delete someone may still holding the nsIFile
|
||||||
// pointer
|
// pointer
|
||||||
NS_IF_RELEASE(mCopyFileSpec2);
|
mCopyFile2 = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTempFileSpec)
|
if (mTempFile)
|
||||||
{
|
{
|
||||||
if (mReturnFileSpec == nsnull)
|
if (mReturnFile == nsnull)
|
||||||
{
|
{
|
||||||
mTempFileSpec->Delete(PR_FALSE);
|
mTempFile->Remove(PR_FALSE);
|
||||||
delete mTempFileSpec;
|
mTempFile = nsnull;
|
||||||
mTempFileSpec = nsnull;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,6 +655,8 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
||||||
goto FAILMEM;
|
goto FAILMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
// If we have a text/html main part, and we need a plaintext attachment, then
|
// If we have a text/html main part, and we need a plaintext attachment, then
|
||||||
// we'll do so now. This is an asynchronous thing, so we'll kick it off and
|
// we'll do so now. This is an asynchronous thing, so we'll kick it off and
|
||||||
// count on getting back here when it finishes.
|
// count on getting back here when it finishes.
|
||||||
|
@ -681,19 +672,20 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
||||||
// fire off another URL request for this local disk file and that will
|
// fire off another URL request for this local disk file and that will
|
||||||
// take care of the conversion...
|
// take care of the conversion...
|
||||||
//
|
//
|
||||||
mHTMLFileSpec = nsMsgCreateTempFileSpec("nsmail.html");
|
rv = nsMsgCreateTempFile("nsemail.html", getter_AddRefs(mHTMLFile));
|
||||||
if (!mHTMLFileSpec)
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
goto FAILMEM;
|
|
||||||
|
|
||||||
nsOutputFileStream tempfile(*mHTMLFileSpec, kDefaultMode, 00600);
|
nsCOMPtr<nsIOutputStream> tempfile;
|
||||||
if (! tempfile.is_open())
|
rv = NS_NewLocalFileOutputStream(getter_AddRefs(tempfile), mHTMLFile, -1, 00600);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
if (mSendReport)
|
if (mSendReport)
|
||||||
{
|
{
|
||||||
nsAutoString error_msg;
|
nsAutoString error_msg;
|
||||||
|
nsCAutoString cPath;
|
||||||
nsAutoString path;
|
nsAutoString path;
|
||||||
NS_CopyNativeToUnicode(
|
mTempFile->GetNativePath(cPath);
|
||||||
nsDependentCString(mHTMLFileSpec->GetNativePathCString()), path);
|
NS_CopyNativeToUnicode(cPath, path);
|
||||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||||
}
|
}
|
||||||
|
@ -703,23 +695,23 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
||||||
|
|
||||||
if (mOriginalHTMLBody)
|
if (mOriginalHTMLBody)
|
||||||
{
|
{
|
||||||
PRUint32 origLen = strlen(mOriginalHTMLBody);
|
PRUint32 origLen = strlen(mOriginalHTMLBody);
|
||||||
status = tempfile.write(mOriginalHTMLBody, origLen);
|
PRUint32 n;
|
||||||
if (status < int(origLen))
|
nsresult rv = tempfile->Write(mOriginalHTMLBody, origLen, &n);
|
||||||
|
if (NS_FAILED(rv) || n != origLen)
|
||||||
{
|
{
|
||||||
if (status >= 0)
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
status = NS_MSG_ERROR_WRITING_FILE;
|
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(tempfile.flush()) || tempfile.failed())
|
if (NS_FAILED(tempfile->Flush()))
|
||||||
{
|
{
|
||||||
status = NS_MSG_ERROR_WRITING_FILE;
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tempfile.close();
|
tempfile->Close();
|
||||||
|
|
||||||
m_plaintext = new nsMsgAttachmentHandler;
|
m_plaintext = new nsMsgAttachmentHandler;
|
||||||
if (!m_plaintext)
|
if (!m_plaintext)
|
||||||
|
@ -727,16 +719,15 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
||||||
m_plaintext->SetMimeDeliveryState(this);
|
m_plaintext->SetMimeDeliveryState(this);
|
||||||
m_plaintext->m_bogus_attachment = PR_TRUE;
|
m_plaintext->m_bogus_attachment = PR_TRUE;
|
||||||
|
|
||||||
char *tempURL = nsMsgPlatformFileToURL (*mHTMLFileSpec);
|
nsCAutoString tempURL;
|
||||||
if (!tempURL || NS_FAILED(nsMsgNewURL(getter_AddRefs(m_plaintext->mURL), tempURL)))
|
rv = NS_GetURLSpecFromFile(mHTMLFile, tempURL);
|
||||||
|
if (NS_FAILED(rv) || NS_FAILED(nsMsgNewURL(getter_AddRefs(m_plaintext->mURL), tempURL.get())))
|
||||||
{
|
{
|
||||||
delete m_plaintext;
|
delete m_plaintext;
|
||||||
m_plaintext = nsnull;
|
m_plaintext = nsnull;
|
||||||
goto FAILMEM;
|
goto FAILMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_FREEIF(tempURL);
|
|
||||||
|
|
||||||
PR_FREEIF(m_plaintext->m_type);
|
PR_FREEIF(m_plaintext->m_type);
|
||||||
m_plaintext->m_type = PL_strdup(TEXT_HTML);
|
m_plaintext->m_type = PL_strdup(TEXT_HTML);
|
||||||
PR_FREEIF(m_plaintext->m_charset);
|
PR_FREEIF(m_plaintext->m_charset);
|
||||||
|
@ -765,20 +756,20 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
||||||
|
|
||||||
/* First, open the message file.
|
/* First, open the message file.
|
||||||
*/
|
*/
|
||||||
mTempFileSpec = nsMsgCreateTempFileSpec("nsmail.eml");
|
rv = nsMsgCreateTempFile("nsemail.eml", getter_AddRefs(mTempFile));
|
||||||
if (! mTempFileSpec)
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
goto FAILMEM;
|
|
||||||
|
|
||||||
mOutputFile = new nsOutputFileStream(*mTempFileSpec, kDefaultMode, 00600);
|
rv = NS_NewLocalFileOutputStream(getter_AddRefs(mOutputFile), mTempFile, -1, 00600);
|
||||||
if (! mOutputFile->is_open() || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_4))
|
if (NS_FAILED(rv) || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_4))
|
||||||
{
|
{
|
||||||
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||||
if (mSendReport)
|
if (mSendReport)
|
||||||
{
|
{
|
||||||
nsAutoString error_msg;
|
nsAutoString error_msg;
|
||||||
|
nsCAutoString cPath;
|
||||||
nsAutoString path;
|
nsAutoString path;
|
||||||
NS_CopyNativeToUnicode(
|
mTempFile->GetNativePath(cPath);
|
||||||
nsDependentCString(mTempFileSpec->GetNativePathCString()), path);
|
NS_CopyNativeToUnicode(cPath, path);
|
||||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||||
}
|
}
|
||||||
|
@ -1136,20 +1127,26 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
||||||
|
|
||||||
if (mOutputFile)
|
if (mOutputFile)
|
||||||
{
|
{
|
||||||
if (NS_FAILED(mOutputFile->flush()) || mOutputFile->failed())
|
if (NS_FAILED(mOutputFile->Flush()))
|
||||||
{
|
{
|
||||||
status = NS_MSG_ERROR_WRITING_FILE;
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutputFile->close();
|
mOutputFile->Close();
|
||||||
delete mOutputFile;
|
|
||||||
mOutputFile = nsnull;
|
mOutputFile = nsnull;
|
||||||
|
|
||||||
|
// mTempFile is stale because we wrote to it. Get another copy to refresh.
|
||||||
|
nsCOMPtr<nsIFile> tempFileCopy;
|
||||||
|
mTempFile->Clone(getter_AddRefs(tempFileCopy));
|
||||||
|
mTempFile = tempFileCopy;
|
||||||
|
tempFileCopy = nsnull;
|
||||||
/* If we don't do this check...ZERO length files can be sent */
|
/* If we don't do this check...ZERO length files can be sent */
|
||||||
if (mTempFileSpec->GetFileSize() == 0)
|
PRInt64 fileSize;
|
||||||
|
rv = mTempFile->GetFileSize(&fileSize);
|
||||||
|
if (NS_FAILED(rv) || fileSize == 0)
|
||||||
{
|
{
|
||||||
status = NS_MSG_ERROR_WRITING_FILE;
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1163,13 +1160,17 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
||||||
// Need to ditch the file spec here so that we don't delete the
|
// Need to ditch the file spec here so that we don't delete the
|
||||||
// file, since in this case, the caller wants the file
|
// file, since in this case, the caller wants the file
|
||||||
//
|
//
|
||||||
NS_NewFileSpecWithSpec(*mTempFileSpec, &mReturnFileSpec);
|
mReturnFile = mTempFile;
|
||||||
delete mTempFileSpec;
|
mTempFile = nsnull;
|
||||||
mTempFileSpec = nsnull;
|
if (!mReturnFile)
|
||||||
if (!mReturnFileSpec)
|
|
||||||
NotifyListenerOnStopSending(nsnull, NS_ERROR_OUT_OF_MEMORY, nsnull, nsnull);
|
NotifyListenerOnStopSending(nsnull, NS_ERROR_OUT_OF_MEMORY, nsnull, nsnull);
|
||||||
else
|
else
|
||||||
NotifyListenerOnStopSending(nsnull, NS_OK, nsnull, mReturnFileSpec);
|
{
|
||||||
|
nsCOMPtr<nsIFileSpec> aFileSpec;
|
||||||
|
NS_NewFileSpecFromIFile(mTempFile, getter_AddRefs(aFileSpec));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
NotifyListenerOnStopSending(nsnull, NS_OK, nsnull, aFileSpec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1367,20 +1368,22 @@ mime_write_message_body(nsIMsgSend *state, const char *buf, PRInt32 size)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(state);
|
NS_ENSURE_ARG_POINTER(state);
|
||||||
|
|
||||||
nsOutputFileStream * output;
|
nsCOMPtr<nsIOutputStream> output;
|
||||||
nsCOMPtr<nsIMsgComposeSecure> crypto_closure;
|
nsCOMPtr<nsIMsgComposeSecure> crypto_closure;
|
||||||
|
|
||||||
state->GetOutputStream(&output);
|
state->GetOutputStream(getter_AddRefs(output));
|
||||||
if (!output || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_9))
|
if (!output || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_9))
|
||||||
return NS_MSG_ERROR_WRITING_FILE;
|
return NS_MSG_ERROR_WRITING_FILE;
|
||||||
|
|
||||||
state->GetCryptoclosure(getter_AddRefs(crypto_closure));
|
state->GetCryptoclosure(getter_AddRefs(crypto_closure));
|
||||||
if (crypto_closure)
|
if (crypto_closure)
|
||||||
{
|
{
|
||||||
return crypto_closure->MimeCryptoWriteBlock (buf, size);
|
return crypto_closure->MimeCryptoWriteBlock (buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRInt32(output->write(buf, size)) < size)
|
PRUint32 n;
|
||||||
|
nsresult rv = output->Write(buf, size, &n);
|
||||||
|
if (NS_FAILED(rv) || n != size)
|
||||||
{
|
{
|
||||||
return NS_MSG_ERROR_WRITING_FILE;
|
return NS_MSG_ERROR_WRITING_FILE;
|
||||||
}
|
}
|
||||||
|
@ -3211,7 +3214,7 @@ nsMsgComposeAndSend::Init(
|
||||||
nsIMsgIdentity *aUserIdentity,
|
nsIMsgIdentity *aUserIdentity,
|
||||||
const char *aAccountKey,
|
const char *aAccountKey,
|
||||||
nsMsgCompFields *fields,
|
nsMsgCompFields *fields,
|
||||||
nsFileSpec *sendFileSpec,
|
nsIFile *sendFile,
|
||||||
PRBool digest_p,
|
PRBool digest_p,
|
||||||
PRBool dont_deliver_p,
|
PRBool dont_deliver_p,
|
||||||
nsMsgDeliverMode mode,
|
nsMsgDeliverMode mode,
|
||||||
|
@ -3273,16 +3276,16 @@ nsMsgComposeAndSend::Init(
|
||||||
//
|
//
|
||||||
// At this point, if we are only creating this object to do
|
// At this point, if we are only creating this object to do
|
||||||
// send operations on externally created RFC822 disk files,
|
// send operations on externally created RFC822 disk files,
|
||||||
// make sure we have setup the appropriate nsFileSpec and
|
// make sure we have setup the appropriate nsIFile and
|
||||||
// move on with life.
|
// move on with life.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// First check to see if we are doing a send operation on an external file
|
// First check to see if we are doing a send operation on an external file
|
||||||
// or creating the file itself.
|
// or creating the file itself.
|
||||||
//
|
//
|
||||||
if (sendFileSpec)
|
if (sendFile)
|
||||||
{
|
{
|
||||||
mTempFileSpec = sendFileSpec;
|
mTempFile = sendFile;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3407,7 +3410,12 @@ nsMsgComposeAndSend::DeliverMessage()
|
||||||
// if this is a mongo email...we should have a way to warn the user that
|
// 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.
|
// they are about to do something they may not want to do.
|
||||||
//
|
//
|
||||||
if (((mMessageWarningSize > 0) && (mTempFileSpec->GetFileSize() > mMessageWarningSize) && (mGUINotificationEnabled)) ||
|
PRInt64 fileSize;
|
||||||
|
nsresult rv = mTempFile->GetFileSize(&fileSize);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
if (((mMessageWarningSize > 0) && (fileSize > mMessageWarningSize) && (mGUINotificationEnabled)) ||
|
||||||
CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_15))
|
CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_15))
|
||||||
{
|
{
|
||||||
PRBool abortTheSend = PR_FALSE;
|
PRBool abortTheSend = PR_FALSE;
|
||||||
|
@ -3417,7 +3425,7 @@ nsMsgComposeAndSend::DeliverMessage()
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
PRUnichar *printfString = nsTextFormatter::smprintf(msg, mTempFileSpec->GetFileSize());
|
PRUnichar *printfString = nsTextFormatter::smprintf(msg, fileSize);
|
||||||
|
|
||||||
if (printfString)
|
if (printfString)
|
||||||
{
|
{
|
||||||
|
@ -3602,7 +3610,7 @@ nsMsgComposeAndSend::DeliverFileAsMail()
|
||||||
// using callbacks for notification
|
// using callbacks for notification
|
||||||
|
|
||||||
nsCOMPtr<nsIFileSpec> aFileSpec;
|
nsCOMPtr<nsIFileSpec> aFileSpec;
|
||||||
NS_NewFileSpecWithSpec(*mTempFileSpec, getter_AddRefs(aFileSpec));
|
NS_NewFileSpecFromIFile(mTempFile, getter_AddRefs(aFileSpec));
|
||||||
|
|
||||||
// we used to get the prompt from the compose window and we'd pass that in
|
// we used to get the prompt from the compose window and we'd pass that in
|
||||||
// to the smtp protocol as the prompt to use. But when you send a message,
|
// to the smtp protocol as the prompt to use. But when you send a message,
|
||||||
|
@ -3657,11 +3665,6 @@ nsMsgComposeAndSend::DeliverFileAsNews()
|
||||||
// Note: Don't do a SetMsgComposeAndSendObject since we are in the same thread, and
|
// Note: Don't do a SetMsgComposeAndSendObject since we are in the same thread, and
|
||||||
// using callbacks for notification
|
// using callbacks for notification
|
||||||
|
|
||||||
nsCOMPtr<nsILocalFile> fileToPost;
|
|
||||||
|
|
||||||
rv = NS_FileSpecToIFile(mTempFileSpec, getter_AddRefs(fileToPost));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
// Tell the user we are posting the message!
|
// Tell the user we are posting the message!
|
||||||
nsXPIDLString msg;
|
nsXPIDLString msg;
|
||||||
mComposeBundle->GetStringByID(NS_MSG_POSTING_MESSAGE, getter_Copies(msg));
|
mComposeBundle->GetStringByID(NS_MSG_POSTING_MESSAGE, getter_Copies(msg));
|
||||||
|
@ -3680,7 +3683,7 @@ nsMsgComposeAndSend::DeliverFileAsNews()
|
||||||
if(NS_FAILED(rv))
|
if(NS_FAILED(rv))
|
||||||
msgWindow = nsnull;
|
msgWindow = nsnull;
|
||||||
|
|
||||||
rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mAccountKey.get(),
|
rv = nntpService->PostMessage(mTempFile, mCompFields->GetNewsgroups(), mAccountKey.get(),
|
||||||
uriListener, msgWindow, nsnull);
|
uriListener, msgWindow, nsnull);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
|
@ -3903,7 +3906,7 @@ nsMsgComposeAndSend::DoFcc()
|
||||||
// start the copy operation. MimeDoFCC() will take care of all of this
|
// start the copy operation. MimeDoFCC() will take care of all of this
|
||||||
// for us.
|
// for us.
|
||||||
//
|
//
|
||||||
nsresult rv = MimeDoFCC(mTempFileSpec,
|
nsresult rv = MimeDoFCC(mTempFile,
|
||||||
nsMsgDeliverNow,
|
nsMsgDeliverNow,
|
||||||
mCompFields->GetBcc(),
|
mCompFields->GetBcc(),
|
||||||
mCompFields->GetFcc(),
|
mCompFields->GetFcc(),
|
||||||
|
@ -4066,7 +4069,7 @@ nsMsgComposeAndSend::NotifyListenerOnStopCopy(nsresult aStatus)
|
||||||
const char *fcc2 = mCompFields->GetFcc2();
|
const char *fcc2 = mCompFields->GetFcc2();
|
||||||
if (fcc2 && *fcc2)
|
if (fcc2 && *fcc2)
|
||||||
{
|
{
|
||||||
nsresult rv = MimeDoFCC(mTempFileSpec,
|
nsresult rv = MimeDoFCC(mTempFile,
|
||||||
nsMsgDeliverNow,
|
nsMsgDeliverNow,
|
||||||
mCompFields->GetBcc(),
|
mCompFields->GetBcc(),
|
||||||
fcc2,
|
fcc2,
|
||||||
|
@ -4196,7 +4199,7 @@ nsMsgComposeAndSend::SendMessageFile(
|
||||||
nsIMsgIdentity *aUserIndentity,
|
nsIMsgIdentity *aUserIndentity,
|
||||||
const char *aAccountKey,
|
const char *aAccountKey,
|
||||||
nsIMsgCompFields *fields,
|
nsIMsgCompFields *fields,
|
||||||
nsIFileSpec *sendIFileSpec,
|
nsIFile *sendIFile,
|
||||||
PRBool deleteSendFileOnCompletion,
|
PRBool deleteSendFileOnCompletion,
|
||||||
PRBool digest_p,
|
PRBool digest_p,
|
||||||
nsMsgDeliverMode mode,
|
nsMsgDeliverMode mode,
|
||||||
|
@ -4219,38 +4222,24 @@ nsMsgComposeAndSend::SendMessageFile(
|
||||||
//
|
//
|
||||||
// First check to see if the external file we are sending is a valid file.
|
// First check to see if the external file we are sending is a valid file.
|
||||||
//
|
//
|
||||||
if (!sendIFileSpec)
|
if (!sendIFile)
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
PRBool valid;
|
PRBool exists;
|
||||||
if (NS_FAILED(sendIFileSpec->IsValid(&valid)))
|
if (NS_FAILED(sendIFile->Exists(&exists)))
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
if (!valid)
|
if (!exists)
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsFileSpec *sendFileSpec = nsnull;
|
|
||||||
nsFileSpec tempFileSpec;
|
|
||||||
|
|
||||||
if (NS_FAILED(sendIFileSpec->GetFileSpec(&tempFileSpec)))
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
|
|
||||||
sendFileSpec = new nsFileSpec(tempFileSpec);
|
|
||||||
if (!sendFileSpec)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
// Setup the listener...
|
// Setup the listener...
|
||||||
mListener = aListener;
|
mListener = aListener;
|
||||||
|
|
||||||
// Should we delete the temp file when done?
|
// Should we delete the temp file when done?
|
||||||
if (!deleteSendFileOnCompletion)
|
if (!deleteSendFileOnCompletion)
|
||||||
{
|
mReturnFile = sendIFile;
|
||||||
NS_NewFileSpecWithSpec(*sendFileSpec, &mReturnFileSpec);
|
|
||||||
if (!mReturnFileSpec)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = Init(aUserIndentity, aAccountKey, (nsMsgCompFields *)fields, sendFileSpec,
|
rv = Init(aUserIndentity, aAccountKey, (nsMsgCompFields *)fields, sendIFile,
|
||||||
digest_p, PR_FALSE, mode, msgToReplace,
|
digest_p, PR_FALSE, mode, msgToReplace,
|
||||||
nsnull, nsnull, nsnull,
|
nsnull, nsnull, nsnull,
|
||||||
nsnull, nsnull,
|
nsnull, nsnull,
|
||||||
|
@ -4307,7 +4296,7 @@ BuildURLAttachmentData(nsIURI *url)
|
||||||
nsresult
|
nsresult
|
||||||
nsMsgComposeAndSend::SendToMagicFolder(nsMsgDeliverMode mode)
|
nsMsgComposeAndSend::SendToMagicFolder(nsMsgDeliverMode mode)
|
||||||
{
|
{
|
||||||
nsresult rv = MimeDoFCC(mTempFileSpec,
|
nsresult rv = MimeDoFCC(mTempFile,
|
||||||
mode,
|
mode,
|
||||||
mCompFields->GetBcc(),
|
mCompFields->GetBcc(),
|
||||||
mCompFields->GetFcc(),
|
mCompFields->GetFcc(),
|
||||||
|
@ -4386,7 +4375,7 @@ nsMsgGetEnvelopeLine(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
nsMsgComposeAndSend::MimeDoFCC(nsIFile *input_file,
|
||||||
nsMsgDeliverMode mode,
|
nsMsgDeliverMode mode,
|
||||||
const char *bcc_header,
|
const char *bcc_header,
|
||||||
const char *fcc_header,
|
const char *fcc_header,
|
||||||
|
@ -4396,8 +4385,7 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
char *ibuffer = 0;
|
char *ibuffer = 0;
|
||||||
PRInt32 ibuffer_size = TEN_K;
|
PRInt32 ibuffer_size = TEN_K;
|
||||||
char *obuffer = 0;
|
char *obuffer = 0;
|
||||||
PRInt32 n;
|
PRUint32 n;
|
||||||
char *envelopeLine = nsMsgGetEnvelopeLine();
|
|
||||||
PRBool folderIsLocal = PR_TRUE;
|
PRBool folderIsLocal = PR_TRUE;
|
||||||
char *turi = nsnull;
|
char *turi = nsnull;
|
||||||
PRUnichar *printfString = nsnull;
|
PRUnichar *printfString = nsnull;
|
||||||
|
@ -4419,57 +4407,52 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
//
|
//
|
||||||
// Ok, this is here to keep track of this for 2 copy operations...
|
// Ok, this is here to keep track of this for 2 copy operations...
|
||||||
//
|
//
|
||||||
if (mCopyFileSpec)
|
if (mCopyFile)
|
||||||
{
|
{
|
||||||
mCopyFileSpec2 = mCopyFileSpec;
|
mCopyFile2 = mCopyFile;
|
||||||
mCopyFileSpec = nsnull;
|
mCopyFile = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create the file that will be used for the copy service!
|
// Create the file that will be used for the copy service!
|
||||||
//
|
//
|
||||||
nsFileSpec *tFileSpec = nsMsgCreateTempFileSpec("nscopy.tmp");
|
nsresult rv = nsMsgCreateTempFile("nscopy.tmp", getter_AddRefs(mCopyFile));
|
||||||
if (!tFileSpec)
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
NS_NewFileSpecWithSpec(*tFileSpec, &mCopyFileSpec);
|
nsCOMPtr<nsIOutputStream> tempOutfile;
|
||||||
if (!mCopyFileSpec)
|
rv = NS_NewLocalFileOutputStream(getter_AddRefs(tempOutfile), mCopyFile, -1, 00600);
|
||||||
{
|
if (NS_FAILED(rv))
|
||||||
delete tFileSpec;
|
|
||||||
return NS_ERROR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsOutputFileStream tempOutfile(*tFileSpec, PR_WRONLY | PR_CREATE_FILE, 00600);
|
|
||||||
delete tFileSpec;
|
|
||||||
if (! tempOutfile.is_open())
|
|
||||||
{
|
{
|
||||||
if (mSendReport)
|
if (mSendReport)
|
||||||
{
|
{
|
||||||
nsAutoString error_msg;
|
nsAutoString error_msg;
|
||||||
|
nsCAutoString cPath;
|
||||||
nsAutoString path;
|
nsAutoString path;
|
||||||
NS_CopyNativeToUnicode(
|
mCopyFile->GetNativePath(cPath);
|
||||||
nsDependentCString(tFileSpec->GetNativePathCString()), path);
|
NS_CopyNativeToUnicode(cPath, path);
|
||||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_TMP_FILE, error_msg, &path, nsnull);
|
||||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||||
}
|
}
|
||||||
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
status = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
|
||||||
|
|
||||||
NS_RELEASE(mCopyFileSpec);
|
mCopyFile = nsnull;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get our files ready...
|
// Get our files ready...
|
||||||
//
|
//
|
||||||
nsInputFileStream inputFile(*input_file);
|
nsCOMPtr<nsIInputStream> inputFile;
|
||||||
if (!inputFile.is_open() || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_2))
|
rv = NS_NewLocalFileInputStream(getter_AddRefs(inputFile), input_file);
|
||||||
|
if (NS_FAILED(rv) || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_2))
|
||||||
{
|
{
|
||||||
if (mSendReport)
|
if (mSendReport)
|
||||||
{
|
{
|
||||||
nsAutoString error_msg;
|
nsAutoString error_msg;
|
||||||
|
nsCAutoString cPath;
|
||||||
nsAutoString path;
|
nsAutoString path;
|
||||||
NS_CopyNativeToUnicode(
|
mTempFile->GetNativePath(cPath);
|
||||||
nsDependentCString(input_file->GetNativePathCString()), path);
|
NS_CopyNativeToUnicode(cPath, path);
|
||||||
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_FILE, error_msg, &path, nsnull);
|
nsMsgBuildErrorMessageByID(NS_MSG_UNABLE_TO_OPEN_FILE, error_msg, &path, nsnull);
|
||||||
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
mSendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), PR_FALSE);
|
||||||
}
|
}
|
||||||
|
@ -4530,12 +4513,13 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (envelopeLine) && (folderIsLocal) )
|
if (folderIsLocal)
|
||||||
{
|
{
|
||||||
PRInt32 len = PL_strlen(envelopeLine);
|
char *envelopeLine = nsMsgGetEnvelopeLine();
|
||||||
|
PRUint32 len = PL_strlen(envelopeLine);
|
||||||
|
|
||||||
n = tempOutfile.write(envelopeLine, len);
|
rv = tempOutfile->Write(envelopeLine, len, &n);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4571,10 +4555,10 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
buf = PR_smprintf(X_MOZILLA_STATUS_FORMAT CRLF, flags);
|
buf = PR_smprintf(X_MOZILLA_STATUS_FORMAT CRLF, flags);
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
PRInt32 len = PL_strlen(buf);
|
PRUint32 len = PL_strlen(buf);
|
||||||
n = tempOutfile.write(buf, len);
|
rv = tempOutfile->Write(buf, len, &n);
|
||||||
PR_Free(buf);
|
PR_Free(buf);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4592,10 +4576,10 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
buf = PR_smprintf(X_MOZILLA_STATUS2_FORMAT CRLF, flags2);
|
buf = PR_smprintf(X_MOZILLA_STATUS2_FORMAT CRLF, flags2);
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
PRInt32 len = PL_strlen(buf);
|
PRUint32 len = PL_strlen(buf);
|
||||||
n = tempOutfile.write(buf, len);
|
rv = tempOutfile->Write(buf, len, &n);
|
||||||
PR_Free(buf);
|
PR_Free(buf);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4642,9 +4626,9 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
|
|
||||||
PR_snprintf(buf, L-1, "FCC: %s" CRLF, fcc_header);
|
PR_snprintf(buf, L-1, "FCC: %s" CRLF, fcc_header);
|
||||||
|
|
||||||
PRInt32 len = PL_strlen(buf);
|
PRUint32 len = PL_strlen(buf);
|
||||||
n = tempOutfile.write(buf, len);
|
rv = tempOutfile->Write(buf, len, &n);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4669,10 +4653,10 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
buf = PR_smprintf(HEADER_X_MOZILLA_IDENTITY_KEY ": %s" CRLF, key);
|
buf = PR_smprintf(HEADER_X_MOZILLA_IDENTITY_KEY ": %s" CRLF, key);
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
PRInt32 len = strlen(buf);
|
PRUint32 len = strlen(buf);
|
||||||
n = tempOutfile.write(buf, len);
|
rv = tempOutfile->Write(buf, len, &n);
|
||||||
PR_Free(buf);
|
PR_Free(buf);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4685,10 +4669,10 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
buf = PR_smprintf(HEADER_X_MOZILLA_ACCOUNT_KEY ": %s" CRLF, mAccountKey.get());
|
buf = PR_smprintf(HEADER_X_MOZILLA_ACCOUNT_KEY ": %s" CRLF, mAccountKey.get());
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
PRInt32 len = strlen(buf);
|
PRUint32 len = strlen(buf);
|
||||||
n = tempOutfile.write(buf, len);
|
rv = tempOutfile->Write(buf, len, &n);
|
||||||
PR_Free(buf);
|
PR_Free(buf);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4718,11 +4702,11 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_snprintf(buf, L-1, "BCC: %s" CRLF, convBcc ? convBcc : bcc_header);
|
PR_snprintf(buf, L-1, "BCC: %s" CRLF, convBcc ? convBcc : bcc_header);
|
||||||
PRInt32 len = strlen(buf);
|
PRUint32 len = strlen(buf);
|
||||||
n = tempOutfile.write(buf, len);
|
rv = tempOutfile->Write(buf, len, &n);
|
||||||
PR_Free(buf);
|
PR_Free(buf);
|
||||||
PR_Free(convBcc);
|
PR_Free(convBcc);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4769,10 +4753,10 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32 len = PL_strlen(line);
|
PRUint32 len = PL_strlen(line);
|
||||||
n = tempOutfile.write(line, len);
|
rv = tempOutfile->Write(line, len, &n);
|
||||||
PR_Free(line);
|
PR_Free(line);
|
||||||
if (n != len)
|
if (NS_FAILED(rv) || n != len)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4792,29 +4776,43 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
||||||
// It's unfortunate that we end up writing the FCC file a line
|
// It's unfortunate that we end up writing the FCC file a line
|
||||||
// at a time, but it's the easiest way...
|
// at a time, but it's the easiest way...
|
||||||
//
|
//
|
||||||
while (! inputFile.eof())
|
PRUint32 available;
|
||||||
|
rv = inputFile->Available(&available);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
while (available > 0)
|
||||||
{
|
{
|
||||||
// check *ibuffer in case that ibuffer isn't big enough
|
// check *ibuffer in case that ibuffer isn't big enough
|
||||||
if (!inputFile.readline(ibuffer, ibuffer_size) && *ibuffer == 0)
|
PRUint32 readCount;
|
||||||
|
rv = inputFile->Read(ibuffer, ibuffer_size, &readCount);
|
||||||
|
if (NS_FAILED(rv) || readCount == 0 || *ibuffer == 0)
|
||||||
{
|
{
|
||||||
status = NS_ERROR_FAILURE;
|
status = NS_ERROR_FAILURE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = tempOutfile.write(ibuffer, PL_strlen(ibuffer));
|
rv = tempOutfile->Write(ibuffer, readCount, &n);
|
||||||
n += tempOutfile.write(CRLF, 2);
|
if (NS_FAILED(rv) || n != readCount) // write failed
|
||||||
if (n != (PRInt32) (PL_strlen(ibuffer) + 2)) // write failed
|
|
||||||
{
|
{
|
||||||
status = NS_MSG_ERROR_WRITING_FILE;
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rv = tempOutfile->Write(CRLF, 2, &n);
|
||||||
|
if (NS_FAILED(rv) || n != 2) // write failed
|
||||||
|
{
|
||||||
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
|
goto FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = inputFile->Available(&available);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Terminate with a final newline.
|
// Terminate with a final newline.
|
||||||
//
|
//
|
||||||
n = tempOutfile.write(CRLF, 2);
|
rv = tempOutfile->Write(CRLF, 2, &n);
|
||||||
if (n != 2) // write failed
|
if (NS_FAILED(rv) || n != 2) // write failed
|
||||||
{
|
{
|
||||||
status = NS_MSG_ERROR_WRITING_FILE;
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
@ -4826,18 +4824,13 @@ FAIL:
|
||||||
PR_Free(obuffer);
|
PR_Free(obuffer);
|
||||||
|
|
||||||
|
|
||||||
if (tempOutfile.is_open())
|
if (NS_FAILED(tempOutfile->Flush()))
|
||||||
{
|
status = NS_MSG_ERROR_WRITING_FILE;
|
||||||
if (NS_FAILED(tempOutfile.flush()) || tempOutfile.failed())
|
|
||||||
status = NS_MSG_ERROR_WRITING_FILE;
|
|
||||||
|
|
||||||
tempOutfile.close();
|
tempOutfile->Close();
|
||||||
if (mCopyFileSpec)
|
|
||||||
mCopyFileSpec->CloseStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputFile.is_open())
|
if (inputFile)
|
||||||
inputFile.close();
|
inputFile->Close();
|
||||||
|
|
||||||
//
|
//
|
||||||
// When we get here, we have to see if we have been successful so far.
|
// When we get here, we have to see if we have been successful so far.
|
||||||
|
@ -4850,7 +4843,7 @@ FAIL:
|
||||||
//
|
//
|
||||||
// If we are here, time to start the async copy service operation!
|
// If we are here, time to start the async copy service operation!
|
||||||
//
|
//
|
||||||
status = StartMessageCopyOperation(mCopyFileSpec, mode, turi);
|
status = StartMessageCopyOperation(mCopyFile, mode, turi);
|
||||||
}
|
}
|
||||||
PR_Free(turi);
|
PR_Free(turi);
|
||||||
return status;
|
return status;
|
||||||
|
@ -4861,8 +4854,8 @@ FAIL:
|
||||||
// nsMsgCopy class
|
// nsMsgCopy class
|
||||||
//
|
//
|
||||||
nsresult
|
nsresult
|
||||||
nsMsgComposeAndSend::StartMessageCopyOperation(nsIFileSpec *aFileSpec,
|
nsMsgComposeAndSend::StartMessageCopyOperation(nsIFile *aFile,
|
||||||
nsMsgDeliverMode mode,
|
nsMsgDeliverMode mode,
|
||||||
char *dest_uri)
|
char *dest_uri)
|
||||||
{
|
{
|
||||||
mCopyObj = new nsMsgCopy();
|
mCopyObj = new nsMsgCopy();
|
||||||
|
@ -4882,7 +4875,11 @@ nsMsgComposeAndSend::StartMessageCopyOperation(nsIFileSpec *aFileSpec,
|
||||||
if (mListener)
|
if (mListener)
|
||||||
mListener->OnGetDraftFolderURI(m_folderName.get());
|
mListener->OnGetDraftFolderURI(m_folderName.get());
|
||||||
|
|
||||||
rv = mCopyObj->StartCopyOperation(mUserIdentity, aFileSpec, mode,
|
nsCOMPtr<nsIFileSpec> fileSpec;
|
||||||
|
rv = NS_NewFileSpecFromIFile(aFile, getter_AddRefs(fileSpec));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = mCopyObj->StartCopyOperation(mUserIdentity, fileSpec, mode,
|
||||||
this, m_folderName.get(), mMsgToReplace);
|
this, m_folderName.get(), mMsgToReplace);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -4948,7 +4945,12 @@ nsresult nsMsgComposeAndSend::Abort()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
|
nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
copyService->NotifyCompletion(mCopyFileSpec, mCopyObj->mDstFolder, NS_ERROR_ABORT);
|
|
||||||
|
nsCOMPtr<nsIFileSpec> fileSpec;
|
||||||
|
rv = NS_NewFileSpecFromIFile(mCopyFile, getter_AddRefs(fileSpec));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
copyService->NotifyCompletion(fileSpec, mCopyObj->mDstFolder, NS_ERROR_ABORT);
|
||||||
}
|
}
|
||||||
mAbortInProcess = PR_FALSE;
|
mAbortInProcess = PR_FALSE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -5001,10 +5003,10 @@ NS_IMETHODIMP nsMsgComposeAndSend::GetProgress(nsIMsgProgress **_retval)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsMsgComposeAndSend::GetOutputStream(nsOutputFileStream * *_retval)
|
NS_IMETHODIMP nsMsgComposeAndSend::GetOutputStream(nsIOutputStream **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(_retval);
|
NS_ENSURE_ARG(_retval);
|
||||||
*_retval = mOutputFile;
|
NS_IF_ADDREF(*_retval = mOutputFile);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,7 @@
|
||||||
#include "msgCore.h"
|
#include "msgCore.h"
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
#include "nsFileStream.h"
|
#include "nsFileStream.h"
|
||||||
|
#include "nsIOutputStream.h"
|
||||||
#include "nsMsgMessageFlags.h"
|
#include "nsMsgMessageFlags.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsMsgAttachmentHandler.h"
|
#include "nsMsgAttachmentHandler.h"
|
||||||
|
@ -216,9 +217,9 @@ public:
|
||||||
nsresult FormatStringWithSMTPHostNameByID(PRInt32 aMsgId, PRUnichar **aString);
|
nsresult FormatStringWithSMTPHostNameByID(PRInt32 aMsgId, PRUnichar **aString);
|
||||||
|
|
||||||
nsresult DoFcc();
|
nsresult DoFcc();
|
||||||
nsresult StartMessageCopyOperation(nsIFileSpec *aFileSpec,
|
nsresult StartMessageCopyOperation(nsIFile *aFileSpec,
|
||||||
nsMsgDeliverMode mode,
|
nsMsgDeliverMode mode,
|
||||||
char *dest_uri);
|
char *dest_uri);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
@ -234,7 +235,7 @@ public:
|
||||||
//
|
//
|
||||||
// FCC operations...
|
// FCC operations...
|
||||||
//
|
//
|
||||||
nsresult MimeDoFCC (nsFileSpec *input_file,
|
nsresult MimeDoFCC (nsIFile *input_file,
|
||||||
nsMsgDeliverMode mode,
|
nsMsgDeliverMode mode,
|
||||||
const char *bcc_header,
|
const char *bcc_header,
|
||||||
const char *fcc_header,
|
const char *fcc_header,
|
||||||
|
@ -247,7 +248,7 @@ public:
|
||||||
nsIMsgIdentity *aUserIdentity,
|
nsIMsgIdentity *aUserIdentity,
|
||||||
const char *aAccountKey,
|
const char *aAccountKey,
|
||||||
nsMsgCompFields *fields,
|
nsMsgCompFields *fields,
|
||||||
nsFileSpec *sendFileSpec,
|
nsIFile *sendFile,
|
||||||
PRBool digest_p,
|
PRBool digest_p,
|
||||||
PRBool dont_deliver_p,
|
PRBool dont_deliver_p,
|
||||||
nsMsgDeliverMode mode,
|
nsMsgDeliverMode mode,
|
||||||
|
@ -306,9 +307,9 @@ public:
|
||||||
nsCOMPtr<nsIMsgIdentity> mUserIdentity;
|
nsCOMPtr<nsIMsgIdentity> mUserIdentity;
|
||||||
nsCString mAccountKey;
|
nsCString mAccountKey;
|
||||||
nsRefPtr<nsMsgCompFields> mCompFields; // All needed composition fields (header, etc...)
|
nsRefPtr<nsMsgCompFields> mCompFields; // All needed composition fields (header, etc...)
|
||||||
nsFileSpec *mTempFileSpec; // our temporary file
|
nsCOMPtr<nsIFile> mTempFile; // our temporary file
|
||||||
|
|
||||||
nsOutputFileStream *mOutputFile; // the actual output file stream
|
nsCOMPtr<nsIOutputStream> mOutputFile; // the actual output file stream
|
||||||
PRUint32 mMessageWarningSize; // Warn if a message is over this size!
|
PRUint32 mMessageWarningSize; // Warn if a message is over this size!
|
||||||
|
|
||||||
PRBool m_dont_deliver_p; // If set, we just return the nsFileSpec of the file
|
PRBool m_dont_deliver_p; // If set, we just return the nsFileSpec of the file
|
||||||
|
@ -325,18 +326,18 @@ public:
|
||||||
nsCOMPtr<nsIMsgStatusFeedback> mStatusFeedback;
|
nsCOMPtr<nsIMsgStatusFeedback> mStatusFeedback;
|
||||||
nsCOMPtr<nsIRequest> mRunningRequest;
|
nsCOMPtr<nsIRequest> mRunningRequest;
|
||||||
PRBool mSendMailAlso;
|
PRBool mSendMailAlso;
|
||||||
nsIFileSpec *mReturnFileSpec; // a holder for file spec's to be returned to caller
|
nsCOMPtr<nsIFile> mReturnFile; // a holder for file spec's to be returned to caller
|
||||||
|
|
||||||
// File where we stored our HTML so that we could make the plaintext form.
|
// File where we stored our HTML so that we could make the plaintext form.
|
||||||
nsFileSpec *mHTMLFileSpec;
|
nsCOMPtr<nsIFile> mHTMLFile;
|
||||||
|
|
||||||
// Variable for storing the draft name;
|
// Variable for storing the draft name;
|
||||||
nsCString m_folderName;
|
nsCString m_folderName;
|
||||||
//
|
//
|
||||||
// These variables are needed for message Copy operations!
|
// These variables are needed for message Copy operations!
|
||||||
//
|
//
|
||||||
nsIFileSpec *mCopyFileSpec;
|
nsCOMPtr<nsIFile> mCopyFile;
|
||||||
nsIFileSpec *mCopyFileSpec2;
|
nsCOMPtr<nsIFile> mCopyFile2;
|
||||||
nsMsgCopy *mCopyObj;
|
nsMsgCopy *mCopyObj;
|
||||||
PRBool mNeedToPerformSecondFCC;
|
PRBool mNeedToPerformSecondFCC;
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsISmtpUrl.h"
|
#include "nsISmtpUrl.h"
|
||||||
#include "nsIChannel.h"
|
#include "nsIChannel.h"
|
||||||
|
#include "nsNetUtil.h"
|
||||||
#include "prlog.h"
|
#include "prlog.h"
|
||||||
#include "nsMsgSimulateError.h"
|
#include "nsMsgSimulateError.h"
|
||||||
#include "nsIMimeConverter.h"
|
#include "nsIMimeConverter.h"
|
||||||
|
@ -76,8 +77,7 @@ NS_IMPL_ISUPPORTS2(nsMsgSendLater, nsIMsgSendLater, nsIStreamListener)
|
||||||
|
|
||||||
nsMsgSendLater::nsMsgSendLater()
|
nsMsgSendLater::nsMsgSendLater()
|
||||||
{
|
{
|
||||||
mTempIFileSpec = nsnull;
|
mTempFile = nsnull;
|
||||||
mTempFileSpec = nsnull;
|
|
||||||
mOutFile = nsnull;
|
mOutFile = nsnull;
|
||||||
mTotalSentSuccessfully = 0;
|
mTotalSentSuccessfully = 0;
|
||||||
mTotalSendCount = 0;
|
mTotalSendCount = 0;
|
||||||
|
@ -112,7 +112,7 @@ nsMsgSendLater::nsMsgSendLater()
|
||||||
|
|
||||||
nsMsgSendLater::~nsMsgSendLater()
|
nsMsgSendLater::~nsMsgSendLater()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(mTempIFileSpec);
|
mTempFile = nsnull;
|
||||||
PR_Free(m_to);
|
PR_Free(m_to);
|
||||||
PR_Free(m_fcc);
|
PR_Free(m_fcc);
|
||||||
PR_Free(m_bcc);
|
PR_Free(m_bcc);
|
||||||
|
@ -138,7 +138,7 @@ nsMsgSendLater::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult s
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOutFile)
|
if (mOutFile)
|
||||||
mOutFile->close();
|
mOutFile->Close();
|
||||||
|
|
||||||
// See if we succeeded on reading the message from the message store?
|
// See if we succeeded on reading the message from the message store?
|
||||||
//
|
//
|
||||||
|
@ -470,7 +470,7 @@ nsMsgSendLater::CompleteMailFileSend()
|
||||||
|
|
||||||
// If for some reason the tmp file didn't get created, we've failed here
|
// If for some reason the tmp file didn't get created, we've failed here
|
||||||
PRBool created;
|
PRBool created;
|
||||||
mTempIFileSpec->Exists(&created);
|
mTempFile->Exists(&created);
|
||||||
if (!created)
|
if (!created)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ nsMsgSendLater::CompleteMailFileSend()
|
||||||
rv = pMsgSend->SendMessageFile(identity,
|
rv = pMsgSend->SendMessageFile(identity,
|
||||||
mAccountKey,
|
mAccountKey,
|
||||||
compFields, // nsIMsgCompFields *fields,
|
compFields, // nsIMsgCompFields *fields,
|
||||||
mTempIFileSpec, // nsIFileSpec *sendFileSpec,
|
mTempFile, // nsIFile *sendFileSpec,
|
||||||
PR_TRUE, // PRBool deleteSendFileOnCompletion,
|
PR_TRUE, // PRBool deleteSendFileOnCompletion,
|
||||||
PR_FALSE, // PRBool digest_p,
|
PR_FALSE, // PRBool digest_p,
|
||||||
nsIMsgSend::nsMsgSendUnsent, // nsMsgDeliverMode mode,
|
nsIMsgSend::nsMsgSendUnsent, // nsMsgDeliverMode mode,
|
||||||
|
@ -601,13 +601,9 @@ nsMsgSendLater::StartNextMailFileSend()
|
||||||
printf("Sending message: [%s]\n", (const char*)subject);
|
printf("Sending message: [%s]\n", (const char*)subject);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mTempFileSpec = nsMsgCreateTempFileSpec("nsqmail.tmp");
|
|
||||||
if (!mTempFileSpec)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
NS_NewFileSpecWithSpec(*mTempFileSpec, &mTempIFileSpec);
|
rv = nsMsgCreateTempFile("nsqmail.tmp", getter_AddRefs(mTempFile));
|
||||||
if (!mTempIFileSpec)
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
nsCOMPtr <nsIMsgMessageService> messageService;
|
nsCOMPtr <nsIMsgMessageService> messageService;
|
||||||
rv = GetMessageServiceFromURI(messageURI, getter_AddRefs(messageService));
|
rv = GetMessageServiceFromURI(messageURI, getter_AddRefs(messageService));
|
||||||
|
@ -1068,15 +1064,17 @@ nsMsgSendLater::DeliverQueuedLine(char *line, PRInt32 length)
|
||||||
// and write the appropriate subset of the headers out.
|
// and write the appropriate subset of the headers out.
|
||||||
m_inhead = PR_FALSE;
|
m_inhead = PR_FALSE;
|
||||||
|
|
||||||
mOutFile = new nsOutputFileStream(*mTempFileSpec, PR_WRONLY | PR_CREATE_FILE, 00600);
|
nsresult rv = NS_NewLocalFileOutputStream(getter_AddRefs(mOutFile), mTempFile, -1, 00600);
|
||||||
if ( (!mOutFile) || (!mOutFile->is_open()) )
|
if (NS_FAILED(rv))
|
||||||
return NS_MSG_ERROR_WRITING_FILE;
|
return NS_MSG_ERROR_WRITING_FILE;
|
||||||
|
|
||||||
nsresult status = BuildHeaders();
|
nsresult status = BuildHeaders();
|
||||||
if (NS_FAILED(status))
|
if (NS_FAILED(status))
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
if (mOutFile->write(m_headers, m_headersFP) != m_headersFP)
|
PRUint32 n;
|
||||||
|
rv = mOutFile->Write(m_headers, m_headersFP, &n);
|
||||||
|
if (NS_FAILED(rv) || n != m_headersFP)
|
||||||
return NS_MSG_ERROR_WRITING_FILE;
|
return NS_MSG_ERROR_WRITING_FILE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1104,8 +1102,9 @@ nsMsgSendLater::DeliverQueuedLine(char *line, PRInt32 length)
|
||||||
PR_ASSERT(mOutFile);
|
PR_ASSERT(mOutFile);
|
||||||
if (mOutFile)
|
if (mOutFile)
|
||||||
{
|
{
|
||||||
PRInt32 wrote = mOutFile->write(line, length);
|
PRUint32 wrote;
|
||||||
if (wrote < (PRInt32) length)
|
nsresult rv = mOutFile->Write(line, length, &wrote);
|
||||||
|
if (NS_FAILED(rv) || wrote < (PRUint32) length)
|
||||||
return NS_MSG_ERROR_WRITING_FILE;
|
return NS_MSG_ERROR_WRITING_FILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,9 +136,8 @@ private:
|
||||||
//
|
//
|
||||||
// File output stuff...
|
// File output stuff...
|
||||||
//
|
//
|
||||||
nsFileSpec *mTempFileSpec;
|
nsCOMPtr<nsIFile> mTempFile;
|
||||||
nsIFileSpec *mTempIFileSpec;
|
nsCOMPtr<nsIOutputStream> mOutFile;
|
||||||
nsOutputFileStream *mOutFile;
|
|
||||||
|
|
||||||
void *mTagData;
|
void *mTagData;
|
||||||
|
|
||||||
|
|
|
@ -457,7 +457,7 @@ nsresult nsMsgComposeSecure::ExtractEncryptionState(nsIMsgIdentity * aIdentity,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* void beginCryptoEncapsulation (in nsOutputFileStream aStream, in boolean aEncrypt, in boolean aSign, in string aRecipeints, in boolean aIsDraft); */
|
/* void beginCryptoEncapsulation (in nsOutputFileStream aStream, in boolean aEncrypt, in boolean aSign, in string aRecipeints, in boolean aIsDraft); */
|
||||||
NS_IMETHODIMP nsMsgComposeSecure::BeginCryptoEncapsulation(nsOutputFileStream * aStream,
|
NS_IMETHODIMP nsMsgComposeSecure::BeginCryptoEncapsulation(nsIOutputStream * aStream,
|
||||||
const char * aRecipients,
|
const char * aRecipients,
|
||||||
nsIMsgCompFields * aCompFields,
|
nsIMsgCompFields * aCompFields,
|
||||||
nsIMsgIdentity * aIdentity,
|
nsIMsgIdentity * aIdentity,
|
||||||
|
@ -557,7 +557,7 @@ nsresult nsMsgComposeSecure::MimeInitMultipartSigned(PRBool aOuter, nsIMsgSendRe
|
||||||
*/
|
*/
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
char *header = 0;
|
char *header = 0;
|
||||||
PRInt32 L;
|
PRUint32 L;
|
||||||
|
|
||||||
rv = make_multipart_signed_header_string(aOuter, &header,
|
rv = make_multipart_signed_header_string(aOuter, &header,
|
||||||
&mMultipartSignedBoundary);
|
&mMultipartSignedBoundary);
|
||||||
|
@ -567,7 +567,9 @@ nsresult nsMsgComposeSecure::MimeInitMultipartSigned(PRBool aOuter, nsIMsgSendRe
|
||||||
|
|
||||||
if (aOuter){
|
if (aOuter){
|
||||||
/* If this is the outer block, write it to the file. */
|
/* If this is the outer block, write it to the file. */
|
||||||
if (PRInt32(mStream->write(header, L)) < L) {
|
PRUint32 n;
|
||||||
|
rv = mStream->Write(header, L, &n);
|
||||||
|
if (NS_FAILED(rv) || n < L) {
|
||||||
rv = MK_MIME_ERROR_WRITING_FILE;
|
rv = MK_MIME_ERROR_WRITING_FILE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -614,10 +616,12 @@ nsresult nsMsgComposeSecure::MimeInitEncryption(PRBool aSign, nsIMsgSendReport *
|
||||||
"Content-Description: %s" CRLF
|
"Content-Description: %s" CRLF
|
||||||
CRLF,
|
CRLF,
|
||||||
MIME_SMIME_ENCRYPTED_CONTENT_DESCRIPTION);
|
MIME_SMIME_ENCRYPTED_CONTENT_DESCRIPTION);
|
||||||
PRInt32 L;
|
PRUint32 L;
|
||||||
if (!s) return NS_ERROR_OUT_OF_MEMORY;
|
if (!s) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
L = strlen(s);
|
L = strlen(s);
|
||||||
if (PRInt32(mStream->write(s, L)) < L) {
|
PRUint32 n;
|
||||||
|
rv = mStream->Write(s, L, &n);
|
||||||
|
if (NS_FAILED(rv) || n < L) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
PR_Free(s);
|
PR_Free(s);
|
||||||
|
@ -703,7 +707,7 @@ nsresult nsMsgComposeSecure::MimeFinishMultipartSigned (PRBool aOuter, nsIMsgSen
|
||||||
|
|
||||||
/* Write out the headers for the signature.
|
/* Write out the headers for the signature.
|
||||||
*/
|
*/
|
||||||
PRInt32 L;
|
PRUint32 L;
|
||||||
header =
|
header =
|
||||||
PR_smprintf(CRLF
|
PR_smprintf(CRLF
|
||||||
"--%s" CRLF
|
"--%s" CRLF
|
||||||
|
@ -724,7 +728,9 @@ nsresult nsMsgComposeSecure::MimeFinishMultipartSigned (PRBool aOuter, nsIMsgSen
|
||||||
L = strlen(header);
|
L = strlen(header);
|
||||||
if (aOuter) {
|
if (aOuter) {
|
||||||
/* If this is the outer block, write it to the file. */
|
/* If this is the outer block, write it to the file. */
|
||||||
if (PRInt32(mStream->write(header, L)) < L) {
|
PRUint32 n;
|
||||||
|
rv = mStream->Write(header, L, &n);
|
||||||
|
if (NS_FAILED(rv) || n < L) {
|
||||||
rv = MK_MIME_ERROR_WRITING_FILE;
|
rv = MK_MIME_ERROR_WRITING_FILE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -790,7 +796,7 @@ nsresult nsMsgComposeSecure::MimeFinishMultipartSigned (PRBool aOuter, nsIMsgSen
|
||||||
/* Now write out the terminating boundary.
|
/* Now write out the terminating boundary.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PRInt32 L;
|
PRUint32 L;
|
||||||
char *header = PR_smprintf(CRLF "--%s--" CRLF,
|
char *header = PR_smprintf(CRLF "--%s--" CRLF,
|
||||||
mMultipartSignedBoundary);
|
mMultipartSignedBoundary);
|
||||||
PR_Free(mMultipartSignedBoundary);
|
PR_Free(mMultipartSignedBoundary);
|
||||||
|
@ -803,7 +809,9 @@ nsresult nsMsgComposeSecure::MimeFinishMultipartSigned (PRBool aOuter, nsIMsgSen
|
||||||
L = strlen(header);
|
L = strlen(header);
|
||||||
if (aOuter) {
|
if (aOuter) {
|
||||||
/* If this is the outer block, write it to the file. */
|
/* If this is the outer block, write it to the file. */
|
||||||
if (PRInt32(mStream->write(header, L)) < L)
|
PRUint32 n;
|
||||||
|
rv = mStream->Write(header, L, &n);
|
||||||
|
if (NS_FAILED(rv) || n < L)
|
||||||
rv = MK_MIME_ERROR_WRITING_FILE;
|
rv = MK_MIME_ERROR_WRITING_FILE;
|
||||||
} else {
|
} else {
|
||||||
/* If this is an inner block, feed it through the crypto stream. */
|
/* If this is an inner block, feed it through the crypto stream. */
|
||||||
|
@ -865,7 +873,9 @@ nsresult nsMsgComposeSecure::MimeFinishEncryption (PRBool aSign, nsIMsgSendRepor
|
||||||
rv = MIME_EncoderDestroy(mCryptoEncoderData, PR_FALSE);
|
rv = MIME_EncoderDestroy(mCryptoEncoderData, PR_FALSE);
|
||||||
mCryptoEncoderData = 0;
|
mCryptoEncoderData = 0;
|
||||||
|
|
||||||
if (PRInt32(mStream->write(CRLF, 2)) < 2)
|
PRUint32 n;
|
||||||
|
rv = mStream->Write(CRLF, 2, &n);
|
||||||
|
if (NS_FAILED(rv) || n < 2)
|
||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
|
|
||||||
FAIL:
|
FAIL:
|
||||||
|
@ -1059,10 +1069,12 @@ NS_IMETHODIMP nsMsgComposeSecure::MimeCryptoWriteBlock (const char *buf, PRInt32
|
||||||
/* If we're not encrypting (presumably just signing) then write this
|
/* If we're not encrypting (presumably just signing) then write this
|
||||||
data directly to the file. */
|
data directly to the file. */
|
||||||
|
|
||||||
if (PRInt32(mStream->write (buf, size)) < size) {
|
PRUint32 n;
|
||||||
return MK_MIME_ERROR_WRITING_FILE;
|
rv = mStream->Write(buf, size, &n);
|
||||||
|
if (NS_FAILED(rv) || n < size) {
|
||||||
|
return MK_MIME_ERROR_WRITING_FILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FAIL:
|
FAIL:
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1137,8 +1149,11 @@ mime_crypto_write_base64 (void *closure, const char *buf,
|
||||||
nsresult mime_encoder_output_fn(const char *buf, PRInt32 size, void *closure)
|
nsresult mime_encoder_output_fn(const char *buf, PRInt32 size, void *closure)
|
||||||
{
|
{
|
||||||
nsMsgComposeSecure *state = (nsMsgComposeSecure *) closure;
|
nsMsgComposeSecure *state = (nsMsgComposeSecure *) closure;
|
||||||
nsOutputFileStream *stream = state->GetOutputStream();
|
nsCOMPtr<nsIOutputStream> stream;
|
||||||
if (PRInt32(stream->write((char *) buf, size)) < size)
|
state->GetOutputStream(getter_AddRefs(stream));
|
||||||
|
PRUint32 n;
|
||||||
|
nsresult rv = stream->Write((char *) buf, size, &n);
|
||||||
|
if (NS_FAILED(rv) || n < size)
|
||||||
return MK_MIME_ERROR_WRITING_FILE;
|
return MK_MIME_ERROR_WRITING_FILE;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "nsICMSMessage.h"
|
#include "nsICMSMessage.h"
|
||||||
#include "nsIMutableArray.h"
|
#include "nsIMutableArray.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
#include "nsIOutputStream.h"
|
||||||
|
|
||||||
class nsIMsgCompFields;
|
class nsIMsgCompFields;
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ public:
|
||||||
nsMsgComposeSecure();
|
nsMsgComposeSecure();
|
||||||
virtual ~nsMsgComposeSecure();
|
virtual ~nsMsgComposeSecure();
|
||||||
/* additional members */
|
/* additional members */
|
||||||
nsOutputFileStream *GetOutputStream() { return mStream;}
|
void GetOutputStream(nsIOutputStream **stream) { NS_IF_ADDREF(*stream = mStream);}
|
||||||
private:
|
private:
|
||||||
nsresult MimeInitMultipartSigned(PRBool aOuter, nsIMsgSendReport *sendReport);
|
nsresult MimeInitMultipartSigned(PRBool aOuter, nsIMsgSendReport *sendReport);
|
||||||
nsresult MimeInitEncryption(PRBool aSign, nsIMsgSendReport *sendReport);
|
nsresult MimeInitEncryption(PRBool aSign, nsIMsgSendReport *sendReport);
|
||||||
|
@ -100,7 +101,7 @@ private:
|
||||||
nsresult ExtractEncryptionState(nsIMsgIdentity * aIdentity, nsIMsgCompFields * aComposeFields, PRBool * aSignMessage, PRBool * aEncrypt);
|
nsresult ExtractEncryptionState(nsIMsgIdentity * aIdentity, nsIMsgCompFields * aComposeFields, PRBool * aSignMessage, PRBool * aEncrypt);
|
||||||
|
|
||||||
mimeDeliveryCryptoState mCryptoState;
|
mimeDeliveryCryptoState mCryptoState;
|
||||||
nsOutputFileStream *mStream;
|
nsCOMPtr<nsIOutputStream> mStream;
|
||||||
PRInt16 mHashType;
|
PRInt16 mHashType;
|
||||||
nsCOMPtr<nsICryptoHash> mDataHash;
|
nsCOMPtr<nsICryptoHash> mDataHash;
|
||||||
MimeEncoderData *mSigEncoderData;
|
MimeEncoderData *mSigEncoderData;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче