зеркало из https://github.com/mozilla/gecko-dev.git
Bug 140532 Attached messages display incorrect headers r=ducarroz sr=bienvenu
This commit is contained in:
Родитель
9051645d49
Коммит
27d9b80c10
|
@ -70,7 +70,6 @@ static PRLogModuleInfo * gMimeEmitterLogModule = nsnull;
|
|||
|
||||
#define MIME_HEADER_URL "chrome://messenger/locale/mimeheader.properties"
|
||||
#define MIME_URL "chrome://messenger/locale/mime.properties"
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsMimeBaseEmitter)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsMimeBaseEmitter)
|
||||
|
@ -120,20 +119,15 @@ nsMimeBaseEmitter::nsMimeBaseEmitter()
|
|||
// mBody = "";
|
||||
|
||||
// This is needed for conversion of I18N Strings...
|
||||
nsComponentManager::CreateInstance(NS_MIME_CONVERTER_CONTRACTID, nsnull,
|
||||
NS_GET_IID(nsIMimeConverter),
|
||||
getter_AddRefs(mUnicodeConverter));
|
||||
|
||||
// Do prefs last since we can live without this if it fails...
|
||||
nsresult rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**)&(mPrefs));
|
||||
if (! (mPrefs && NS_SUCCEEDED(rv)))
|
||||
return;
|
||||
|
||||
if ((mPrefs && NS_SUCCEEDED(rv)))
|
||||
mPrefs->GetIntPref("mail.show_headers", &mHeaderDisplayType);
|
||||
mUnicodeConverter = do_GetService(NS_MIME_CONVERTER_CONTRACTID);
|
||||
|
||||
if (!gMimeEmitterLogModule)
|
||||
gMimeEmitterLogModule = PR_NewLogModule("MIME");
|
||||
|
||||
// Do prefs last since we can live without this if it fails...
|
||||
mPrefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (mPrefs)
|
||||
mPrefs->GetIntPref("mail.show_headers", &mHeaderDisplayType);
|
||||
}
|
||||
|
||||
nsMimeBaseEmitter::~nsMimeBaseEmitter(void)
|
||||
|
@ -147,10 +141,6 @@ nsMimeBaseEmitter::~nsMimeBaseEmitter(void)
|
|||
mBufferMgr = nsnull;
|
||||
}
|
||||
|
||||
// Release the prefs service...
|
||||
if (mPrefs)
|
||||
nsServiceManager::ReleaseService(kPrefCID, mPrefs);
|
||||
|
||||
// Clean up the attachment array structures...
|
||||
if (mAttachArray)
|
||||
{
|
||||
|
@ -541,19 +531,19 @@ nsMimeBaseEmitter::WriteHelper(const char *buf, PRUint32 count, PRUint32 *countW
|
|||
//
|
||||
// Find a cached header! Note: Do NOT free this value!
|
||||
//
|
||||
char *
|
||||
nsMimeBaseEmitter::GetHeaderValue(const char *aHeaderName,
|
||||
nsVoidArray *aArray)
|
||||
const char *
|
||||
nsMimeBaseEmitter::GetHeaderValue(const char *aHeaderName)
|
||||
{
|
||||
PRInt32 i;
|
||||
char *retVal = nsnull;
|
||||
nsVoidArray *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
|
||||
|
||||
if (!aArray)
|
||||
if (!array)
|
||||
return nsnull;
|
||||
|
||||
for (i=0; i<aArray->Count(); i++)
|
||||
for (i = 0; i < array->Count(); i++)
|
||||
{
|
||||
headerInfoType *headerInfo = (headerInfoType *)aArray->ElementAt(i);
|
||||
headerInfoType *headerInfo = (headerInfoType *)array->ElementAt(i);
|
||||
if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) )
|
||||
continue;
|
||||
|
||||
|
@ -816,7 +806,8 @@ nsMimeBaseEmitter::WriteHTMLHeaders()
|
|||
|
||||
// Do the rest of the headers, but these will only be written if
|
||||
// the user has the "show all headers" pref set
|
||||
DumpRestOfHeaders();
|
||||
if (mHeaderDisplayType == nsMimeHeaderDisplayTypes::AllHeaders)
|
||||
DumpRestOfHeaders();
|
||||
|
||||
WriteHeaderFieldHTMLPostfix();
|
||||
|
||||
|
@ -852,10 +843,10 @@ nsMimeBaseEmitter::DumpSubjectFromDate()
|
|||
nsresult
|
||||
nsMimeBaseEmitter::DumpToCC()
|
||||
{
|
||||
char * toField = GetHeaderValue(HEADER_TO, mHeaderArray);
|
||||
char * ccField = GetHeaderValue(HEADER_CC, mHeaderArray);
|
||||
char * bccField = GetHeaderValue(HEADER_BCC, mHeaderArray);
|
||||
char * newsgroupField = GetHeaderValue(HEADER_NEWSGROUPS, mHeaderArray);
|
||||
const char * toField = GetHeaderValue(HEADER_TO);
|
||||
const char * ccField = GetHeaderValue(HEADER_CC);
|
||||
const char * bccField = GetHeaderValue(HEADER_BCC);
|
||||
const char * newsgroupField = GetHeaderValue(HEADER_NEWSGROUPS);
|
||||
|
||||
// only dump these fields if we have at least one of them! When displaying news
|
||||
// messages that didn't have a To or Cc field, we'd always get an empty box
|
||||
|
@ -864,10 +855,14 @@ nsMimeBaseEmitter::DumpToCC()
|
|||
{
|
||||
mHTMLHeaders.Append("<table border=0 cellspacing=0 cellpadding=0 width=\"100%\" class=\"header-part2\">");
|
||||
|
||||
OutputGenericHeader(HEADER_TO);
|
||||
OutputGenericHeader(HEADER_CC);
|
||||
OutputGenericHeader(HEADER_BCC);
|
||||
OutputGenericHeader(HEADER_NEWSGROUPS);
|
||||
if (toField)
|
||||
WriteHeaderFieldHTML(HEADER_TO, toField);
|
||||
if (ccField)
|
||||
WriteHeaderFieldHTML(HEADER_CC, ccField);
|
||||
if (bccField)
|
||||
WriteHeaderFieldHTML(HEADER_BCC, bccField);
|
||||
if (newsgroupField)
|
||||
WriteHeaderFieldHTML(HEADER_NEWSGROUPS, newsgroupField);
|
||||
|
||||
mHTMLHeaders.Append("</table>");
|
||||
}
|
||||
|
@ -879,15 +874,13 @@ nsresult
|
|||
nsMimeBaseEmitter::DumpRestOfHeaders()
|
||||
{
|
||||
PRInt32 i;
|
||||
|
||||
if (mHeaderDisplayType != nsMimeHeaderDisplayTypes::AllHeaders)
|
||||
return NS_OK;
|
||||
nsVoidArray *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
|
||||
|
||||
mHTMLHeaders.Append("<table border=0 cellspacing=0 cellpadding=0 width=\"100%\" class=\"header-part3\">");
|
||||
|
||||
for (i=0; i<mHeaderArray->Count(); i++)
|
||||
for (i = 0; i < array->Count(); i++)
|
||||
{
|
||||
headerInfoType *headerInfo = (headerInfoType *)mHeaderArray->ElementAt(i);
|
||||
headerInfoType *headerInfo = (headerInfoType *)array->ElementAt(i);
|
||||
if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) ||
|
||||
(!headerInfo->value) || (!(*headerInfo->value)))
|
||||
continue;
|
||||
|
@ -909,21 +902,12 @@ nsMimeBaseEmitter::DumpRestOfHeaders()
|
|||
nsresult
|
||||
nsMimeBaseEmitter::OutputGenericHeader(const char *aHeaderVal)
|
||||
{
|
||||
char *val = nsnull;
|
||||
nsresult rv;
|
||||
|
||||
if (mDocHeader)
|
||||
val = GetHeaderValue(aHeaderVal, mHeaderArray);
|
||||
else
|
||||
val = GetHeaderValue(aHeaderVal, mEmbeddedHeaderArray);
|
||||
const char *val = GetHeaderValue(aHeaderVal);
|
||||
|
||||
if (val)
|
||||
{
|
||||
rv = WriteHeaderFieldHTML(aHeaderVal, val);
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return WriteHeaderFieldHTML(aHeaderVal, val);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
char *LocalizeHeaderName(const char *aHeaderName, const char *aDefaultName);
|
||||
|
||||
// For header processing...
|
||||
char *GetHeaderValue(const char *aHeaderName, nsVoidArray *aArray);
|
||||
const char *GetHeaderValue(const char *aHeaderName);
|
||||
|
||||
// To write out a stored header array as HTML
|
||||
virtual nsresult WriteHeaderFieldHTMLPrefix();
|
||||
|
@ -147,7 +147,7 @@ protected:
|
|||
PRUint32 mTotalRead;
|
||||
|
||||
// Output control and info...
|
||||
nsIPref *mPrefs; // Connnection to prefs service manager
|
||||
nsCOMPtr<nsIPref> mPrefs; // Connnection to prefs service manager
|
||||
PRBool mDocHeader; // For header determination...
|
||||
nsIURI *mURL; // the url for the data being processed...
|
||||
PRInt32 mHeaderDisplayType; // The setting for header output...
|
||||
|
|
|
@ -320,7 +320,7 @@ nsMimeHtmlDisplayEmitter::EndHeader()
|
|||
UtilityWriteCRLF("<html>");
|
||||
UtilityWriteCRLF("<head>");
|
||||
|
||||
char * val = GetHeaderValue(HEADER_SUBJECT, mHeaderArray); // do not free this value
|
||||
const char * val = GetHeaderValue(HEADER_SUBJECT); // do not free this value
|
||||
if (val)
|
||||
{
|
||||
char * subject = nsEscapeHTML(val);
|
||||
|
|
Загрузка…
Ссылка в новой задаче