зеркало из https://github.com/mozilla/pjs.git
Improve X-Priority support b=146075 p=sgautherie.bz@free.fr r=me sr=bienvenu
This commit is contained in:
Родитель
ea4e625f11
Коммит
04bf002b25
|
@ -746,11 +746,10 @@ nsresult nsMsgFilter::SaveRule(nsIOFileStream *aStream)
|
||||||
{
|
{
|
||||||
nsMsgPriorityValue priorityValue;
|
nsMsgPriorityValue priorityValue;
|
||||||
action->GetPriority(&priorityValue);
|
action->GetPriority(&priorityValue);
|
||||||
nsAutoString priority;
|
nsCAutoString priority;
|
||||||
NS_MsgGetUntranslatedPriorityName (priorityValue, &priority);
|
NS_MsgGetUntranslatedPriorityName(priorityValue, priority);
|
||||||
nsCAutoString cStr;
|
err = filterList->WriteStrAttr(
|
||||||
cStr.AssignWithConversion(priority);
|
nsIMsgFilterList::attribActionValue, priority.get(), aStream);
|
||||||
err = filterList->WriteStrAttr(nsIMsgFilterList::attribActionValue, cStr.get(), aStream);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case nsMsgFilterAction::Label:
|
case nsMsgFilterAction::Label:
|
||||||
|
|
|
@ -69,7 +69,10 @@ nsMsgFilterList::nsMsgFilterList() :
|
||||||
m_fileVersion(0)
|
m_fileVersion(0)
|
||||||
{
|
{
|
||||||
// I don't know how we're going to report this error if we failed to create the isupports array...
|
// I don't know how we're going to report this error if we failed to create the isupports array...
|
||||||
nsresult rv = NS_NewISupportsArray(getter_AddRefs(m_filters));
|
#ifdef DEBUG
|
||||||
|
nsresult rv =
|
||||||
|
#endif
|
||||||
|
NS_NewISupportsArray(getter_AddRefs(m_filters));
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Fixme bug 180312: NS_NewISupportsArray() failed");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Fixme bug 180312: NS_NewISupportsArray() failed");
|
||||||
|
|
||||||
m_loggingEnabled = PR_FALSE;
|
m_loggingEnabled = PR_FALSE;
|
||||||
|
@ -159,10 +162,14 @@ NS_IMETHODIMP nsMsgFilterList::ClearLog()
|
||||||
// disable logging while clearing
|
// disable logging while clearing
|
||||||
m_loggingEnabled = PR_FALSE;
|
m_loggingEnabled = PR_FALSE;
|
||||||
|
|
||||||
nsresult rv = TruncateLog();
|
#ifdef DEBUG
|
||||||
|
nsresult rv =
|
||||||
|
#endif
|
||||||
|
TruncateLog();
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to truncate filter log");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to truncate filter log");
|
||||||
|
|
||||||
m_loggingEnabled = loggingEnabled;
|
m_loggingEnabled = loggingEnabled;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +685,7 @@ nsresult nsMsgFilterList::LoadTextFilters(nsIOFileStream *aStream)
|
||||||
else if (type == nsMsgFilterAction::ChangePriority)
|
else if (type == nsMsgFilterAction::ChangePriority)
|
||||||
{
|
{
|
||||||
nsMsgPriorityValue outPriority;
|
nsMsgPriorityValue outPriority;
|
||||||
nsresult res = NS_MsgGetPriorityFromString(value.get(), &outPriority);
|
nsresult res = NS_MsgGetPriorityFromString(value.get(), outPriority);
|
||||||
if (NS_SUCCEEDED(res))
|
if (NS_SUCCEEDED(res))
|
||||||
currentFilterAction->SetPriority(outPriority);
|
currentFilterAction->SetPriority(outPriority);
|
||||||
else
|
else
|
||||||
|
|
|
@ -469,10 +469,9 @@ nsresult nsMsgSearchTerm::OutputValue(nsCString &outputStr)
|
||||||
}
|
}
|
||||||
case nsMsgSearchAttrib::Priority:
|
case nsMsgSearchAttrib::Priority:
|
||||||
{
|
{
|
||||||
nsAutoString priority;
|
nsCAutoString priority;
|
||||||
NS_MsgGetUntranslatedPriorityName( m_value.u.priority,
|
NS_MsgGetUntranslatedPriorityName(m_value.u.priority, priority);
|
||||||
&priority);
|
outputStr += priority;
|
||||||
outputStr.AppendWithConversion(priority);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsMsgSearchAttrib::HasAttachmentStatus:
|
case nsMsgSearchAttrib::HasAttachmentStatus:
|
||||||
|
@ -564,7 +563,7 @@ nsresult nsMsgSearchTerm::ParseValue(char *inStream)
|
||||||
m_value.u.msgStatus = NS_MsgGetStatusValueFromName(inStream);
|
m_value.u.msgStatus = NS_MsgGetStatusValueFromName(inStream);
|
||||||
break;
|
break;
|
||||||
case nsMsgSearchAttrib::Priority:
|
case nsMsgSearchAttrib::Priority:
|
||||||
NS_MsgGetPriorityFromString(inStream, &m_value.u.priority);
|
NS_MsgGetPriorityFromString(inStream, m_value.u.priority);
|
||||||
break;
|
break;
|
||||||
case nsMsgSearchAttrib::AgeInDays:
|
case nsMsgSearchAttrib::AgeInDays:
|
||||||
m_value.u.age = atoi(inStream);
|
m_value.u.age = atoi(inStream);
|
||||||
|
|
|
@ -172,76 +172,119 @@ nsresult CreateStartupUrl(const char *uri, nsIURI** aUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Where should this live? It's a utility used to convert a string priority, e.g., "High, Low, Normal" to an enum.
|
// Where should this live? It's a utility used to convert a string priority,
|
||||||
// Perhaps we should have an interface that groups together all these utilities...
|
// e.g., "High, Low, Normal" to an enum.
|
||||||
nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriorityValue *outPriority)
|
// Perhaps we should have an interface that groups together all these
|
||||||
|
// utilities...
|
||||||
|
nsresult NS_MsgGetPriorityFromString(
|
||||||
|
const char * const priority,
|
||||||
|
nsMsgPriorityValue & outPriority)
|
||||||
{
|
{
|
||||||
if (!outPriority)
|
if (!priority)
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsMsgPriorityValue retPriority = nsMsgPriority::normal;
|
// Note: Checking the values separately and _before_ the names,
|
||||||
|
// hoping for a much faster match;
|
||||||
if (PL_strcasestr(priority, "Normal") != NULL)
|
// Only _drawback_, as "priority" handling is not truly specified:
|
||||||
retPriority = nsMsgPriority::normal;
|
// some softwares may have the number meanings reversed (1=Lowest) !?
|
||||||
else if (PL_strcasestr(priority, "Lowest") != NULL)
|
if (PL_strchr(priority, '1'))
|
||||||
retPriority = nsMsgPriority::lowest;
|
outPriority = nsMsgPriority::highest;
|
||||||
else if (PL_strcasestr(priority, "Highest") != NULL)
|
else if (PL_strchr(priority, '2'))
|
||||||
retPriority = nsMsgPriority::highest;
|
outPriority = nsMsgPriority::high;
|
||||||
else if (PL_strcasestr(priority, "High") != NULL ||
|
else if (PL_strchr(priority, '3'))
|
||||||
PL_strcasestr(priority, "Urgent") != NULL)
|
outPriority = nsMsgPriority::normal;
|
||||||
retPriority = nsMsgPriority::high;
|
else if (PL_strchr(priority, '4'))
|
||||||
else if (PL_strcasestr(priority, "Low") != NULL ||
|
outPriority = nsMsgPriority::low;
|
||||||
PL_strcasestr(priority, "Non-urgent") != NULL)
|
else if (PL_strchr(priority, '5'))
|
||||||
retPriority = nsMsgPriority::low;
|
outPriority = nsMsgPriority::lowest;
|
||||||
else if (PL_strcasestr(priority, "1") != NULL)
|
else if (PL_strcasestr(priority, "Highest"))
|
||||||
retPriority = nsMsgPriority::highest;
|
outPriority = nsMsgPriority::highest;
|
||||||
else if (PL_strcasestr(priority, "2") != NULL)
|
// Important: "High" must be tested after "Highest" !
|
||||||
retPriority = nsMsgPriority::high;
|
else if (PL_strcasestr(priority, "High") ||
|
||||||
else if (PL_strcasestr(priority, "3") != NULL)
|
PL_strcasestr(priority, "Urgent"))
|
||||||
retPriority = nsMsgPriority::normal;
|
outPriority = nsMsgPriority::high;
|
||||||
else if (PL_strcasestr(priority, "4") != NULL)
|
else if (PL_strcasestr(priority, "Normal"))
|
||||||
retPriority = nsMsgPriority::low;
|
outPriority = nsMsgPriority::normal;
|
||||||
else if (PL_strcasestr(priority, "5") != NULL)
|
else if (PL_strcasestr(priority, "Lowest"))
|
||||||
retPriority = nsMsgPriority::lowest;
|
outPriority = nsMsgPriority::lowest;
|
||||||
|
// Important: "Low" must be tested after "Lowest" !
|
||||||
|
else if (PL_strcasestr(priority, "Low") ||
|
||||||
|
PL_strcasestr(priority, "Non-urgent"))
|
||||||
|
outPriority = nsMsgPriority::low;
|
||||||
else
|
else
|
||||||
retPriority = nsMsgPriority::normal;
|
// "Default" case gets default value.
|
||||||
*outPriority = retPriority;
|
outPriority = nsMsgPriority::Default;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
//return nsMsgNoPriority;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult NS_MsgGetPriorityValueString(
|
||||||
nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriorityValue p, nsString *outName)
|
const nsMsgPriorityValue p,
|
||||||
|
nsACString & outValueString)
|
||||||
{
|
{
|
||||||
if (!outName)
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
switch (p)
|
switch (p)
|
||||||
{
|
{
|
||||||
case nsMsgPriority::notSet:
|
case nsMsgPriority::highest:
|
||||||
case nsMsgPriority::none:
|
outValueString.AssignLiteral("1");
|
||||||
outName->AssignLiteral("None");
|
|
||||||
break;
|
|
||||||
case nsMsgPriority::lowest:
|
|
||||||
outName->AssignLiteral("Lowest");
|
|
||||||
break;
|
|
||||||
case nsMsgPriority::low:
|
|
||||||
outName->AssignLiteral("Low");
|
|
||||||
break;
|
|
||||||
case nsMsgPriority::normal:
|
|
||||||
outName->AssignLiteral("Normal");
|
|
||||||
break;
|
break;
|
||||||
case nsMsgPriority::high:
|
case nsMsgPriority::high:
|
||||||
outName->AssignLiteral("High");
|
outValueString.AssignLiteral("2");
|
||||||
break;
|
break;
|
||||||
case nsMsgPriority::highest:
|
case nsMsgPriority::normal:
|
||||||
outName->AssignLiteral("Highest");
|
outValueString.AssignLiteral("3");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::low:
|
||||||
|
outValueString.AssignLiteral("4");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::lowest:
|
||||||
|
outValueString.AssignLiteral("5");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::none:
|
||||||
|
case nsMsgPriority::notSet:
|
||||||
|
// Note: '0' is a "fake" value; we expect to never be in this case.
|
||||||
|
outValueString.AssignLiteral("0");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NS_ASSERTION(PR_FALSE, "invalid priority value");
|
NS_ASSERTION(PR_FALSE, "invalid priority value");
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult NS_MsgGetUntranslatedPriorityName(
|
||||||
|
const nsMsgPriorityValue p,
|
||||||
|
nsACString & outName)
|
||||||
|
{
|
||||||
|
switch (p)
|
||||||
|
{
|
||||||
|
case nsMsgPriority::highest:
|
||||||
|
outName.AssignLiteral("Highest");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::high:
|
||||||
|
outName.AssignLiteral("High");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::normal:
|
||||||
|
outName.AssignLiteral("Normal");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::low:
|
||||||
|
outName.AssignLiteral("Low");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::lowest:
|
||||||
|
outName.AssignLiteral("Lowest");
|
||||||
|
break;
|
||||||
|
case nsMsgPriority::none:
|
||||||
|
case nsMsgPriority::notSet:
|
||||||
|
// Note: 'None' is a "fake" value; we expect to never be in this case.
|
||||||
|
outName.AssignLiteral("None");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NS_ASSERTION(PR_FALSE, "invalid priority value");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* this used to be XP_StringHash2 from xp_hash.c */
|
/* this used to be XP_StringHash2 from xp_hash.c */
|
||||||
/* phong's linear congruential hash */
|
/* phong's linear congruential hash */
|
||||||
static PRUint32 StringHash(const char *ubuf, PRInt32 len = -1)
|
static PRUint32 StringHash(const char *ubuf, PRInt32 len = -1)
|
||||||
|
|
|
@ -64,9 +64,17 @@ NS_MSG_BASE nsresult GetMsgDBHdrFromURI(const char *uri, nsIMsgDBHdr **msgHdr);
|
||||||
|
|
||||||
NS_MSG_BASE nsresult CreateStartupUrl(const char *uri, nsIURI** aUrl);
|
NS_MSG_BASE nsresult CreateStartupUrl(const char *uri, nsIURI** aUrl);
|
||||||
|
|
||||||
NS_MSG_BASE nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriorityValue *outPriority);
|
NS_MSG_BASE nsresult NS_MsgGetPriorityFromString(
|
||||||
|
const char * const priority,
|
||||||
|
nsMsgPriorityValue & outPriority);
|
||||||
|
|
||||||
NS_MSG_BASE nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriorityValue p, nsString *outName);
|
NS_MSG_BASE nsresult NS_MsgGetPriorityValueString(
|
||||||
|
const nsMsgPriorityValue p,
|
||||||
|
nsACString & outValueString);
|
||||||
|
|
||||||
|
NS_MSG_BASE nsresult NS_MsgGetUntranslatedPriorityName(
|
||||||
|
const nsMsgPriorityValue p,
|
||||||
|
nsACString & outName);
|
||||||
|
|
||||||
NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsAutoString &name);
|
NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsAutoString &name);
|
||||||
NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsCAutoString &name);
|
NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsCAutoString &name);
|
||||||
|
|
|
@ -392,16 +392,13 @@ mime_generate_headers (nsMsgCompFields *fields,
|
||||||
|
|
||||||
// nsIMsgMdnGenerator::eDntType = MDN Disposition-Notification-To: ;
|
// nsIMsgMdnGenerator::eDntType = MDN Disposition-Notification-To: ;
|
||||||
// nsIMsgMdnGenerator::eRrtType = Return-Receipt-To: ;
|
// nsIMsgMdnGenerator::eRrtType = Return-Receipt-To: ;
|
||||||
// nsIMsgMdnGenerator::eDntRrtType = both MDN DNT & RRT headers
|
// nsIMsgMdnGenerator::eDntRrtType = both MDN DNT and RRT headers .
|
||||||
if (receipt_header_type == nsIMsgMdnGenerator::eRrtType) {
|
if (receipt_header_type != nsIMsgMdnGenerator::eRrtType)
|
||||||
RRT_HEADER:
|
ENCODE_AND_PUSH(
|
||||||
ENCODE_AND_PUSH("Return-Receipt-To: ", PR_TRUE, pFrom, charset, usemime);
|
"Disposition-Notification-To: ", PR_TRUE, pFrom, charset, usemime);
|
||||||
}
|
if (receipt_header_type != nsIMsgMdnGenerator::eDntType)
|
||||||
else {
|
ENCODE_AND_PUSH(
|
||||||
ENCODE_AND_PUSH("Disposition-Notification-To: ", PR_TRUE, pFrom, charset, usemime);
|
"Return-Receipt-To: ", PR_TRUE, pFrom, charset, usemime);
|
||||||
if (receipt_header_type == nsIMsgMdnGenerator::eDntRrtType)
|
|
||||||
goto RRT_HEADER;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SUPPORT_X_TEMPLATE_NAME
|
#ifdef SUPPORT_X_TEMPLATE_NAME
|
||||||
|
@ -696,24 +693,28 @@ RRT_HEADER:
|
||||||
ENCODE_AND_PUSH("Subject: ", PR_FALSE, pSubject, charset, usemime);
|
ENCODE_AND_PUSH("Subject: ", PR_FALSE, pSubject, charset, usemime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pPriority && *pPriority)
|
// Skip no or empty priority.
|
||||||
if (!PL_strcasestr(pPriority, "normal")) {
|
if (pPriority && *pPriority) {
|
||||||
PUSH_STRING ("X-Priority: ");
|
nsMsgPriorityValue priorityValue;
|
||||||
/* Important: do not change the order of the
|
|
||||||
* following if statements
|
|
||||||
*/
|
|
||||||
if (PL_strcasestr (pPriority, "highest"))
|
|
||||||
PUSH_STRING("1 (");
|
|
||||||
else if (PL_strcasestr(pPriority, "high"))
|
|
||||||
PUSH_STRING("2 (");
|
|
||||||
else if (PL_strcasestr(pPriority, "lowest"))
|
|
||||||
PUSH_STRING("5 (");
|
|
||||||
else if (PL_strcasestr(pPriority, "low"))
|
|
||||||
PUSH_STRING("4 (");
|
|
||||||
|
|
||||||
PUSH_STRING (pPriority);
|
NS_MsgGetPriorityFromString(pPriority, priorityValue);
|
||||||
|
|
||||||
|
// Skip default priority.
|
||||||
|
if (priorityValue != nsMsgPriority::Default) {
|
||||||
|
nsCAutoString priorityName;
|
||||||
|
nsCAutoString priorityValueString;
|
||||||
|
|
||||||
|
NS_MsgGetPriorityValueString(priorityValue, priorityValueString);
|
||||||
|
NS_MsgGetUntranslatedPriorityName(priorityValue, priorityName);
|
||||||
|
|
||||||
|
// Output format: [X-Priority: <pValue> (<pName>)]
|
||||||
|
PUSH_STRING("X-Priority: ");
|
||||||
|
PUSH_STRING(priorityValueString.get());
|
||||||
|
PUSH_STRING(" (");
|
||||||
|
PUSH_STRING(priorityName.get());
|
||||||
PUSH_STRING(")");
|
PUSH_STRING(")");
|
||||||
PUSH_NEWLINE ();
|
PUSH_NEWLINE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReference && *pReference) {
|
if (pReference && *pReference) {
|
||||||
|
|
|
@ -634,12 +634,12 @@ NS_IMETHODIMP nsMsgHdr::GetLineCount(PRUint32 *result)
|
||||||
|
|
||||||
NS_IMETHODIMP nsMsgHdr::SetPriorityString(const char *priority)
|
NS_IMETHODIMP nsMsgHdr::SetPriorityString(const char *priority)
|
||||||
{
|
{
|
||||||
nsMsgPriorityValue priorityVal = nsMsgPriority::normal;
|
nsMsgPriorityValue priorityVal = nsMsgPriority::Default;
|
||||||
|
|
||||||
|
// We can ignore |NS_MsgGetPriorityFromString()| return value,
|
||||||
|
// since we set a default value for |priorityVal|.
|
||||||
|
NS_MsgGetPriorityFromString(priority, priorityVal);
|
||||||
|
|
||||||
// NS_MsgGetPriorityFromString will return normal in case of error,
|
|
||||||
// so we can ignore return value.
|
|
||||||
nsresult res;
|
|
||||||
res = NS_MsgGetPriorityFromString(priority, &priorityVal);
|
|
||||||
return SetPriority(priorityVal);
|
return SetPriority(priorityVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче