зеркало из https://github.com/mozilla/gecko-dev.git
Bug 61520 Add additional headers to every message p=telio+bugzilla@telio.net r=dmose sr=mscott a=rjesup a=asa
This commit is contained in:
Родитель
438504e36f
Коммит
9081af54eb
|
@ -2955,7 +2955,9 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
|
|||
pStr = fields->GetOtherRandomHeaders();
|
||||
if (pStr)
|
||||
mCompFields->SetOtherRandomHeaders((char *) pStr);
|
||||
|
||||
|
||||
AddDefaultCustomHeaders();
|
||||
|
||||
pStr = fields->GetPriority();
|
||||
if (pStr)
|
||||
mCompFields->SetPriority((char *) pStr);
|
||||
|
@ -2994,6 +2996,65 @@ nsMsgComposeAndSend::InitCompositionFields(nsMsgCompFields *fields)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Add default headers to outgoing messages see Bug #61520
|
||||
// mail.identity.<id#>.headers pref is a comma separated value of pref names
|
||||
// containging headers to add headers are stored in
|
||||
// mail.identity.<id#>.header.<header name> grab all the headers, mime encode
|
||||
// them and add them to the other custom headers.
|
||||
nsresult
|
||||
nsMsgComposeAndSend::AddDefaultCustomHeaders() {
|
||||
nsXPIDLCString headersList;
|
||||
// get names of prefs containing headers to add
|
||||
nsresult rv = mUserIdentity->GetCharAttribute("headers",
|
||||
getter_Copies(headersList));
|
||||
if (NS_SUCCEEDED(rv) && !headersList.IsEmpty()) {
|
||||
PRInt32 start = 0;
|
||||
PRInt32 end = 0;
|
||||
PRInt32 len = 0;
|
||||
// preserve any custom headers that have been added through the UI
|
||||
nsCAutoString newHeaderVal(mCompFields->GetOtherRandomHeaders());
|
||||
|
||||
while (end != -1) {
|
||||
end = headersList.FindChar(',', start);
|
||||
if (end == -1) {
|
||||
len = headersList.Length() - start;
|
||||
} else {
|
||||
len = end - start;
|
||||
}
|
||||
// grab the name of the current header pref
|
||||
nsCAutoString headerName(NS_LITERAL_CSTRING("header.") +
|
||||
Substring(headersList, start, len));
|
||||
start = end + 1;
|
||||
|
||||
nsXPIDLCString headerVal;
|
||||
rv = mUserIdentity->GetCharAttribute(headerName.get(),
|
||||
getter_Copies(headerVal));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 colonIdx = headerVal.FindChar(':') + 1;
|
||||
if (colonIdx != 0) { // check that the header is *most likely* valid.
|
||||
char * convHeader =
|
||||
nsMsgI18NEncodeMimePartIIStr(headerVal.get() + colonIdx,
|
||||
PR_FALSE,
|
||||
mCompFields->GetCharacterSet(),
|
||||
colonIdx,
|
||||
PR_TRUE);
|
||||
if (convHeader) {
|
||||
newHeaderVal.Append(Substring(headerVal, 0, colonIdx));
|
||||
newHeaderVal.Append(convHeader);
|
||||
// we must terminate the header with CRLF here
|
||||
// as nsMsgCompUtils.cpp just calls PUSH_STRING
|
||||
newHeaderVal.Append("\r\n");
|
||||
PR_Free(convHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mCompFields->SetOtherRandomHeaders(newHeaderVal.get());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsMsgComposeAndSend::SnarfAndCopyBody(const char *attachment1_body,
|
||||
PRUint32 attachment1_body_length,
|
||||
|
|
|
@ -409,6 +409,9 @@ private:
|
|||
// generates a message id for our message, if necessary
|
||||
void GenerateMessageId( );
|
||||
|
||||
// add default custom headers to the message
|
||||
nsresult AddDefaultCustomHeaders();
|
||||
|
||||
nsCOMPtr<nsIMsgSendReport> mSendReport;
|
||||
nsCString mSmtpPassword; // store the smtp Password use during a send
|
||||
};
|
||||
|
|
|
@ -142,9 +142,9 @@ pref("mail.addr_book.displayName.lastnamefirst", "chrome://messenger/locale/mess
|
|||
pref("mail.addr_book.show_phonetic_fields", "chrome://messenger/locale/messenger.properties");
|
||||
pref("mail.attach_vcard", false);
|
||||
pref("mail.html_compose", true);
|
||||
// you can specify one, option header
|
||||
// you can specify multiple, option headers
|
||||
// this will show up in the address picker in the compose window
|
||||
// examples: "X-Face" or "Approved"
|
||||
// examples: "X-Face" or "Approved,X-No-Archive"
|
||||
pref("mail.compose.other.header", "");
|
||||
pref("mail.fcc_folder", "");
|
||||
pref("mail.encrypt_outgoing_mail", false);
|
||||
|
@ -311,6 +311,11 @@ pref("mail.identity.default.draft_folder","mailbox://nobody@Local%20Folders/Draf
|
|||
pref("mail.identity.default.stationery_folder","mailbox://nobody@Local%20Folders/Templates");
|
||||
pref("mail.identity.default.directoryServer","");
|
||||
pref("mail.identity.default.overrideGlobal_Pref", false);
|
||||
// Headers to always add to outgoing mail
|
||||
// examples: "header1,header2"
|
||||
// pref("mail.identity.id1.headers", "header1");
|
||||
// user_pref("mail.identity.id1.header.header1", "X-Mozilla-Rocks: True")
|
||||
pref("mail.identity.default.headers", "");
|
||||
|
||||
// by default, only collect addresses the user sends to (outgoing)
|
||||
// incoming is all spam anyways
|
||||
|
|
|
@ -142,9 +142,9 @@ pref("mail.addr_book.displayName.lastnamefirst", "chrome://messenger/locale/mess
|
|||
pref("mail.addr_book.show_phonetic_fields", "chrome://messenger/locale/messenger.properties");
|
||||
pref("mail.attach_vcard", false);
|
||||
pref("mail.html_compose", true);
|
||||
// you can specify one, option header
|
||||
// you can specify multiple, option headers
|
||||
// this will show up in the address picker in the compose window
|
||||
// examples: "X-Face" or "Approved"
|
||||
// examples: "X-Face" or "Approved,X-No-Archive"
|
||||
pref("mail.compose.other.header", "");
|
||||
pref("mail.fcc_folder", "");
|
||||
pref("mail.encrypt_outgoing_mail", false);
|
||||
|
@ -311,6 +311,11 @@ pref("mail.identity.default.draft_folder","mailbox://nobody@Local%20Folders/Draf
|
|||
pref("mail.identity.default.stationery_folder","mailbox://nobody@Local%20Folders/Templates");
|
||||
pref("mail.identity.default.directoryServer","");
|
||||
pref("mail.identity.default.overrideGlobal_Pref", false);
|
||||
// Headers to always add to outgoing mail
|
||||
// examples: "header1,header2"
|
||||
// pref("mail.identity.id1.headers", "header1");
|
||||
// user_pref("mail.identity.id1.header.header1", "X-Mozilla-Rocks: True")
|
||||
pref("mail.identity.default.headers", "");
|
||||
|
||||
// by default, only collect addresses the user sends to (outgoing)
|
||||
// incoming is all spam anyways
|
||||
|
|
Загрузка…
Ссылка в новой задаче