Rewrite nsIMsgCompFields/nsMsgCompFields in order to be usable from JS. Remove dependence on the UI implementation (except for the message body)

This commit is contained in:
ducarroz%netscape.com 1999-07-03 21:40:38 +00:00
Родитель d1357e7a81
Коммит faee0f3324
9 изменённых файлов: 459 добавлений и 476 удалений

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

@ -24,95 +24,95 @@ interface nsIMsgCompFields : nsISupports {
void Copy(in nsIMsgCompFields pMsgCompFields); void Copy(in nsIMsgCompFields pMsgCompFields);
long SetHeader(in long header, in string value); void SetHeader(in long header, in wstring value);
string GetHeader(in long header); wstring GetHeader(in long header);
long SetBoolHeader(in long header, in boolean bValue); void SetBoolHeader(in long header, in boolean bValue);
boolean GetBoolHeader(in long header); boolean GetBoolHeader(in long header);
/* Convenience routines to get and set header's value... */ /* Convenience routines to get and set header's value... */
long SetFrom(in string value); void SetFrom(in wstring value);
string GetFrom(); wstring GetFrom();
long SetReplyTo(in string value); void SetReplyTo(in wstring value);
string GetReplyTo(); wstring GetReplyTo();
long SetTo(in string value); void SetTo(in wstring value);
string GetTo(); wstring GetTo();
long SetCc(in string value); void SetCc(in wstring value);
string GetCc(); wstring GetCc();
long SetBcc(in string value); void SetBcc(in wstring value);
string GetBcc(); wstring GetBcc();
long SetFcc(in string value); void SetFcc(in wstring value);
string GetFcc(); wstring GetFcc();
long SetNewsFcc(in string value); void SetNewsFcc(in wstring value);
string GetNewsFcc(); wstring GetNewsFcc();
long SetNewsBcc(in string value); void SetNewsBcc(in wstring value);
string GetNewsBcc(); wstring GetNewsBcc();
long SetNewsgroups(in string value); void SetNewsgroups(in wstring value);
string GetNewsgroups(); wstring GetNewsgroups();
long SetFollowupTo(in string value); void SetFollowupTo(in wstring value);
string GetFollowupTo(); wstring GetFollowupTo();
long SetSubject(in string value); void SetSubject(in wstring value);
string GetSubject(); wstring GetSubject();
long SetAttachments(in string value); void SetAttachments(in wstring value);
string GetAttachments(); wstring GetAttachments();
long SetOrganization(in string value); void SetOrganization(in wstring value);
string GetOrganization(); wstring GetOrganization();
long SetReferences(in string value); void SetReferences(in wstring value);
string GetReferences(); wstring GetReferences();
long SetOtherRandomHeaders(in string value); void SetOtherRandomHeaders(in wstring value);
string GetOtherRandomHeaders(); wstring GetOtherRandomHeaders();
long SetNewspostUrl(in string value); void SetNewspostUrl(in wstring value);
string GetNewspostUrl(); wstring GetNewspostUrl();
long SetDefaultBody(in string value); void SetDefaultBody(in wstring value);
string GetDefaultBody(); wstring GetDefaultBody();
long SetPriority(in string value); void SetPriority(in wstring value);
string GetPriority(); wstring GetPriority();
long SetMessageEncoding(in string value); void SetMessageEncoding(in wstring value);
string GetMessageEncoding(); wstring GetMessageEncoding();
long SetCharacterSet(in string value); void SetCharacterSet(in wstring value);
string GetCharacterSet(); wstring GetCharacterSet();
long SetMessageId(in string value); void SetMessageId(in wstring value);
string GetMessageId(); wstring GetMessageId();
long SetHTMLPart(in string value); void SetHTMLPart(in wstring value);
string GetHTMLPart(); wstring GetHTMLPart();
long SetTemplateName(in string value); void SetTemplateName(in wstring value);
string GetTemplateName(); wstring GetTemplateName();
long SetReturnReceipt(in boolean value); void SetReturnReceipt(in boolean value);
boolean GetReturnReceipt(); boolean GetReturnReceipt();
long SetAttachVCard(in boolean value); void SetAttachVCard(in boolean value);
boolean GetAttachVCard(); boolean GetAttachVCard();
long SetBody(in string value); void SetBody(in wstring value);
string GetBody(); wstring GetBody();
long SetUUEncodeAttachments(in boolean value); void SetUUEncodeAttachments(in boolean value);
boolean GetUUEncodeAttachments(); boolean GetUUEncodeAttachments();
long SetTheForcePlainText(in boolean value); void SetTheForcePlainText(in boolean value);
boolean GetTheForcePlainText(); boolean GetTheForcePlainText();
}; };

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

@ -21,6 +21,7 @@
#include "nsMsgCompFields.h" #include "nsMsgCompFields.h"
#include "nsMsgCompFieldsFact.h" #include "nsMsgCompFieldsFact.h"
#include "nsIPref.h" #include "nsIPref.h"
#include "nsMsgI18N.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -70,7 +71,8 @@ nsMsgCompFields::nsMsgCompFields()
prefs->GetBoolPref("mail.request.return_receipt_on", &bReturnReceiptOn); prefs->GetBoolPref("mail.request.return_receipt_on", &bReturnReceiptOn);
prefs->GetIntPref("mail.request.return_receipt", &m_receiptType); prefs->GetIntPref("mail.request.return_receipt", &m_receiptType);
} }
SetReturnReceipt (bReturnReceiptOn, NULL); SetReturnReceipt (bReturnReceiptOn);
m_internalCharSet = msgCompHeaderInternalCharset();
NS_INIT_REFCNT(); NS_INIT_REFCNT();
} }
@ -116,7 +118,7 @@ nsresult nsMsgCompFields::Copy(nsIMsgCompFields* pMsgCompFields)
nsresult nsMsgCompFields::SetHeader(PRInt32 header, const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetHeader(PRInt32 header, const char *value)
{ {
int status = 0; int status = 0;
@ -162,17 +164,7 @@ nsresult nsMsgCompFields::SetHeader(PRInt32 header, const char *value, PRInt32 *
} }
} }
if (_retval) return status;
*_retval = status;
return NS_OK;
}
nsresult nsMsgCompFields::GetHeader(PRInt32 header, char **_retval)
{
NS_PRECONDITION(nsnull != _retval, "nsnull ptr");
*_retval = NS_CONST_CAST(char*, GetHeader(header));
return NS_OK;
} }
const char* nsMsgCompFields::GetHeader(PRInt32 header) const char* nsMsgCompFields::GetHeader(PRInt32 header)
@ -184,9 +176,27 @@ const char* nsMsgCompFields::GetHeader(PRInt32 header)
return NULL; return NULL;
} }
nsresult nsMsgCompFields::SetBoolHeader(PRInt32 header, PRBool bValue, PRInt32 *_retval) nsresult nsMsgCompFields::SetHeader(PRInt32 header, const PRUnichar *value)
{
char* cString;
ConvertFromUnicode(m_internalCharSet, value, &cString);
nsresult rv = SetHeader(header, cString);
PR_Free(cString);
return rv;
}
nsresult nsMsgCompFields::GetHeader(PRInt32 header, PRUnichar **_retval)
{
nsString unicodeStr;
const char* cString = GetHeader(header);
ConvertToUnicode(m_internalCharSet, cString, unicodeStr);
*_retval = unicodeStr.ToNewUnicode();
return NS_OK;
}
nsresult nsMsgCompFields::SetBoolHeader(PRInt32 header, PRBool bValue)
{ {
int status = 0;
NS_ASSERTION ((int) header >= (int) MSG_RETURN_RECEIPT_BOOL_HEADER_MASK && NS_ASSERTION ((int) header >= (int) MSG_RETURN_RECEIPT_BOOL_HEADER_MASK &&
(int) header < (int) MSG_LAST_BOOL_HEADER_MASK, "invalid header index"); (int) header < (int) MSG_LAST_BOOL_HEADER_MASK, "invalid header index");
@ -196,9 +206,6 @@ nsresult nsMsgCompFields::SetBoolHeader(PRInt32 header, PRBool bValue, PRInt32 *
m_boolHeaders[header] = bValue; m_boolHeaders[header] = bValue;
if (_retval)
*_retval = status;
return NS_OK; return NS_OK;
} }
@ -222,239 +229,239 @@ PRBool nsMsgCompFields::GetBoolHeader(PRInt32 header)
return m_boolHeaders[header]; return m_boolHeaders[header];
} }
nsresult nsMsgCompFields::SetFrom(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetFrom(const PRUnichar *value)
{ {
return SetHeader(MSG_FROM_HEADER_MASK, value, _retval); return SetHeader(MSG_FROM_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetFrom(char **_retval) nsresult nsMsgCompFields::GetFrom(PRUnichar **_retval)
{ {
return GetHeader(MSG_FROM_HEADER_MASK, _retval); return GetHeader(MSG_FROM_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetReplyTo(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetReplyTo(const PRUnichar *value)
{ {
return SetHeader(MSG_REPLY_TO_HEADER_MASK, value, _retval); return SetHeader(MSG_REPLY_TO_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetReplyTo(char **_retval) nsresult nsMsgCompFields::GetReplyTo(PRUnichar **_retval)
{ {
return GetHeader(MSG_REPLY_TO_HEADER_MASK, _retval); return GetHeader(MSG_REPLY_TO_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetTo(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetTo(const PRUnichar *value)
{ {
return SetHeader(MSG_TO_HEADER_MASK, value, _retval); return SetHeader(MSG_TO_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetTo(char **_retval) nsresult nsMsgCompFields::GetTo(PRUnichar **_retval)
{ {
return GetHeader(MSG_TO_HEADER_MASK, _retval); return GetHeader(MSG_TO_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetCc(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetCc(const PRUnichar *value)
{ {
return SetHeader(MSG_CC_HEADER_MASK, value, _retval); return SetHeader(MSG_CC_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetCc(char **_retval) nsresult nsMsgCompFields::GetCc(PRUnichar **_retval)
{ {
return GetHeader(MSG_CC_HEADER_MASK, _retval); return GetHeader(MSG_CC_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetBcc(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetBcc(const PRUnichar *value)
{ {
return SetHeader(MSG_BCC_HEADER_MASK, value, _retval); return SetHeader(MSG_BCC_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetBcc(char **_retval) nsresult nsMsgCompFields::GetBcc(PRUnichar **_retval)
{ {
return GetHeader(MSG_BCC_HEADER_MASK, _retval); return GetHeader(MSG_BCC_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetFcc(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetFcc(const PRUnichar *value)
{ {
return SetHeader(MSG_FCC_HEADER_MASK, value, _retval); return SetHeader(MSG_FCC_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetFcc(char **_retval) nsresult nsMsgCompFields::GetFcc(PRUnichar **_retval)
{ {
return GetHeader(MSG_FCC_HEADER_MASK, _retval); return GetHeader(MSG_FCC_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetNewsFcc(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetNewsFcc(const PRUnichar *value)
{ {
return SetHeader(MSG_NEWS_FCC_HEADER_MASK, value, _retval); return SetHeader(MSG_NEWS_FCC_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetNewsFcc(char **_retval) nsresult nsMsgCompFields::GetNewsFcc(PRUnichar **_retval)
{ {
return GetHeader(MSG_NEWS_FCC_HEADER_MASK, _retval); return GetHeader(MSG_NEWS_FCC_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetNewsBcc(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetNewsBcc(const PRUnichar *value)
{ {
return SetHeader(MSG_NEWS_BCC_HEADER_MASK, value, _retval); return SetHeader(MSG_NEWS_BCC_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetNewsBcc(char **_retval) nsresult nsMsgCompFields::GetNewsBcc(PRUnichar **_retval)
{ {
return GetHeader(MSG_NEWS_BCC_HEADER_MASK, _retval); return GetHeader(MSG_NEWS_BCC_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetNewsgroups(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetNewsgroups(const PRUnichar *value)
{ {
return SetHeader(MSG_NEWSGROUPS_HEADER_MASK, value, _retval); return SetHeader(MSG_NEWSGROUPS_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetNewsgroups(char **_retval) nsresult nsMsgCompFields::GetNewsgroups(PRUnichar **_retval)
{ {
return GetHeader(MSG_NEWSGROUPS_HEADER_MASK, _retval); return GetHeader(MSG_NEWSGROUPS_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetFollowupTo(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetFollowupTo(const PRUnichar *value)
{ {
return SetHeader(MSG_FOLLOWUP_TO_HEADER_MASK, value, _retval); return SetHeader(MSG_FOLLOWUP_TO_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetFollowupTo(char **_retval) nsresult nsMsgCompFields::GetFollowupTo(PRUnichar **_retval)
{ {
return GetHeader(MSG_FOLLOWUP_TO_HEADER_MASK, _retval); return GetHeader(MSG_FOLLOWUP_TO_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetSubject(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetSubject(const PRUnichar *value)
{ {
return SetHeader(MSG_SUBJECT_HEADER_MASK, value, _retval); return SetHeader(MSG_SUBJECT_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetSubject(char **_retval) nsresult nsMsgCompFields::GetSubject(PRUnichar **_retval)
{ {
return GetHeader(MSG_SUBJECT_HEADER_MASK, _retval); return GetHeader(MSG_SUBJECT_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetAttachments(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetAttachments(const PRUnichar *value)
{ {
return SetHeader(MSG_ATTACHMENTS_HEADER_MASK, value, _retval); return SetHeader(MSG_ATTACHMENTS_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetAttachments(char **_retval) nsresult nsMsgCompFields::GetAttachments(PRUnichar **_retval)
{ {
return GetHeader(MSG_ATTACHMENTS_HEADER_MASK, _retval); return GetHeader(MSG_ATTACHMENTS_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetOrganization(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetOrganization(const PRUnichar *value)
{ {
return SetHeader(MSG_ORGANIZATION_HEADER_MASK, value, _retval); return SetHeader(MSG_ORGANIZATION_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetOrganization(char **_retval) nsresult nsMsgCompFields::GetOrganization(PRUnichar **_retval)
{ {
return GetHeader(MSG_ORGANIZATION_HEADER_MASK, _retval); return GetHeader(MSG_ORGANIZATION_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetReferences(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetReferences(const PRUnichar *value)
{ {
return SetHeader(MSG_REFERENCES_HEADER_MASK, value, _retval); return SetHeader(MSG_REFERENCES_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetReferences(char **_retval) nsresult nsMsgCompFields::GetReferences(PRUnichar **_retval)
{ {
return GetHeader(MSG_REFERENCES_HEADER_MASK, _retval); return GetHeader(MSG_REFERENCES_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetOtherRandomHeaders(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetOtherRandomHeaders(const PRUnichar *value)
{ {
return SetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK, value, _retval); return SetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetOtherRandomHeaders(char **_retval) nsresult nsMsgCompFields::GetOtherRandomHeaders(PRUnichar **_retval)
{ {
return GetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK, _retval); return GetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetNewspostUrl(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetNewspostUrl(const PRUnichar *value)
{ {
return SetHeader(MSG_NEWSPOSTURL_HEADER_MASK, value, _retval); return SetHeader(MSG_NEWSPOSTURL_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetNewspostUrl(char **_retval) nsresult nsMsgCompFields::GetNewspostUrl(PRUnichar **_retval)
{ {
return GetHeader(MSG_NEWSPOSTURL_HEADER_MASK, _retval); return GetHeader(MSG_NEWSPOSTURL_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetDefaultBody(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetDefaultBody(const PRUnichar *value)
{ {
return SetHeader(MSG_DEFAULTBODY_HEADER_MASK, value, _retval); return SetHeader(MSG_DEFAULTBODY_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetDefaultBody(char **_retval) nsresult nsMsgCompFields::GetDefaultBody(PRUnichar **_retval)
{ {
return GetHeader(MSG_DEFAULTBODY_HEADER_MASK, _retval); return GetHeader(MSG_DEFAULTBODY_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetPriority(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetPriority(const PRUnichar *value)
{ {
return SetHeader(MSG_PRIORITY_HEADER_MASK, value, _retval); return SetHeader(MSG_PRIORITY_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetPriority(char **_retval) nsresult nsMsgCompFields::GetPriority(PRUnichar **_retval)
{ {
return GetHeader(MSG_PRIORITY_HEADER_MASK, _retval); return GetHeader(MSG_PRIORITY_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetMessageEncoding(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetMessageEncoding(const PRUnichar *value)
{ {
return SetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK, value, _retval); return SetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetMessageEncoding(char **_retval) nsresult nsMsgCompFields::GetMessageEncoding(PRUnichar **_retval)
{ {
return GetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK, _retval); return GetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetCharacterSet(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetCharacterSet(const PRUnichar *value)
{ {
return SetHeader(MSG_CHARACTER_SET_HEADER_MASK, value, _retval); return SetHeader(MSG_CHARACTER_SET_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetCharacterSet(char **_retval) nsresult nsMsgCompFields::GetCharacterSet(PRUnichar **_retval)
{ {
return GetHeader(MSG_CHARACTER_SET_HEADER_MASK, _retval); return GetHeader(MSG_CHARACTER_SET_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetMessageId(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetMessageId(const PRUnichar *value)
{ {
return SetHeader(MSG_MESSAGE_ID_HEADER_MASK, value, _retval); return SetHeader(MSG_MESSAGE_ID_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetMessageId(char **_retval) nsresult nsMsgCompFields::GetMessageId(PRUnichar **_retval)
{ {
return GetHeader(MSG_MESSAGE_ID_HEADER_MASK, _retval); return GetHeader(MSG_MESSAGE_ID_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetHTMLPart(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetHTMLPart(const PRUnichar *value)
{ {
return SetHeader(MSG_HTML_PART_HEADER_MASK, value, _retval); return SetHeader(MSG_HTML_PART_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetHTMLPart(char **_retval) nsresult nsMsgCompFields::GetHTMLPart(PRUnichar **_retval)
{ {
return GetHeader(MSG_HTML_PART_HEADER_MASK, _retval); return GetHeader(MSG_HTML_PART_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetTemplateName(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetTemplateName(const PRUnichar *value)
{ {
return SetHeader(MSG_X_TEMPLATE_HEADER_MASK, value, _retval); return SetHeader(MSG_X_TEMPLATE_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetTemplateName(char **_retval) nsresult nsMsgCompFields::GetTemplateName(PRUnichar **_retval)
{ {
return GetHeader(MSG_X_TEMPLATE_HEADER_MASK, _retval); return GetHeader(MSG_X_TEMPLATE_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetReturnReceipt(PRBool value, PRInt32 *_retval) nsresult nsMsgCompFields::SetReturnReceipt(PRBool value)
{ {
return SetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK, value, _retval); return SetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetReturnReceipt(PRBool *_retval) nsresult nsMsgCompFields::GetReturnReceipt(PRBool *_retval)
@ -462,9 +469,9 @@ nsresult nsMsgCompFields::GetReturnReceipt(PRBool *_retval)
return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK, _retval); return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK, _retval);
} }
nsresult nsMsgCompFields::SetAttachVCard(PRBool value, PRInt32 *_retval) nsresult nsMsgCompFields::SetAttachVCard(PRBool value)
{ {
return SetBoolHeader(MSG_ATTACH_VCARD_BOOL_HEADER_MASK, value, _retval); return SetBoolHeader(MSG_ATTACH_VCARD_BOOL_HEADER_MASK, value);
} }
nsresult nsMsgCompFields::GetAttachVCard(PRBool *_retval) nsresult nsMsgCompFields::GetAttachVCard(PRBool *_retval)
@ -473,9 +480,9 @@ nsresult nsMsgCompFields::GetAttachVCard(PRBool *_retval)
} }
nsresult nsresult
nsMsgCompFields::SetUUEncodeAttachments(PRBool value, PRInt32 *_retval) nsMsgCompFields::SetUUEncodeAttachments(PRBool value)
{ {
return GetBoolHeader(MSG_UUENCODE_BINARY_BOOL_HEADER_MASK, _retval); return GetBoolHeader(MSG_UUENCODE_BINARY_BOOL_HEADER_MASK);
} }
nsresult nsresult
@ -485,7 +492,7 @@ nsMsgCompFields::GetUUEncodeAttachments(PRBool *_retval)
} }
nsresult nsresult
nsMsgCompFields::SetTheForcePlainText(PRBool value, PRInt32 *_retval) nsMsgCompFields::SetTheForcePlainText(PRBool value)
{ {
m_force_plain_text = value; m_force_plain_text = value;
return NS_OK; return NS_OK;
@ -507,12 +514,11 @@ HJ36954
if (hostPort && group) { /* must have a group */ if (hostPort && group) { /* must have a group */
char *newsPostUrl = HJ57077 char *newsPostUrl = HJ57077
if (newsPostUrl) { if (newsPostUrl) {
const char *existingHeader; const char *existingHeader = GetHeader(MSG_NEWSPOSTURL_HEADER_MASK);
GetHeader (MSG_NEWSPOSTURL_HEADER_MASK, (char **)&existingHeader);
if (existingHeader && *existingHeader && nsCRT::strcasecmp(newsPostUrl, existingHeader)) if (existingHeader && *existingHeader && nsCRT::strcasecmp(newsPostUrl, existingHeader))
status = MK_MSG_CANT_POST_TO_MULTIPLE_NEWS_HOSTS; /* can only send to one news host at a time */ status = MK_MSG_CANT_POST_TO_MULTIPLE_NEWS_HOSTS; /* can only send to one news host at a time */
else { else {
SetHeader (MSG_NEWSPOSTURL_HEADER_MASK, newsPostUrl, NULL); SetHeader (MSG_NEWSPOSTURL_HEADER_MASK, newsPostUrl);
status = 0; /* we succeeded, no need to keep looking at this header */ status = 0; /* we succeeded, no need to keep looking at this header */
} }
PR_Free(newsPostUrl); PR_Free(newsPostUrl);
@ -568,7 +574,34 @@ PRInt16 nsMsgCompFields::ParseNewsgroupsForUrls (const char *value)
return status; return status;
} }
nsresult nsMsgCompFields::SetBody(const char *value, PRInt32 *_retval) nsresult nsMsgCompFields::SetBody(const PRUnichar *value)
{
long retval = 0;
PR_FREEIF(m_body);
if (value) {
char* cString;
ConvertFromUnicode(m_internalCharSet, value, &cString);
m_body = cString;
if (!m_body)
retval = MK_OUT_OF_MEMORY;
}
return retval;
}
nsresult nsMsgCompFields::GetBody(PRUnichar **_retval)
{
NS_PRECONDITION(nsnull != _retval, "nsnull ptr");
nsString unicodeStr;
const char* cString = GetBody();
ConvertToUnicode(m_internalCharSet, cString, unicodeStr);
*_retval = unicodeStr.ToNewUnicode();
return NS_OK;
}
nsresult nsMsgCompFields::SetBody(const char *value)
{ {
long retval = 0; long retval = 0;
@ -578,18 +611,7 @@ nsresult nsMsgCompFields::SetBody(const char *value, PRInt32 *_retval)
if (!m_body) if (!m_body)
retval = MK_OUT_OF_MEMORY; retval = MK_OUT_OF_MEMORY;
} }
if (_retval) return retval;
*_retval = retval;
return NS_OK;
}
nsresult nsMsgCompFields::GetBody(char **_retval)
{
NS_PRECONDITION(nsnull != _retval, "nsnull ptr");
*_retval = NS_CONST_CAST(char*, GetBody());
return NS_OK;
} }
const char* nsMsgCompFields::GetBody() const char* nsMsgCompFields::GetBody()
@ -604,7 +626,7 @@ PRInt16 nsMsgCompFields::AppendBody(char* value)
return 0; return 0;
if (!m_body) { if (!m_body) {
return SetBody(value, NULL); return SetBody(value);
} else { } else {
char* tmp = (char*) PR_Malloc(nsCRT::strlen(m_body) + nsCRT::strlen(value) + 1); char* tmp = (char*) PR_Malloc(nsCRT::strlen(m_body) + nsCRT::strlen(value) + 1);
if (tmp) { if (tmp) {

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

@ -45,122 +45,156 @@ public:
NS_IMETHOD Copy(nsIMsgCompFields* pMsgCompFields); NS_IMETHOD Copy(nsIMsgCompFields* pMsgCompFields);
NS_IMETHOD SetHeader(PRInt32 header, const char *value, PRInt32 *_retval); NS_IMETHOD SetHeader(PRInt32 header, const char *value);
NS_IMETHOD GetHeader(PRInt32 header, char **_retval); const char* GetHeader(PRInt32 header); //just return the address of the internal header variable, don't dispose it
const char* GetHeader(PRInt32 header);
NS_IMETHOD SetBoolHeader(PRInt32 header, PRBool bValue, PRInt32 *_retval); NS_IMETHOD SetHeader(PRInt32 header, const PRUnichar *value);
NS_IMETHOD GetHeader(PRInt32 header, PRUnichar **_retval); //Will return a copy of the header, must be free using PR_Free()
NS_IMETHOD SetBoolHeader(PRInt32 header, PRBool bValue);
NS_IMETHOD GetBoolHeader(PRInt32 header, PRBool *_retval); NS_IMETHOD GetBoolHeader(PRInt32 header, PRBool *_retval);
PRBool GetBoolHeader(PRInt32 header); PRBool GetBoolHeader(PRInt32 header);
/* Convenience routines to get and set header's value... */ /* Convenience routines to get and set header's value...
NS_IMETHOD SetFrom(const char *value, PRInt32 *_retval);
NS_IMETHOD GetFrom(char **_retval); IMPORTANT:
all routines NS_IMETHOD GetXxx(char **_retval) will allocate a string that must be free later using free()
all routines const char* GetXxx(void) will return a pointer to the header, please don't free it.
accessor and mutator that are scriptable use Unicode only.
*/
NS_IMETHOD SetFrom(const PRUnichar *value);
NS_IMETHOD GetFrom(PRUnichar **_retval);
NS_IMETHOD SetFrom(const char *value) {return SetHeader(MSG_FROM_HEADER_MASK, value);}
const char* GetFrom(void) {return GetHeader(MSG_FROM_HEADER_MASK);} const char* GetFrom(void) {return GetHeader(MSG_FROM_HEADER_MASK);}
NS_IMETHOD SetReplyTo(const char *value, PRInt32 *_retval); NS_IMETHOD SetReplyTo(const PRUnichar *value);
NS_IMETHOD GetReplyTo(char **_retval); NS_IMETHOD GetReplyTo(PRUnichar **_retval);
NS_IMETHOD SetReplyTo(const char *value) {return SetHeader(MSG_REPLY_TO_HEADER_MASK, value);}
const char* GetReplyTo() {return GetHeader(MSG_REPLY_TO_HEADER_MASK);} const char* GetReplyTo() {return GetHeader(MSG_REPLY_TO_HEADER_MASK);}
NS_IMETHOD SetTo(const char *value, PRInt32 *_retval); NS_IMETHOD SetTo(const PRUnichar *value);
NS_IMETHOD GetTo(char **_retval); NS_IMETHOD GetTo(PRUnichar **_retval);
NS_IMETHOD SetTo(const char *value) {return SetHeader(MSG_TO_HEADER_MASK, value);}
const char* GetTo() {return GetHeader(MSG_TO_HEADER_MASK);} const char* GetTo() {return GetHeader(MSG_TO_HEADER_MASK);}
NS_IMETHOD SetCc(const char *value, PRInt32 *_retval); NS_IMETHOD SetCc(const PRUnichar *value);
NS_IMETHOD GetCc(char **_retval); NS_IMETHOD GetCc(PRUnichar **_retval);
NS_IMETHOD SetCc(const char *value) {return SetHeader(MSG_CC_HEADER_MASK, value);}
const char* GetCc() {return GetHeader(MSG_CC_HEADER_MASK);} const char* GetCc() {return GetHeader(MSG_CC_HEADER_MASK);}
NS_IMETHOD SetBcc(const char *value, PRInt32 *_retval); NS_IMETHOD SetBcc(const PRUnichar *value);
NS_IMETHOD GetBcc(char **_retval); NS_IMETHOD GetBcc(PRUnichar **_retval);
NS_IMETHOD SetBcc(const char *value) {return SetHeader(MSG_BCC_HEADER_MASK, value);}
const char* GetBcc() {return GetHeader(MSG_BCC_HEADER_MASK);} const char* GetBcc() {return GetHeader(MSG_BCC_HEADER_MASK);}
NS_IMETHOD SetFcc(const char *value, PRInt32 *_retval); NS_IMETHOD SetFcc(const PRUnichar *value);
NS_IMETHOD GetFcc(char **_retval); NS_IMETHOD GetFcc(PRUnichar **_retval);
NS_IMETHOD SetFcc(const char *value) {return SetHeader(MSG_FCC_HEADER_MASK, value);}
const char* GetFcc() {return GetHeader(MSG_FCC_HEADER_MASK);} const char* GetFcc() {return GetHeader(MSG_FCC_HEADER_MASK);}
NS_IMETHOD SetNewsFcc(const char *value, PRInt32 *_retval); NS_IMETHOD SetNewsFcc(const PRUnichar *value);
NS_IMETHOD GetNewsFcc(char **_retval); NS_IMETHOD GetNewsFcc(PRUnichar **_retval);
NS_IMETHOD SetNewsFcc(const char *value) {return SetHeader(MSG_NEWS_FCC_HEADER_MASK, value);}
const char* GetNewsFcc() {return GetHeader(MSG_NEWS_FCC_HEADER_MASK);} const char* GetNewsFcc() {return GetHeader(MSG_NEWS_FCC_HEADER_MASK);}
NS_IMETHOD SetNewsBcc(const char *value, PRInt32 *_retval); NS_IMETHOD SetNewsBcc(const PRUnichar *value);
NS_IMETHOD GetNewsBcc(char **_retval); NS_IMETHOD GetNewsBcc(PRUnichar **_retval);
NS_IMETHOD SetNewsBcc(const char *value) {return SetHeader(MSG_NEWS_BCC_HEADER_MASK, value);}
const char* GetNewsBcc() {return GetHeader(MSG_NEWS_BCC_HEADER_MASK);} const char* GetNewsBcc() {return GetHeader(MSG_NEWS_BCC_HEADER_MASK);}
NS_IMETHOD SetNewsgroups(const char *value, PRInt32 *_retval); NS_IMETHOD SetNewsgroups(const PRUnichar *value);
NS_IMETHOD GetNewsgroups(char **_retval); NS_IMETHOD GetNewsgroups(PRUnichar **_retval);
NS_IMETHOD SetNewsgroups(const char *value) {return SetHeader(MSG_NEWSGROUPS_HEADER_MASK, value);}
const char* GetNewsgroups() {return GetHeader(MSG_NEWSGROUPS_HEADER_MASK);} const char* GetNewsgroups() {return GetHeader(MSG_NEWSGROUPS_HEADER_MASK);}
NS_IMETHOD SetFollowupTo(const char *value, PRInt32 *_retval); NS_IMETHOD SetFollowupTo(const PRUnichar *value);
NS_IMETHOD GetFollowupTo(char **_retval); NS_IMETHOD GetFollowupTo(PRUnichar **_retval);
NS_IMETHOD SetFollowupTo(const char *value) {return SetHeader(MSG_FOLLOWUP_TO_HEADER_MASK, value);}
const char* GetFollowupTo() {return GetHeader(MSG_FOLLOWUP_TO_HEADER_MASK);} const char* GetFollowupTo() {return GetHeader(MSG_FOLLOWUP_TO_HEADER_MASK);}
NS_IMETHOD SetSubject(const char *value, PRInt32 *_retval); NS_IMETHOD SetSubject(const PRUnichar *value);
NS_IMETHOD GetSubject(char **_retval); NS_IMETHOD GetSubject(PRUnichar **_retval);
NS_IMETHOD SetSubject(const char *value) {return SetHeader(MSG_SUBJECT_HEADER_MASK, value);}
const char* GetSubject() {return GetHeader(MSG_SUBJECT_HEADER_MASK);} const char* GetSubject() {return GetHeader(MSG_SUBJECT_HEADER_MASK);}
NS_IMETHOD SetAttachments(const char *value, PRInt32 *_retval); NS_IMETHOD SetAttachments(const PRUnichar *value);
NS_IMETHOD GetAttachments(char **_retval); NS_IMETHOD GetAttachments(PRUnichar **_retval);
NS_IMETHOD SetAttachments(const char *value) {return SetHeader(MSG_ATTACHMENTS_HEADER_MASK, value);}
const char* GetAttachments() {return GetHeader(MSG_ATTACHMENTS_HEADER_MASK);} const char* GetAttachments() {return GetHeader(MSG_ATTACHMENTS_HEADER_MASK);}
NS_IMETHOD SetOrganization(const char *value, PRInt32 *_retval); NS_IMETHOD SetOrganization(const PRUnichar *value);
NS_IMETHOD GetOrganization(char **_retval); NS_IMETHOD GetOrganization(PRUnichar **_retval);
NS_IMETHOD SetOrganization(const char *value) {return SetHeader(MSG_ORGANIZATION_HEADER_MASK, value);}
const char* GetOrganization() {return GetHeader(MSG_ORGANIZATION_HEADER_MASK);} const char* GetOrganization() {return GetHeader(MSG_ORGANIZATION_HEADER_MASK);}
NS_IMETHOD SetReferences(const char *value, PRInt32 *_retval); NS_IMETHOD SetReferences(const PRUnichar *value);
NS_IMETHOD GetReferences(char **_retval); NS_IMETHOD GetReferences(PRUnichar **_retval);
NS_IMETHOD SetReferences(const char *value) {return SetHeader(MSG_REFERENCES_HEADER_MASK, value);}
const char* GetReferences() {return GetHeader(MSG_REFERENCES_HEADER_MASK);} const char* GetReferences() {return GetHeader(MSG_REFERENCES_HEADER_MASK);}
NS_IMETHOD SetOtherRandomHeaders(const char *value, PRInt32 *_retval); NS_IMETHOD SetOtherRandomHeaders(const PRUnichar *value);
NS_IMETHOD GetOtherRandomHeaders(char **_retval); NS_IMETHOD GetOtherRandomHeaders(PRUnichar **_retval);
NS_IMETHOD SetOtherRandomHeaders(const char *value) {return SetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK, value);}
const char* GetOtherRandomHeaders() {return GetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK);} const char* GetOtherRandomHeaders() {return GetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK);}
NS_IMETHOD SetNewspostUrl(const char *value, PRInt32 *_retval); NS_IMETHOD SetNewspostUrl(const PRUnichar *value);
NS_IMETHOD GetNewspostUrl(char **_retval); NS_IMETHOD GetNewspostUrl(PRUnichar **_retval);
NS_IMETHOD SetNewspostUrl(const char *value) {return SetHeader(MSG_NEWSPOSTURL_HEADER_MASK, value);}
const char* GetNewspostUrl() {return GetHeader(MSG_NEWSPOSTURL_HEADER_MASK);} const char* GetNewspostUrl() {return GetHeader(MSG_NEWSPOSTURL_HEADER_MASK);}
NS_IMETHOD SetDefaultBody(const char *value, PRInt32 *_retval); NS_IMETHOD SetDefaultBody(const PRUnichar *value);
NS_IMETHOD GetDefaultBody(char **_retval); NS_IMETHOD GetDefaultBody(PRUnichar **_retval);
NS_IMETHOD SetDefaultBody(const char *value) {return SetHeader(MSG_DEFAULTBODY_HEADER_MASK, value);}
const char* GetDefaultBody() {return GetHeader(MSG_DEFAULTBODY_HEADER_MASK);} const char* GetDefaultBody() {return GetHeader(MSG_DEFAULTBODY_HEADER_MASK);}
NS_IMETHOD SetPriority(const char *value, PRInt32 *_retval); NS_IMETHOD SetPriority(const PRUnichar *value);
NS_IMETHOD GetPriority(char **_retval); NS_IMETHOD GetPriority(PRUnichar **_retval);
NS_IMETHOD SetPriority(const char *value) {return SetHeader(MSG_PRIORITY_HEADER_MASK, value);}
const char* GetPriority() {return GetHeader(MSG_PRIORITY_HEADER_MASK);} const char* GetPriority() {return GetHeader(MSG_PRIORITY_HEADER_MASK);}
NS_IMETHOD SetMessageEncoding(const char *value, PRInt32 *_retval); NS_IMETHOD SetMessageEncoding(const PRUnichar *value);
NS_IMETHOD GetMessageEncoding(char **_retval); NS_IMETHOD GetMessageEncoding(PRUnichar **_retval);
NS_IMETHOD SetMessageEncoding(const char *value) {return SetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK, (const char *)value);}
const char* GetMessageEncoding() {return GetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK);} const char* GetMessageEncoding() {return GetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK);}
NS_IMETHOD SetCharacterSet(const char *value, PRInt32 *_retval); NS_IMETHOD SetCharacterSet(const PRUnichar *value);
NS_IMETHOD GetCharacterSet(char **_retval); NS_IMETHOD GetCharacterSet(PRUnichar **_retval);
NS_IMETHOD SetCharacterSet(const char *value) {return SetHeader(MSG_CHARACTER_SET_HEADER_MASK, (const char *)value);}
const char* GetCharacterSet() {return GetHeader(MSG_CHARACTER_SET_HEADER_MASK);} const char* GetCharacterSet() {return GetHeader(MSG_CHARACTER_SET_HEADER_MASK);}
NS_IMETHOD SetMessageId(const char *value, PRInt32 *_retval); NS_IMETHOD SetMessageId(const PRUnichar *value);
NS_IMETHOD GetMessageId(char **_retval); NS_IMETHOD GetMessageId(PRUnichar **_retval);
NS_IMETHOD SetMessageId(const char *value) {return SetHeader(MSG_MESSAGE_ID_HEADER_MASK, value);}
const char* GetMessageId() {return GetHeader(MSG_MESSAGE_ID_HEADER_MASK);} const char* GetMessageId() {return GetHeader(MSG_MESSAGE_ID_HEADER_MASK);}
NS_IMETHOD SetHTMLPart(const char *value, PRInt32 *_retval); NS_IMETHOD SetHTMLPart(const PRUnichar *value);
NS_IMETHOD GetHTMLPart(char **_retval); NS_IMETHOD GetHTMLPart(PRUnichar **_retval);
NS_IMETHOD SetHTMLPart(const char *value) {return SetHeader(MSG_HTML_PART_HEADER_MASK, value);}
const char* GetHTMLPart() {return GetHeader(MSG_HTML_PART_HEADER_MASK);} const char* GetHTMLPart() {return GetHeader(MSG_HTML_PART_HEADER_MASK);}
NS_IMETHOD SetTemplateName(const char *value, PRInt32 *_retval); NS_IMETHOD SetTemplateName(const PRUnichar *value);
NS_IMETHOD GetTemplateName(char **_retval); NS_IMETHOD GetTemplateName(PRUnichar **_retval);
NS_IMETHOD SetTemplateName(const char *value) {return SetHeader(MSG_X_TEMPLATE_HEADER_MASK, value);}
const char* GetTemplateName() {return GetHeader(MSG_X_TEMPLATE_HEADER_MASK);} const char* GetTemplateName() {return GetHeader(MSG_X_TEMPLATE_HEADER_MASK);}
NS_IMETHOD SetReturnReceipt(PRBool value, PRInt32 *_retval); NS_IMETHOD SetReturnReceipt(PRBool value);
NS_IMETHOD GetReturnReceipt(PRBool *_retval); NS_IMETHOD GetReturnReceipt(PRBool *_retval);
PRBool GetReturnReceipt() {return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK);} PRBool GetReturnReceipt() {return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK);}
NS_IMETHOD SetAttachVCard(PRBool value, PRInt32 *_retval); NS_IMETHOD SetAttachVCard(PRBool value);
NS_IMETHOD GetAttachVCard(PRBool *_retval); NS_IMETHOD GetAttachVCard(PRBool *_retval);
PRBool GetAttachVCard() {return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK);} PRBool GetAttachVCard() {return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK);}
NS_IMETHOD SetUUEncodeAttachments(PRBool value, PRInt32 *_retval); NS_IMETHOD SetUUEncodeAttachments(PRBool value);
NS_IMETHOD GetUUEncodeAttachments(PRBool *_retval); NS_IMETHOD GetUUEncodeAttachments(PRBool *_retval);
PRBool GetUUEncodeAttachments() {return GetBoolHeader(MSG_UUENCODE_BINARY_BOOL_HEADER_MASK);} PRBool GetUUEncodeAttachments() {return GetBoolHeader(MSG_UUENCODE_BINARY_BOOL_HEADER_MASK);}
NS_IMETHOD SetBody(const char *value, PRInt32 *_retval); NS_IMETHOD SetBody(const PRUnichar *value);
NS_IMETHOD GetBody(char **_retval); NS_IMETHOD GetBody(PRUnichar **_retval);
NS_IMETHOD SetBody(const char *value);
const char* GetBody(); const char* GetBody();
PRInt16 AppendBody(char*); PRInt16 AppendBody(char*);
@ -182,9 +216,9 @@ public:
MSG_Pane * GetOwner() { return m_owner; } MSG_Pane * GetOwner() { return m_owner; }
NS_IMETHOD SetTheForcePlainText(PRBool value, PRInt32 *_retval); NS_IMETHOD SetTheForcePlainText(PRBool value);
NS_IMETHOD GetTheForcePlainText(PRBool *_retval); NS_IMETHOD GetTheForcePlainText(PRBool *_retval);
void SetForcePlainText(PRBool value) {m_force_plain_text = value;} void SetForcePlainText(PRBool value) {m_force_plain_text = value;}
PRBool GetForcePlainText() {return m_force_plain_text;} PRBool GetForcePlainText() {return m_force_plain_text;}
void SetUseMultipartAlternative(PRBool value) {m_multipart_alt = value;} void SetUseMultipartAlternative(PRBool value) {m_multipart_alt = value;}
@ -208,7 +242,7 @@ protected:
PRBool m_force_plain_text; PRBool m_force_plain_text;
PRBool m_multipart_alt; PRBool m_multipart_alt;
PRInt32 m_receiptType; /* 0:None 1:DSN 2:MDN 3:BOTH */ PRInt32 m_receiptType; /* 0:None 1:DSN 2:MDN 3:BOTH */
nsString m_internalCharSet;
}; };

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

@ -1750,7 +1750,7 @@ nsMsgMIMEGenerateMailtoFormPostHeaders (const char *old_post_url,
goto FAIL; goto FAIL;
} }
fields->SetDefaultBody(body, NULL); fields->SetDefaultBody(body);
*headers_return = mime_generate_headers (fields, 0, nsMsgDeliverNow); *headers_return = mime_generate_headers (fields, 0, nsMsgDeliverNow);
if (*headers_return == 0) if (*headers_return == 0)

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

@ -63,19 +63,19 @@ nsMsgCompose::nsMsgCompose()
m_webShellWin = nsnull; m_webShellWin = nsnull;
m_editor = nsnull; m_editor = nsnull;
mOutStream=nsnull; mOutStream=nsnull;
m_compFields = do_QueryInterface(new nsMsgCompFields); m_compFields = new nsMsgCompFields;
mBodyLoaded = PR_FALSE; NS_IF_ADDREF(m_compFields);
mQuotingToFollow = PR_FALSE; mBodyLoaded = PR_FALSE;
mQuotingToFollow = PR_FALSE;
// Get the default charset from pref, use this as a mail charset. // Get the default charset from pref, use this as a mail charset.
char * default_mail_charset = nsMsgI18NGetDefaultMailCharset(); char * default_mail_charset = nsMsgI18NGetDefaultMailCharset();
if (default_mail_charset) if (default_mail_charset)
{ {
m_compFields->SetCharacterSet(default_mail_charset, nsnull); m_compFields->SetCharacterSet(default_mail_charset);
PR_Free(default_mail_charset); PR_Free(default_mail_charset);
} }
m_composeHTML = PR_FALSE; m_composeHTML = PR_FALSE;
// temporary - m_composeHTML from the "current" identity // temporary - m_composeHTML from the "current" identity
// eventually we should know this when we open the compose window // eventually we should know this when we open the compose window
@ -96,7 +96,8 @@ nsMsgCompose::nsMsgCompose()
nsMsgCompose::~nsMsgCompose() nsMsgCompose::~nsMsgCompose()
{ {
NS_IF_RELEASE(mOutStream); NS_IF_RELEASE(m_compFields);
NS_IF_RELEASE(mOutStream);
// ducarroz: we don't need to own the editor shell as JS does it for us. // ducarroz: we don't need to own the editor shell as JS does it for us.
// NS_IF_RELEASE(m_editor); // NS_IF_RELEASE(m_editor);
} }
@ -182,9 +183,7 @@ nsMsgCompose::LoadBody()
if (m_editor) if (m_editor)
{ {
char *body; nsAutoString msgBody(m_compFields->GetBody());
m_compFields->GetBody(&body);
nsAutoString msgBody(body);
if (msgBody.Length()) if (msgBody.Length())
{ {
// Another change...have to load a file with the correct extension or // Another change...have to load a file with the correct extension or
@ -247,62 +246,13 @@ nsresult nsMsgCompose::LoadFields()
{ {
nsresult rv; nsresult rv;
if (!m_window || !m_webShell || !m_webShellWin || !m_compFields)
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> theDoc; // Now we do the LoadURL on the editor because we *may* not have have to wait for any
rv= m_window->GetDocument(getter_AddRefs(theDoc)); // sort of quoting operation...otherwise we are waiting for an async completion and do the load
if (NS_SUCCEEDED(rv) && theDoc) // in that callback...this will prevent multiple LoadURL's which is not a good thing for the
{ // editor or our users
nsCOMPtr<nsIDOMNode> node; LoadBody();
nsCOMPtr<nsIDOMNodeList> nodeList;
nsCOMPtr<nsIDOMHTMLInputElement> inputElement;
rv = theDoc->GetElementsByTagName("INPUT", getter_AddRefs(nodeList));
if ((NS_SUCCEEDED(rv)) && nodeList)
{
PRUint32 count;
PRUint32 i;
nodeList->GetLength(&count);
for (i = 0; i < count; i ++)
{
rv = nodeList->Item(i, getter_AddRefs(node));
if ((NS_SUCCEEDED(rv)) && node)
{
nsString value;
rv = node->QueryInterface(nsIDOMHTMLInputElement::GetIID(), getter_AddRefs(inputElement));
if ((NS_SUCCEEDED(rv)) && inputElement)
{
nsString id;
inputElement->GetId(id);
char *elementValue;
m_compFields->GetTo(&elementValue);
if (id == "msgTo") inputElement->SetValue(elementValue);
m_compFields->GetCc(&elementValue);
if (id == "msgCc") inputElement->SetValue(elementValue);
m_compFields->GetBcc(&elementValue);
if (id == "msgBcc") inputElement->SetValue(elementValue);
m_compFields->GetNewsgroups(&elementValue);
if (id == "msgNewsgroup") inputElement->SetValue(elementValue);
m_compFields->GetSubject(&elementValue);
if (id == "msgSubject") inputElement->SetValue(elementValue);
}
}
}
// Now we do the LoadURL on the editor because we *may* not have have to wait for any
// sort of quoting operation...otherwise we are waiting for an async completion and do the load
// in that callback...this will prevent multiple LoadURL's which is not a good thing for the
// editor or our users
LoadBody();
}
}
return rv; return rv;
} }
@ -310,11 +260,74 @@ nsresult nsMsgCompose::LoadFields()
nsresult nsMsgCompose::SetDocumentCharset(const PRUnichar *charset) nsresult nsMsgCompose::SetDocumentCharset(const PRUnichar *charset)
{ {
// Set charset, this will be used for the MIME charset labeling. // Set charset, this will be used for the MIME charset labeling.
m_compFields->SetCharacterSet(nsAutoCString(charset), nsnull); m_compFields->SetCharacterSet(nsAutoCString(charset));
return NS_OK; return NS_OK;
} }
nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode,
nsIMsgIdentity *identity,
const PRUnichar *callback)
{
nsresult rv = NS_OK;
if (m_compFields && identity)
{
#ifdef DEBUG
printf("----------------------------\n");
printf("-- Sending Mail Message --\n");
printf("----------------------------\n");
printf("To: %s Cc: %s Bcc: %s\n", m_compFields->GetTo(), m_compFields->GetCc(), m_compFields->GetBcc());
printf("Newsgroups: %s\n", m_compFields->GetNewsgroups());
printf("Subject: %s \nMsg: %s\n", m_compFields->GetSubject(), m_compFields->GetBody());
printf("----------------------------\n");
#endif //DEBUG
nsCOMPtr<nsIMsgSend>msgSend = do_QueryInterface(new nsMsgComposeAndSend);
if (msgSend)
{
const char *bodyString = m_compFields->GetBody();
PRInt32 bodyLength = PL_strlen(bodyString);
rv = msgSend->CreateAndSendMessage(
identity,
m_compFields,
PR_FALSE, // PRBool digest_p,
PR_FALSE, // PRBool dont_deliver_p,
(nsMsgDeliverMode)deliverMode, // nsMsgDeliverMode mode,
nsnull, // nsIMessage *msgToReplace,
m_composeHTML?TEXT_HTML:TEXT_PLAIN, // const char *attachment1_type,
bodyString, // const char *attachment1_body,
bodyLength, // PRUint32 attachment1_body_length,
nsnull, // const struct nsMsgAttachmentData *attachments,
nsnull, // const struct nsMsgAttachedFile *preloaded_attachments,
nsnull, // nsMsgSendPart *relatedPart,
nsnull); // listener array
}
else
rv = NS_ERROR_FAILURE;
}
else
rv = NS_ERROR_NOT_INITIALIZED;
if (NS_SUCCEEDED(rv))
{
/*TODO, don't close the window but just hide it, we will close it later when we receive a call back from the BE
if (nsnull != mScriptContext) {
const char* url = "";
PRBool isUndefined = PR_FALSE;
nsString rVal;
mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined);
CloseWindow();
}
else // If we don't have a JS callback, then close the window by default!
*/
CloseWindow();
}
return rv;
}
nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
nsIMsgIdentity *identity, nsIMsgIdentity *identity,
@ -322,68 +335,32 @@ nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsCOMPtr<nsIDOMDocument> domDoc; if (m_editor && m_compFields)
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIDOMNodeList> nodeList;
nsCOMPtr<nsIDOMHTMLInputElement> inputElement;
nsAutoString msgTo;
nsAutoString msgCc;
nsAutoString msgBcc;
nsAutoString msgNewsgroup;
nsAutoString msgSubject;
nsAutoString msgBody;
if (nsnull != m_window)
{ {
rv = m_window->GetDocument(getter_AddRefs(domDoc)); nsAutoString msgBody;
if (NS_SUCCEEDED(rv) && domDoc) PRUnichar *bodyText = NULL;
if (m_composeHTML)
m_editor->GetContentsAsHTML(&bodyText);
else
m_editor->GetContentsAsText(&bodyText);
msgBody = bodyText;
delete [] bodyText;
// Convert body to mail charset not to utf-8 (because we don't manipulate body text)
char *outCString;
nsString aCharset = m_compFields->GetCharacterSet();
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, msgBody, &outCString)))
{ {
rv = domDoc->GetElementsByTagName("INPUT", getter_AddRefs(nodeList)); m_compFields->SetBody(outCString);
if ((NS_SUCCEEDED(rv)) && nodeList) PR_Free(outCString);
{
PRUint32 count;
PRUint32 i;
nodeList->GetLength(&count);
for (i = 0; i < count; i ++)
{
rv = nodeList->Item(i, getter_AddRefs(node));
if ((NS_SUCCEEDED(rv)) && node)
{
nsString value;
rv = node->QueryInterface(nsCOMTypeInfo<nsIDOMHTMLInputElement>::GetIID(), getter_AddRefs(inputElement));
if ((NS_SUCCEEDED(rv)) && inputElement)
{
nsString id;
inputElement->GetId(id);
if (id == "msgTo") inputElement->GetValue(msgTo);
if (id == "msgCc") inputElement->GetValue(msgCc);
if (id == "msgBcc") inputElement->GetValue(msgBcc);
if (id == "msgSubject") inputElement->GetValue(msgSubject);
if (id == "msgNewsgroup") inputElement->GetValue(msgNewsgroup);
}
}
}
if (m_editor)
{
PRUnichar *bodyText = NULL;
if (m_composeHTML)
m_editor->GetContentsAsHTML(&bodyText);
else
m_editor->GetContentsAsText(&bodyText);
msgBody = bodyText;
delete [] bodyText;
SendMsgEx(deliverMode, identity, msgTo.GetUnicode(), msgCc.GetUnicode(), msgBcc.GetUnicode(),
msgNewsgroup.GetUnicode(), msgSubject.GetUnicode(), msgBody.GetUnicode(), callback);
}
}
} }
else
m_compFields->SetBody(nsAutoCString(msgBody));
} }
rv = _SendMsg(deliverMode, identity, callback);
return rv; return rv;
} }
@ -396,18 +373,8 @@ nsMsgCompose::SendMsgEx(MSG_DeliverMode deliverMode,
const PRUnichar *subject, const PRUnichar *body, const PRUnichar *subject, const PRUnichar *body,
const PRUnichar *callback) const PRUnichar *callback)
{ {
nsresult rv = NS_OK;
#ifdef DEBUG
printf("----------------------------\n");
printf("-- Sending Mail Message --\n");
printf("----------------------------\n");
printf("To: %s Cc: %s Bcc: %s\n", (const char *)nsAutoCString(addrTo),
(const char *)nsAutoCString(addrCc), (const char *)nsAutoCString(addrBcc));
printf("Subject: %s \nMsg: %s\n", (const char *)nsAutoCString(subject), (const char *)nsAutoCString(body));
printf("----------------------------\n");
#endif //DEBUG
// nsIMsgCompose *pMsgCompose;
if (m_compFields && identity) if (m_compFields && identity)
{ {
nsString aString; nsString aString;
@ -415,111 +382,75 @@ nsMsgCompose::SendMsgEx(MSG_DeliverMode deliverMode,
char *outCString; char *outCString;
// Pref values are supposed to be stored as UTF-8, so no conversion // Pref values are supposed to be stored as UTF-8, so no conversion
nsXPIDLCString email; nsXPIDLCString email;
nsXPIDLCString replyTo; nsXPIDLCString replyTo;
nsXPIDLCString organization; nsXPIDLCString organization;
identity->GetEmail(getter_Copies(email)); identity->GetEmail(getter_Copies(email));
identity->GetReplyTo(getter_Copies(replyTo)); identity->GetReplyTo(getter_Copies(replyTo));
identity->GetOrganization(getter_Copies(organization)); identity->GetOrganization(getter_Copies(organization));
m_compFields->SetFrom(NS_CONST_CAST(char*, (const char *)email), nsnull); m_compFields->SetFrom(NS_CONST_CAST(char*, (const char *)email));
m_compFields->SetReplyTo(NS_CONST_CAST(char*, (const char *)replyTo), m_compFields->SetReplyTo(NS_CONST_CAST(char*, (const char *)replyTo));
nsnull); m_compFields->SetOrganization(NS_CONST_CAST(char*, (const char *)organization));
m_compFields->SetOrganization(NS_CONST_CAST(char*, (const char *)organization), nsnull);
// Convert fields to UTF-8 // Convert fields to UTF-8
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, addrTo, &outCString))) if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, addrTo, &outCString)))
{ {
m_compFields->SetTo(outCString, nsnull); m_compFields->SetTo(outCString);
PR_Free(outCString); PR_Free(outCString);
} }
else else
m_compFields->SetTo(nsAutoCString(addrTo), nsnull); m_compFields->SetTo(nsAutoCString(addrTo));
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, addrCc, &outCString))) if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, addrCc, &outCString)))
{ {
m_compFields->SetCc(outCString, nsnull); m_compFields->SetCc(outCString);
PR_Free(outCString); PR_Free(outCString);
} }
else else
m_compFields->SetCc(nsAutoCString(addrCc), nsnull); m_compFields->SetCc(nsAutoCString(addrCc));
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, addrBcc, &outCString))) if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, addrBcc, &outCString)))
{ {
m_compFields->SetBcc(outCString, nsnull); m_compFields->SetBcc(outCString);
PR_Free(outCString); PR_Free(outCString);
} }
else else
m_compFields->SetBcc(nsAutoCString(addrBcc), nsnull); m_compFields->SetBcc(nsAutoCString(addrBcc));
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, newsgroup, &outCString))) if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, newsgroup, &outCString)))
{ {
m_compFields->SetNewsgroups(outCString, nsnull); m_compFields->SetNewsgroups(outCString);
PR_Free(outCString); PR_Free(outCString);
} }
else else
m_compFields->SetNewsgroups(nsAutoCString(newsgroup), nsnull); m_compFields->SetNewsgroups(nsAutoCString(newsgroup));
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, subject, &outCString))) if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, subject, &outCString)))
{ {
m_compFields->SetSubject(outCString, nsnull); m_compFields->SetSubject(outCString);
PR_Free(outCString); PR_Free(outCString);
} }
else else
m_compFields->SetSubject(nsAutoCString(subject), nsnull); m_compFields->SetSubject(nsAutoCString(subject));
// Convert body to mail charset not to utf-8 (because we don't manipulate body text) // Convert body to mail charset not to utf-8 (because we don't manipulate body text)
char *mail_charset; aCharset.SetString(m_compFields->GetCharacterSet());
m_compFields->GetCharacterSet(&mail_charset);
aCharset.SetString(mail_charset);
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, body, &outCString))) if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, body, &outCString)))
{ {
m_compFields->SetBody(outCString, nsnull); m_compFields->SetBody(outCString);
PR_Free(outCString); PR_Free(outCString);
} }
else else
m_compFields->SetBody(nsAutoCString(body), nsnull); m_compFields->SetBody(nsAutoCString(body));
nsCOMPtr<nsIMsgSend>msgSend = do_QueryInterface(new nsMsgComposeAndSend); rv = _SendMsg(deliverMode, identity, callback);
if (msgSend)
{
char *bodyString = nsnull;
PRInt32 bodyLength;
m_compFields->GetBody(&bodyString);
bodyLength = PL_strlen(bodyString);
msgSend->CreateAndSendMessage(
identity,
m_compFields,
PR_FALSE, // PRBool digest_p,
PR_FALSE, // PRBool dont_deliver_p,
(nsMsgDeliverMode)deliverMode, // nsMsgDeliverMode mode,
nsnull, // nsIMessage *msgToReplace,
m_composeHTML?TEXT_HTML:TEXT_PLAIN, // const char *attachment1_type,
bodyString, // const char *attachment1_body,
bodyLength, // PRUint32 attachment1_body_length,
nsnull, // const struct nsMsgAttachmentData *attachments,
nsnull, // const struct nsMsgAttachedFile *preloaded_attachments,
nsnull, // nsMsgSendPart *relatedPart,
nsnull); // listener array
}
} }
/*TODO, don't close the window but just hide it, we will close it later when we receive a call back from the BE else
if (nsnull != mScriptContext) { rv = NS_ERROR_NOT_INITIALIZED;
const char* url = "";
PRBool isUndefined = PR_FALSE;
nsString rVal;
mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined);
CloseWindow();
}
else // If we don't have a JS callback, then close the window by default!
*/
CloseWindow();
return NS_OK; return rv;
} }
nsresult nsMsgCompose::CloseWindow() nsresult nsMsgCompose::CloseWindow()
@ -559,6 +490,7 @@ nsresult nsMsgCompose::GetDomWindow(nsIDOMWindow * *aDomWindow)
nsresult nsMsgCompose::GetCompFields(nsIMsgCompFields * *aCompFields) nsresult nsMsgCompose::GetCompFields(nsIMsgCompFields * *aCompFields)
{ {
*aCompFields = (nsIMsgCompFields*)m_compFields; *aCompFields = (nsIMsgCompFields*)m_compFields;
NS_IF_ADDREF(*aCompFields);
return NS_OK; return NS_OK;
} }
@ -608,24 +540,21 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
mQuotingToFollow = PR_TRUE; mQuotingToFollow = PR_TRUE;
// get an original charset, used for a label, UTF-8 is used for the internal processing // get an original charset, used for a label, UTF-8 is used for the internal processing
if (!aCharset.Equals("")) if (!aCharset.Equals(""))
m_compFields->SetCharacterSet(nsAutoCString(aCharset), nsnull); m_compFields->SetCharacterSet(nsAutoCString(aCharset));
bString += "Re: "; bString += "Re: ";
bString += aString; bString += aString;
m_compFields->SetSubject(nsAutoCString(bString), nsnull);
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(bString, encodedCharset, decodedString))) if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(bString, encodedCharset, decodedString)))
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) m_compFields->SetSubject(decodedString.GetUnicode());
{ else
m_compFields->SetSubject(aCString, NULL); m_compFields->SetSubject(bString.GetUnicode());
PR_Free(aCString);
}
message->GetAuthor(aString); message->GetAuthor(aString);
m_compFields->SetTo(nsAutoCString(aString), NULL); m_compFields->SetTo(nsAutoCString(aString));
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(aString, encodedCharset, decodedString))) if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(aString, encodedCharset, decodedString)))
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString)))
{ {
m_compFields->SetTo(aCString, NULL); m_compFields->SetTo(aCString);
PR_Free(aCString); PR_Free(aCString);
} }
@ -639,11 +568,11 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
if (cString.Length() > 0 && dString.Length() > 0) if (cString.Length() > 0 && dString.Length() > 0)
cString = cString + ", "; cString = cString + ", ";
cString = cString + dString; cString = cString + dString;
m_compFields->SetCc(nsAutoCString(cString), NULL); m_compFields->SetCc(nsAutoCString(cString));
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(cString, encodedCharset, decodedString))) if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(cString, encodedCharset, decodedString)))
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString)))
{ {
m_compFields->SetCc(aCString, NULL); m_compFields->SetCc(aCString);
PR_Free(aCString); PR_Free(aCString);
} }
} }
@ -658,19 +587,16 @@ nsresult nsMsgCompose::CreateMessage(const PRUnichar * originalMsgURI, MSG_Compo
mQuotingToFollow = PR_TRUE; mQuotingToFollow = PR_TRUE;
if (!aCharset.Equals("")) if (!aCharset.Equals(""))
m_compFields->SetCharacterSet(nsAutoCString(aCharset), nsnull); m_compFields->SetCharacterSet(nsAutoCString(aCharset));
bString += "[Fwd: "; bString += "[Fwd: ";
bString += aString; bString += aString;
bString += "]"; bString += "]";
m_compFields->SetSubject(nsAutoCString(bString), nsnull); if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(bString, encodedCharset, decodedString)))
if (NS_SUCCEEDED(rv = nsMsgI18NDecodeMimePartIIStr(bString, encodedCharset, decodedString))) m_compFields->SetSubject(decodedString.GetUnicode());
if (NS_SUCCEEDED(rv = ConvertFromUnicode(msgCompHeaderInternalCharset(), decodedString, &aCString))) else
{ m_compFields->SetSubject(bString.GetUnicode());
m_compFields->SetSubject(aCString, nsnull);
PR_Free(aCString);
}
if (type == MSGCOMP_TYPE_ForwardAsAttachment) if (type == MSGCOMP_TYPE_ForwardAsAttachment)
QuoteOriginalMessage(originalMsgURI, 0); QuoteOriginalMessage(originalMsgURI, 0);
@ -771,9 +697,12 @@ QuotingOutputStreamImpl::Close(void)
ConvertToPlainText(); ConvertToPlainText();
nsIMsgCompFields *compFields; nsIMsgCompFields *compFields;
if (NS_SUCCEEDED(mComposeObj->GetCompFields(&compFields))) if (NS_SUCCEEDED(mComposeObj->GetCompFields(&compFields)))
if (compFields) if (compFields)
compFields->SetBody(nsAutoCString(mMsgBody), NULL); {
((nsMsgCompFields*)compFields)->SetBody(nsAutoCString(mMsgBody));
NS_RELEASE(compFields);
}
mComposeObj->SetQuotingToFollow(PR_FALSE); mComposeObj->SetQuotingToFollow(PR_FALSE);
mComposeObj->LoadBody(); mComposeObj->LoadBody();
@ -968,9 +897,9 @@ void nsMsgCompose::HackToGetBody(PRInt32 what)
//ducarroz: today, we are not converting HTML to plain text if needed! //ducarroz: today, we are not converting HTML to plain text if needed!
} }
// m_compFields->SetBody(msgBody.ToNewCString(), NULL); // m_compFields->SetBody(msgBody.ToNewCString());
// SetBody() strdup()'s cmsgBody. // SetBody() strdup()'s cmsgBody.
m_compFields->SetBody(nsAutoCString(msgBody), NULL); m_compFields->SetBody(nsAutoCString(msgBody));
PR_Free(buffer); PR_Free(buffer);
} }
} }

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

@ -72,7 +72,7 @@ class nsMsgCompose : public nsIMsgCompose
NS_IMETHOD GetDomWindow(nsIDOMWindow * *aDomWindow); NS_IMETHOD GetDomWindow(nsIDOMWindow * *aDomWindow);
/* readonly attribute nsIMsgCompFields compFields; */ /* readonly attribute nsIMsgCompFields compFields; */
NS_IMETHOD GetCompFields(nsIMsgCompFields * *aCompFields); NS_IMETHOD GetCompFields(nsIMsgCompFields * *aCompFields); //GetCompFields will addref, you need to release when your are done with it
/* readonly attribute boolean composeHTML; */ /* readonly attribute boolean composeHTML; */
NS_IMETHOD GetComposeHTML(PRBool *aComposeHTML); NS_IMETHOD GetComposeHTML(PRBool *aComposeHTML);
@ -86,6 +86,7 @@ class nsMsgCompose : public nsIMsgCompose
private: private:
nsresult _SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const PRUnichar *callback);
nsresult CreateMessage(const PRUnichar * originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsISupports* object); nsresult CreateMessage(const PRUnichar * originalMsgURI, MSG_ComposeType type, MSG_ComposeFormat format, nsISupports* object);
void HackToGetBody(PRInt32 what); //Temporary void HackToGetBody(PRInt32 what); //Temporary
void CleanUpRecipients(nsString& recipients); void CleanUpRecipients(nsString& recipients);
@ -96,7 +97,7 @@ private:
nsIDOMWindow* m_window; nsIDOMWindow* m_window;
nsIWebShell* m_webShell; nsIWebShell* m_webShell;
nsIWebShellWindow* m_webShellWin; nsIWebShellWindow* m_webShellWin;
nsCOMPtr<nsIMsgCompFields> m_compFields; nsMsgCompFields* m_compFields;
PRBool m_composeHTML; PRBool m_composeHTML;
QuotingOutputStreamImpl *mOutStream; QuotingOutputStreamImpl *mOutStream;
nsCOMPtr<nsIOutputStream> mBaseStream; nsCOMPtr<nsIOutputStream> mBaseStream;

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

@ -385,7 +385,7 @@ nsMsgComposeAndSend::GatherMimeAttachments()
if (mCompFields->GetMessageId() == nsnull || *mCompFields->GetMessageId() == 0) if (mCompFields->GetMessageId() == nsnull || *mCompFields->GetMessageId() == 0)
{ {
char * msgID = msg_generate_message_id(mUserIdentity); char * msgID = msg_generate_message_id(mUserIdentity);
mCompFields->SetMessageId(msgID, nsnull); mCompFields->SetMessageId(msgID);
PR_FREEIF(msgID); PR_FREEIF(msgID);
} }
@ -1068,7 +1068,7 @@ int nsMsgComposeAndSend::SetMimeHeader(MSG_HEADER_SET header, const char *value)
if (dupHeader) if (dupHeader)
{ {
mCompFields->SetHeader(header, dupHeader, &ret); ret = mCompFields->SetHeader(header, dupHeader);
PR_Free(dupHeader); PR_Free(dupHeader);
} }
return ret; return ret;
@ -1089,22 +1089,21 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
else else
return MK_OUT_OF_MEMORY; return MK_OUT_OF_MEMORY;
char *cset = nsnull; const char *cset = fields->GetCharacterSet();
nsresult lrv = fields->GetCharacterSet(&cset);
// Make sure charset is sane... // Make sure charset is sane...
if (NS_FAILED(lrv) || !cset || !*cset) if (!cset || !*cset)
{ {
mCompFields->SetCharacterSet("us-ascii", nsnull); mCompFields->SetCharacterSet("us-ascii");
} }
else else
{ {
mCompFields->SetCharacterSet(fields->GetCharacterSet(), nsnull); mCompFields->SetCharacterSet(fields->GetCharacterSet());
} }
pStr = fields->GetMessageId(); pStr = fields->GetMessageId();
if (pStr) if (pStr)
{ {
mCompFields->SetMessageId((char *) pStr, nsnull); mCompFields->SetMessageId((char *) pStr);
/* Don't bother checking for out of memory; if it fails, then we'll just /* Don't bother checking for out of memory; if it fails, then we'll just
let the server generate the message-id, and suffer with the let the server generate the message-id, and suffer with the
possibility of duplicate messages.*/ possibility of duplicate messages.*/
@ -1128,9 +1127,9 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
if (fieldsFCC && *fieldsFCC) if (fieldsFCC && *fieldsFCC)
{ {
if (PL_strcasecmp(fieldsFCC, "nocopy://") == 0) if (PL_strcasecmp(fieldsFCC, "nocopy://") == 0)
mCompFields->SetFcc("", nsnull); mCompFields->SetFcc("");
else else
mCompFields->SetFcc(fieldsFCC, nsnull); mCompFields->SetFcc(fieldsFCC);
} }
else else
{ {
@ -1142,16 +1141,16 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
if ( (uri) || (*uri) ) if ( (uri) || (*uri) )
{ {
if (PL_strcasecmp(uri, "nocopy://") == 0) if (PL_strcasecmp(uri, "nocopy://") == 0)
mCompFields->SetFcc("", nsnull); mCompFields->SetFcc("");
else else
mCompFields->SetFcc(uri, nsnull); mCompFields->SetFcc(uri);
} }
else else
mCompFields->SetFcc("", nsnull); mCompFields->SetFcc("");
} }
mCompFields->SetNewspostUrl((char *) fields->GetNewspostUrl(), nsnull); mCompFields->SetNewspostUrl((char *) fields->GetNewspostUrl());
mCompFields->SetDefaultBody((char *) fields->GetDefaultBody(), nsnull); mCompFields->SetDefaultBody((char *) fields->GetDefaultBody());
/* strip whitespace from and duplicate header fields. */ /* strip whitespace from and duplicate header fields. */
SetMimeHeader(MSG_FROM_HEADER_MASK, fields->GetFrom()); SetMimeHeader(MSG_FROM_HEADER_MASK, fields->GetFrom());
@ -1169,17 +1168,16 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
pStr = fields->GetOtherRandomHeaders(); pStr = fields->GetOtherRandomHeaders();
if (pStr) if (pStr)
mCompFields->SetOtherRandomHeaders((char *) pStr, nsnull); mCompFields->SetOtherRandomHeaders((char *) pStr);
pStr = fields->GetPriority(); pStr = fields->GetPriority();
if (pStr) if (pStr)
mCompFields->SetPriority((char *) pStr, nsnull); mCompFields->SetPriority((char *) pStr);
int i, j = (int) MSG_LAST_BOOL_HEADER_MASK; int i, j = (int) MSG_LAST_BOOL_HEADER_MASK;
for (i = 0; i < j; i++) for (i = 0; i < j; i++)
{ {
mCompFields->SetBoolHeader((MSG_BOOL_HEADER_SET) i, mCompFields->SetBoolHeader((MSG_BOOL_HEADER_SET) i, fields->GetBoolHeader((MSG_BOOL_HEADER_SET) i));
fields->GetBoolHeader((MSG_BOOL_HEADER_SET) i), nsnull);
} }
mCompFields->SetForcePlainText(fields->GetForcePlainText()); mCompFields->SetForcePlainText(fields->GetForcePlainText());
@ -2180,11 +2178,9 @@ nsMsgComposeAndSend::SendWebPage(nsIMsgIdentity *aUserIndenti
SetListenerArray(aListenerArray); SetListenerArray(aListenerArray);
/* string GetBody(); */ /* string GetBody(); */
char *msgBody = nsnull;
PRInt32 bodyLen; PRInt32 bodyLen;
const char *msgBody = ((nsMsgCompFields*)fields)->GetBody();
rv = fields->GetBody(&msgBody); if (!msgBody)
if (NS_FAILED(rv) || (!msgBody))
{ {
const char *body = nsnull; const char *body = nsnull;
url->GetSpec(&body); url->GetSpec(&body);

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

@ -453,23 +453,24 @@ nsCOMPtr<nsIMsgSend> pMsgSend = nsnull;
// Since we have already parsed all of the headers, we are simply going to // Since we have already parsed all of the headers, we are simply going to
// set the composition fields and move on. // set the composition fields and move on.
// //
nsMsgCompFields * fields = (nsMsgCompFields *)compFields.get();
if (m_to) if (m_to)
compFields->SetTo(m_to, NULL); fields->SetTo(m_to);
if (m_bcc) if (m_bcc)
compFields->SetBcc(m_bcc, NULL); fields->SetBcc(m_bcc);
if (m_fcc) if (m_fcc)
compFields->SetFcc(m_fcc, NULL); fields->SetFcc(m_fcc);
if (m_newsgroups) if (m_newsgroups)
compFields->SetNewsgroups(m_newsgroups, NULL); fields->SetNewsgroups(m_newsgroups);
// If we have this, we found a HEADER_X_MOZILLA_NEWSHOST which means // If we have this, we found a HEADER_X_MOZILLA_NEWSHOST which means
// that we saved what the user typed into the "Newsgroup" line in this // that we saved what the user typed into the "Newsgroup" line in this
// header // header
if (m_newshost) if (m_newshost)
compFields->SetNewsgroups(m_newshost, NULL); fields->SetNewsgroups(m_newshost);
// Create the listener for the send operation... // Create the listener for the send operation...
mSendListener = new SendOperationListener(); mSendListener = new SendOperationListener();

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

@ -82,7 +82,7 @@
#define HJ91531 #define HJ91531
#define HJ62011 #define HJ62011
#define HJ41792 \ #define HJ41792 \
fields->SetNewspostUrl("news:", NULL); fields->SetNewspostUrl("news:");
#define HJ70669 #define HJ70669
#define HJ77514 #define HJ77514