Fix bug 15682. We need to carry an idendity when opening a draft (used when forwarding a message inline) or a template. That let us to open a compose window with the right sender, signature (only forward inline) and format (only forward online). R=jefft

This commit is contained in:
ducarroz%netscape.com 2000-01-28 06:20:44 +00:00
Родитель 91f877240e
Коммит d4fa824108
17 изменённых файлов: 204 добавлений и 135 удалений

Просмотреть файл

@ -197,11 +197,14 @@ function AbEditCard()
function AbNewMessage()
{
var msgComposeType = Components.interfaces.nsIMsgCompType;
var msgComposFormat = Components.interfaces.nsIMsgCompFormat;
var msgComposeService = Components.classes["component://netscape/messengercompose"].getService();
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
msgComposeService.OpenComposeWindowWithValues(null, 0, GetSelectedAddresses(), null, null,
null, null, null, null);
msgComposeService.OpenComposeWindowWithValues(null, msgComposeType.New, msgComposFormat.Default,
GetSelectedAddresses(), null, null,
null, null, null, null, null);
}
function GetSelectedAddresses()

Просмотреть файл

@ -1125,7 +1125,7 @@ nsMessenger::LoadFirstDraft()
// This should really pass in a URI, but for now, just to test, we can pass in nsnull
rv = pMsgDraft->OpenDraftMsg(nsnull, nsnull, PR_FALSE);
rv = pMsgDraft->OpenDraftMsg(nsnull, nsnull, nsnull, PR_FALSE);
}
return rv;

Просмотреть файл

@ -123,6 +123,8 @@ interface nsIMsgCompFields : nsISupports {
void SetTheForcePlainText(in boolean value);
boolean GetTheForcePlainText();
/* some utility functions */
nsIMsgRecipientArray SplitRecipients(in wstring recipients);
void ConvertBodyToPlainText();
};

Просмотреть файл

@ -42,6 +42,9 @@ interface nsIMsgCompType {
const long ForwardAsAttachment = 3;
const long ForwardInline = 4;
const long NewsPost = 5;
const long Draft = 6;
const long Template = 7;
const long MailToUrl = 8;
};

Просмотреть файл

@ -37,7 +37,7 @@ interface nsIMsgComposeService : nsISupports {
/* ... */
void OpenComposeWindow(in wstring msgComposeWindowURL, in wstring originalMsgURI, in MSG_ComposeType type, in MSG_ComposeFormat format,
in nsIMsgIdentity identity); /*object is temporary*/
in nsIMsgIdentity identity);
/* use this method to invoke a compose window given a mailto url.
aMsgComposeWindowURL --> can be null in most cases. If you have your own chrome
@ -47,12 +47,13 @@ interface nsIMsgComposeService : nsISupports {
void OpenComposeWindowWithURI(in wstring msgComposeWindowURL, in nsIURI aURI);
/* ... */
void OpenComposeWindowWithValues(in wstring msgComposeWindowURL, in MSG_ComposeFormat format,
void OpenComposeWindowWithValues(in wstring msgComposeWindowURL, in MSG_ComposeType type, in MSG_ComposeFormat format,
in wstring to, in wstring cc, in wstring bcc, in wstring newsgroups,
in wstring subject, in wstring body, in wstring attachment);
in wstring subject, in wstring body, in wstring attachment, in nsIMsgIdentity identity);
/* ... */
void OpenComposeWindowWithCompFields(in wstring msgComposeWindowURL, in MSG_ComposeFormat format, in nsIMsgCompFields compFields);
void OpenComposeWindowWithCompFields(in wstring msgComposeWindowURL, in MSG_ComposeType type, in MSG_ComposeFormat format,
in nsIMsgCompFields compFields, in nsIMsgIdentity identity);
/* ... */
nsIMsgCompose InitCompose(in nsIDOMWindow aWindow,

Просмотреть файл

@ -21,6 +21,7 @@
*/
#include "nsISupports.idl"
#include "nsIOutputStream.idl"
#include "nsIMsgIdentity.idl"
interface nsIMessage;
@ -33,8 +34,9 @@ interface nsIMsgDraft : nsISupports
* a URI
*/
void OpenDraftMsg(in wstring msgURI, out nsIMessage aMsgToReplace,
in PRBool addInlineHeaders);
in nsIMsgIdentity identity, in PRBool addInlineHeaders);
void OpenEditorTemplate(in wstring msgURI, out nsIMessage aMsgReplace);
void OpenEditorTemplate(in wstring msgURI, out nsIMessage aMsgReplace,
in nsIMsgIdentity identity);
};

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsMsgComposeStringBundle.h"
#include "nsMsgRecipientArray.h"
#include "nsIMsgHeaderParser.h"
#include "nsMsgCompUtils.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
@ -740,3 +741,23 @@ nsresult nsMsgCompFields::SplitRecipients(const PRUnichar *recipients, nsIMsgRec
return rv;
}
nsresult nsMsgCompFields::ConvertBodyToPlainText()
{
nsresult rv = NS_OK;
if (m_body && *m_body != 0)
{
PRUnichar * ubody;
rv = GetBody(&ubody);
if (NS_SUCCEEDED(rv))
{
nsString body(ubody);
PR_Free(ubody);
rv = ConvertBufToPlainText(body, msgCompHeaderInternalCharset());
if (NS_SUCCEEDED(rv))
rv = SetBody(body.GetUnicode());
}
}
return rv;
}

Просмотреть файл

@ -200,6 +200,7 @@ public:
nsresult AppendBody(char*);
NS_IMETHOD SplitRecipients(const PRUnichar *recipients, nsIMsgRecipientArray **_retval);
NS_IMETHOD ConvertBodyToPlainText(void);
// When forwarding a bunch of messages, we can have a bunch of

Просмотреть файл

@ -889,12 +889,13 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
{
nsresult rv = NS_OK;
if (compFields)
{
if (m_compFields)
m_compFields->Copy(compFields);
return rv;
}
mType = type;
if (compFields)
{
if (m_compFields)
rv = m_compFields->Copy(compFields);
return rv;
}
/* In case of forwarding multiple messages, originalMsgURI will contains several URI separated by a comma. */
/* we need to extract only the first URI*/
@ -918,7 +919,6 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
rv = message->GetSubject(getter_Copies(subject));
if (NS_FAILED(rv)) return rv;
mType = type;
switch (type)
{
default: break;
@ -1001,7 +1001,6 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
break;
}
case nsIMsgCompType::ForwardAsAttachment:
case nsIMsgCompType::ForwardInline:
{
if (!aCharset.Equals(""))
@ -1017,17 +1016,8 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI,
m_compFields->SetSubject(subjectStr.GetUnicode());
// Setup quoting callbacks for later...
if (type == nsIMsgCompType::ForwardAsAttachment)
{
mQuotingToFollow = PR_FALSE; //We don't need to quote the original message.
m_compFields->SetAttachments(originalMsgURI);
}
else
{
mQuotingToFollow = PR_TRUE;
mWhatHolder = 2;
mQuoteURI = originalMsgURI;
}
mQuotingToFollow = PR_FALSE; //We don't need to quote the original message.
m_compFields->SetAttachments(originalMsgURI);
break;
}
@ -1681,49 +1671,12 @@ nsMsgDocumentStateListener::NotifyDocumentCreated(void)
// Ok, now the document has been loaded, so we are ready to setup
// the compose window and let the user run hog wild!
//
// Have to check to see if there is a body stored in the
// comp fields...
//
PRBool bodyInCompFields = PR_FALSE;
nsMsgCompFields *compFields = nsnull;
nsIMsgIdentity *identity = nsnull;
PRBool compHTML = PR_FALSE;
nsIEditorShell *editor = nsnull;
mComposeObj->GetCompFields(&compFields);
mComposeObj->GetIdentity(&identity);
mComposeObj->GetComposeHTML(&compHTML);
mComposeObj->GetEditor(&editor);
if (compFields)
{
PRUnichar *bod;
compFields->GetBody(&bod);
if ((bod) && (*bod))
bodyInCompFields = PR_TRUE;
}
// Now, do the appropriate startup operation...signature only
// or quoted message and signature...
if ( mComposeObj->QuotingToFollow() )
return mComposeObj->BuildQuotedMessageAndSignature();
else if (bodyInCompFields)
return mComposeObj->BuildBodyMessage();
else
{
nsresult rv;
nsAutoString tSignature = "";
rv = mComposeObj->ProcessSignature(identity, &tSignature);
if ((NS_SUCCEEDED(rv)) && editor)
{
mComposeObj->ConvertAndLoadComposeWindow(editor, "", "", tSignature, PR_FALSE, compHTML);
}
return rv;
}
return mComposeObj->BuildBodyMessageAndSignature();
}
nsresult
@ -1913,9 +1866,10 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
}
nsresult
nsMsgCompose::BuildBodyMessage()
nsMsgCompose::BuildBodyMessageAndSignature()
{
PRUnichar *bod;
PRUnichar *bod = nsnull;
nsresult rv;
//
// This should never happen...if it does, just bail out...
@ -1928,12 +1882,46 @@ nsMsgCompose::BuildBodyMessage()
// composition editor window.
//
m_compFields->GetBody(&bod);
if (bod)
nsAutoString tSignature = "";
/* Some time we want to add a signature and sometime we wont. Let's figure that now...*/
PRBool addSignature;
switch (mType)
{
ConvertAndLoadComposeWindow(m_editor, "", bod, "", PR_FALSE, m_composeHTML);
case nsIMsgCompType::New :
case nsIMsgCompType::Reply : /* should not append! but just in case */
case nsIMsgCompType::ReplyAll : /* should not append! but just in case */
case nsIMsgCompType::ForwardAsAttachment : /* should not append! but just in case */
case nsIMsgCompType::ForwardInline :
case nsIMsgCompType::NewsPost :
addSignature = PR_TRUE;
break;
case nsIMsgCompType::Draft :
case nsIMsgCompType::Template :
addSignature = PR_FALSE;
break;
case nsIMsgCompType::MailToUrl :
addSignature = !(bod && *bod != 0);
break;
default :
addSignature = PR_FALSE;
break;
}
if (addSignature)
ProcessSignature(m_identity, &tSignature);
if (m_editor)
{
if (bod)
rv = ConvertAndLoadComposeWindow(m_editor, "", bod, tSignature, PR_FALSE, m_composeHTML);
else
rv = ConvertAndLoadComposeWindow(m_editor, "", "", tSignature, PR_FALSE, m_composeHTML);
}
return NS_OK;
PR_FREEIF(bod);
return rv;
}
nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotificationType)

Просмотреть файл

@ -64,7 +64,7 @@ class nsMsgCompose : public nsIMsgCompose
nsresult SetQuotingToFollow(PRBool aVal);
nsresult ConvertHTMLToText(nsFileSpec& aSigFile, nsString &aSigData);
nsresult ConvertTextToHTML(nsFileSpec& aSigFile, nsString &aSigData);
nsresult BuildBodyMessage();
nsresult BuildBodyMessageAndSignature();
nsString mQuoteURI;

Просмотреть файл

@ -105,24 +105,22 @@ nsresult nsMsgComposeService::OpenComposeWindow(const PRUnichar *msgComposeWindo
nsCOMTypeInfo<nsIMsgDraft>::GetIID(),
getter_AddRefs(pMsgDraft));
if (NS_SUCCEEDED(rv) && pMsgDraft)
rv = pMsgDraft->OpenDraftMsg(originalMsgURI, nsnull, PR_TRUE);
rv = pMsgDraft->OpenDraftMsg(originalMsgURI, nsnull, identity, PR_TRUE);
return rv;
}
args.Append("type=");
args.Append(type);
args.Append(",");
args.Append("format=");
args.Append(",format=");
args.Append(format);
if (identity) {
nsXPIDLCString key;
rv = identity->GetKey(getter_Copies(key));
if (NS_SUCCEEDED(rv) && key && (PL_strlen(key) > 0)) {
args.Append(",");
args.Append("preselectid=");
args.Append(",preselectid=");
args.Append(key);
}
}
@ -176,7 +174,7 @@ NS_IMETHODIMP nsMsgComposeService::OpenComposeWindowWithURI(const PRUnichar * aM
nsnull /* priority */, getter_Copies(aNewsgroup), nsnull /* host */,
&aPlainText);
MSG_ComposeFormat format = 0;
MSG_ComposeFormat format = nsIMsgCompFormat::Default;
if (aPlainText)
format = nsIMsgCompFormat::PlainText;
@ -189,13 +187,17 @@ NS_IMETHODIMP nsMsgComposeService::OpenComposeWindowWithURI(const PRUnichar * aM
nsAutoString uniBodyPart((const char*)aBodyPart);
nsAutoString uniAttachmentPart((const char*)aAttachmentPart);
rv = OpenComposeWindowWithValues(aMsgComposeWindowURL, format, uniToPart.GetUnicode(),
rv = OpenComposeWindowWithValues(aMsgComposeWindowURL,
nsIMsgCompType::MailToUrl,
format,
uniToPart.GetUnicode(),
uniCcPart.GetUnicode(),
unicBccPart.GetUnicode(),
uniNewsgroup.GetUnicode(),
uniSubjectPart.GetUnicode(),
uniBodyPart.GetUnicode(),
uniAttachmentPart.GetUnicode());
uniAttachmentPart.GetUnicode(),
nsnull);
}
}
@ -203,6 +205,7 @@ NS_IMETHODIMP nsMsgComposeService::OpenComposeWindowWithURI(const PRUnichar * aM
}
nsresult nsMsgComposeService::OpenComposeWindowWithValues(const PRUnichar *msgComposeWindowURL,
MSG_ComposeType type,
MSG_ComposeFormat format,
const PRUnichar *to,
const PRUnichar *cc,
@ -210,7 +213,8 @@ nsresult nsMsgComposeService::OpenComposeWindowWithValues(const PRUnichar *msgCo
const PRUnichar *newsgroups,
const PRUnichar *subject,
const PRUnichar *body,
const PRUnichar *attachment)
const PRUnichar *attachment,
nsIMsgIdentity *identity)
{
nsresult rv;
nsCOMPtr<nsIMsgCompFields> pCompFields;
@ -228,20 +232,25 @@ nsresult nsMsgComposeService::OpenComposeWindowWithValues(const PRUnichar *msgCo
if (attachment) {pCompFields->SetAttachments(attachment);}
if (body) {pCompFields->SetBody(body);}
rv = OpenComposeWindowWithCompFields(msgComposeWindowURL, format, pCompFields);
rv = OpenComposeWindowWithCompFields(msgComposeWindowURL, type, format, pCompFields, identity);
}
return rv;
}
nsresult nsMsgComposeService::OpenComposeWindowWithCompFields(const PRUnichar *msgComposeWindowURL,
MSG_ComposeType type,
MSG_ComposeFormat format,
nsIMsgCompFields *compFields)
nsIMsgCompFields *compFields,
nsIMsgIdentity *identity)
{
nsAutoString args = "";
nsresult rv;
args.Append("format=");
args.Append("type=");
args.Append(type);
args.Append(",format=");
args.Append(format);
if (compFields)
@ -250,6 +259,14 @@ nsresult nsMsgComposeService::OpenComposeWindowWithCompFields(const PRUnichar *m
args.Append(",fieldsAddr="); args.Append((PRInt32)compFields, 10);
}
if (identity) {
nsXPIDLCString key;
rv = identity->GetKey(getter_Copies(key));
if (NS_SUCCEEDED(rv) && key && (PL_strlen(key) > 0)) {
args.Append(",preselectid=");
args.Append(key);
}
}
if (msgComposeWindowURL && *msgComposeWindowURL)
rv = openWindow( msgComposeWindowURL, args.GetUnicode() );
else

Просмотреть файл

@ -129,7 +129,7 @@ GetIMessageFromURI(const PRUnichar *msgURI)
nsresult
nsMsgDraft::ProcessDraftOrTemplateOperation(const PRUnichar *msgURI, nsMimeOutputType aOutType,
nsIMessage **aMsgToReplace)
nsIMsgIdentity * identity, nsIMessage **aMsgToReplace)
{
nsresult rv;
@ -172,8 +172,9 @@ nsresult rv;
nsCOMPtr<nsIMimeStreamConverter> mimeConverter = do_QueryInterface(mimeParser);
if (mimeConverter)
{
mimeConverter->SetMimeOutputType(mOutType); // Set the type of output for libmime
mimeConverter->SetMimeOutputType(mOutType); // Set the type of output for libmime
mimeConverter->SetForwardInline(mAddInlineHeaders);
mimeConverter->SetIdentity(identity);
}
nsCOMPtr<nsIStreamListener> convertedListener = do_QueryInterface(mimeParser);
@ -233,7 +234,7 @@ nsresult rv;
nsresult
nsMsgDraft::OpenDraftMsg(const PRUnichar *msgURI, nsIMessage **aMsgToReplace,
PRBool addInlineHeaders)
nsIMsgIdentity * identity, PRBool addInlineHeaders)
{
PRUnichar *HackUpAURIToPlayWith(void); // RICHIE - forward declare for now
@ -245,14 +246,15 @@ PRUnichar *HackUpAURIToPlayWith(void); // RICHIE - forward declare for
mAddInlineHeaders = addInlineHeaders;
return ProcessDraftOrTemplateOperation(msgURI, nsMimeOutput::nsMimeMessageDraftOrTemplate,
aMsgToReplace);
identity, aMsgToReplace);
}
nsresult
nsMsgDraft::OpenEditorTemplate(const PRUnichar *msgURI, nsIMessage **aMsgToReplace)
nsMsgDraft::OpenEditorTemplate(const PRUnichar *msgURI, nsIMessage **aMsgToReplace,
nsIMsgIdentity * identity)
{
return ProcessDraftOrTemplateOperation(msgURI, nsMimeOutput::nsMimeMessageEditorTemplate,
aMsgToReplace);
identity, aMsgToReplace);
}
//////////////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -37,16 +37,10 @@ public:
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
/* long QuoteMessage (in wstring msgURI, in nsIOutputStream outStream, nsIMessage **aMsgToReplace); */
NS_IMETHOD OpenDraftMsg(const PRUnichar *msgURI,
nsIMessage **aMsgToReplace,
PRBool addInlineHeaders);
/* long QuoteMessage (in wstring msgURI, in nsIOutputStream outStream, nsIMessage **aMsgToReplace); */
NS_IMETHOD OpenEditorTemplate(const PRUnichar *msgURI, nsIMessage **aMsgToReplace);
NS_DECL_NSIMSGDRAFT
nsresult ProcessDraftOrTemplateOperation(const PRUnichar *msgURI, nsMimeOutputType aOutType,
nsIMessage **aMsgToReplace);
nsIMsgIdentity * identity, nsIMessage **aMsgToReplace);
//
// Implementation data...

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsISupports.idl"
#include "nsrootidl.idl"
#include "nsIMimeHeaders.idl"
#include "nsIMsgIdentity.idl"
interface nsIURI;
@ -81,4 +82,10 @@ interface nsIMimeStreamConverter : nsISupports {
* This is used for forward inline
*/
attribute PRBool forwardInline;
/*
* This is used for OpenDraft, OpenEditorTemplate and Forward inline (which use OpenDraft)
*/
attribute nsIMsgIdentity identity;
};

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsMsgI18N.h"
#include "nsSpecialSystemDirectory.h"
//
// Header strings...
//
@ -134,18 +135,10 @@ struct mime_draft_data
MimeDecoderData *decoder_data;
char *mailcharset; // get it from CHARSET of Content-Type
PRBool forwardInline;
PRBool forwardInline;
nsCOMPtr<nsIMsgIdentity> identity;
};
// RICHIE - PROBABLY BELONGS IN A HEADER SOMEWHERE!!!
//Message Compose Editor Type
typedef enum
{
nsMsgDefault = 0,
nsMsgPlainTextEditor,
nsMsgHTMLEditor
} nsMsgEditorType;
typedef enum {
nsMsg_RETURN_RECEIPT_BOOL_HEADER_MASK = 0,
nsMsg_ENCRYPTED_BOOL_HEADER_MASK,
@ -188,7 +181,9 @@ mime_dump_attachments ( nsMsgAttachmentData *attachData )
nsresult
CreateTheComposeWindow(nsIMsgCompFields *compFields,
nsMsgAttachmentData *attachmentList,
nsMsgEditorType editorType)
MSG_ComposeType composeType,
MSG_ComposeFormat composeFormat,
nsIMsgIdentity * identity)
{
nsresult rv;
MSG_ComposeFormat format = nsIMsgCompFormat::Default;
@ -226,13 +221,25 @@ mime_dump_attachments ( attachmentList );
if ((NS_FAILED(rv)) || (!msgComposeService))
return rv;
if (editorType == nsMsgPlainTextEditor)
format = nsIMsgCompFormat::PlainText;
else if (editorType == nsMsgHTMLEditor)
format = nsIMsgCompFormat::HTML;
if (identity)
{
PRBool composeHtml = PR_FALSE;
identity->GetComposeHtml(&composeHtml);
if (composeHtml)
format = nsIMsgCompFormat::HTML;
else
{
format = nsIMsgCompFormat::PlainText;
/* do we we need to convert the HTML body to plain text? */
if (composeFormat == nsIMsgCompFormat::HTML)
compFields->ConvertBodyToPlainText();
}
}
else
format = composeFormat;
rv = msgComposeService->OpenComposeWindowWithCompFields(nsnull, /* default chrome */
format, compFields);
composeType, format, compFields, identity);
return rv;
}
@ -575,10 +582,10 @@ mime_intl_insert_message_header_1(char **body,
static void
mime_insert_all_headers(char **body,
MimeHeaders *headers,
nsMsgEditorType editorType,
MSG_ComposeFormat composeFormat,
char *mailcharset)
{
PRBool htmlEdit = editorType == nsMsgHTMLEditor;
PRBool htmlEdit = (composeFormat == nsIMsgCompFormat::HTML);
char *newBody = NULL;
char *html_tag = PL_strcasestr(*body, "<HTML>");
int i;
@ -714,7 +721,7 @@ MimeGetNamedString(PRInt32 id)
static void
mime_insert_normal_headers(char **body,
MimeHeaders *headers,
nsMsgEditorType editorType,
MSG_ComposeFormat composeFormat,
char *mailcharset)
{
char *newBody = NULL;
@ -741,7 +748,7 @@ mime_insert_normal_headers(char **body,
PR_TRUE);
char *references = MimeHeaders_get(headers, HEADER_REFERENCES, PR_FALSE, PR_TRUE);
const char *html_tag = PL_strcasestr(*body, "<HTML>");
PRBool htmlEdit = editorType == nsMsgHTMLEditor;
PRBool htmlEdit = composeFormat == nsIMsgCompFormat::HTML;
if (!from)
from = MimeHeaders_get(headers, HEADER_SENDER, PR_FALSE, PR_TRUE);
@ -902,7 +909,7 @@ mime_insert_normal_headers(char **body,
static void
mime_insert_micro_headers(char **body,
MimeHeaders *headers,
nsMsgEditorType editorType,
MSG_ComposeFormat composeFormat,
char *mailcharset)
{
char *newBody = NULL;
@ -917,7 +924,7 @@ mime_insert_micro_headers(char **body,
char *newsgroups = MimeHeaders_get(headers, HEADER_NEWSGROUPS, PR_FALSE,
PR_TRUE);
const char *html_tag = PL_strcasestr(*body, "<HTML>");
PRBool htmlEdit = editorType == nsMsgHTMLEditor;
PRBool htmlEdit = composeFormat == nsIMsgCompFormat::HTML;
if (!from)
from = MimeHeaders_get(headers, HEADER_SENDER, PR_FALSE, PR_TRUE);
@ -1022,7 +1029,7 @@ mime_insert_micro_headers(char **body,
static void
mime_insert_forwarded_message_headers(char **body,
MimeHeaders *headers,
nsMsgEditorType editorType,
MSG_ComposeFormat composeFormat,
char *mailcharset)
{
if (body && *body && headers)
@ -1037,14 +1044,14 @@ mime_insert_forwarded_message_headers(char **body,
switch (show_headers)
{
case 0:
mime_insert_micro_headers(body, headers, editorType, mailcharset);
mime_insert_micro_headers(body, headers, composeFormat, mailcharset);
break;
default:
case 1:
mime_insert_normal_headers(body, headers, editorType, mailcharset);
mime_insert_normal_headers(body, headers, composeFormat, mailcharset);
break;
case 2:
mime_insert_all_headers(body, headers, editorType, mailcharset);
mime_insert_all_headers(body, headers, composeFormat, mailcharset);
break;
}
}
@ -1245,7 +1252,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
{
char *body;
PRUint32 bodyLen = 0;
nsMsgEditorType editorType = nsMsgDefault;
MSG_ComposeFormat composeFormat = nsIMsgCompFormat::Default;
bodyLen = mdd->messageBody->file_spec->GetFileSize();
body = (char *)PR_MALLOC (bodyLen + 1);
@ -1262,23 +1269,23 @@ mime_parse_stream_complete (nsMIMESession *stream)
if (mdd->messageBody->type && *mdd->messageBody->type)
{
if( PL_strcasestr(mdd->messageBody->type, "text/html") != NULL )
editorType = nsMsgHTMLEditor;
composeFormat = nsIMsgCompFormat::HTML;
else if ( PL_strcasestr(mdd->messageBody->type, "text/plain") != NULL )
editorType = nsMsgPlainTextEditor;
composeFormat = nsIMsgCompFormat::PlainText;
}
else
{
editorType = nsMsgPlainTextEditor;
composeFormat = nsIMsgCompFormat::PlainText;
}
// Since we have body text, then we should set the compose fields with
// this data.
if (editorType == nsMsgPlainTextEditor)
if (composeFormat == nsIMsgCompFormat::PlainText)
fields->SetTheForcePlainText(PR_TRUE);
if (forward_inline)
{
mime_insert_forwarded_message_headers(&body, mdd->headers, editorType,
mime_insert_forwarded_message_headers(&body, mdd->headers, composeFormat,
mdd->mailcharset);
}
// setting the charset while we were creating the composition fields
@ -1301,7 +1308,8 @@ mime_parse_stream_complete (nsMIMESession *stream)
#ifdef NS_DEBUG
printf("Time to create the composition window WITH a body!!!!\n");
#endif
CreateTheComposeWindow(fields, newAttachData, editorType);
MSG_ComposeType type = mdd->forwardInline ? nsIMsgCompType::ForwardInline : nsIMsgCompType::Draft;
CreateTheComposeWindow(fields, newAttachData, type, composeFormat, mdd->identity);
}
PR_FREEIF(body);
@ -1316,14 +1324,15 @@ mime_parse_stream_complete (nsMIMESession *stream)
if (mdd->format_out == nsMimeOutput::nsMimeMessageEditorTemplate)
{
printf("RICHIE: Time to create the EDITOR with this template - NO body!!!!\n");
CreateTheComposeWindow(fields, newAttachData, nsMsgDefault);
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::Template, nsIMsgCompFormat::Default, mdd->identity);
}
else
{
#ifdef NS_DEBUG
printf("Time to create the composition window WITHOUT a body!!!!\n");
#endif
CreateTheComposeWindow(fields, newAttachData, nsMsgDefault);
MSG_ComposeType type = mdd->forwardInline ? nsIMsgCompType::ForwardInline : nsIMsgCompType::Draft;
CreateTheComposeWindow(fields, newAttachData, type, nsIMsgCompFormat::Default, mdd->identity);
}
}
}
@ -1335,7 +1344,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
GetMailSigningPreference(),
mdd->mailcharset);
if (fields)
CreateTheComposeWindow(fields, newAttachData, nsMsgDefault);
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::New, nsIMsgCompFormat::Default, mdd->identity);
}
if ( mdd->headers )
@ -1775,6 +1784,7 @@ mime_bridge_create_draft_stream(
}
newPluginObj2->GetForwardInline(&mdd->forwardInline);
newPluginObj2->GetIdentity(getter_AddRefs(mdd->identity));
mdd->format_out = format_out;
mdd->options = PR_NEWZAP ( MimeDisplayOptions );
if ( !mdd->options )

Просмотреть файл

@ -608,6 +608,23 @@ nsStreamConverter::GetForwardInline(PRBool *result)
return NS_OK;
}
NS_IMETHODIMP
nsStreamConverter::GetIdentity(nsIMsgIdentity * *aIdentity)
{
if (!aIdentity) return NS_ERROR_NULL_POINTER;
*aIdentity = mIdentity;
NS_ADDREF(*aIdentity);
return NS_OK;
}
NS_IMETHODIMP
nsStreamConverter::SetIdentity(nsIMsgIdentity * aIdentity)
{
mIdentity = aIdentity;
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////////
// Methods for nsIStreamListener...
/////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -86,7 +86,8 @@ private:
PRBool mDoneParsing; // If this is true, we've already been told by libmime to stop sending
// data so don't feed the parser any more!
nsIMimeStreamConverterListener* mMimeStreamConverterListener;
PRBool mForwardInline;
PRBool mForwardInline;
nsCOMPtr<nsIMsgIdentity> mIdentity;
};
#endif /* nsStreamConverter_h_ */