зеркало из https://github.com/mozilla/gecko-dev.git
allow users or extensions to add headers to display in the message pane header area via a pref 353193, sr=mscott
This commit is contained in:
Родитель
52961ada07
Коммит
f167435223
|
@ -62,6 +62,7 @@ var gViewAllHeaders = false;
|
||||||
var gShowOrganization = false;
|
var gShowOrganization = false;
|
||||||
var gShowLargeAttachmentView = false;
|
var gShowLargeAttachmentView = false;
|
||||||
var gShowUserAgent = false;
|
var gShowUserAgent = false;
|
||||||
|
var gExtraExpandedHeaders;
|
||||||
var gMinNumberOfHeaders = 0;
|
var gMinNumberOfHeaders = 0;
|
||||||
var gDummyHeaderIdIndex = 0;
|
var gDummyHeaderIdIndex = 0;
|
||||||
var gCollapsedHeaderViewMode = false;
|
var gCollapsedHeaderViewMode = false;
|
||||||
|
@ -214,6 +215,12 @@ function initializeHeaderViewTables()
|
||||||
gExpandedHeaderView[headerName] = new createHeaderEntry('expanded', gExpandedHeaderList[index]);
|
gExpandedHeaderView[headerName] = new createHeaderEntry('expanded', gExpandedHeaderList[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var extraHeaders = gExtraExpandedHeaders.split(' ');
|
||||||
|
for (index = 0; index < extraHeaders.length; index++)
|
||||||
|
{
|
||||||
|
var extraHeader = extraHeaders[index];
|
||||||
|
gExpandedHeaderView[extraHeader.toLowerCase()] = new createNewHeaderView(extraHeader, extraHeader + ':');
|
||||||
|
}
|
||||||
if (gShowOrganization)
|
if (gShowOrganization)
|
||||||
{
|
{
|
||||||
var organizationEntry = {name:"organization", outputFunction:updateHeaderValue};
|
var organizationEntry = {name:"organization", outputFunction:updateHeaderValue};
|
||||||
|
@ -240,6 +247,7 @@ function OnLoadMsgHeaderPane()
|
||||||
gShowOrganization = pref.getBoolPref("mailnews.headers.showOrganization");
|
gShowOrganization = pref.getBoolPref("mailnews.headers.showOrganization");
|
||||||
gShowLargeAttachmentView = pref.getBoolPref("mailnews.attachments.display.largeView");
|
gShowLargeAttachmentView = pref.getBoolPref("mailnews.attachments.display.largeView");
|
||||||
gShowCondensedEmailAddresses = pref.getBoolPref("mail.showCondensedAddresses");
|
gShowCondensedEmailAddresses = pref.getBoolPref("mail.showCondensedAddresses");
|
||||||
|
gExtraExpandedHeaders = pref.getCharPref("mailnews.headers.extraExpandedHeaders");
|
||||||
|
|
||||||
// listen to the
|
// listen to the
|
||||||
pref.addObserver("mail.showCondensedAddresses", MsgHdrViewObserver, false);
|
pref.addObserver("mail.showCondensedAddresses", MsgHdrViewObserver, false);
|
||||||
|
@ -684,7 +692,7 @@ function EnsureMinimumNumberOfHeaders (headerTable)
|
||||||
while (numEmptyHeaders)
|
while (numEmptyHeaders)
|
||||||
{
|
{
|
||||||
var dummyHeaderId = "Dummy-Header" + gDummyHeaderIdIndex;
|
var dummyHeaderId = "Dummy-Header" + gDummyHeaderIdIndex;
|
||||||
gExpandedHeaderView[dummyHeaderId] = new createNewHeaderView(dummyHeaderId);
|
gExpandedHeaderView[dummyHeaderId] = new createNewHeaderView(dummyHeaderId, "");
|
||||||
gExpandedHeaderView[dummyHeaderId].valid = true;
|
gExpandedHeaderView[dummyHeaderId].valid = true;
|
||||||
|
|
||||||
gDummyHeaderIdIndex++;
|
gDummyHeaderIdIndex++;
|
||||||
|
@ -738,17 +746,13 @@ function updateHeaderValueInTextNode(headerEntry, headerValue)
|
||||||
headerEntry.textNode.value = headerValue;
|
headerEntry.textNode.value = headerValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNewHeaderView(headerName)
|
function createNewHeaderView(headerName, label)
|
||||||
{
|
{
|
||||||
var idName = 'expanded' + headerName + 'Box';
|
var idName = 'expanded' + headerName + 'Box';
|
||||||
var newHeader = document.createElement("mail-headerfield");
|
var newHeader = document.createElement("mail-headerfield");
|
||||||
|
|
||||||
newHeader.setAttribute('id', idName);
|
newHeader.setAttribute('id', idName);
|
||||||
|
newHeader.setAttribute('label', label);
|
||||||
if (headerName.indexOf("Dummy-Header") == 0) // -1 means not found, 0 means starts at the beginning
|
|
||||||
newHeader.setAttribute('label', "");
|
|
||||||
else
|
|
||||||
newHeader.setAttribute('label', currentHeaderData[headerName].headerName + ':');
|
|
||||||
|
|
||||||
newHeader.collapsed = true;
|
newHeader.collapsed = true;
|
||||||
|
|
||||||
// this new element needs to be inserted into the view...
|
// this new element needs to be inserted into the view...
|
||||||
|
@ -803,7 +807,7 @@ function UpdateMessageHeaders()
|
||||||
{
|
{
|
||||||
// for view all headers, if we don't have a header field for this value....cheat and create one....then
|
// for view all headers, if we don't have a header field for this value....cheat and create one....then
|
||||||
// fill in a headerEntry
|
// fill in a headerEntry
|
||||||
gExpandedHeaderView[headerName] = new createNewHeaderView(headerName);
|
gExpandedHeaderView[headerName] = new createNewHeaderView(headerName, currentHeaderData[headerName].headerName + ':');
|
||||||
headerEntry = gExpandedHeaderView[headerName];
|
headerEntry = gExpandedHeaderView[headerName];
|
||||||
}
|
}
|
||||||
} // if we are in expanded view....
|
} // if we are in expanded view....
|
||||||
|
|
|
@ -72,6 +72,9 @@ pref("mailnews.headers.showUserAgent", false);
|
||||||
// is displayed in the message pane or not...
|
// is displayed in the message pane or not...
|
||||||
pref("mailnews.headers.showOrganization", false);
|
pref("mailnews.headers.showOrganization", false);
|
||||||
|
|
||||||
|
// space-delimited list of extra headers to show in msg header display area.
|
||||||
|
pref("mailnews.headers.extraExpandedHeaders", "");
|
||||||
|
|
||||||
// default sort order settings (when creating new folder views)
|
// default sort order settings (when creating new folder views)
|
||||||
// sort_order is an int value reflecting nsMsgViewSortOrder values
|
// sort_order is an int value reflecting nsMsgViewSortOrder values
|
||||||
// as defined in nsIMsgDBView.idl (ascending = 1, descending = 2)
|
// as defined in nsIMsgDBView.idl (ascending = 1, descending = 2)
|
||||||
|
|
|
@ -161,14 +161,25 @@ nsresult nsMimeHtmlDisplayEmitter::BroadcastHeaders(nsIMsgHeaderSink * aHeaderSi
|
||||||
// CStringArrays which we can pass into the enumerators
|
// CStringArrays which we can pass into the enumerators
|
||||||
nsCStringArray headerNameArray;
|
nsCStringArray headerNameArray;
|
||||||
nsCStringArray headerValueArray;
|
nsCStringArray headerValueArray;
|
||||||
|
nsXPIDLCString extraExpandedHeaders;
|
||||||
|
nsCStringArray extraExpandedHeadersArray;
|
||||||
nsCAutoString convertedDateString;
|
nsCAutoString convertedDateString;
|
||||||
|
|
||||||
PRBool displayOriginalDate = PR_FALSE;
|
PRBool displayOriginalDate = PR_FALSE;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||||
if (pPrefBranch)
|
if (pPrefBranch)
|
||||||
|
{
|
||||||
pPrefBranch->GetBoolPref("mailnews.display.original_date", &displayOriginalDate);
|
pPrefBranch->GetBoolPref("mailnews.display.original_date", &displayOriginalDate);
|
||||||
|
pPrefBranch->GetCharPref("mailnews.headers.extraExpandedHeaders", getter_Copies(extraExpandedHeaders));
|
||||||
|
// todo - should make this upper case
|
||||||
|
if (!extraExpandedHeaders.IsEmpty())
|
||||||
|
{
|
||||||
|
ToLowerCase(extraExpandedHeaders);
|
||||||
|
extraExpandedHeadersArray.ParseString(extraExpandedHeaders, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for (PRInt32 i=0; i<mHeaderArray->Count(); i++)
|
for (PRInt32 i=0; i<mHeaderArray->Count(); i++)
|
||||||
{
|
{
|
||||||
|
@ -182,6 +193,7 @@ nsresult nsMimeHtmlDisplayEmitter::BroadcastHeaders(nsIMsgHeaderSink * aHeaderSi
|
||||||
// don't waste time sending those out to the UI since the UI is going to ignore them anyway.
|
// don't waste time sending those out to the UI since the UI is going to ignore them anyway.
|
||||||
if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer))
|
if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer))
|
||||||
{
|
{
|
||||||
|
nsDependentCString headerStr(headerInfo->name);
|
||||||
if (nsCRT::strcasecmp("to", headerInfo->name) && nsCRT::strcasecmp("from", headerInfo->name) &&
|
if (nsCRT::strcasecmp("to", headerInfo->name) && nsCRT::strcasecmp("from", headerInfo->name) &&
|
||||||
nsCRT::strcasecmp("cc", headerInfo->name) && nsCRT::strcasecmp("newsgroups", headerInfo->name) &&
|
nsCRT::strcasecmp("cc", headerInfo->name) && nsCRT::strcasecmp("newsgroups", headerInfo->name) &&
|
||||||
nsCRT::strcasecmp("bcc", headerInfo->name) && nsCRT::strcasecmp("followup-to", headerInfo->name) &&
|
nsCRT::strcasecmp("bcc", headerInfo->name) && nsCRT::strcasecmp("followup-to", headerInfo->name) &&
|
||||||
|
@ -190,7 +202,10 @@ nsresult nsMimeHtmlDisplayEmitter::BroadcastHeaders(nsIMsgHeaderSink * aHeaderSi
|
||||||
nsCRT::strcasecmp("content-base", headerInfo->name) && nsCRT::strcasecmp("sender", headerInfo->name) &&
|
nsCRT::strcasecmp("content-base", headerInfo->name) && nsCRT::strcasecmp("sender", headerInfo->name) &&
|
||||||
nsCRT::strcasecmp("date", headerInfo->name) && nsCRT::strcasecmp("x-mailer", headerInfo->name) &&
|
nsCRT::strcasecmp("date", headerInfo->name) && nsCRT::strcasecmp("x-mailer", headerInfo->name) &&
|
||||||
nsCRT::strcasecmp("content-type", headerInfo->name) && nsCRT::strcasecmp("message-id", headerInfo->name) &&
|
nsCRT::strcasecmp("content-type", headerInfo->name) && nsCRT::strcasecmp("message-id", headerInfo->name) &&
|
||||||
nsCRT::strcasecmp("x-newsreader", headerInfo->name) && nsCRT::strcasecmp("x-mimeole", headerInfo->name))
|
nsCRT::strcasecmp("x-newsreader", headerInfo->name) && nsCRT::strcasecmp("x-mimeole", headerInfo->name) &&
|
||||||
|
// make headerStr lower case because IndexOf is case-sensitive
|
||||||
|
(!extraExpandedHeadersArray.Count() || (ToLowerCase(headerStr),
|
||||||
|
extraExpandedHeadersArray.IndexOf(headerStr) == kNotFound)))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче