make priority a scriptable type

add scriptable enums for priority
make more of the search interface use nsIMsgSearchValue instead of nsMsgSearchValue
This commit is contained in:
alecf%netscape.com 2000-05-01 23:19:46 +00:00
Родитель 6fd1a569fd
Коммит 3ec3aa314b
27 изменённых файлов: 276 добавлений и 201 удалений

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

@ -33,8 +33,6 @@
[ref] native nsStringRef(nsString);
[ref] native nsCStringRef(nsCString);
native nsMsgPriority(nsMsgPriority);
[scriptable, uuid(4e994f60-c317-11d2-8cc9-0060b0fc14a3)]
interface nsIMsgHdr : nsISupports
{
@ -53,7 +51,7 @@ interface nsIMsgHdr : nsISupports
void markRead(in boolean read);
void markFlagged(in boolean flagged);
[noscript] attribute nsMsgPriority priority;
attribute nsMsgPriorityValue priority;
void setPriorityString(in string priority);
/* flag handling routines */

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

@ -53,8 +53,9 @@ interface nsIMsgFilter : nsISupports {
attribute nsIMsgSearchScopeTerm scope;
[noscript] void SetAction(in nsMsgRuleActionType type, in voidStar value);
[noscript] void GetAction(out nsMsgRuleActionType type, out voidStar value);
attribute nsMsgRuleActionType action;
attribute nsMsgPriorityValue actionPriority;
attribute string actionTargetFolderUri;
void MatchHdr(in nsIMsgDBHdr msgHdr, in nsIMsgFolder folder,
in nsIMsgDatabase db, in string headers,

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

@ -22,6 +22,7 @@
#include "nsISupports.idl"
#include "nsMsgSearchCore.idl"
#include "nsIMsgSearchValue.idl"
interface nsMsgResultElement;
interface nsIMsgSearchAdapter;
@ -35,21 +36,20 @@ interface nsIMsgSearchAdapter;
[scriptable, uuid(a819050a-0302-11d3-a50a-0060b0fc04b7)]
interface nsIMsgSearchSession : nsISupports {
[noscript]
void AddSearchTerm(in nsMsgSearchAttribValue attrib, /* attribute for this term */
in nsMsgSearchOpValue op,/* operator e.g. opContains */
in nsMsgSearchValue value, /* value e.g. "Dogbert" */
in nsIMsgSearchValue value, /* value e.g. "Dogbert" */
in boolean BooleanAND, /* set to true if associated boolean operator is AND */
in string arbitraryHeader); /* user defined arbitrary header. ignored unless attrib = attribOtherHeader */
readonly attribute long numSearchTerms;
readonly attribute nsIMsgSearchAdapter runningAdapter;
[noscript]
void GetNthSearchTerm(in long whichTerm,
in nsMsgSearchAttribValue attrib,
in nsMsgSearchOpValue op,
in nsMsgSearchValue value); // wrong, should be out
in nsIMsgSearchValue value); // wrong, should be out
long CountSearchScopes();

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

@ -25,9 +25,6 @@
interface nsIMsgFolder;
// for now
native nsMsgPriority(nsMsgPriority);
[scriptable, uuid(12156d67-6071-4354-b204-4cb9b561cc94)]
interface nsIMsgSearchValue : nsISupports {
// type of object
@ -36,7 +33,7 @@ interface nsIMsgSearchValue : nsISupports {
// accessing these will throw an exception if the above
// attribute does not match the type!
attribute string str;
[noscript] attribute nsMsgPriority priority;
attribute nsMsgPriorityValue priority;
attribute PRTime date;
attribute unsigned long status; // see MSG_FLAG in msgcom.h
attribute unsigned long size;

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
@ -40,23 +40,24 @@ public:
nsMsgResultElement (nsIMsgSearchAdapter *);
virtual ~nsMsgResultElement ();
static nsresult AssignValues (nsMsgSearchValue *src, nsMsgSearchValue *dst);
static nsresult AssignValues (nsIMsgSearchValue *src, nsMsgSearchValue *dst);
nsresult GetValue (nsMsgSearchAttribValue, nsMsgSearchValue **) const;
nsresult AddValue (nsIMsgSearchValue*);
nsresult AddValue (nsMsgSearchValue*);
nsresult GetPrettyName (nsMsgSearchValue**);
const nsMsgSearchValue *GetValueRef (nsMsgSearchAttribValue) const;
nsresult GetValueRef (nsMsgSearchAttribValue, nsIMsgSearchValue**) const;
nsresult Open (void *window);
// added as part of the search as view capabilities...
static int CompareByFolderInfoPtrs (const void *, const void *);
static int Compare (const void *, const void *);
static nsresult DestroyValue (nsMsgSearchValue *value);
static nsresult DestroyValue (nsIMsgSearchValue *value);
nsMsgSearchValueArray m_valueList;
nsCOMPtr<nsISupportsArray> m_valueList;
nsIMsgSearchAdapter *m_adapter;
protected:

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

@ -190,7 +190,7 @@ typedef struct nsMsgSearchValue
union
{
char *string;
nsMsgPriority priority;
nsMsgPriorityValue priority;
PRTime date;
PRUint32 msgStatus; /* see MSG_FLAG in msgcom.h */
PRUint32 size;

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

@ -39,9 +39,9 @@ class nsMsgSearchTerm
public:
nsMsgSearchTerm();
#if 0
nsMsgSearchTerm (nsMsgSearchAttribute, nsMsgSearchOperator, nsMsgSearchValue *, PRBool, char * arbitraryHeader); // the bool is true if AND, PR_FALSE if OR
nsMsgSearchTerm (nsMsgSearchAttribute, nsMsgSearchOperator, nsIMsgSearchValue *, PRBool, char * arbitraryHeader); // the bool is true if AND, PR_FALSE if OR
#endif
nsMsgSearchTerm (nsMsgSearchAttribValue, nsMsgSearchOpValue, nsMsgSearchValue *, nsMsgSearchBooleanOperator, const char * arbitraryHeader);
nsMsgSearchTerm (nsMsgSearchAttribValue, nsMsgSearchOpValue, nsIMsgSearchValue *, nsMsgSearchBooleanOperator, const char * arbitraryHeader);
virtual ~nsMsgSearchTerm ();
@ -64,7 +64,7 @@ public:
nsresult MatchString (nsCString *, const char *charset, PRBool body, PRBool *result);
nsresult MatchDate (PRTime, PRBool *result);
nsresult MatchStatus (PRUint32, PRBool *result);
nsresult MatchPriority (nsMsgPriority, PRBool *result);
nsresult MatchPriority (nsMsgPriorityValue, PRBool *result);
nsresult MatchSize (PRUint32, PRBool *result);
nsresult MatchRfc822String(const char *, const char *charset, PRBool *pResult);
nsresult MatchAge (PRTime, PRBool *result);

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

@ -201,36 +201,54 @@ NS_IMETHODIMP nsMsgFilter::GetScope(nsIMsgSearchScopeTerm **aResult)
If type is acMoveToFolder, value is pointer to folder name.
Otherwise, value is ignored.
*/
NS_IMETHODIMP nsMsgFilter::SetAction(nsMsgRuleActionType type, void *value)
NS_IMETHODIMP nsMsgFilter::SetAction(nsMsgRuleActionType type)
{
switch (type)
{
case nsMsgFilterAction::MoveToFolder:
m_action.m_folderUri = (const char *) value;
break;
case nsMsgFilterAction::ChangePriority:
m_action.m_priority = (nsMsgPriority) (PRInt32) value;
break;
default:
break;
}
m_action.m_type = type;
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::GetAction(nsMsgRuleActionType *type, void **value)
NS_IMETHODIMP nsMsgFilter::SetActionPriority(nsMsgPriorityValue aPriority)
{
NS_ENSURE_TRUE(m_action.m_type == nsMsgFilterAction::ChangePriority,
NS_ERROR_ILLEGAL_VALUE);
m_action.m_priority = aPriority;
return NS_OK;
}
NS_IMETHODIMP
nsMsgFilter::SetActionTargetFolderUri(const char *aUri)
{
NS_ENSURE_TRUE(m_action.m_type == nsMsgFilterAction::MoveToFolder,
NS_ERROR_ILLEGAL_VALUE);
m_action.m_folderUri = aUri;
return NS_OK;
}
NS_IMETHODIMP
nsMsgFilter::GetAction(nsMsgRuleActionType *type)
{
NS_ENSURE_ARG_POINTER(type);
*type = m_action.m_type;
switch (m_action.m_type)
{
case nsMsgFilterAction::MoveToFolder:
* (const char **) value = m_action.m_folderUri.GetBuffer();
break;
case nsMsgFilterAction::ChangePriority:
* (nsMsgPriority *) value = m_action.m_priority;
break;
default:
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsMsgFilter::GetActionPriority(nsMsgPriorityValue *aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_TRUE(m_action.m_type == nsMsgFilterAction::ChangePriority,
NS_ERROR_ILLEGAL_VALUE);
*aResult = m_action.m_priority;
return NS_OK;
}
NS_IMETHODIMP
nsMsgFilter::GetActionTargetFolderUri(char** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_TRUE(m_action.m_type == nsMsgFilterAction::MoveToFolder,
NS_ERROR_ILLEGAL_VALUE);
*aResult = m_action.m_folderUri.ToNewCString();
return NS_OK;
}
@ -240,12 +258,13 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd
PRTime date;
char dateStr[40]; /* 30 probably not enough */
nsMsgRuleActionType actionType;
void *value;
nsXPIDLCString actionFolderUri;
nsXPIDLCString author;
nsXPIDLCString subject;
GetFilterName(&filterName);
GetAction(&actionType, &value);
GetAction(&actionType);
nsresult res;
res = msgHdr->GetDate(&date);
PRExplodedTime exploded;
@ -266,13 +285,17 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd
*stream << dateStr;
*stream << "\n";
const char *actionStr = GetActionStr(actionType);
char *actionValue = "";
if (actionType == nsMsgFilterAction::MoveToFolder)
actionValue = (char *) value;
*stream << "Action = ";
*stream << actionStr;
*stream << " ";
*stream << actionValue;
if (actionType == nsMsgFilterAction::MoveToFolder) {
GetActionTargetFolderUri(getter_Copies(actionFolderUri));
*stream << (const char *)actionFolderUri;
} else {
*stream << "";
}
*stream << "\n\n";
// XP_FilePrintf(*m_logFile, "Action = %s %s\n\n", actionStr, actionValue);
if (actionType == nsMsgFilterAction::MoveToFolder)
@ -280,7 +303,7 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd
nsXPIDLCString msgId;
msgHdr->GetMessageId(getter_Copies(msgId));
*stream << "mailbox:";
*stream << (char *) value;
*stream << (const char *) actionFolderUri;
*stream << "id = ";
*stream << (const char*)msgId;
*stream << "\n";

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

@ -36,7 +36,7 @@ public:
virtual ~nsMsgRuleAction();
nsMsgRuleActionType m_type;
// this used to be a union - why bother?
nsMsgPriority m_priority; /* priority to set rule to */
nsMsgPriorityValue m_priority; /* priority to set rule to */
nsCString m_folderUri; /* Or some folder identifier, if such a thing is invented */
nsCString m_originalServerPath;
} ;

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

@ -462,11 +462,12 @@ nsresult nsMsgFilterList::LoadTextFilters()
err = m_curFilter->ConvertMoveToFolderValue(value);
else if (m_curFilter->m_action.m_type == nsMsgFilterAction::ChangePriority)
{
nsMsgPriority outPriority;
nsMsgPriorityValue outPriority;
nsresult res = NS_MsgGetPriorityFromString(value.GetBuffer(), &outPriority);
if (NS_SUCCEEDED(res))
{
m_curFilter->SetAction(m_curFilter->m_action.m_type, (void *) (int32) outPriority);
m_curFilter->SetAction(m_curFilter->m_action.m_type);
m_curFilter->SetActionPriority(outPriority);
}
else
NS_ASSERTION(PR_FALSE, "invalid priority in filter file");

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

@ -33,6 +33,7 @@
#include "nsMsgResultElement.h"
#include "nsMsgBaseCID.h"
#include "nsMsgSearchValue.h"
static NS_DEFINE_CID(kValidityManagerCID, NS_MSGSEARCHVALIDITYMANAGER_CID);
@ -574,7 +575,7 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
break;
case nsMsgSearchAttrib::Priority:
{
nsMsgPriority msgPriority;
nsMsgPriorityValue msgPriority;
msgToMatch->GetPriority(&msgPriority);
err = pTerm->MatchPriority (msgPriority, &result);
}

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

@ -59,7 +59,7 @@ nsMsgSearchSession::~nsMsgSearchSession()
NS_IMETHODIMP
nsMsgSearchSession::AddSearchTerm(nsMsgSearchAttribValue attrib,
nsMsgSearchOpValue op,
nsMsgSearchValue * value,
nsIMsgSearchValue * value,
PRBool BooleanAND,
const char *arbitraryHeader)
{
@ -83,7 +83,7 @@ NS_IMETHODIMP
nsMsgSearchSession::GetNthSearchTerm(PRInt32 whichTerm,
nsMsgSearchAttribValue attrib,
nsMsgSearchOpValue op,
nsMsgSearchValue * value)
nsIMsgSearchValue * value)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -33,6 +33,7 @@
#include "nsMsgSearchImap.h"
#include "nsMsgLocalSearch.h"
#include "nsMsgSearchNews.h"
#include "nsMsgSearchValue.h"
//---------------------------------------------------------------------------
// nsMsgSearchTerm specifies one criterion, e.g. name contains phil
//---------------------------------------------------------------------------
@ -256,7 +257,7 @@ nsMsgSearchTerm::nsMsgSearchTerm (
nsMsgSearchTerm::nsMsgSearchTerm (
nsMsgSearchAttribValue attrib,
nsMsgSearchOpValue op,
nsMsgSearchValue *val,
nsIMsgSearchValue *val,
nsMsgSearchBooleanOperator boolOp,
const char * arbitraryHeader)
{
@ -1079,7 +1080,9 @@ nsresult nsMsgSearchTerm::MatchStatus (PRUint32 statusToMatch, PRBool *pResult)
}
nsresult nsMsgSearchTerm::MatchPriority (nsMsgPriority priorityToMatch, PRBool *pResult)
nsresult
nsMsgSearchTerm::MatchPriority (nsMsgPriorityValue priorityToMatch,
PRBool *pResult)
{
if (!pResult)
return NS_ERROR_NULL_POINTER;
@ -1307,15 +1310,25 @@ char *nsMsgSearchScopeTerm::GetStatusBarName ()
nsMsgResultElement::nsMsgResultElement(nsIMsgSearchAdapter *adapter)
{
NS_NewISupportsArray(getter_AddRefs(m_valueList));
m_adapter = adapter;
}
nsMsgResultElement::~nsMsgResultElement ()
{
for (int i = 0; i < m_valueList.Count(); i++)
#if 0 // this should happen automatically
// when the nsISupportsArray goes away
nsresult rv;
PRUint32 count;
m_valueList->Count(&count);
for (PRUint32 i = 0; i < count; i++)
{
nsMsgSearchValue *value = m_valueList.ElementAt(i);
nsCOMPtr<nsIMsgSearchValue> value;
rv = m_valueList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchValue),
(void **)getter_AddRefs(value));
NS_ASSERTION(NS_SUCCEEDED(rv), "bad element of array");
#ifdef HUH_WHATS_THIS
if (value->attribute == nsMsgSearchAttrib::JpegFile)
{
@ -1325,65 +1338,63 @@ nsMsgResultElement::~nsMsgResultElement ()
XP_FREE(url);
}
#endif
#if 0
nsMsgResultElement::DestroyValue (value);
#endif
}
#endif
}
nsresult nsMsgResultElement::AddValue (nsIMsgSearchValue *value)
{
m_valueList->AppendElement (value);
return NS_OK;
}
nsresult nsMsgResultElement::AddValue (nsMsgSearchValue *value)
{
m_valueList.AppendElement (value);
return NS_OK;
nsMsgSearchValueImpl* valueImpl = new nsMsgSearchValueImpl(value);
delete value; // we keep the nsIMsgSearchValue, not
// the nsMsgSearchValue
return AddValue(valueImpl);
}
nsresult nsMsgResultElement::DestroyValue (nsMsgSearchValue *value)
#if 0
nsresult nsMsgResultElement::DestroyValue (nsIMsgSearchValue *value)
{
if (IS_STRING_ATTRIBUTE(value->attribute))
{
NS_ASSERTION(value->u.string, "got null result value string");
PR_Free (value->u.string);
}
delete value;
return NS_OK;
}
#endif
nsresult nsMsgResultElement::AssignValues (nsMsgSearchValue *src, nsMsgSearchValue *dst)
nsresult nsMsgResultElement::AssignValues (nsIMsgSearchValue *src, nsMsgSearchValue *dst)
{
// Yes, this could be an operator overload, but nsMsgSearchValue is totally public, so I'd
// have to define a derived class with nothing by operator=, and that seems like a bit much
nsresult err = NS_OK;
switch (src->attribute)
src->GetAttrib(&dst->attribute);
switch (dst->attribute)
{
case nsMsgSearchAttrib::Priority:
dst->attribute = src->attribute;
dst->u.priority = src->u.priority;
err = src->GetPriority(&dst->u.priority);
break;
case nsMsgSearchAttrib::Date:
dst->attribute = src->attribute;
dst->u.date = src->u.date;
err = src->GetDate(&dst->u.date);
break;
case nsMsgSearchAttrib::MsgStatus:
dst->attribute = src->attribute;
dst->u.msgStatus = src->u.msgStatus;
err = src->GetStatus(&dst->u.msgStatus);
break;
case nsMsgSearchAttrib::MessageKey:
dst->attribute = src->attribute;
dst->u.key = src->u.key;
err = src->GetMsgKey(&dst->u.key);
break;
case nsMsgSearchAttrib::AgeInDays:
dst->attribute = src->attribute;
dst->u.age = src->u.age;
err = src->GetAge(&dst->u.age);
break;
default:
if (src->attribute < nsMsgSearchAttrib::kNumMsgSearchAttributes)
if (dst->attribute < nsMsgSearchAttrib::kNumMsgSearchAttributes)
{
NS_ASSERTION(IS_STRING_ATTRIBUTE(src->attribute), "assigning non-string result");
dst->attribute = src->attribute;
dst->u.string = PL_strdup(src->u.string);
if (!dst->u.string)
err = NS_ERROR_OUT_OF_MEMORY;
NS_ASSERTION(IS_STRING_ATTRIBUTE(dst->attribute), "assigning non-string result");
err = src->GetStr(&dst->u.string);
}
else
err = NS_ERROR_INVALID_ARG;
@ -1396,13 +1407,19 @@ nsresult nsMsgResultElement::GetValue (nsMsgSearchAttribValue attrib,
nsMsgSearchValue **outValue) const
{
nsresult err = NS_OK;
nsMsgSearchValue *value = NULL;
nsCOMPtr<nsIMsgSearchValue> value;
*outValue = NULL;
for (int i = 0; i < m_valueList.Count() && err != NS_OK; i++)
PRUint32 count;
m_valueList->Count(&count);
for (PRUint32 i = 0; i < count && err != NS_OK; i++)
{
value = m_valueList.ElementAt(i);
if (attrib == value->attribute)
m_valueList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchValue),
(void **)getter_AddRefs(value));
nsMsgSearchAttribValue valueAttribute;
value->GetAttrib(&valueAttribute);
if (attrib == valueAttribute)
{
*outValue = new nsMsgSearchValue;
if (*outValue)
@ -1436,17 +1453,29 @@ nsresult nsMsgResultElement::GetValue (nsMsgSearchAttribValue attrib,
}
const nsMsgSearchValue *
nsMsgResultElement::GetValueRef (nsMsgSearchAttribValue attrib) const
nsresult
nsMsgResultElement::GetValueRef (nsMsgSearchAttribValue attrib,
nsIMsgSearchValue* *aResult) const
{
nsMsgSearchValue *value = NULL;
for (int i = 0; i < m_valueList.Count(); i++)
nsCOMPtr<nsIMsgSearchValue> value;
PRUint32 count;
m_valueList->Count(&count);
nsresult rv;
for (PRUint32 i = 0; i < count; i++)
{
value = m_valueList.ElementAt(i);
if (attrib == value->attribute)
return value;
rv = m_valueList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchValue),
getter_AddRefs(value));
NS_ASSERTION(NS_SUCCEEDED(rv), "bad element of array");
if (NS_FAILED(rv)) continue;
nsMsgSearchAttribValue valueAttribute;
value->GetAttrib(&valueAttribute);
if (attrib == valueAttribute) {
*aResult = value;
NS_ADDREF(*aResult);
}
return NULL;
}
return NS_ERROR_FAILURE;
}

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

@ -28,14 +28,14 @@ nsMsgSearchValueImpl::nsMsgSearchValueImpl(nsMsgSearchValue *aInitialValue)
{
NS_INIT_ISUPPORTS();
mValue = *aInitialValue;
// XXX TODO - make a copy of the string if it's a string attribute
// (right now we dont' know when it's a string!)
if (IS_STRING_ATTRIBUTE(aInitialValue->attribute))
mValue.u.string = nsCRT::strdup(aInitialValue->u.string);
}
nsMsgSearchValueImpl::~nsMsgSearchValueImpl()
{
// XXX TODO - free the string if it's a string attribute
if (IS_STRING_ATTRIBUTE(mValue.attribute))
nsCRT::free(mValue.u.string);
}
@ -58,13 +58,13 @@ nsMsgSearchValueImpl::SetStr(const char* aValue)
}
NS_IMETHODIMP
nsMsgSearchValueImpl::GetPriority(nsMsgPriority *aResult)
nsMsgSearchValueImpl::GetPriority(nsMsgPriorityValue *aResult)
{
*aResult = mValue.u.priority;
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchValueImpl::SetPriority(nsMsgPriority aValue)
nsMsgSearchValueImpl::SetPriority(nsMsgPriorityValue aValue)
{
aValue = mValue.u.priority;
return NS_OK;

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

@ -1242,27 +1242,27 @@ nsMsgMessageDataSource::createFlaggedStringFromFlag(PRUint32 flags, nsCAutoStrin
}
nsresult
nsMsgMessageDataSource::createPriorityString(nsMsgPriority priority, nsCAutoString &priorityStr)
nsMsgMessageDataSource::createPriorityString(nsMsgPriorityValue priority, nsCAutoString &priorityStr)
{
nsresult rv = NS_OK;
priorityStr = " ";
switch (priority)
{
case nsMsgPriorityNotSet:
case nsMsgPriorityNone:
case nsMsgPriorityNormal:
case nsMsgPriority::notSet:
case nsMsgPriority::none:
case nsMsgPriority::normal:
priorityStr = " ";
break;
case nsMsgPriorityLowest:
case nsMsgPriority::lowest:
priorityStr = "Lowest";
break;
case nsMsgPriorityLow:
case nsMsgPriority::low:
priorityStr = "Low";
break;
case nsMsgPriorityHigh:
case nsMsgPriority::high:
priorityStr = "High";
break;
case nsMsgPriorityHighest:
case nsMsgPriority::highest:
priorityStr = "Highest";
break;
}
@ -1274,28 +1274,28 @@ nsMsgMessageDataSource::createMessagePriorityNode(nsIMessage *message,
nsIRDFNode **target)
{
nsresult rv;
nsMsgPriority priority;
nsMsgPriorityValue priority;
rv = message->GetPriority(&priority);
if(NS_FAILED(rv))
return rv;
*target = kEmptyStringLiteral;
switch (priority)
{
case nsMsgPriorityNotSet:
case nsMsgPriorityNone:
case nsMsgPriorityNormal:
case nsMsgPriority::notSet:
case nsMsgPriority::none:
case nsMsgPriority::normal:
*target = kEmptyStringLiteral;
break;
case nsMsgPriorityLowest:
case nsMsgPriority::lowest:
*target = kLowestLiteral;
break;
case nsMsgPriorityLow:
case nsMsgPriority::low:
*target = kLowLiteral;
break;
case nsMsgPriorityHigh:
case nsMsgPriority::high:
*target = kHighLiteral;
break;
case nsMsgPriorityHighest:
case nsMsgPriority::highest:
*target = kHighestLiteral;
break;
}
@ -1308,28 +1308,28 @@ nsresult
nsMsgMessageDataSource::createMessagePrioritySortNode(nsIMessage *message, nsIRDFNode **target)
{
nsresult rv;
nsMsgPriority priority;
nsMsgPriorityValue priority;
rv = message->GetPriority(&priority);
if(NS_FAILED(rv))
return rv;
*target = kNormalSortLiteral;
switch (priority)
{
case nsMsgPriorityNotSet:
case nsMsgPriorityNone:
case nsMsgPriorityNormal:
case nsMsgPriority::notSet:
case nsMsgPriority::none:
case nsMsgPriority::normal:
*target = kNormalSortLiteral;
break;
case nsMsgPriorityLowest:
case nsMsgPriority::lowest:
*target = kLowestSortLiteral;
break;
case nsMsgPriorityLow:
case nsMsgPriority::low:
*target = kLowSortLiteral;
break;
case nsMsgPriorityHigh:
case nsMsgPriority::high:
*target = kHighSortLiteral;
break;
case nsMsgPriorityHighest:
case nsMsgPriority::highest:
*target = kHighestSortLiteral;
break;
}

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

@ -141,7 +141,7 @@ protected:
nsresult createMessagePrioritySortNode(nsIMessage *message, nsIRDFNode **target);
nsresult createPriorityString(nsMsgPriority priority, nsCAutoString &priorityStr);
nsresult createPriorityString(nsMsgPriorityValue priority, nsCAutoString &priorityStr);
nsresult createMessageSizeNode(nsIMessage *message, nsIRDFNode **target, PRBool sort);

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

@ -429,7 +429,7 @@ NS_IMETHODIMP nsMessage::SetLineCount(PRUint32 lineCount)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::SetPriority(nsMsgPriority priority)
NS_IMETHODIMP nsMessage::SetPriority(nsMsgPriorityValue priority)
{
if(mMsgHdr)
return mMsgHdr->SetPriority(priority);
@ -445,7 +445,7 @@ NS_IMETHODIMP nsMessage::SetPriorityString(const char *priority)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMessage::GetPriority(nsMsgPriority *result)
NS_IMETHODIMP nsMessage::GetPriority(nsMsgPriorityValue *result)
{
if(mMsgHdr)
return mMsgHdr->GetPriority(result);

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

@ -212,66 +212,66 @@ nsresult NS_NewMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator,
// Where should this live? It's a utility used to convert a string priority, e.g., "High, Low, Normal" to an enum.
// Perhaps we should have an interface that groups together all these utilities...
nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriority *outPriority)
nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriorityValue *outPriority)
{
if (!outPriority)
return NS_ERROR_NULL_POINTER;
nsMsgPriority retPriority = nsMsgPriorityNormal;
nsMsgPriorityValue retPriority = nsMsgPriority::normal;
if (PL_strcasestr(priority, "Normal") != NULL)
retPriority = nsMsgPriorityNormal;
retPriority = nsMsgPriority::normal;
else if (PL_strcasestr(priority, "Lowest") != NULL)
retPriority = nsMsgPriorityLowest;
retPriority = nsMsgPriority::lowest;
else if (PL_strcasestr(priority, "Highest") != NULL)
retPriority = nsMsgPriorityHighest;
retPriority = nsMsgPriority::highest;
else if (PL_strcasestr(priority, "High") != NULL ||
PL_strcasestr(priority, "Urgent") != NULL)
retPriority = nsMsgPriorityHigh;
retPriority = nsMsgPriority::high;
else if (PL_strcasestr(priority, "Low") != NULL ||
PL_strcasestr(priority, "Non-urgent") != NULL)
retPriority = nsMsgPriorityLow;
retPriority = nsMsgPriority::low;
else if (PL_strcasestr(priority, "1") != NULL)
retPriority = nsMsgPriorityHighest;
retPriority = nsMsgPriority::highest;
else if (PL_strcasestr(priority, "2") != NULL)
retPriority = nsMsgPriorityHigh;
retPriority = nsMsgPriority::high;
else if (PL_strcasestr(priority, "3") != NULL)
retPriority = nsMsgPriorityNormal;
retPriority = nsMsgPriority::normal;
else if (PL_strcasestr(priority, "4") != NULL)
retPriority = nsMsgPriorityLow;
retPriority = nsMsgPriority::low;
else if (PL_strcasestr(priority, "5") != NULL)
retPriority = nsMsgPriorityLowest;
retPriority = nsMsgPriority::lowest;
else
retPriority = nsMsgPriorityNormal;
retPriority = nsMsgPriority::normal;
*outPriority = retPriority;
return NS_OK;
//return nsMsgNoPriority;
}
nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriority p, nsString *outName)
nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriorityValue p, nsString *outName)
{
if (!outName)
return NS_ERROR_NULL_POINTER;
switch (p)
{
case nsMsgPriorityNotSet:
case nsMsgPriorityNone:
case nsMsgPriority::notSet:
case nsMsgPriority::none:
outName->AssignWithConversion("None");
break;
case nsMsgPriorityLowest:
case nsMsgPriority::lowest:
outName->AssignWithConversion("Lowest");
break;
case nsMsgPriorityLow:
case nsMsgPriority::low:
outName->AssignWithConversion("Low");
break;
case nsMsgPriorityNormal:
case nsMsgPriority::normal:
outName->AssignWithConversion("Normal");
break;
case nsMsgPriorityHigh:
case nsMsgPriority::high:
outName->AssignWithConversion("High");
break;
case nsMsgPriorityHighest:
case nsMsgPriority::highest:
outName->AssignWithConversion("Highest");
break;
default:

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

@ -61,9 +61,9 @@ NS_MSG_BASE nsresult NS_NewMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcE
nsIMsgFolder *folder,
nsMessageFromMsgHdrEnumerator **messageEnumerator);
NS_MSG_BASE nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriority *outPriority);
NS_MSG_BASE nsresult NS_MsgGetPriorityFromString(const char *priority, nsMsgPriorityValue *outPriority);
NS_MSG_BASE nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriority p, nsString *outName);
NS_MSG_BASE nsresult NS_MsgGetUntranslatedPriorityName (nsMsgPriorityValue p, nsString *outName);
NS_MSG_BASE nsresult NS_MsgHashIfNecessary(nsCAutoString &name);

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

@ -72,7 +72,7 @@ protected:
PRInt16 m_csID; // cs id of message
nsCString m_charSet; // OK, charset of headers, since cs id's aren't supported.
nsCStringArray m_references; // avoid parsing references every time we want one
nsMsgPriority m_priority;
nsMsgPriorityValue m_priority;
PRBool m_recipientsIsNewsgroup;
// nsMsgHdrs will have to know what db and row they belong to, since they are really

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

@ -506,13 +506,13 @@ NS_IMETHODIMP nsMsgHdr::GetStatusOffset(PRUint32 *result)
return res;
}
NS_IMETHODIMP nsMsgHdr::SetPriority(nsMsgPriority priority)
NS_IMETHODIMP nsMsgHdr::SetPriority(nsMsgPriorityValue priority)
{
SetUInt32Column((PRUint32) priority, m_mdb->m_priorityColumnToken);
return NS_OK;
}
NS_IMETHODIMP nsMsgHdr::GetPriority(nsMsgPriority *result)
NS_IMETHODIMP nsMsgHdr::GetPriority(nsMsgPriorityValue *result)
{
if (!result)
return NS_ERROR_NULL_POINTER;
@ -521,7 +521,7 @@ NS_IMETHODIMP nsMsgHdr::GetPriority(nsMsgPriority *result)
nsresult rv = GetUInt32Column(m_mdb->m_priorityColumnToken, &priority);
if (NS_FAILED(rv)) return rv;
*result = (nsMsgPriority) priority;
*result = (nsMsgPriorityValue) priority;
return NS_OK;
}
@ -550,7 +550,7 @@ NS_IMETHODIMP nsMsgHdr::GetLineCount(PRUint32 *result)
NS_IMETHODIMP nsMsgHdr::SetPriorityString(const char *priority)
{
nsMsgPriority priorityVal = nsMsgPriorityNormal;
nsMsgPriorityValue priorityVal = nsMsgPriority::normal;
// NS_MsgGetPriorityFromString will return normal in case of error,
// so we can ignore return value.

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

@ -2176,7 +2176,7 @@ NS_IMETHODIMP nsImapMailFolder::EndMessage(nsMsgKey key)
NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore)
{
nsMsgRuleActionType actionType;
void *value = nsnull;
nsXPIDLCString actionTargetFolderUri;
PRUint32 newFlags;
nsresult rv = NS_OK;
@ -2189,8 +2189,11 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *app
#ifdef DEBUG_bienvenu
printf("got a rule hit!\n");
#endif
if (NS_SUCCEEDED(filter->GetAction(&actionType, &value)))
if (NS_SUCCEEDED(filter->GetAction(&actionType)))
{
if (actionType == nsMsgFilterAction::MoveToFolder)
filter->GetActionTargetFolderUri(getter_Copies(actionTargetFolderUri));
nsCOMPtr<nsIMsgDBHdr> msgHdr;
if (m_msgParser)
@ -2223,7 +2226,7 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *app
rv = mailTrash->GetName(&folderName);
trashNameVal.AssignWithConversion(folderName);
nsCRT::free(folderName);
value = (void *) trashNameVal.GetBuffer();
*(char **)getter_Copies(actionTargetFolderUri) = trashNameVal.ToNewCString();
}
msgHdr->OrFlags(MSG_FLAG_READ, &newFlags); // mark read in trash.
@ -2247,7 +2250,8 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *app
nsXPIDLCString uri;
rv = GetURI(getter_Copies(uri));
if (value && nsCRT::strcasecmp((const char *) uri, (const char *) value))
if ((const char*)actionTargetFolderUri &&
nsCRT::strcasecmp(uri, actionTargetFolderUri))
{
msgHdr->GetFlags(&msgFlags);
@ -2290,7 +2294,7 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *app
PR_FREEIF(tmp);
#endif
}
nsresult err = MoveIncorporatedMessage(msgHdr, mDatabase, (char *) value, filter);
nsresult err = MoveIncorporatedMessage(msgHdr, mDatabase, actionTargetFolderUri, filter);
if (NS_SUCCEEDED(err))
{
m_msgMovedByFilter = PR_TRUE;
@ -2320,7 +2324,11 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, PRBool *app
msgHdr->OrFlags(MSG_FLAG_WATCHED, &newFlags);
break;
case nsMsgFilterAction::ChangePriority:
msgHdr->SetPriority(*(nsMsgPriority *) &value);
{
nsMsgPriorityValue filterPriority;
filter->GetActionPriority(&filterPriority);
msgHdr->SetPriority(filterPriority);
}
break;
default:
break;
@ -2418,7 +2426,7 @@ nsresult nsImapMailFolder::StoreImapFlags(imapMessageFlagsType flags, PRBool add
nsresult nsImapMailFolder::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
nsIMsgDatabase *sourceDB,
char *destFolderUri,
const char *destFolderUri,
nsIMsgFilter *filter)
{
nsresult err = NS_OK;

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

@ -253,7 +253,7 @@ public:
nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
nsIMsgDatabase *sourceDB,
char *destFolder,
const char *destFolder,
nsIMsgFilter *filter);
nsresult StoreImapFlags(imapMessageFlagsType flags, PRBool addFlags, nsMsgKeyArray &msgKeys);
static nsresult AllocateUidStringFromKeyArray(nsMsgKeyArray &keyArray, nsCString &msgIds);

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

@ -1103,7 +1103,7 @@ int nsParseMailMessageState::FinalizeHeaders()
const char *s;
PRUint32 flags = 0;
PRUint32 delta = 0;
nsMsgPriority priorityFlags = nsMsgPriorityNotSet;
nsMsgPriorityValue priorityFlags = nsMsgPriority::notSet;
if (!m_mailDB) // if we don't have a valid db, skip the header.
return 0;
@ -1146,7 +1146,7 @@ int nsParseMailMessageState::FinalizeHeaders()
}
// strip off and remember priority bits.
flags &= ~MSG_FLAG_RUNTIME_ONLY;
priorityFlags = (nsMsgPriority) ((flags & MSG_FLAG_PRIORITIES) >> 13);
priorityFlags = (nsMsgPriorityValue) ((flags & MSG_FLAG_PRIORITIES) >> 13);
flags &= ~MSG_FLAG_PRIORITIES;
/* We trust the X-Mozilla-Status line to be the smartest in almost
all things. One exception, however, is the HAS_RE flag. Since
@ -1184,7 +1184,7 @@ int nsParseMailMessageState::FinalizeHeaders()
flags |= MSG_FLAG_MDN_REPORT_NEEDED;
m_newMsgHdr->SetFlags(flags);
if (priorityFlags != nsMsgPriorityNotSet)
if (priorityFlags != nsMsgPriority::notSet)
m_newMsgHdr->SetPriority(priorityFlags);
if (delta < 0xffff)
@ -1325,8 +1325,8 @@ int nsParseMailMessageState::FinalizeHeaders()
}
if (priority)
m_newMsgHdr->SetPriorityString(priority->value);
else if (priorityFlags == nsMsgPriorityNotSet)
m_newMsgHdr->SetPriority(nsMsgPriorityNone);
else if (priorityFlags == nsMsgPriority::notSet)
m_newMsgHdr->SetPriority(nsMsgPriority::none);
}
}
else
@ -1683,7 +1683,7 @@ void nsParseNewMailState::ApplyFilters(PRBool *pMoved)
NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *applyMore)
{
nsMsgRuleActionType actionType;
void *value = nsnull;
nsXPIDLCString actionTargetFolderUri;
PRUint32 newFlags;
nsresult rv = NS_OK;
@ -1699,8 +1699,10 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *
#ifdef DEBUG_bienvenu
printf("got a rule hit!\n");
#endif
if (NS_SUCCEEDED(filter->GetAction(&actionType, &value)))
if (NS_SUCCEEDED(filter->GetAction(&actionType)))
{
if (actionType == nsMsgFilterAction::MoveToFolder)
filter->GetActionTargetFolderUri(getter_Copies(actionTargetFolderUri));
nsCOMPtr<nsIMsgDBHdr> msgHdr = m_newMsgHdr;
PRUint32 msgFlags;
nsCAutoString trashNameVal;
@ -1723,14 +1725,15 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *
rv = trash->GetName(&folderName);
trashNameVal.AssignWithConversion(folderName);
PR_FREEIF(folderName);
value = (void *) trashNameVal.GetBuffer();
*(char **)getter_Copies(actionTargetFolderUri) = trashNameVal.ToNewCString();
}
msgHdr->OrFlags(MSG_FLAG_READ, &newFlags); // mark read in trash.
}
case nsMsgFilterAction::MoveToFolder:
// if moving to a different file, do it.
if (value && PL_strcasecmp(m_mailboxName, (char *) value))
if ((const char*)actionTargetFolderUri &&
PL_strcasecmp(m_mailboxName, actionTargetFolderUri))
{
msgHdr->GetFlags(&msgFlags);
@ -1773,7 +1776,7 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *
tmp = (char*) cc.value;
PR_FREEIF(tmp);
}
nsresult err = MoveIncorporatedMessage(msgHdr, m_mailDB, (char *) value, filter);
nsresult err = MoveIncorporatedMessage(msgHdr, m_mailDB, (const char *) actionTargetFolderUri, filter);
if (NS_SUCCEEDED(err))
{
m_msgMovedByFilter = PR_TRUE;
@ -1796,7 +1799,11 @@ NS_IMETHODIMP nsParseNewMailState::ApplyFilterHit(nsIMsgFilter *filter, PRBool *
msgHdr->OrFlags(MSG_FLAG_WATCHED, &newFlags);
break;
case nsMsgFilterAction::ChangePriority:
msgHdr->SetPriority(*(nsMsgPriority *) &value);
{
nsMsgPriorityValue filterPriority;
filter->GetActionPriority(&filterPriority);
msgHdr->SetPriority(filterPriority);
}
break;
default:
break;
@ -1821,7 +1828,7 @@ int nsParseNewMailState::MarkFilteredMessageRead(nsIMsgDBHdr *msgHdr)
nsresult nsParseNewMailState::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
nsIMsgDatabase *sourceDB,
char *destFolderUri,
const char *destFolderUri,
nsIMsgFilter *filter)
{
nsresult err = 0;

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

@ -245,7 +245,7 @@ protected:
virtual nsresult GetTrashFolder(nsIMsgFolder **pTrashFolder);
virtual nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
nsIMsgDatabase *sourceDB,
char *destFolder,
const char *destFolder,
nsIMsgFilter *filter);
virtual int MarkFilteredMessageRead(nsIMsgDBHdr *msgHdr);
void LogRuleHit(nsIMsgFilter *filter, nsIMsgDBHdr *msgHdr);

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

@ -49,6 +49,7 @@ const nsMsgKey nsMsgKey_None = 0xffffffff;
const nsMsgViewIndex nsMsgViewIndex_None = 0xFFFFFFFF;
#if 0
/* Message priorities as determined by X-Priority hdr, or Priority header? */
enum nsMsgPriority {
nsMsgPriorityNotSet = 0,
@ -59,6 +60,7 @@ enum nsMsgPriority {
nsMsgPriorityHigh,
nsMsgPriorityHighest
};
#endif
// The following enums are all persistent in databases, so don't go changing the values!
enum nsMsgSortOrder {

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

@ -23,10 +23,17 @@
typedef unsigned long nsMsgKey;
typedef unsigned long nsMsgViewIndex;
/* I'm doing this because I can't get it to build without this.
I need to revisit this later*/
typedef long nsMsgPriorityValue;
[uuid(94C0D8D8-2045-11d3-8A8F-0060B0FC04D2)]
interface hack{
void hackFunction();
interface nsMsgPriority {
const nsMsgPriorityValue notSet = 0;
const nsMsgPriorityValue none = 1;
const nsMsgPriorityValue lowest = 2;
const nsMsgPriorityValue low = 3;
const nsMsgPriorityValue normal = 4;
const nsMsgPriorityValue high = 5;
const nsMsgPriorityValue highest = 6;
};