xpidlize nsIMsgSearchTerm

This commit is contained in:
alecf%netscape.com 2000-05-09 07:12:19 +00:00
parent e6a15f0510
commit 2f1cec3217
19 changed files with 292 additions and 197 deletions

View File

@ -25,6 +25,7 @@
#include "nsMsgFilterCore.idl"
#include "nsIMsgSearchScopeTerm.idl"
#include "nsIMsgSearchValue.idl"
#include "nsIMsgSearchTerm.idl"
interface nsOutputStream;
@ -51,6 +52,12 @@ interface nsIMsgFilter : nsISupports {
out boolean BooleanAND,
out string arbitraryHeader);
void appendTerm(in nsIMsgSearchTerm term);
void getSearchTerms(out unsigned long length,
[array, size_is(length), retval]
out nsIMsgSearchTerm termList);
attribute nsIMsgSearchScopeTerm scope;
attribute nsMsgRuleActionType action;
@ -60,9 +67,13 @@ interface nsIMsgFilter : nsISupports {
// target folder.. throws an exception if the action is not move to folder
attribute string actionTargetFolderUri;
void MatchHdr(in nsIMsgDBHdr msgHdr, in nsIMsgFolder folder,
in nsIMsgDatabase db, in string headers,
// marking noscript because "headers" is actually a null-seperated
// list of headers, which is not scriptable
[noscript] void MatchHdr(in nsIMsgDBHdr msgHdr, in nsIMsgFolder folder,
in nsIMsgDatabase db,
in string headers,
// [array, size_is(headerSize)] in string headers,
in unsigned long headerSize, out boolean result);
void LogRuleHit(in nsOutputStream stream, in nsIMsgDBHdr header);

View File

@ -73,12 +73,16 @@ interface nsIMsgFilterList : nsISupports {
void saveToFile(in nsIOFileStream stream);
// marking noscript because headers is a null-seperated list
// of strings, which is not scriptable
[noscript]
void applyFiltersToHdr(in nsMsgFilterTypeType filterType,
in nsIMsgDBHdr msgHdr,
in nsIMsgFolder folder,
in nsIMsgDatabase db,
in string headers,
in unsigned long headersSize,
//[array, size_is(headerSize)] in string headers,
in unsigned long headerSize,
in nsIMsgFilterHitNotify listener);
// IO routines, used by filter object filing code.

View File

@ -56,13 +56,16 @@ interface nsIMsgSearchTerm : nsISupports {
in nsIMsgDBHdr msg,
in nsIMsgDatabase db);
// marking noscript because headers is a null-seperated list of strings,
// which is not scriptable
[noscript]
boolean matchArbitraryHeader(in nsIMsgSearchScopeTerm scopeTerm,
in unsigned long offset,
in unsigned long length,
in string charset,
in nsIMsgDBHdr msg,
in nsIMsgDatabase db,
[array, size_is(headerLength)]
//[array, size_is(headerLength)] in string headers,
in string headers,
in unsigned long headerLength,
in boolean forFilters);

View File

@ -21,8 +21,10 @@ public:
// filtering...we need the list of headers and the header size as well
// if we are doing filtering...if ForFilters is false, headers and
// headersSize is ignored!!!
nsMsgBodyHandler (nsIMsgSearchScopeTerm *, PRUint32 offset, PRUint32 length, nsIMsgDBHdr * msg, nsIMsgDatabase * db,
const char * headers /* NULL terminated list of headers */, PRUint32 headersSize, PRBool ForFilters);
nsMsgBodyHandler (nsIMsgSearchScopeTerm *, PRUint32 offset,
PRUint32 length, nsIMsgDBHdr * msg, nsIMsgDatabase * db,
const char * headers /* NULL terminated list of headers */,
PRUint32 headersSize, PRBool ForFilters);
virtual ~nsMsgBodyHandler();

View File

@ -60,10 +60,10 @@ class nsMsgSearchBoolExpression
public:
// create a leaf node expression
nsMsgSearchBoolExpression(nsMsgSearchTerm * newTerm,
nsMsgSearchBoolExpression(nsIMsgSearchTerm * newTerm,
PRBool EvaluationValue = PR_TRUE,
char * encodingStr = NULL);
nsMsgSearchBoolExpression(nsMsgSearchTerm * newTerm, char * encodingStr);
nsMsgSearchBoolExpression(nsIMsgSearchTerm * newTerm, char * encodingStr);
// create a non-leaf node expression containing 2 expressions
// and a boolean operator
@ -78,9 +78,9 @@ public:
// accesors
// Offline
nsMsgSearchBoolExpression * AddSearchTerm (nsMsgSearchTerm * newTerm,
nsMsgSearchBoolExpression * AddSearchTerm (nsIMsgSearchTerm * newTerm,
PRBool EvaluationValue = PR_TRUE);
nsMsgSearchBoolExpression * AddSearchTerm (nsMsgSearchTerm * newTerm,
nsMsgSearchBoolExpression * AddSearchTerm (nsIMsgSearchTerm * newTerm,
char * encodingStr); // IMAP/NNTP
// parses the expression tree and all
@ -103,7 +103,7 @@ protected:
// if we are a leaf node, all we have is a search term
// and a Evaluation value for that search term
nsMsgSearchTerm * m_term;
nsIMsgSearchTerm * m_term;
PRBool m_evalValue;
// store IMAP/NNTP encoding for the search term if applicable
@ -124,7 +124,7 @@ protected:
// left to right evaluation so the tree is constructed to represent
// that by calling leftToRightAddTerm. If future forms of evaluation
// need to be supported, add new methods here for proper tree construction.
nsMsgSearchBoolExpression * leftToRightAddTerm(nsMsgSearchTerm * newTerm,
nsMsgSearchBoolExpression * leftToRightAddTerm(nsIMsgSearchTerm * newTerm,
PRBool EvaluationValue,
char * encodingStr);
};

View File

@ -189,7 +189,6 @@ typedef struct nsMsgSearchValue
nsMsgSearchAttribValue attribute;
union
{
char *string;
nsMsgPriorityValue priority;
PRTime date;
PRUint32 msgStatus; /* see MSG_FLAG in msgcom.h */
@ -198,6 +197,7 @@ typedef struct nsMsgSearchValue
PRUint32 age; /* in days */
nsIMsgFolder *folder;
} u;
char *string;
} nsMsgSearchValue;
%}

View File

@ -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
@ -31,10 +31,11 @@
// its own cpp file, nsMsgSearchTerm.cpp
#include "nsIMsgSearchSession.h"
#include "nsIMsgSearchScopeTerm.h"
#include "nsIMsgSearchTerm.h"
#define EMPTY_MESSAGE_LINE(buf) (buf[0] == CR || buf[0] == LF || buf[0] == '\0')
class nsMsgSearchTerm
class nsMsgSearchTerm : public nsIMsgSearchTerm
{
public:
nsMsgSearchTerm();
@ -45,31 +46,34 @@ public:
virtual ~nsMsgSearchTerm ();
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGSEARCHTERM
void StripQuotedPrintable (unsigned char*);
PRInt32 GetNextIMAPOfflineMsgLine (char * buf, int bufferSize, int msgOffset, nsIMessage * msg, nsIMsgDatabase * db);
nsresult MatchBody (nsIMsgSearchScopeTerm*, PRUint32 offset, PRUint32 length, const char *charset,
nsIMsgDBHdr * msg, nsIMsgDatabase * db, PRBool *pResult);
nsresult MatchArbitraryHeader (nsIMsgSearchScopeTerm *,
PRUint32 offset,
PRUint32 length,
const char *charset,
nsIMsgDBHdr * msg,
nsIMsgDatabase *db,
const char * headers, /* NULL terminated header list for msgs being filtered. Ignored unless ForFilters */
PRUint32 headersSize, /* size of the NULL terminated list of headers */
PRBool ForFilters /* true if we are filtering */,
PRBool *pResult);
nsresult MatchString (nsCString *, const char *charset, PRBool body, PRBool *result);
nsresult MatchDate (PRTime, PRBool *result);
nsresult MatchStatus (PRUint32, 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);
nsresult EnStreamNew (nsCString &stream);
// nsresult MatchBody (nsIMsgSearchScopeTerm*, PRUint32 offset, PRUint32 length, const char *charset,
// nsIMsgDBHdr * msg, nsIMsgDatabase * db, PRBool *pResult);
// nsresult MatchArbitraryHeader (nsIMsgSearchScopeTerm *,
// PRUint32 offset,
// PRUint32 length,
// const char *charset,
// nsIMsgDBHdr * msg,
// nsIMsgDatabase *db,
// const char * headers, /* NULL terminated header list for msgs being filtered. Ignored unless ForFilters */
// PRUint32 headersSize, /* size of the NULL terminated list of headers */
// PRBool ForFilters /* true if we are filtering */,
// PRBool *pResult);
// nsresult MatchString (nsCString *, const char *charset, PRBool body, PRBool *result);
// nsresult MatchDate (PRTime, PRBool *result);
// nsresult MatchStatus (PRUint32, 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);
nsresult DeStream (char *, PRInt16 length);
nsresult DeStreamNew (char *, PRInt16 length);
@ -81,7 +85,6 @@ public:
const char * GetArbitraryHeader() {return m_arbitraryHeader.GetBuffer();}
static char * EscapeQuotesInStr(const char *str);
PRBool MatchAllBeforeDeciding ();
nsCOMPtr<nsIMsgHeaderParser> m_headerAddressParser;

View File

@ -154,6 +154,7 @@ PRInt32 nsMsgBodyHandler::GetNextFilterLine(char * buf, PRUint32 bufSize)
// #mscott. Ugly hack! filter headers list have CRs & LFs inside the NULL delimited list of header
// strings. It is possible to have: To NULL CR LF From. We want to skip over these CR/LFs if they start
// at the beginning of what we think is another header.
while ((m_headers[0] == CR || m_headers[0] == LF || m_headers[0] == ' ' || m_headers[0] == '\0') && m_headersSize > 0)
{
m_headers++; // skip over these chars...

View File

@ -52,6 +52,7 @@ nsMsgFilter::nsMsgFilter() :
m_filterList(nsnull)
{
NS_INIT_REFCNT();
NS_NewISupportsArray(getter_AddRefs(m_termList));
}
nsMsgFilter::~nsMsgFilter()
@ -140,12 +141,21 @@ NS_IMETHODIMP nsMsgFilter::AddTerm(
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::AppendTerm(nsIMsgSearchTerm * aTerm)
{
NS_ENSURE_TRUE(aTerm, NS_ERROR_NULL_POINTER);
return m_termList->AppendElement(aTerm);
}
NS_IMETHODIMP nsMsgFilter::GetNumTerms(PRInt32 *aResult)
{
if (aResult == NULL)
return NS_ERROR_NULL_POINTER;
*aResult = m_termList.Count();
PRUint32 count;
m_termList->Count(&count);
*aResult = count;
return NS_OK;
}
@ -159,28 +169,49 @@ NS_IMETHODIMP nsMsgFilter::GetTerm(PRInt32 termIndex,
char ** arbitraryHeader) /* arbitrary header specified by user.
ignore unless attrib = attribOtherHeader */
{
nsresult rv;
if (!attrib || !op || !value || !booleanAnd || !arbitraryHeader)
return NS_ERROR_NULL_POINTER;
nsMsgSearchTerm *term = m_termList.ElementAt (termIndex);
if (term)
nsCOMPtr<nsIMsgSearchTerm> term;
rv = m_termList->QueryElementAt(termIndex, NS_GET_IID(nsIMsgSearchTerm),
(void **)getter_AddRefs(term));
if (NS_SUCCEEDED(rv) && term)
{
*attrib = term->m_attribute;
*op = term->m_operator;
term->GetAttrib(attrib);
term->GetOp(op);
// create the search value object
nsMsgSearchValueImpl *searchValue =
new nsMsgSearchValueImpl(&term->m_value);
*value = (nsIMsgSearchValue*)searchValue;
NS_ADDREF(*value);
*booleanAnd = term->m_booleanOp;
if (term->m_attribute == nsMsgSearchAttrib::OtherHeader)
*arbitraryHeader = PL_strdup(term->m_arbitraryHeader.GetBuffer());
term->GetValue(value);
term->GetBooleanAnd(booleanAnd);
if (*attrib == nsMsgSearchAttrib::OtherHeader)
term->GetArbitraryHeader(arbitraryHeader);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::GetSearchTerms(PRUint32 *aLength,
nsIMsgSearchTerm ***aResult)
{
NS_ENSURE_ARG_POINTER(aLength);
NS_ENSURE_ARG_POINTER(aResult);
PRUint32 terms; m_termList->Count(&terms);
nsIMsgSearchTerm** resultList = (nsIMsgSearchTerm**)
nsAllocator::Alloc(sizeof(nsIMsgSearchTerm*) * terms);
*aLength = terms;
PRUint32 i;
for (i=0; i<terms; i++)
m_termList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchTerm),
(void **)resultList[i]);
*aResult = resultList;
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::SetScope(nsIMsgSearchScopeTerm *aResult)
{
m_scope = aResult;
@ -480,24 +511,30 @@ nsresult nsMsgFilter::SaveRule()
break;
}
// and here the fun begins - file out term list...
int searchIndex;
PRUint32 searchIndex;
nsCAutoString condition;
for (searchIndex = 0; searchIndex < m_termList.Count() && NS_SUCCEEDED(err);
PRUint32 count;
m_termList->Count(&count);
for (searchIndex = 0; searchIndex < count && NS_SUCCEEDED(err);
searchIndex++)
{
nsCAutoString stream;
nsMsgSearchTerm * term = (nsMsgSearchTerm *) m_termList.ElementAt(searchIndex);
if (term == NULL)
nsCOMPtr<nsIMsgSearchTerm> term;
m_termList->QueryElementAt(searchIndex, NS_GET_IID(nsIMsgSearchTerm),
(void **)getter_AddRefs(term));
if (!term)
continue;
if (condition.Length() > 1)
condition += ' ';
if (term->m_booleanOp == nsMsgSearchBooleanOp::BooleanOR)
condition += "OR (";
else
PRBool booleanAnd;
term->GetBooleanAnd(&booleanAnd);
if (booleanAnd)
condition += "AND (";
else
condition += "OR (";
nsresult searchError = term->EnStreamNew(stream);
if (!NS_SUCCEEDED(searchError))

View File

@ -71,7 +71,6 @@ public:
PRInt16 GetVersion();
void SetDontFileMe(PRBool bDontFileMe) {m_dontFileMe = bDontFileMe;}
nsMsgSearchTermArray* GetTermList() {return &m_termList;} /* linked list of criteria terms */
#ifdef DEBUG
void Dump();
#endif
@ -90,7 +89,7 @@ protected:
PRBool m_dontFileMe;
nsIMsgFilterList *m_filterList; /* owning filter list */
nsMsgSearchTermArray m_termList; /* linked list of criteria terms */
nsCOMPtr<nsISupportsArray> m_termList; /* linked list of criteria terms */
nsCOMPtr<nsIMsgSearchScopeTerm> m_scope; /* default for mail rules is inbox, but news rules could
have a newsgroup - LDAP would be invalid */

View File

@ -549,7 +549,7 @@ nsresult nsMsgFilterList::ParseCondition(nsCString &value)
}
if (newTerm->DeStreamNew(termDup, PL_strlen(termDup)) == NS_OK)
m_curFilter->GetTermList()->AppendElement(newTerm);
m_curFilter->AppendTerm(newTerm);
}
PR_FREEIF(termDup);
}

View File

@ -87,7 +87,7 @@ NS_IMETHODIMP nsMsgSearchOnlineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
pHeaders->GetFlags(&flags);
char *reString = (flags & MSG_FLAG_HAS_RE) ? (char *)"Re:" : (char *)"";
pHeaders->GetSubject(getter_Copies(subject));
pValue->u.string = PR_smprintf ("%s%s", reString, (const char*) subject); // hack. invoke cast operator by force
pValue->string = PR_smprintf ("%s%s", reString, (const char*) subject); // hack. invoke cast operator by force
newResult->AddValue (pValue);
}
pValue = new nsMsgSearchValue;
@ -95,11 +95,11 @@ NS_IMETHODIMP nsMsgSearchOnlineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
{
nsXPIDLCString author;
pValue->attribute = nsMsgSearchAttrib::Sender;
pValue->u.string = (char*) PR_Malloc(64);
if (pValue->u.string)
pValue->string = (char*) PR_Malloc(64);
if (pValue->string)
{
pHeaders->GetAuthor(getter_Copies(author));
PL_strncpy(pValue->u.string, (const char *) author, 64);
PL_strncpy(pValue->string, (const char *) author, 64);
newResult->AddValue (pValue);
}
else
@ -257,7 +257,7 @@ nsresult nsMsgSearchOnlineMail::Encode (nsCString *pEncoding, nsMsgSearchTermArr
nsMsgSearchTerm *term = searchTerms.ElementAt(i);
if (IsStringAttribute(term->m_attribute))
{
char *pchar = term->m_value.u.string;
char *pchar = term->m_value.string;
for (; *pchar ; pchar++)
{
if (*pchar & 0x80)

View File

@ -57,7 +57,7 @@ nsMsgSearchBoolExpression::nsMsgSearchBoolExpression()
m_rightChild = nsnull;
}
nsMsgSearchBoolExpression::nsMsgSearchBoolExpression (nsMsgSearchTerm * newTerm, PRBool evalValue, char * encodingStr)
nsMsgSearchBoolExpression::nsMsgSearchBoolExpression (nsIMsgSearchTerm * newTerm, PRBool evalValue, char * encodingStr)
// we are creating an expression which contains a single search term (newTerm)
// and the search term's IMAP or NNTP encoding value for online search expressions AND
// a boolean evaluation value which is used for offline search expressions.
@ -93,14 +93,16 @@ nsMsgSearchBoolExpression::~nsMsgSearchBoolExpression()
delete m_rightChild;
}
nsMsgSearchBoolExpression * nsMsgSearchBoolExpression::AddSearchTerm(nsMsgSearchTerm * newTerm, char * encodingStr)
nsMsgSearchBoolExpression *
nsMsgSearchBoolExpression::AddSearchTerm(nsIMsgSearchTerm * newTerm, char * encodingStr)
// appropriately add the search term to the current expression and return a pointer to the
// new expression. The encodingStr is the IMAP/NNTP encoding string for newTerm.
{
return leftToRightAddTerm(newTerm,PR_FALSE,encodingStr);
}
nsMsgSearchBoolExpression * nsMsgSearchBoolExpression::AddSearchTerm(nsMsgSearchTerm * newTerm, PRBool evalValue)
nsMsgSearchBoolExpression *
nsMsgSearchBoolExpression::AddSearchTerm(nsIMsgSearchTerm * newTerm, PRBool evalValue)
// appropriately add the search term to the current expression
// Returns: a pointer to the new expression which includes this new search term
{
@ -108,7 +110,8 @@ nsMsgSearchBoolExpression * nsMsgSearchBoolExpression::AddSearchTerm(nsMsgSearch
// evaluate left to right.
}
nsMsgSearchBoolExpression * nsMsgSearchBoolExpression::leftToRightAddTerm(nsMsgSearchTerm * newTerm, PRBool evalValue, char * encodingStr)
nsMsgSearchBoolExpression *
nsMsgSearchBoolExpression::leftToRightAddTerm(nsIMsgSearchTerm * newTerm, PRBool evalValue, char * encodingStr)
{
// we have a base case where this is the first term being added to the expression:
if (!m_term && !m_leftChild && !m_rightChild)
@ -122,7 +125,9 @@ nsMsgSearchBoolExpression * nsMsgSearchBoolExpression::leftToRightAddTerm(nsMsgS
nsMsgSearchBoolExpression * tempExpr = new nsMsgSearchBoolExpression (newTerm,evalValue,encodingStr);
if (tempExpr) // make sure creation succeeded
{
nsMsgSearchBoolExpression * newExpr = new nsMsgSearchBoolExpression (this, tempExpr, newTerm->GetBooleanOp());
PRBool booleanAnd;
newTerm->GetBooleanAnd(&booleanAnd);
nsMsgSearchBoolExpression * newExpr = new nsMsgSearchBoolExpression (this, tempExpr, booleanAnd);
if (newExpr)
return newExpr;
else
@ -468,29 +473,31 @@ nsresult nsMsgSearchOfflineMail::SummaryFileError ()
return NS_OK;// SearchError_ScopeDone;
}
nsresult nsMsgSearchOfflineMail::MatchTermsForFilter(nsIMsgDBHdr *msgToMatch,
nsMsgSearchTermArray & termList,
nsIMsgSearchScopeTerm * scope,
nsIMsgDatabase * db,
const char * headers,
PRUint32 headerSize,
PRBool *pResult)
nsresult
nsMsgSearchOfflineMail::MatchTermsForFilter(nsIMsgDBHdr *msgToMatch,
nsISupportsArray *termList,
nsIMsgSearchScopeTerm * scope,
nsIMsgDatabase * db,
const char * headers,
PRUint32 headerSize,
PRBool *pResult)
{
return MatchTerms(msgToMatch, termList, scope, db, headers, headerSize, PR_TRUE, pResult);
}
// static method which matches a header against a list of search terms.
nsresult nsMsgSearchOfflineMail::MatchTermsForSearch(nsIMsgDBHdr *msgToMatch,
nsMsgSearchTermArray &termList,
nsIMsgSearchScopeTerm *scope,
nsIMsgDatabase *db,
PRBool *pResult)
nsresult
nsMsgSearchOfflineMail::MatchTermsForSearch(nsIMsgDBHdr *msgToMatch,
nsISupportsArray* termList,
nsIMsgSearchScopeTerm *scope,
nsIMsgDatabase *db,
PRBool *pResult)
{
return MatchTerms(msgToMatch, termList, scope, db, nsnull, 0, PR_FALSE, pResult);
}
nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
nsMsgSearchTermArray & termList,
nsISupportsArray * termList,
nsIMsgSearchScopeTerm * scope,
nsIMsgDatabase * db,
const char * headers,
@ -523,34 +530,40 @@ nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
nsMsgSearchBoolExpression * expression = new nsMsgSearchBoolExpression(); // create our expression
if (!expression)
return NS_ERROR_OUT_OF_MEMORY;
for (int i = 0; i < termList.Count(); i++)
PRUint32 count;
termList->Count(&count);
for (PRUint32 i = 0; i < count; i++)
{
nsMsgSearchTerm *pTerm = termList.ElementAt(i);
nsCOMPtr<nsIMsgSearchTerm> pTerm;
termList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchTerm),
(void **)getter_AddRefs(pTerm));
// NS_ASSERTION (pTerm->IsValid(), "invalid search term");
NS_ASSERTION (msgToMatch, "couldn't get term to match");
switch (pTerm->m_attribute)
nsMsgSearchAttribValue attrib;
pTerm->GetAttrib(&attrib);
switch (attrib)
{
case nsMsgSearchAttrib::Sender:
msgToMatch->GetAuthor(getter_Copies(matchString));
err = pTerm->MatchRfc822String (nsCAutoString(matchString), charset, &result);
err = pTerm->MatchRfc822String (matchString, charset, &result);
break;
case nsMsgSearchAttrib::Subject:
{
msgToMatch->GetSubject(getter_Copies(matchString) /* , PR_TRUE */);
nsCAutoString singleByteString(matchString);
err = pTerm->MatchString (&singleByteString, charset, PR_FALSE, &result);
err = pTerm->MatchString (matchString, charset, PR_FALSE, &result);
}
break;
case nsMsgSearchAttrib::ToOrCC:
{
PRBool boolKeepGoing = pTerm->MatchAllBeforeDeciding();
PRBool boolKeepGoing;
pTerm->GetMatchAllBeforeDeciding(&boolKeepGoing);
msgToMatch->GetRecipients(getter_Copies(recipients));
err = pTerm->MatchRfc822String (nsCAutoString(recipients), charset, &result);
err = pTerm->MatchRfc822String (recipients, charset, &result);
if (boolKeepGoing == result)
{
msgToMatch->GetCcList(getter_Copies(ccList));
err = pTerm->MatchRfc822String (nsCAutoString(ccList), charset, &result);
err = pTerm->MatchRfc822String (ccList, charset, &result);
}
}
break;
@ -730,7 +743,7 @@ NS_IMETHODIMP nsMsgSearchOfflineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
pValue->attribute = nsMsgSearchAttrib::Subject;
char *reString = (msgFlags & MSG_FLAG_HAS_RE) ? (char *)"Re: " : (char *)"";
pHeaders->GetSubject(getter_Copies(subject));
pValue->u.string = PR_smprintf ("%s%s", reString, (const char*)subject);
pValue->string = PR_smprintf ("%s%s", reString, (const char*)subject);
newResult->AddValue (pValue);
}
pValue = new nsMsgSearchValue;
@ -739,7 +752,7 @@ NS_IMETHODIMP nsMsgSearchOfflineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
pValue->attribute = nsMsgSearchAttrib::Sender;
nsXPIDLCString author;
pHeaders->GetAuthor(getter_Copies(author));
pValue->u.string = PL_strdup(author);
pValue->string = PL_strdup(author);
newResult->AddValue (pValue);
err = NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -44,15 +44,17 @@ public:
NS_IMETHOD Abort ();
NS_IMETHOD AddResultElement (nsIMsgDBHdr *);
static nsresult MatchTermsForFilter(nsIMsgDBHdr * msgToMatch,
nsMsgSearchTermArray &termList,
nsISupportsArray *termList,
nsIMsgSearchScopeTerm *scope,
nsIMsgDatabase * db,
const char * headers,
PRUint32 headerSize,
PRBool *pResult);
static nsresult MatchTermsForSearch(nsIMsgDBHdr * msgTomatch, nsMsgSearchTermArray & termList, nsIMsgSearchScopeTerm *scope,
nsIMsgDatabase *db, PRBool *pResult);
static nsresult MatchTermsForSearch(nsIMsgDBHdr * msgTomatch,
nsISupportsArray * termList,
nsIMsgSearchScopeTerm *scope,
nsIMsgDatabase *db, PRBool *pResult);
virtual nsresult BuildSummaryFile ();
virtual nsresult OpenSummaryFile ();
@ -62,7 +64,7 @@ public:
protected:
static nsresult MatchTerms(nsIMsgDBHdr *msgToMatch,
nsMsgSearchTermArray &termList,
nsISupportsArray *termList,
nsIMsgSearchScopeTerm *scope,
nsIMsgDatabase * db,
const char * headers,

View File

@ -551,12 +551,12 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsMsgSearchTerm *term, PRBool reall
dest_csid = INTL_DefaultMailCharSetID(dest_csid);
#endif
unconvertedValue = TryToConvertCharset(term->m_value.u.string,
unconvertedValue = TryToConvertCharset(term->m_value.string,
srcCharset,
destCharset,
reallyDredd);
if (!unconvertedValue)
unconvertedValue = nsCRT::strdup(term->m_value.u.string); // couldn't convert, send as is
unconvertedValue = nsCRT::strdup(term->m_value.string); // couldn't convert, send as is
value = reallyDredd ? EscapeSearchUrl (unconvertedValue) : EscapeImapSearchProtocol(unconvertedValue);
PR_Free(unconvertedValue);

View File

@ -158,7 +158,7 @@ char *nsMsgSearchNews::EncodeTerm (nsMsgSearchTerm *term)
// Do INTL_FormatNNTPXPATInRFC1522Format trick for non-ASCII string
// unsigned char *intlNonRFC1522Value = INTL_FormatNNTPXPATInNonRFC1522Format (wincsid, (unsigned char*)term->m_value.u.string);
char *intlNonRFC1522Value = nsCRT::strdup((const char*)term->m_value.u.string);
char *intlNonRFC1522Value = nsCRT::strdup((const char*)term->m_value.string);
if (!intlNonRFC1522Value)
return nsnull;
@ -427,7 +427,7 @@ void nsMsgSearchNews::ReportHit (nsIMsgDBHdr *pHeaders, const char *location)
pHeaders->GetFlags(&flags);
char *reString = (flags & MSG_FLAG_HAS_RE) ? (char *)"Re:" : (char *)"";
pHeaders->GetSubject(getter_Copies(subject));
pValue->u.string = PR_smprintf ("%s%s", reString, (const char*) subject); // hack. invoke cast operator by force
pValue->string = PR_smprintf ("%s%s", reString, (const char*) subject); // hack. invoke cast operator by force
newResult->AddValue (pValue);
}
pValue = new nsMsgSearchValue;
@ -435,11 +435,11 @@ void nsMsgSearchNews::ReportHit (nsIMsgDBHdr *pHeaders, const char *location)
{
pValue->attribute = nsMsgSearchAttrib::Sender;
nsXPIDLCString author;
pValue->u.string = (char*) PR_Malloc(64);
if (pValue->u.string)
pValue->string = (char*) PR_Malloc(64);
if (pValue->string)
{
pHeaders->GetAuthor(getter_Copies(author));
PL_strncpy(pValue->u.string, (const char *) author, 64);
PL_strncpy(pValue->string, (const char *) author, 64);
newResult->AddValue (pValue);
}
else
@ -470,7 +470,7 @@ void nsMsgSearchNews::ReportHit (nsIMsgDBHdr *pHeaders, const char *location)
if (pValue)
{
pValue->attribute = nsMsgSearchAttrib::Location;
pValue->u.string = PL_strdup(location);
pValue->string = PL_strdup(location);
newResult->AddValue (pValue);
}
pValue = new nsMsgSearchValue;
@ -484,12 +484,12 @@ void nsMsgSearchNews::ReportHit (nsIMsgDBHdr *pHeaders, const char *location)
if (pValue)
{
nsXPIDLCString messageId;
pValue->u.string = (char*) PR_Malloc(64);
if (pValue->u.string)
pValue->string = (char*) PR_Malloc(64);
if (pValue->string)
{
pValue->attribute = nsMsgSearchAttrib::MessageId;
pHeaders->GetMessageId(getter_Copies(messageId));
PL_strncpy(pValue->u.string, (const char *) messageId, 64);
PL_strncpy(pValue->string, (const char *) messageId, 64);
newResult->AddValue (pValue);
}
}

View File

@ -234,6 +234,7 @@ PRInt32 NS_MsgGetStatusValueFromName(char *name)
// Needed for DeStream method.
nsMsgSearchTerm::nsMsgSearchTerm()
{
NS_INIT_REFCNT();
}
#if 0
@ -244,6 +245,7 @@ nsMsgSearchTerm::nsMsgSearchTerm (
PRBool booleanAND,
char * arbitraryHeader)
{
NS_INIT_REFCNT();
m_operator = op;
m_booleanOp = (booleanAND) ? nsMsgSearchBooleanOp::BooleanAND : nsMsgSearchBooleanOp::BooleanOR;
if (attrib == nsMsgSearchAttrib::OtherHeader && arbitraryHeader)
@ -261,6 +263,7 @@ nsMsgSearchTerm::nsMsgSearchTerm (
nsMsgSearchBooleanOperator boolOp,
const char * arbitraryHeader)
{
NS_INIT_REFCNT();
m_operator = op;
m_attribute = attrib;
m_booleanOp = boolOp;
@ -273,10 +276,13 @@ nsMsgSearchTerm::nsMsgSearchTerm (
nsMsgSearchTerm::~nsMsgSearchTerm ()
{
if (IS_STRING_ATTRIBUTE (m_attribute))
PR_Free(m_value.u.string);
if (IS_STRING_ATTRIBUTE (m_attribute) && m_value.string)
PR_Free(m_value.string);
}
NS_IMPL_ISUPPORTS1(nsMsgSearchTerm, nsIMsgSearchTerm)
// Perhaps we could find a better place for this?
// Caller needs to free.
/* static */char *nsMsgSearchTerm::EscapeQuotesInStr(const char *str)
@ -304,18 +310,18 @@ nsMsgSearchTerm::~nsMsgSearchTerm ()
nsresult nsMsgSearchTerm::OutputValue(nsCString &outputStr)
{
if (IS_STRING_ATTRIBUTE(m_attribute))
if (IS_STRING_ATTRIBUTE(m_attribute) && m_value.string)
{
PRBool quoteVal = PR_FALSE;
// need to quote strings with ')' - filter code will escape quotes
if (PL_strchr(m_value.u.string, ')'))
if (PL_strchr(m_value.string, ')'))
{
quoteVal = PR_TRUE;
outputStr += "\"";
}
if (PL_strchr(m_value.u.string, '"'))
if (PL_strchr(m_value.string, '"'))
{
char *escapedString = nsMsgSearchTerm::EscapeQuotesInStr(m_value.u.string);
char *escapedString = nsMsgSearchTerm::EscapeQuotesInStr(m_value.string);
if (escapedString)
{
outputStr += escapedString;
@ -325,7 +331,7 @@ nsresult nsMsgSearchTerm::OutputValue(nsCString &outputStr)
}
else
{
outputStr += m_value.u.string;
outputStr += m_value.string;
}
if (quoteVal)
outputStr += "\"";
@ -420,9 +426,9 @@ nsresult nsMsgSearchTerm::ParseValue(char *inStream)
if (quoteVal && inStream[valueLen - 1] == '"')
valueLen--;
m_value.u.string = (char *) PR_Malloc(valueLen + 1);
PL_strncpy(m_value.u.string, inStream, valueLen + 1);
m_value.u.string[valueLen] = '\0';
m_value.string = (char *) PR_Malloc(valueLen + 1);
PL_strncpy(m_value.string, inStream, valueLen + 1);
m_value.string[valueLen] = '\0';
}
else
{
@ -581,9 +587,16 @@ void nsMsgSearchTerm::StripQuotedPrintable (unsigned char *src)
// Looks in the MessageDB for the user specified arbitrary header, if it finds the header, it then looks for a match against
// the value for the header.
nsresult nsMsgSearchTerm::MatchArbitraryHeader (nsIMsgSearchScopeTerm *scope, PRUint32 offset, PRUint32 length /* in lines*/, const char *charset,
nsIMsgDBHdr *msg, nsIMsgDatabase* db, const char * headers,
PRUint32 headersSize, PRBool ForFiltering, PRBool *pResult)
nsresult nsMsgSearchTerm::MatchArbitraryHeader (nsIMsgSearchScopeTerm *scope,
PRUint32 offset,
PRUint32 length /* in lines*/,
const char *charset,
nsIMsgDBHdr *msg,
nsIMsgDatabase* db,
const char * headers,
PRUint32 headersSize,
PRBool ForFiltering,
PRBool *pResult)
{
if (!pResult)
return NS_ERROR_NULL_POINTER;
@ -597,10 +610,7 @@ nsresult nsMsgSearchTerm::MatchArbitraryHeader (nsIMsgSearchScopeTerm *scope, PR
bodyHandler->SetStripHeaders (PR_FALSE);
if (MatchAllBeforeDeciding())
result = PR_TRUE;
else
result = PR_FALSE;
GetMatchAllBeforeDeciding(&result);
const int kBufSize = 512; // max size of a line??
char * buf = (char *) PR_Malloc(kBufSize);
@ -631,9 +641,8 @@ nsresult nsMsgSearchTerm::MatchArbitraryHeader (nsIMsgSearchScopeTerm *scope, PR
if (headerValue < buf_end && *headerValue) // make sure buf has info besides just the header
{
nsCAutoString headerStr (headerValue);
PRBool result2;
err = MatchString(&headerStr, charset, PR_FALSE, &result2); // match value with the other info...
err = MatchString(headerValue, charset, PR_FALSE, &result2); // match value with the other info...
if (result != result2) // if we found a match
{
searchingHeaders = PR_FALSE; // then stop examining the headers
@ -670,7 +679,7 @@ nsresult nsMsgSearchTerm::MatchBody (nsIMsgSearchScopeTerm *scope, PRUint32 offs
// Small hack so we don't look all through a message when someone has
// specified "BODY IS foo"
if ((length > 0) && (m_operator == nsMsgSearchOp::Is || m_operator == nsMsgSearchOp::Isnt))
length = PL_strlen (m_value.u.string);
length = PL_strlen (m_value.string);
nsMsgBodyHandler * bodyHan = new nsMsgBodyHandler (scope, offset, length, msg, db);
if (!bodyHan)
@ -694,10 +703,8 @@ nsresult nsMsgSearchTerm::MatchBody (nsIMsgSearchScopeTerm *scope, PRUint32 offs
// Change the sense of the loop so we don't bail out prematurely
// on negative terms. i.e. opDoesntContain must look at all lines
PRBool boolContinueLoop;
if (MatchAllBeforeDeciding())
result = boolContinueLoop = PR_TRUE;
else
result = boolContinueLoop = PR_FALSE;
GetMatchAllBeforeDeciding(&boolContinueLoop);
result = boolContinueLoop;
// If there's a '=' in the search term, then we're not going to do
// quoted printable decoding. Otherwise we assume everything is
@ -708,7 +715,7 @@ nsresult nsMsgSearchTerm::MatchBody (nsIMsgSearchScopeTerm *scope, PRUint32 offs
// bug fix #88935: for stateful csids like JIS, we don't want to decode
// quoted printable since it contains '='.
PRBool isQuotedPrintable = /*!(mail_csid & STATEFUL) && */
(PL_strchr (m_value.u.string, '=') == nsnull);
(PL_strchr (m_value.string, '=') == nsnull);
while (!endOfFile && result == boolContinueLoop)
{
@ -736,7 +743,7 @@ nsresult nsMsgSearchTerm::MatchBody (nsIMsgSearchScopeTerm *scope, PRUint32 offs
char startChar = (char) compare.CharAt(0);
if (startChar != CR && startChar != LF)
{
err = MatchString (&compare, nsnull, PR_TRUE, &result);
err = MatchString (compare, nsnull, PR_TRUE, &result);
lines++;
}
}
@ -758,7 +765,9 @@ nsresult nsMsgSearchTerm::MatchBody (nsIMsgSearchScopeTerm *scope, PRUint32 offs
// *pResult is PR_FALSE when strings don't match, PR_TRUE if they do.
nsresult nsMsgSearchTerm::MatchString (nsCString *stringToMatch, const char *charset, PRBool body, PRBool *pResult)
nsresult nsMsgSearchTerm::MatchString (const char *stringToMatch,
const char *charset,
PRBool body, PRBool *pResult)
{
if (!pResult)
return NS_ERROR_NULL_POINTER;
@ -772,27 +781,27 @@ nsresult nsMsgSearchTerm::MatchString (nsCString *stringToMatch, const char *cha
#ifdef DO_I18N
n_str = INTL_GetNormalizeStr(csid , (unsigned char*)m_value.u.string); // Always new buffer unless not enough memory
if (!body)
n_header = INTL_GetNormalizeStrFromRFC1522(csid , (unsigned char*)stringToMatch); // Always new buffer unless not enough memory
n_header = INTL_GetNormalizeStrFromRFC1522(csid , stringToMatch); // Always new buffer unless not enough memory
else
n_header = INTL_GetNormalizeStr(csid , (unsigned char*)stringToMatch); // Always new buffer unless not enough memory
n_header = INTL_GetNormalizeStr(csid , stringToMatch); // Always new buffer unless not enough memory
NS_ASSERTION(n_str, "failed get normalized string");
NS_ASSERTION(n_header, "failed get normalized header");
#else
n_header = *stringToMatch;
n_str = m_value.u.string;
n_header = stringToMatch;
n_str = m_value.string;
#endif // DO_I18N
}
switch (m_operator)
{
case nsMsgSearchOp::Contains:
if ((nsnull != n_header) && ((n_str.GetBuffer())[0]) && /* INTL_StrContains(csid, n_header, n_str) */
stringToMatch->Find(n_str, PR_TRUE) != -1)
PL_strstr(stringToMatch, n_str))
result = PR_TRUE;
break;
case nsMsgSearchOp::DoesntContain:
if ((nsnull != n_header) && ((n_str.GetBuffer())[0]) && /* !INTL_StrContains(csid, n_header, n_str) */
stringToMatch->Find(n_str, PR_TRUE) == -1)
PL_strstr(stringToMatch, n_str))
result = PR_TRUE;
break;
case nsMsgSearchOp::Is:
@ -800,7 +809,7 @@ nsresult nsMsgSearchTerm::MatchString (nsCString *stringToMatch, const char *cha
{
if ((n_str.GetBuffer())[0])
{
if (n_str.Equals(*stringToMatch, PR_TRUE /*ignore case*/) /* INTL_StrIs(csid, n_header, n_str)*/ )
if (n_str.Equals(stringToMatch, PR_TRUE /*ignore case*/) /* INTL_StrIs(csid, n_header, n_str)*/ )
result = PR_TRUE;
}
else if (n_header[0] == '\0') // Special case for "is <the empty string>"
@ -812,7 +821,7 @@ nsresult nsMsgSearchTerm::MatchString (nsCString *stringToMatch, const char *cha
{
if ((n_str.GetBuffer())[0])
{
if (!n_str.Equals(*stringToMatch, PR_TRUE)/* INTL_StrIs(csid, n_header, n_str)*/ )
if (!n_str.Equals(stringToMatch, PR_TRUE)/* INTL_StrIs(csid, n_header, n_str)*/ )
result = PR_TRUE;
}
else if (n_header[0] != '\0') // Special case for "isn't <the empty string>"
@ -820,7 +829,7 @@ nsresult nsMsgSearchTerm::MatchString (nsCString *stringToMatch, const char *cha
}
break;
case nsMsgSearchOp::IsEmpty:
if (stringToMatch->Length() == 0)
if (PL_strlen(stringToMatch))
result = PR_TRUE;
break;
case nsMsgSearchOp::BeginsWith:
@ -829,7 +838,7 @@ nsresult nsMsgSearchTerm::MatchString (nsCString *stringToMatch, const char *cha
result = PR_TRUE;
#else
// ### DMB - not the most efficient way to do this.
if (stringToMatch->Find(n_str, PR_TRUE) == 0)
if (PL_strncmp(stringToMatch, n_str, PL_strlen(stringToMatch)) == 0)
result = PR_TRUE;
#endif
break;
@ -851,11 +860,14 @@ nsresult nsMsgSearchTerm::MatchString (nsCString *stringToMatch, const char *cha
return err;
}
PRBool nsMsgSearchTerm::MatchAllBeforeDeciding ()
nsresult nsMsgSearchTerm::GetMatchAllBeforeDeciding (PRBool *aResult)
{
if (m_operator == nsMsgSearchOp::DoesntContain || m_operator == nsMsgSearchOp::Isnt)
return PR_TRUE;
return PR_FALSE;
*aResult = PR_TRUE;
else
*aResult = PR_FALSE;
return NS_OK;
}
@ -877,10 +889,8 @@ nsresult nsMsgSearchTerm::MatchRfc822String (const char *string, const char *cha
// Change the sense of the loop so we don't bail out prematurely
// on negative terms. i.e. opDoesntContain must look at all recipients
PRBool boolContinueLoop;
if (MatchAllBeforeDeciding())
result = boolContinueLoop = PR_TRUE;
else
result = boolContinueLoop = PR_FALSE;
GetMatchAllBeforeDeciding(&boolContinueLoop);
result = boolContinueLoop;
PRUint32 count;
nsresult parseErr = m_headerAddressParser->ParseHeaderAddresses(charset, string, &names, &addresses, &count) ;
@ -898,9 +908,9 @@ nsresult nsMsgSearchTerm::MatchRfc822String (const char *string, const char *cha
PRInt32 addressPos = 0;
for (PRUint32 i = 0; i < count && result == boolContinueLoop; i++)
{
err = MatchString (&walkNames, charset, PR_FALSE, &result);
err = MatchString (walkNames, charset, PR_FALSE, &result);
if (boolContinueLoop == result)
err = MatchString (&walkAddresses, charset, PR_FALSE, &result);
err = MatchString (walkAddresses, charset, PR_FALSE, &result);
namePos += walkNames.Length() + 1;
addressPos += walkAddresses.Length() + 1;
@ -1132,6 +1142,47 @@ nsresult nsMsgSearchTerm::InitHeaderAddressParser()
return res;
}
NS_IMETHODIMP
nsMsgSearchTerm::GetAttrib(nsMsgSearchAttribValue *aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = m_attribute;
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchTerm::GetOp(nsMsgSearchOpValue *aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = m_operator;
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchTerm::GetValue(nsIMsgSearchValue **aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = new nsMsgSearchValueImpl(&m_value);
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchTerm::GetBooleanAnd(PRBool *aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = (m_booleanOp == nsMsgSearchBooleanOp::BooleanAND);
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchTerm::GetArbitraryHeader(char* *aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = m_arbitraryHeader.ToNewCString();
return NS_OK;
}
//-----------------------------------------------------------------------------
// nsMsgSearchScopeTerm implementation
//-----------------------------------------------------------------------------
@ -1317,32 +1368,6 @@ nsMsgResultElement::nsMsgResultElement(nsIMsgSearchAdapter *adapter)
nsMsgResultElement::~nsMsgResultElement ()
{
#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++)
{
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)
{
char *url = XP_PlatformFileToURL (value->u.string);
char *tmp = url + PL_strlen("file://");
XP_FileRemove (tmp, xpMailFolder /*###phil hacky*/);
XP_FREE(url);
}
#endif
#if 0
nsMsgResultElement::DestroyValue (value);
#endif
}
#endif
}
@ -1360,12 +1385,6 @@ nsresult nsMsgResultElement::AddValue (nsMsgSearchValue *value)
return AddValue(valueImpl);
}
#if 0
nsresult nsMsgResultElement::DestroyValue (nsIMsgSearchValue *value)
{
return NS_OK;
}
#endif
nsresult nsMsgResultElement::AssignValues (nsIMsgSearchValue *src, nsMsgSearchValue *dst)
{
@ -1394,7 +1413,7 @@ nsresult nsMsgResultElement::AssignValues (nsIMsgSearchValue *src, nsMsgSearchVa
if (dst->attribute < nsMsgSearchAttrib::kNumMsgSearchAttributes)
{
NS_ASSERTION(IS_STRING_ATTRIBUTE(dst->attribute), "assigning non-string result");
err = src->GetStr(&dst->u.string);
err = src->GetStr(&dst->string);
}
else
err = NS_ERROR_INVALID_ARG;

View File

@ -29,13 +29,13 @@ nsMsgSearchValueImpl::nsMsgSearchValueImpl(nsMsgSearchValue *aInitialValue)
NS_INIT_ISUPPORTS();
mValue = *aInitialValue;
if (IS_STRING_ATTRIBUTE(aInitialValue->attribute))
mValue.u.string = nsCRT::strdup(aInitialValue->u.string);
mValue.string = nsCRT::strdup(aInitialValue->string);
}
nsMsgSearchValueImpl::~nsMsgSearchValueImpl()
{
if (IS_STRING_ATTRIBUTE(mValue.attribute))
nsCRT::free(mValue.u.string);
nsCRT::free(mValue.string);
}
@ -46,7 +46,7 @@ nsMsgSearchValueImpl::GetStr(char** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_TRUE(IS_STRING_ATTRIBUTE(mValue.attribute), NS_ERROR_ILLEGAL_VALUE);
*aResult = nsCRT::strdup(mValue.u.string);
*aResult = nsCRT::strdup(mValue.string);
return NS_OK;
}
@ -54,9 +54,9 @@ NS_IMETHODIMP
nsMsgSearchValueImpl::SetStr(const char* aValue)
{
NS_ENSURE_TRUE(IS_STRING_ATTRIBUTE(mValue.attribute), NS_ERROR_ILLEGAL_VALUE);
if (mValue.u.string)
nsCRT::free(mValue.u.string);
mValue.u.string = nsCRT::strdup(aValue);
if (mValue.string)
nsCRT::free(mValue.string);
mValue.string = nsCRT::strdup(aValue);
return NS_OK;
}
@ -200,7 +200,7 @@ nsMsgSearchValueImpl::ToString(PRUnichar **aResult)
NS_ENSURE_ARG_POINTER(aResult);
if (IS_STRING_ATTRIBUTE(mValue.attribute)) {
nsCAutoString str(mValue.u.string);
nsCAutoString str(mValue.string);
*aResult = str.ToNewUnicode();
return NS_OK;
}

View File

@ -30,6 +30,7 @@
class nsMsgSearchValueImpl : public nsIMsgSearchValue {
public:
nsMsgSearchValueImpl(nsMsgSearchValue *aInitialValue);
virtual ~nsMsgSearchValueImpl();
NS_DECL_ISUPPORTS