Changes for composition BE

This commit is contained in:
rhp%netscape.com 1999-06-07 18:58:27 +00:00
parent 0993d9274c
commit a19356c31d
7 changed files with 247 additions and 461 deletions

View File

@ -34,32 +34,8 @@ XP_Bool NET_IsOffline() {return PR_FALSE;}
XP_FILE_URL_PATH XP_PlatformFileToURL (const XP_FILE_NATIVE_PATH ) {return NULL;}
MWContext *XP_FindContextOfType(MWContext *, MWContextType) {return NULL;}
XP_FILE_NATIVE_PATH WH_FileName (const char *, XP_FileType ) {return NULL;}
char * XP_StripLine (char * string)
{
//ducarroz: we should use nsString::Trim
//
char * ptr;
/* remove leading blanks */
while(*string=='\t' || *string==' ' || *string=='\r' || *string=='\n')
string++;
for(ptr=string; *ptr; ptr++)
; /* NULL BODY; Find end of string */
/* remove trailing blanks */
for(ptr--; ptr >= string; ptr--)
{
if(*ptr=='\t' || *ptr==' ' || *ptr=='\r' || *ptr=='\n')
*ptr = '\0';
else
break;
}
return string;
}
int XP_Stat(const char * name, XP_StatStruct * outStat, XP_FileType type) {return 0;}
int XP_FileTruncate(const char* name, XP_FileType type, int32 length) {return 0;}
@ -72,23 +48,9 @@ int MSG_ExplodeHeaderField(MSG_HEADER_SET,const char * ,MSG_HeaderEntry **)
char * MSG_MakeFullAddress (const char* , const char* ) {return NULL;}
void MSG_MailCompositionAllConnectionsComplete (MSG_Pane* /*pane*/) {return;}
void INTL_DestroyCharCodeConverter(CCCDataObject) {return;}
unsigned char * INTL_CallCharCodeConverter(CCCDataObject,const unsigned char *,int32) {return NULL;}
int INTL_GetCharCodeConverter(int16 ,int16 ,CCCDataObject) {return nsnull;}
CCCDataObject INTL_CreateCharCodeConverter() {return NULL;}
int16 INTL_GetCSIWinCSID(INTL_CharSetInfo) {return 2;}
INTL_CharSetInfo LO_GetDocumentCharacterSetInfo(MWContext *) {return NULL;}
int16 INTL_GetCSIDocCSID(INTL_CharSetInfo obj) {return 2;}
int16 INTL_DefaultWinCharSetID(MWContext *) {return 2;}
int16 INTL_DefaultMailCharSetID(int16 csid) {return 2;}
int16 INTL_DefaultNewsCharSetID(int16 csid) {return 2;}
void INTL_MessageSendToNews(XP_Bool toNews) {return;}
char *MimeGuessURLContentName(MWContext *context, const char *url) {return NULL;}
void MIME_GetMessageCryptoState(MWContext *,PRBool *,PRBool *,PRBool *,PRBool *) {return;}
XP_FILE_NATIVE_PATH WH_FileName (const char *, XP_FileType ) {return NULL;}
XP_Bool isMacFile(char* filename) {return PR_FALSE;}
HJ10196
@ -103,212 +65,3 @@ extern "C" {
HJ98703
}
//
// Begin international functions.
//
// Convert an unicode string to a C string with a given charset.
nsresult ConvertFromUnicode(const nsString& aCharset,
const nsString& inString,
char** outCString)
{
nsresult res;
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
nsIUnicodeEncoder* encoder = nsnull;
nsString convCharset;
// map to converter charset
if (aCharset.EqualsIgnoreCase("us-ascii")) {
convCharset.SetString("iso-8859-1");
}
else {
convCharset = aCharset;
}
// get an unicode converter
res = ccm->GetUnicodeEncoder(&convCharset, &encoder);
if(NS_SUCCEEDED(res) && (nsnull != encoder)) {
const PRUnichar *unichars = inString.GetUnicode();
PRInt32 unicharLength = inString.Length();
PRInt32 dstLength;
res = encoder->GetMaxLength(unichars, unicharLength, &dstLength);
// allocale an output buffer
*outCString = (char *) PR_Malloc(dstLength + 1);
if (*outCString != nsnull) {
PRInt32 originalLength = unicharLength;
// convert from unicode
res = encoder->Convert(unichars, &unicharLength, *outCString, &dstLength);
// estimation of GetMaxLength was incorrect
if (unicharLength < originalLength) {
PR_Free(*outCString);
res = NS_ERROR_FAILURE;
}
else {
(*outCString)[dstLength] = '\0';
}
}
else {
res = NS_ERROR_OUT_OF_MEMORY;
}
NS_IF_RELEASE(encoder);
}
}
return res;
}
// Convert a C string to an unicode string.
nsresult ConvertToUnicode(const nsString& aCharset,
const char* inCString,
nsString& outString)
{
nsresult res;
NS_WITH_SERVICE(nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &res);
if(NS_SUCCEEDED(res) && (nsnull != ccm)) {
nsIUnicodeDecoder* decoder = nsnull;
PRUnichar *unichars;
PRInt32 unicharLength;
nsString convCharset;
// map to converter charset
if (aCharset.EqualsIgnoreCase("us-ascii")) {
convCharset.SetString("iso-8859-1");
}
else {
convCharset = aCharset;
}
// get an unicode converter
res = ccm->GetUnicodeDecoder(&convCharset, &decoder);
if(NS_SUCCEEDED(res) && (nsnull != decoder)) {
PRInt32 srcLen = PL_strlen(inCString);
res = decoder->Length(inCString, 0, srcLen, &unicharLength);
// allocale an output buffer
unichars = (PRUnichar *) PR_Malloc(unicharLength * sizeof(PRUnichar));
if (unichars != nsnull) {
// convert to unicode
res = decoder->Convert(unichars, 0, &unicharLength, inCString, 0, &srcLen);
outString.SetString(unichars, unicharLength);
PR_Free(unichars);
}
else {
res = NS_ERROR_OUT_OF_MEMORY;
}
NS_IF_RELEASE(decoder);
}
}
return res;
}
// Charset to be used for the internatl processing.
const char *msgCompHeaderInternalCharset()
{
// UTF-8 is a super set of us-ascii.
// We can use the same string manipulation methods as us-ascii without breaking non us-ascii characters.
return "UTF-8";
}
// MIME encoder, output string should be freed by PR_FREE
char * INTL_EncodeMimePartIIStr(const char *header, const char *charset, PRBool bUseMime)
{
// No MIME, just duplicate the string.
if (PR_FALSE == bUseMime) {
return PL_strdup(header);
}
char *encodedString = nsnull;
nsIMimeConverter *converter;
nsresult res = nsComponentManager::CreateInstance(kCMimeConverterCID, nsnull,
nsIMimeConverter::GetIID(), (void **)&converter);
if (NS_SUCCEEDED(res) && nsnull != converter) {
res = converter->EncodeMimePartIIStr_UTF8(header, charset, kMIME_ENCODED_WORD_SIZE, &encodedString);
NS_RELEASE(converter);
}
return NS_SUCCEEDED(res) ? encodedString : nsnull;
}
// MIME decoder
nsresult INTL_DecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString)
{
nsIMimeConverter *converter;
nsresult res = nsComponentManager::CreateInstance(kCMimeConverterCID, nsnull,
nsIMimeConverter::GetIID(), (void **)&converter);
if (NS_SUCCEEDED(res) && nsnull != converter) {
res = converter->DecodeMimePartIIStr(header, charset, decodedString);
NS_RELEASE(converter);
}
return res;
}
// Get a default mail character set.
char * INTL_GetDefaultMailCharset()
{
nsresult res = NS_OK;
char * retVal = nsnull;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res);
if (nsnull != prefs && NS_SUCCEEDED(res))
{
char *prefValue;
res = prefs->CopyCharPref("intl.character_set_name", &prefValue);
if (NS_SUCCEEDED(res))
{
//TODO: map to mail charset (e.g. Shift_JIS -> ISO-2022-JP) bug#3941.
retVal = prefValue;
}
else
retVal = PL_strdup("us-ascii");
}
return (nsnull != retVal) ? retVal : PL_strdup("us-ascii");
}
// Return True if a charset is stateful (e.g. JIS).
PRBool INTL_stateful_charset(const char *charset)
{
//TODO: use charset manager's service
return (PL_strcasecmp(charset, "iso-2022-jp") == 0);
}
// Check 7bit in a given buffer.
// This is expensive (both memory and performance).
// The check would be very simple if applied to an unicode text (e.g. nsString or utf-8).
// Possible optimazaion is to search ESC(0x1B) in case of iso-2022-jp and iso-2022-kr.
// Or convert and check line by line.
PRBool INTL_7bit_data_part(const char *charset, const char *inString, const PRUint32 size)
{
char *aCString;
nsString aCharset(charset);
nsString outString;
nsresult res;
aCString = (char *) PR_Malloc(size + 1);
if (nsnull != aCString) {
PL_strncpy(aCString, inString, size); // make a C string
res = ConvertToUnicode(aCharset, aCString, outString);
PR_Free(aCString);
if (NS_SUCCEEDED(res)) {
for (PRInt32 i = 0; i < outString.Length(); i++) {
if (outString.CharAt(i) > 127) {
return PR_FALSE;
}
}
}
}
return PR_TRUE; // all 7 bit
}
// Obsolescent
int INTL_IsLeadByte(int charSetID,unsigned char ch) {return 0;}
// Obsolescent
CCCDataObject INTL_CreateDocToMailConverter(iDocumentContext context, XP_Bool isHTML, unsigned char *buffer,uint32 buffer_size) {return NULL;}
// Obsolescent
char * INTL_GetAcceptLanguage() {return "en";}
//
// End international functions.
//

View File

@ -67,7 +67,7 @@
#include "jsapi.h"
static NS_DEFINE_IID(kIDOMAppCoresManagerIID, NS_IDOMAPPCORESMANAGER_IID);
static NS_DEFINE_IID(kAppCoresManagerCID, NS_APPCORESMANAGER_CID);
static NS_DEFINE_CID(kAppCoresManagerCID, NS_APPCORESMANAGER_CID);
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIDocumentIID, nsIDocument::GetIID());
@ -86,7 +86,7 @@ static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
// defined in msgCompGlue.cpp
extern char * INTL_GetDefaultMailCharset(void);
extern char * nsMsgI18NGetDefaultMailCharset(void);
extern nsresult ConvertFromUnicode(const nsString& aCharset,
const nsString& inString,
char** outCString);
@ -94,7 +94,7 @@ extern nsresult ConvertToUnicode(const nsString& aCharset,
const char* inCString,
nsString& outString);
extern const char *msgCompHeaderInternalCharset(void);
extern nsresult INTL_DecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString);
extern nsresult nsMsgI18NDecodeMimePartIIStr(const nsString& header, nsString& charset, nsString& decodedString);
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
@ -762,7 +762,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
650); // height
// Get the default charset from pref, use this as a mail charset.
default_mail_charset = INTL_GetDefaultMailCharset();
default_mail_charset = nsMsgI18NGetDefaultMailCharset();
if (NULL != default_mail_charset) {
mMsgCompFields->SetCharacterSet(default_mail_charset, NULL);
PR_Free(default_mail_charset);
@ -805,7 +805,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
bString += "Re: ";
bString += aString;
mMsgCompFields->SetSubject(nsAutoCString(bString), NULL);
if (NS_SUCCEEDED(rv = INTL_DecodeMimePartIIStr(bString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(bString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) {
mMsgCompFields->SetSubject(aCString, NULL);
PR_Free(aCString);
@ -814,7 +814,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
message->GetAuthor(aString);
mMsgCompFields->SetTo(nsAutoCString(aString), NULL);
if (NS_SUCCEEDED(rv = INTL_DecodeMimePartIIStr(aString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(aString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) {
mMsgCompFields->SetTo(aCString, NULL);
PR_Free(aCString);
@ -830,7 +830,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
cString = cString + ", ";
cString = cString + dString;
mMsgCompFields->SetCc(nsAutoCString(cString), NULL);
if (NS_SUCCEEDED(rv = INTL_DecodeMimePartIIStr(cString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(cString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) {
mMsgCompFields->SetTo(aCString, NULL);
PR_Free(aCString);
@ -852,7 +852,7 @@ nsComposeAppCore::NewMessage(nsAutoString& aUrl,
bString += "]";
mMsgCompFields->SetSubject(nsAutoCString(bString), NULL);
if (NS_SUCCEEDED(rv = INTL_DecodeMimePartIIStr(bString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(bString, encodedCharset, decodedString))) {
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) {
mMsgCompFields->SetSubject(aCString, NULL);
PR_Free(aCString);

View File

@ -23,7 +23,7 @@
#include "nsDOMCID.h"
static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID);
static NS_DEFINE_CID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID);
class nsComposerBootstrap : public nsIAppShellComponent {

View File

@ -19,11 +19,10 @@
#ifndef _MsgCompFields_H_
#define _MsgCompFields_H_
/*JFD #include "msgzap.h" */
#include "msgCore.h"
#include "prprf.h" /* should be defined into msgCore.h? */
#include "net.h" /* should be defined into msgCore.h? */
#include "intl_csi.h"
//#include "intl_csi.h"
#include "msgcom.h"
#include "nsMsgHeaderMasks.h"
@ -36,7 +35,7 @@
error, like an illegal parameter); rather, they return "" if things were set
to NULL. This makes it real handy for the callers. */
class nsMsgCompFields : public nsIMsgCompFields, public MSG_ZapIt {
class nsMsgCompFields : public nsIMsgCompFields, public nsMsgZapIt {
public:
nsMsgCompFields();
virtual ~nsMsgCompFields();
@ -202,6 +201,8 @@ protected:
PRBool m_force_plain_text;
PRBool m_multipart_alt;
PRInt32 m_receiptType; /* 0:None 1:DSN 2:MDN 3:BOTH */
};

View File

@ -19,103 +19,162 @@
#ifndef __MSGSEND_H__
#define __MSGSEND_H__
/*JFD
#include "msgpane.h"
#include "mimeenc.h" // For base64/QP encoder
#include "mhtmlstm.h"
*/
/* Asynchronous mailing of messages with attached URLs.
- If there are any attachments, start their URLs going, and write each
of them to a temp file.
- While writing to their files, examine the data going by and decide
what kind of encoding, if any, they need. Also remember their content
types.
- Once that URLs has been saved to a temp file (or, if there were no
attachments) generate a final temp file, of the actual message:
- Generate a string of the headers.
- Open the final temp file.
- Write the headers.
- Examine the first part, and decide whether to encode it.
- Write the first part to the file, possibly encoded.
- Write the second and subsequent parts to the file, possibly encoded.
(Open the first temp file and copy it to the final temp file, and so
on, through an encoding filter.)
- Delete the attachment temp file(s) as we finish with them.
- Close the final temp file.
- Open the news: url.
- Send the final temp file to NNTP.
If there's an error, run the callback with "failure" status.
- If mail succeeded, open the mailto: url.
- Send the final temp file to SMTP.
If there's an error, run the callback with "failure" status.
- Otherwise, run the callback with "success" status.
- Free everything, delete the final temp file.
The theory behind the encoding logic:
=====================================
If the document is of type text/html, and the user has asked to attach it
as source or postscript, it will be run through the appropriate converter
(which will result in a document of type text/plain.)
An attachment will be encoded if:
- it is of a non-text type (in which case we will use base64); or
- The "use QP" option has been selected and high-bit characters exist; or
- any NULLs exist in the document; or
- any line is longer than 900 bytes.
- If we are encoding, and more than 10% of the document consists of
non-ASCII characters, then we always use base64 instead of QP.
We eschew quoted-printable in favor of base64 for documents which are likely
to always be binary (images, sound) because, on the off chance that a GIF
file (for example) might contain primarily bytes in the ASCII range, using
the quoted-printable representation might cause corruption due to the
translation of CR or LF to CRLF. So, when we don't know that the document
has "lines", we don't use quoted-printable.
*/
/* It's better to send a message as news before sending it as mail, because
the NNTP server is more likely to reject the article (for any number of
reasons) than the SMTP server is. */
#undef MAIL_BEFORE_NEWS
/* Generating a message ID here is a good because it means that if a message
is sent to both mail and news, it will have the same ID in both places. */
#define GENERATE_MESSAGE_ID
/* For maximal compatibility, it helps to emit both
Content-Type: <type>; name="<original-file-name>"
as well as
Content-Disposition: inline; filename="<original-file-name>"
The lossage here is, RFC1341 defined the "name" parameter to Content-Type,
but then RFC1521 deprecated it in anticipation of RFC1806, which defines
Content-Type and the "filename" parameter. But, RFC1521 is "Standards Track"
while RFC1806 is still "Experimental." So, it's probably best to just
implement both.
*/
#define EMIT_NAME_IN_CONTENT_TYPE
/* Whether the contents of the BCC header should be preserved in the FCC'ed
copy of a message. See comments below, in mime_do_fcc_1().
*/
#define SAVE_BCC_IN_FCC_FILE
/* When attaching an HTML document, one must indicate the original URL of
that document, if the receiver is to have any chance of being able to
retreive and display the inline images, or to click on any links in the
HTML.
The way we have done this in the past is by inserting a <BASE> tag as the
first line of all HTML documents we attach. (This is kind of bad in that
we're actually modifying the document, and it really isn't our place to
do that.)
The sanctioned *new* way of doing this is to insert a Content-Base header
field on the attachment. This is (will be) a part of the forthcoming MHTML
spec.
If GENERATE_CONTENT_BASE, we generate a Content-Base header.
We used to have a MANGLE_HTML_ATTACHMENTS_WITH_BASE_TAG symbol that we
defined, which added a BASE tag to the bodies. We stopped doing this in
4.0. */
#define GENERATE_CONTENT_BASE
//
// Necessary includes
//
#include "rosetta_mailnews.h"
#include "msgCore.h"
#include "prprf.h" /* should be defined into msgCore.h? */
#include "net.h" /* should be defined into msgCore.h? */
#include "intl_csi.h"
//#include "msgcom.h"
#include "nsFileStream.h"
#include "nsMsgMessageFlags.h"
#include "MsgCompGlue.h"
#include "nsIMsgSend.h"
#include "nsIUrl.h"
#include "nsMsgAttachmentHandler.h"
//
// Some necessary defines...
//
#define TEN_K 10240
#define MIME_BUFFER_SIZE 4096
#define FCC_FAILURE 0
#define FCC_BLOCKING_SUCCESS 1
#define FCC_ASYNC_SUCCESS 2
//
// Utilities for string handling
//
#define PUSH_STRING(S) \
do { PL_strcpy (buffer_tail, S); buffer_tail += PL_strlen (S); } while(0)
#define PUSH_NEWLINE() \
do { *buffer_tail++ = CR; *buffer_tail++ = LF; *buffer_tail = '\0'; } while(0)
//
////////////////////////////////////////////////////////////////////////////////
// REWORK THIS STUF!!!!!!!!!
// REWORK THIS STUF!!!!!!!!!
// REWORK THIS STUF!!!!!!!!!
////////////////////////////////////////////////////////////////////////////////
//
class MSG_DeliverMimeAttachment;
class ParseOutgoingMessage;
class MailDB;
class nsMsgSendPart;
class nsMsgCompFields;
#define MIME_BUFFER_SIZE 4096
#define FCC_FAILURE 0
#define FCC_BLOCKING_SUCCESS 1
#define FCC_ASYNC_SUCCESS 2
#if 0 //JFD - We shouldn't use it anymore...
extern "C" void
msg_StartMessageDeliveryWithAttachments (MSG_Pane *pane,
void *fe_data,
nsMsgCompFields *fields,
PRBool digest_p,
PRBool dont_deliver_p,
nsMsgDeliverMode mode,
const char *attachment1_type,
const char *attachment1_body,
PRUint32 attachment1_body_length,
const struct nsMsgAttachedFile *attachments,
//#ifdef MSG_SEND_MULTIPART_RELATED
void *relatedPart,
//#endif
void (*message_delivery_done_callback)
(MWContext *context,
void *fe_data,
int status,
const char *error_message),
const char *smtp
);
#endif //JFD
class nsMsgSendMimeDeliveryState : public nsIMsgSend
class nsMsgComposeAndSend : public nsIMsgSend
{
public:
nsMsgSendMimeDeliveryState();
virtual ~nsMsgSendMimeDeliveryState();
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
void StartMessageDelivery(MSG_Pane *pane,
void *fe_data,
nsMsgCompFields *fields,
PRBool digest_p,
PRBool dont_deliver_p,
nsMsgDeliverMode mode,
const char *attachment1_type,
const char *attachment1_body,
PRUint32 attachment1_body_length,
const struct nsMsgAttachmentData
*attachments,
const struct nsMsgAttachedFile
*preloaded_attachments,
//#ifdef MSG_SEND_MULTIPART_RELATED
nsMsgSendPart *relatedPart,
//#endif
void (*message_delivery_done_callback)
(MWContext *context,
void *fe_data,
int status,
const char *error_message));
NS_IMETHOD SendMessage(
nsIMsgCompFields *fields,
const char *smtp,
PRBool digest_p,
PRBool dont_deliver_p,
PRInt32 mode,
const char *attachment1_type,
const char *attachment1_body,
PRUint32 attachment1_body_length,
const struct nsMsgAttachmentData *attachments,
const struct nsMsgAttachedFile *preloaded_attachments,
void *relatedPart,
void (*message_delivery_done_callback)(void *context, void *fe_data,
int status, const char *error_message));
int Init(MSG_Pane *pane,
void *fe_data,
@ -128,11 +187,9 @@ public:
PRUint32 attachment1_body_length,
const struct nsMsgAttachmentData *attachments,
const struct nsMsgAttachedFile *preloaded_attachments,
//#ifdef MSG_SEND_MULTIPART_RELATED
nsMsgSendPart *relatedPart,
//#endif
void (*message_delivery_done_callback)
(MWContext *context,
(
void *fe_data,
int status,
const char *error_message));
@ -170,17 +227,13 @@ public:
int InitImapOfflineDB(PRUint32 flag);
int SaveAsOfflineOp();
int DoFcc();
int HackAttachments(const struct nsMsgAttachmentData *attachments,
const struct nsMsgAttachedFile *preloaded_attachments);
void DeliverFileAsMail();
void DeliverFileAsNews();
void DeliverAsMailExit(URL_Struct *url, int status);
void DeliverAsNewsExit(URL_Struct *url, int status);
void Fail(int failure_code, char *error_msg);
void Clear();
HJ58534
MWContext *GetContext() { return (m_pane ? m_pane->GetContext(): NULL); }
@ -238,12 +291,10 @@ public:
PRUint32 m_attachment1_body_length;
// The plaintext form of the first attachment, if needed.
MSG_DeliverMimeAttachment* m_plaintext;
nsMsgAttachmentHandler* m_plaintext;
//#ifdef MSG_SEND_MULTIPART_RELATED
// The multipart/related save object for HTML text.
nsMsgSendPart *m_related_part;
//#endif
// File where we stored our HTML so that we could make the plaintext form.
char* m_html_filename;
@ -252,16 +303,16 @@ public:
*/
PRInt32 m_attachment_count;
PRInt32 m_attachment_pending_count;
MSG_DeliverMimeAttachment *m_attachments;
nsMsgAttachmentHandler *m_attachments;
PRInt32 m_status; /* in case some attachments fail but not all */
/* The caller's `exit' method. */
void (*m_message_delivery_done_callback) (MWContext *context,
void (*m_message_delivery_done_callback) (
void * fe_data, int status,
const char * error_msg);
/* The exit method used when downloading attachments only. */
void (*m_attachments_done_callback) (MWContext *context,
void (*m_attachments_done_callback) (
void * fe_data, int status,
const char * error_msg,
struct nsMsgAttachedFile *attachments);
@ -273,104 +324,84 @@ public:
ParseOutgoingMessage *m_imapOutgoingParser;
MailDB *m_imapLocalMailDB;
//
////////////////////////////////////////////////////////////////////////////////
// RICHIE - These are all calls that have been converted to the new world order!
// Once all done, we will reorganize the layout of the class definition for readability.
// Please bear with me.
////////////////////////////////////////////////////////////////////////////////
//
#if 0
/* char *headers; / * The headers of the message */
//
// this macro defines QueryInterface, AddRef and Release for this class
//
NS_DECL_ISUPPORTS
/* Some state to control the thermometer during message delivery.
*/
PRInt32 m_msg_size; /* Size of the final message. */
PRInt32 m_delivery_total_bytes; /* How many bytes we will be delivering:
for example, if we're sending the
message to both mail and news, this
will be 2x the size of the message.
*/
PRInt32 m_delivery_bytes; /* How many bytes we have delivered so far.
*/
#endif /* 0 */
nsMsgComposeAndSend();
virtual ~nsMsgComposeAndSend();
void DeliverAsMailExit(nsIURL * aUrl, nsresult aExitCode);
void Fail(nsresult failure_code, char *error_msg);
nsresult DoFcc();
void Clear();
//
////////////////////////////////////////////////////////////////////////////////
// RICHIE - These are partly new world, but still need work...still they are better
// than before. Again...Please bear with me.
////////////////////////////////////////////////////////////////////////////////
//
//
// The current nsIMsgSend Interface!
//
NS_IMETHOD SendMessage(
nsIMsgCompFields *fields,
const char *smtp,
PRBool digest_p,
PRBool dont_deliver_p,
PRInt32 mode,
const char *attachment1_type,
const char *attachment1_body,
PRUint32 attachment1_body_length,
const struct nsMsgAttachmentData *attachments,
const struct nsMsgAttachedFile *preloaded_attachments,
void *relatedPart,
void (*message_delivery_done_callback)(void *fe_data,
int status, const char *error_message));
nsresult MimeDoFCC (
const char *input_file_name, XP_FileType input_file_type,
const char *output_name, XP_FileType output_file_type,
nsMsgDeliverMode mode,
const char *bcc_header,
const char *fcc_header,
const char *news_url);
void StartMessageDelivery(MSG_Pane *pane,
void *fe_data,
nsMsgCompFields *fields,
PRBool digest_p,
PRBool dont_deliver_p,
nsMsgDeliverMode mode,
const char *attachment1_type,
const char *attachment1_body,
PRUint32 attachment1_body_length,
const struct nsMsgAttachmentData *attachments,
const struct nsMsgAttachedFile *preloaded_attachments,
nsMsgSendPart *relatedPart,
void (*message_delivery_done_callback)
(void *fe_data,
int status,
const char *error_message));
};
class MSG_DeliverMimeAttachment
{
public:
MSG_DeliverMimeAttachment();
~MSG_DeliverMimeAttachment();
void UrlExit(URL_Struct *url, int status, MWContext *context);
PRInt32 SnarfAttachment ();
void AnalyzeDataChunk (const char *chunk, PRInt32 chunkSize);
void AnalyzeSnarfedFile (); /* Analyze a previously-snarfed file.
(Currently only used for plaintext
converted from HTML.) */
int PickEncoding (const char *charset);
PRBool UseUUEncode_p(void);
char *m_url_string;
URL_Struct *m_url;
PRBool m_done;
nsMsgSendMimeDeliveryState *m_mime_delivery_state;
char *m_charset; /* charset name */
char *m_type; /* The real type, once we know it. */
char *m_override_type; /* The type we should assume it to be
or 0, if we should get it from the
URL_Struct (from the server) */
char *m_override_encoding; /* Goes along with override_type */
char *m_desired_type; /* The type it should be converted to. */
char *m_description; /* For Content-Description header */
char *m_x_mac_type, *m_x_mac_creator; /* Mac file type/creator. */
char *m_real_name; /* The name for the headers, if different
from the URL. */
char *m_encoding; /* The encoding, once we've decided. */
PRBool m_already_encoded_p; /* If we attach a document that is already
encoded, we just pass it through. */
char *m_file_name; /* The temp file to which we save it */
PRFileDesc *m_file;
#ifdef XP_MAC
char *m_ap_filename; /* The temp file holds the appledouble
encoding of the file we want to post. */
#endif
PRBool m_decrypted_p; /* S/MIME -- when attaching a message that was
encrypted, it's necessary to decrypt it first
(since nobody but the original recipient can
read it -- if you forward it to someone in the
raw, it will be useless to them.) This flag
indicates whether decryption occurred, so that
libmsg can issue appropriate warnings about
doing a cleartext forward of a message that was
originally encrypted.
*/
PRUint32 m_size; /* Some state used while filtering it */
PRUint32 m_unprintable_count;
PRUint32 m_highbit_count;
PRUint32 m_ctl_count;
PRUint32 m_null_count;
PRUint32 m_current_column;
PRUint32 m_max_column;
PRUint32 m_lines;
MimeEncoderData *m_encoder_data; /* Opaque state for base64/qp encoder. */
PRBool m_graph_progress_started;
/*JFD
PrintSetup m_print_setup; */ /* Used by HTML->Text and HTML->PS */
};
extern char * msg_generate_message_id (void);
//
// These routines should only be used by the nsMsgSendPart class.
extern PRBool mime_type_needs_charset (const char *type);
extern int mime_write_message_body(nsMsgSendMimeDeliveryState *state,
char *buf, PRInt32 size);
extern char* mime_get_stream_write_buffer(void);
//
extern int mime_write_message_body(nsMsgComposeAndSend *state, char *buf, PRInt32 size);
extern char *mime_get_stream_write_buffer(void);
extern int mime_encoder_output_fn (const char *buf, PRInt32 size, void *closure);
extern PRBool UseQuotedPrintable(void);
#endif /* __MSGSEND_H__ */

View File

@ -15,7 +15,6 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "rosetta_mailnews.h"
#include "nsMsgLocalFolderHdrs.h"
#include "nsMsgCompose.h"
@ -24,11 +23,13 @@
#include "nsIMimeConverter.h"
#include "nsFileStream.h"
#include "nsIMimeURLUtils.h"
#include "nsMsgEncoders.h"
#include "nsMsgI18N.h"
#include "nsMsgUtils.h"
#include "MsgCompGlue.h"
// defined in msgCompGlue.cpp
extern int MIME_EncoderDestroy(MimeEncoderData *data, PRBool abort_p);
static char *mime_mailto_stream_read_buffer = 0;
PRInt32 nsMsgSendPart::M_counter = 0;
@ -50,7 +51,7 @@ int MIME_EncoderWrite(MimeEncoderData *data, const char *buffer, PRInt32 size)
return NS_SUCCEEDED(res) ? 0 : -1;
}
nsMsgSendPart::nsMsgSendPart(nsMsgSendMimeDeliveryState* state, const char *part_charset)
nsMsgSendPart::nsMsgSendPart(nsMsgComposeAndSend* state, const char *part_charset)
{
PL_strcpy(m_charset_name, part_charset ? part_charset : "us-ascii");
m_children = NULL;
@ -137,7 +138,7 @@ int nsMsgSendPart::SetOtherHeaders(const char* other)
return CopyString(&m_other, other);
}
int nsMsgSendPart::SetMimeDeliveryState(nsMsgSendMimeDeliveryState *state)
int nsMsgSendPart::SetMimeDeliveryState(nsMsgComposeAndSend *state)
{
m_state = state;
if (GetNumChildren() > 0)
@ -262,7 +263,7 @@ int nsMsgSendPart::PushBody(char* buffer, PRInt32 length)
if (m_firstBlock) {
if (m_needIntlConversion) {
m_intlDocToMailConverter =
INTL_CreateDocToMailConverter(m_state->GetContext(),
nsMsgI18NCreateDocToMailConverter(m_state->GetContext(),
(!PL_strcasecmp(m_type,
TEXT_HTML)),
(unsigned char*) buffer,
@ -276,7 +277,7 @@ int nsMsgSendPart::PushBody(char* buffer, PRInt32 length)
!PL_strcasecmp(m_type, TEXT_HTML) &&
(m_encoder_data != NULL));
if (Base64HtmlNoChconv) {
INTL_DestroyCharCodeConverter(m_intlDocToMailConverter);
nsMsgI18NDestroyCharCodeConverter(m_intlDocToMailConverter);
m_intlDocToMailConverter = NULL;
}
}
@ -286,7 +287,7 @@ int nsMsgSendPart::PushBody(char* buffer, PRInt32 length)
if (m_intlDocToMailConverter) {
encoded_data =
(char*)INTL_CallCharCodeConverter(m_intlDocToMailConverter,
(char*)nsMsgI18NCallCharCodeConverter(m_intlDocToMailConverter,
(unsigned char*)buffer,
length);
/* the return buffer is different from the */
@ -818,7 +819,7 @@ FAIL:
if (file)
PR_Close(file);
if (m_intlDocToMailConverter) {
INTL_DestroyCharCodeConverter(m_intlDocToMailConverter);
nsMsgI18NDestroyCharCodeConverter(m_intlDocToMailConverter);
m_intlDocToMailConverter = NULL;
}
return status;

View File

@ -25,16 +25,16 @@
#include "intl_csi.h"
#include "msgcom.h"
#include "MsgCompGlue.h"
#include "nsMsgZapIt.h"
#include "nsMsgSend.h"
class nsMsgSendMimeDeliveryState;
typedef int (*MSG_SendPartWriteFunc)(const char* line, PRInt32 size,
PRBool isheader, void* closure);
class nsMsgSendPart : public MSG_ZapIt {
class nsMsgSendPart : public nsMsgZapIt {
public:
nsMsgSendPart(nsMsgSendMimeDeliveryState* state, const char *part_charset = NULL);
nsMsgSendPart(nsMsgComposeAndSend* state, const char *part_charset = NULL);
virtual ~nsMsgSendPart(); // Note that the destructor also destroys
// any children that were added.
@ -56,7 +56,7 @@ public:
const char* SetOtherHeaders() {return m_other;}
virtual int AppendOtherHeaders(const char* moreother);
virtual int SetMimeDeliveryState(nsMsgSendMimeDeliveryState* state);
virtual int SetMimeDeliveryState(nsMsgComposeAndSend* state);
// Note that the nsMsgSendPart class will take over ownership of the
// MimeEncoderData* object, deleting it when it chooses. (This is
@ -85,7 +85,7 @@ protected:
int CopyString(char** dest, const char* src);
int PushBody(char* buffer, PRInt32 length);
nsMsgSendMimeDeliveryState* m_state;
nsMsgComposeAndSend* m_state;
nsMsgSendPart* m_parent;
char* m_filename;
XP_FileType m_filetype;