checkpoint search and filter stuff

This commit is contained in:
bienvenu%netscape.com 1999-05-28 00:26:55 +00:00
Родитель 284a4546f7
Коммит f33301eff9
13 изменённых файлов: 252 добавлений и 122 удалений

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

@ -1,77 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsIMsgFilter_H_
#define _nsIMsgFilter_H_
#include "nscore.h"
#include "nsISupports.h"
#include "nsMsgFilterCore.h"
class nsOutputStream;
class nsIMsgDBHdr;
// 605db0f8-04a1-11d3-a50a-0060b0fc04b7
#define NS_IMSGFILTER_IID \
{ 0x605db0f8, 0x04a1, 0x11d3, \
{ 0xa5, 0x0a, 0x0, 0x60, 0xb0, 0xfc, 0x04, 0xb7 } }
class nsIMsgFilter : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IMSGFILTER_IID; return iid; }
NS_IMETHOD GetFilterType(nsMsgFilterType *filterType)= 0;
NS_IMETHOD EnableFilter(PRBool enable)= 0;
NS_IMETHOD IsFilterEnabled(PRBool *enabled)= 0;
NS_IMETHOD GetFilterName(char **name)= 0;
NS_IMETHOD SetFilterName(char *name)= 0;
NS_IMETHOD GetFilterDesc(char **description)= 0;
NS_IMETHOD SetFilterDesc(char *description)= 0;
NS_IMETHOD AddTerm(
nsMsgSearchAttribute attrib, /* attribute for this term */
nsMsgSearchOperator op, /* operator e.g. opContains */
nsMsgSearchValue *value, /* value e.g. "Dogbert" */
PRBool BooleanAND, /* TRUE if AND is the boolean operator. FALSE if OR is the boolean operators */
char * arbitraryHeader)= 0; /* arbitrary header specified by user. ignored unless attrib = attribOtherHeader */
NS_IMETHOD GetNumTerms(PRInt32 *numTerms)= 0;
NS_IMETHOD GetTerm(PRInt32 termIndex,
nsMsgSearchAttribute *attrib, /* attribute for this term */
nsMsgSearchOperator *op, /* operator e.g. opContains */
nsMsgSearchValue *value, /* value e.g. "Dogbert" */
PRBool *BooleanAnd, /* TRUE if AND is the boolean operator. FALSE if OR is the boolean operator */
char ** arbitraryHeader)= 0; /* arbitrary header specified by user. ignore unless attrib = attribOtherHeader */
NS_IMETHOD SetScope(nsMsgScopeTerm *scope)= 0;
NS_IMETHOD GetScope(nsMsgScopeTerm **scope)= 0;
/* if type is acChangePriority, value is a pointer to priority.
If type is acMoveToFolder, value is pointer to folder name.
Otherwise, value is ignored.
*/
NS_IMETHOD SetAction(nsMsgRuleActionType type, void *value)= 0;
NS_IMETHOD GetAction(nsMsgRuleActionType *type, void **value) = 0;
NS_IMETHOD MatchHdr(nsIMsgDBHdr *msgHdr, char *headers, PRUint32 headersSize) = 0;
NS_IMETHOD LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *header) = 0;
};
#endif

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

@ -34,7 +34,7 @@ class nsIMsgSearchAdapter : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IMSGSEARCHADAPTOR_IID; return iid; }
NS_IMETHOD Init(nsMsgScopeTerm* scope, nsMsgSearchTermArray *terms) = 0;
NS_IMETHOD Init(nsMsgSearchScopeTerm* scope, nsMsgSearchTermArray *terms) = 0;
NS_IMETHOD ValidateTerms () = 0;
NS_IMETHOD Search () = 0;
NS_IMETHOD SendUrl () = 0;
@ -42,6 +42,7 @@ public:
NS_IMETHOD ModifyResultElement (nsMsgResultElement*, nsMsgSearchValue*) = 0;
NS_IMETHOD GetEncoding (const char **encoding) = 0;
NS_IMETHOD FindTargetFolder (const nsMsgResultElement *, nsIMsgFolder **aFolder) = 0;
NS_IMETHOD Abort () = 0;
};

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

@ -20,6 +20,7 @@
#define _nsMsgSearchAdapter_H_
#include "nsMsgSearchCore.h"
#include "nsIMsgSearchAdapter.h"
//-----------------------------------------------------------------------------
// These Adapter classes contain the smarts to convert search criteria from
@ -33,7 +34,7 @@
class nsMsgSearchAdapter : public nsIMsgSearchAdapter
{
public:
nsMsgSearchAdapter (nsMsgScopeTerm*, nsMsgSearchTermArray&);
nsMsgSearchAdapter (nsMsgSearchScopeTerm*, nsMsgSearchTermArray&);
virtual ~nsMsgSearchAdapter ();
NS_IMETHOD ValidateTerms ();
@ -44,11 +45,11 @@ public:
NS_IMETHOD GetEncoding (const char **encoding) { return NS_OK; }
NS_IMETHOD FindTargetFolder (nsMsgResultElement*, nsIMsgFolder **aFolder);
NS_IMETHOD Abort ();
nsMsgScopeTerm *m_scope;
nsMsgSearchScopeTerm *m_scope;
nsMsgSearchTermArray &m_searchTerms;
virtual int Abort ();
PRBool m_abortCalled;
static nsresult EncodeImap (char **ppEncoding,

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

@ -26,7 +26,7 @@
class nsIMsgDatabase;
class nsIMsgFolder;
class nsMsgSearchAdapter;
class nsIMsgSearchAdapter;
class nsIMsgDBHdr;
typedef enum
@ -174,7 +174,7 @@ typedef struct nsMsgSearchValue
} u;
} nsMsgSearchValue;
struct nsMsgScopeTerm;
class nsMsgSearchScopeTerm;
struct nsMsgDIRServer;
class nsMsgSearchTerm;
@ -190,10 +190,10 @@ public:
nsMsgSearchValue *ElementAt(PRUint32 i) const { return (nsMsgSearchValue*) nsVoidArray::ElementAt(i); }
};
class nsMsgScopeTermArray : public nsVoidArray
class nsMsgSearchScopeTermArray : public nsVoidArray
{
public:
nsMsgScopeTerm *ElementAt(PRUint32 i) const { return (nsMsgScopeTerm*) nsVoidArray::ElementAt(i); }
nsMsgSearchScopeTerm *ElementAt(PRUint32 i) const { return (nsMsgSearchScopeTerm*) nsVoidArray::ElementAt(i); }
};
//-----------------------------------------------------------------------------
@ -271,6 +271,31 @@ protected:
nsMsgSearchBoolExpression * leftToRightAddTerm(nsMsgSearchTerm * newTerm, PRBool EvaluationValue, char * encodingStr);
};
class nsMsgSearchScopeTerm
{
public:
nsMsgSearchScopeTerm (nsMsgSearchScopeAttribute, nsIMsgFolder *);
nsMsgSearchScopeTerm ();
virtual ~nsMsgSearchScopeTerm ();
PRBool IsOfflineNews();
PRBool IsOfflineMail ();
PRBool IsOfflineIMAPMail(); // added by mscott
const char *GetMailPath();
nsresult TimeSlice ();
nsresult InitializeAdapter (nsMsgSearchTermArray &termList);
char *GetStatusBarName ();
nsMsgSearchScopeAttribute m_attribute;
char *m_name;
nsCOMPtr <nsIMsgFolder> m_folder;
// XP_File m_file;
nsCOMPtr <nsIMsgSearchAdapter> m_adapter;
PRBool m_searchServer;
};
// nsMsgResultElement specifies a single search hit.
@ -283,7 +308,7 @@ protected:
class nsMsgResultElement
{
public:
nsMsgResultElement (nsMsgSearchAdapter *);
nsMsgResultElement (nsIMsgSearchAdapter *);
virtual ~nsMsgResultElement ();
static nsresult AssignValues (nsMsgSearchValue *src, nsMsgSearchValue *dst);
@ -303,7 +328,7 @@ public:
static nsresult DestroyValue (nsMsgSearchValue *value);
nsMsgSearchValueArray m_valueList;
nsMsgSearchAdapter *m_adapter;
nsIMsgSearchAdapter *m_adapter;
protected:
};
@ -338,8 +363,8 @@ public:
PRInt32 GetNextIMAPOfflineMsgLine (char * buf, int bufferSize, int msgOffset, nsIMessage * msg, nsIMsgDatabase * db);
nsresult MatchBody (nsMsgScopeTerm*, PRUint32 offset, PRUint32 length, const char *charset, nsIMsgDBHdr * msg, nsIMsgDatabase * db);
nsresult MatchArbitraryHeader (nsMsgScopeTerm *,PRUint32 offset, PRUint32 length, const char *charset, nsIMsgDBHdr * msg, nsIMsgDatabase *db,
nsresult MatchBody (nsMsgSearchScopeTerm*, PRUint32 offset, PRUint32 length, const char *charset, nsIMsgDBHdr * msg, nsIMsgDatabase * db);
nsresult MatchArbitraryHeader (nsMsgSearchScopeTerm *,PRUint32 offset, PRUint32 length, const char *charset, nsIMsgDBHdr * msg, nsIMsgDatabase *db,
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 */);
@ -400,11 +425,11 @@ typedef struct nsMsgSearchMenuItem
class nsMsgBodyHandler
{
public:
nsMsgBodyHandler (nsMsgScopeTerm *, PRUint32 offset, PRUint32 length, nsIMsgDBHdr * msg, nsIMsgDatabase * db);
nsMsgBodyHandler (nsMsgSearchScopeTerm *, PRUint32 offset, PRUint32 length, nsIMsgDBHdr * msg, nsIMsgDatabase * db);
// we can also create a body handler when doing arbitrary header 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 (nsMsgScopeTerm *, PRUint32 offset, PRUint32 length, nsIMsgDBHdr * msg, nsIMsgDatabase * db,
nsMsgBodyHandler (nsMsgSearchScopeTerm *, PRUint32 offset, PRUint32 length, nsIMsgDBHdr * msg, nsIMsgDatabase * db,
char * headers /* NULL terminated list of headers */, PRUint32 headersSize, PRBool ForFilters);
virtual ~nsMsgBodyHandler();
@ -430,7 +455,7 @@ protected:
void OpenLocalFolder();
PRInt32 GetNextLocalLine(char * buf, int bufSize); // goes through the mail folder
nsMsgScopeTerm *m_scope;
nsMsgSearchScopeTerm *m_scope;
// local file state
// XP_File *m_localFile;

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

@ -35,6 +35,7 @@ CPPSRCS = \
nsMsgSearchTerm.cpp\
nsMsgBodyHandler.cpp\
nsMsgLocalSearch.cpp\
nsMsgSearchAdapter.cpp\
$(NULL)
EXTRA_DSO_LDOPTS = \

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

@ -32,6 +32,7 @@ CPPSRCS= nsMsgFilterService.cpp\
nsMsgSearchTerm.cpp\
nsMsgBodyHandler.cpp\
nsMsgLocalSearch.cpp\
nsMsgSearchAdapter.cpp\
$(NULL)
CPP_OBJS= .\$(OBJDIR)\nsMsgFilterService.obj \
@ -40,6 +41,7 @@ CPP_OBJS= .\$(OBJDIR)\nsMsgFilterService.obj \
.\$(OBJDIR)\nsMsgSearchTerm.obj\
.\$(OBJDIR)\nsMsgBodyHandler.obj\
.\$(OBJDIR)\nsMsgLocalSearch.obj\
.\$(OBJDIR)\nsMsgSearchAdapter.obj\
$(NULL)

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

@ -20,7 +20,7 @@
#include "nsMsgSearchCore.h"
#include "nsMsgUtils.h"
nsMsgBodyHandler::nsMsgBodyHandler (nsMsgScopeTerm * scope, PRUint32 offset, PRUint32 numLines, nsIMsgDBHdr* msg, nsIMsgDatabase * db)
nsMsgBodyHandler::nsMsgBodyHandler (nsMsgSearchScopeTerm * scope, PRUint32 offset, PRUint32 numLines, nsIMsgDBHdr* msg, nsIMsgDatabase * db)
{
m_scope = scope;
m_localFileOffset = offset;
@ -43,7 +43,7 @@ nsMsgBodyHandler::nsMsgBodyHandler (nsMsgScopeTerm * scope, PRUint32 offset, PRU
#endif
}
nsMsgBodyHandler::nsMsgBodyHandler(nsMsgScopeTerm * scope, PRUint32 offset, PRUint32 numLines, nsIMsgDBHdr* msg, nsIMsgDatabase* db,
nsMsgBodyHandler::nsMsgBodyHandler(nsMsgSearchScopeTerm * scope, PRUint32 offset, PRUint32 numLines, nsIMsgDBHdr* msg, nsIMsgDatabase* db,
char * headers, PRUint32 headersSize, PRBool Filtering)
{
m_scope = scope;

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

@ -23,6 +23,7 @@
#include "nsMsgFilter.h"
#include "nsMsgUtils.h"
#include "nsFileStream.h"
#include "nsMsgLocalSearch.h"
static const char *kImapPrefix = "//imap:";
@ -55,18 +56,27 @@ NS_IMETHODIMP nsMsgFilter::QueryInterface(REFNSIID aIID, void** aResult)
return NS_NOINTERFACE;
}
NS_IMETHODIMP nsMsgFilter::GetFilterType(nsMsgFilterType *filterType)
NS_IMETHODIMP nsMsgFilter::GetFilterType(nsMsgFilterType *aResult)
{
if (aResult == NULL)
return NS_ERROR_NULL_POINTER;
*aResult = m_type;
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::EnableFilter(PRBool enable)
{
m_enabled = enable;
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::IsFilterEnabled(PRBool *enabled)
NS_IMETHODIMP nsMsgFilter::IsFilterEnabled(PRBool *aResult)
{
if (aResult == NULL)
return NS_ERROR_NULL_POINTER;
*aResult = m_enabled;
return NS_OK;
}
@ -100,8 +110,12 @@ NS_IMETHODIMP nsMsgFilter::AddTerm(
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::GetNumTerms(PRInt32 *numTerms)
NS_IMETHODIMP nsMsgFilter::GetNumTerms(PRInt32 *aResult)
{
if (aResult == NULL)
return NS_ERROR_NULL_POINTER;
*aResult = m_termList.Count();
return NS_OK;
}
@ -110,19 +124,37 @@ NS_IMETHODIMP nsMsgFilter::GetTerm(PRInt32 termIndex,
nsMsgSearchAttribute *attrib, /* attribute for this term */
nsMsgSearchOperator *op, /* operator e.g. opContains */
nsMsgSearchValue *value, /* value e.g. "Dogbert" */
PRBool *BooleanAnd, /* TRUE if AND is the boolean operator. FALSE if OR is the boolean operator */
PRBool *booleanAnd, /* TRUE if AND is the boolean operator. FALSE if OR is the boolean operator */
char ** arbitraryHeader) /* arbitrary header specified by user. ignore unless attrib = attribOtherHeader */
{
if (!attrib || !op || !value || !booleanAnd || !arbitraryHeader)
return NS_ERROR_NULL_POINTER;
nsMsgSearchTerm *term = m_termList.ElementAt (termIndex);
if (term)
{
*attrib = term->m_attribute;
*op = term->m_operator;
*value = term->m_value;
*booleanAnd = term->m_booleanOp;
if (term->m_attribute == nsMsgSearchAttribOtherHeader)
*arbitraryHeader = PL_strdup(term->m_arbitraryHeader.GetBuffer());
}
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::SetScope(nsMsgScopeTerm *scope)
NS_IMETHODIMP nsMsgFilter::SetScope(nsMsgSearchScopeTerm *aResult)
{
m_scope = aResult;
return NS_OK;
}
NS_IMETHODIMP nsMsgFilter::GetScope(nsMsgScopeTerm **scope)
NS_IMETHODIMP nsMsgFilter::GetScope(nsMsgSearchScopeTerm **aResult)
{
if (aResult == NULL)
return NS_ERROR_NULL_POINTER;
*aResult = m_scope;
return NS_OK;
}
@ -220,9 +252,15 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd
}
NS_IMETHODIMP nsMsgFilter::MatchHdr(nsIMsgDBHdr *msgHdr, char *headers, PRUint32 headersSize)
NS_IMETHODIMP nsMsgFilter::MatchHdr(nsIMsgDBHdr *msgHdr, nsIMsgFolder *folder, nsIMsgDatabase *db, char *headers, PRUint32 headersSize)
{
return NS_ERROR_NOT_IMPLEMENTED;
nsMsgSearchScopeTerm scope (nsMsgSearchScopeMailFolder, folder);
return nsMsgSearchOfflineMail::MatchTermsForFilter(msgHdr, m_termList,
&scope,
db,
headers,
headersSize);
}
void nsMsgFilter::SetFilterList(nsMsgFilterList *filterList)

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

@ -67,8 +67,8 @@ public:
PRBool *BooleanAnd, /* TRUE if AND is the boolean operator. FALSE if OR is the boolean operator */
char ** arbitraryHeader); /* arbitrary header specified by user. ignore unless attrib = attribOtherHeader */
NS_IMETHOD SetScope(nsMsgScopeTerm *scope);
NS_IMETHOD GetScope(nsMsgScopeTerm **scope);
NS_IMETHOD SetScope(nsMsgSearchScopeTerm *scope);
NS_IMETHOD GetScope(nsMsgSearchScopeTerm **scope);
/* if type is acChangePriority, value is a pointer to priority.
If type is acMoveToFolder, value is pointer to folder name.
@ -76,7 +76,7 @@ public:
*/
NS_IMETHOD SetAction(nsMsgRuleActionType type, void *value);
NS_IMETHOD GetAction(nsMsgRuleActionType *type, void **value) ;
NS_IMETHOD MatchHdr(nsIMsgDBHdr *msgHdr, char *headers, PRUint32 headersSize) ;
NS_IMETHOD MatchHdr(nsIMsgDBHdr *msgHdr, nsIMsgFolder *folder, nsIMsgDatabase *db, char *headers, PRUint32 headersSize) ;
NS_IMETHOD LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *header);
@ -122,7 +122,7 @@ protected:
nsMsgFilterList *m_filterList; /* owning filter list */
nsMsgSearchTermArray m_termList; /* linked list of criteria terms */
nsMsgScopeTerm *m_scope; /* default for mail rules is inbox, but news rules could
nsMsgSearchScopeTerm *m_scope; /* default for mail rules is inbox, but news rules could
have a newsgroup - LDAP would be invalid */
};

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

@ -217,7 +217,7 @@ PRInt32 nsMsgSearchBoolExpression::GenerateEncodeStr(nsString2 * buffer)
//---------------- Adapter class for searching offline IMAP folders -----------
//-----------------------------------------------------------------------------
nsMsgSearchIMAPOfflineMail::nsMsgSearchIMAPOfflineMail (nsMsgScopeTerm *scope, nsMsgSearchTermArray &termList) : nsMsgSearchOfflineMail(scope, termList)
nsMsgSearchIMAPOfflineMail::nsMsgSearchIMAPOfflineMail (nsMsgSearchScopeTerm *scope, nsMsgSearchTermArray &termList) : nsMsgSearchOfflineMail(scope, termList)
{
}
@ -266,7 +266,7 @@ nsresult nsMsgSearchIMAPOfflineMail::ValidateTerms ()
//-----------------------------------------------------------------------------
nsMsgSearchOfflineMail::nsMsgSearchOfflineMail (nsMsgScopeTerm *scope, nsMsgSearchTermArray &termList) : nsMsgSearchAdapter (scope, termList)
nsMsgSearchOfflineMail::nsMsgSearchOfflineMail (nsMsgSearchScopeTerm *scope, nsMsgSearchTermArray &termList) : nsMsgSearchAdapter (scope, termList)
{
m_db = nsnull;
m_listContext = nsnull;
@ -445,7 +445,7 @@ nsresult nsMsgSearchOfflineMail::SummaryFileError ()
nsresult nsMsgSearchOfflineMail::MatchTermsForFilter(nsIMsgDBHdr *msgToMatch,
nsMsgSearchTermArray & termList,
nsMsgScopeTerm * scope,
nsMsgSearchScopeTerm * scope,
nsIMsgDatabase * db,
char * headers,
PRUint32 headerSize)
@ -456,7 +456,7 @@ nsresult nsMsgSearchOfflineMail::MatchTermsForFilter(nsIMsgDBHdr *msgToMatch,
// static method which matches a header against a list of search terms.
nsresult nsMsgSearchOfflineMail::MatchTermsForSearch(nsIMsgDBHdr *msgToMatch,
nsMsgSearchTermArray &termList,
nsMsgScopeTerm *scope,
nsMsgSearchScopeTerm *scope,
nsIMsgDatabase *db)
{
return MatchTerms(msgToMatch, termList, scope, db, nsnull, 0, FALSE);
@ -464,7 +464,7 @@ nsresult nsMsgSearchOfflineMail::MatchTermsForSearch(nsIMsgDBHdr *msgToMatch,
nsresult nsMsgSearchOfflineMail::MatchTerms(nsIMsgDBHdr *msgToMatch,
nsMsgSearchTermArray & termList,
nsMsgScopeTerm * scope,
nsMsgSearchScopeTerm * scope,
nsIMsgDatabase * db,
char * headers,
PRUint32 headerSize,
@ -761,7 +761,7 @@ nsresult nsMsgSearchOfflineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
return err;
}
int
NS_IMETHODIMP
nsMsgSearchOfflineMail::Abort ()
{
// Let go of the DB when we're done with it so we don't kill the db cache

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

@ -30,16 +30,17 @@ class nsMsgMailboxParser;
class nsMsgSearchOfflineMail : public nsMsgSearchAdapter
{
public:
nsMsgSearchOfflineMail (nsMsgScopeTerm*, nsMsgSearchTermArray&);
nsMsgSearchOfflineMail (nsMsgSearchScopeTerm*, nsMsgSearchTermArray&);
virtual ~nsMsgSearchOfflineMail ();
NS_IMETHOD ValidateTerms ();
NS_IMETHOD Search ();
static nsresult MatchTermsForFilter(nsIMsgDBHdr * msgToMatch,nsMsgSearchTermArray &termList, nsMsgScopeTerm *scope,
NS_IMETHOD Abort ();
static nsresult MatchTermsForFilter(nsIMsgDBHdr * msgToMatch,nsMsgSearchTermArray &termList, nsMsgSearchScopeTerm *scope,
nsIMsgDatabase * db,
char * headers, PRUint32 headerSize);
static nsresult MatchTermsForSearch(nsIMsgDBHdr * msgTomatch, nsMsgSearchTermArray & termList, nsMsgScopeTerm *scope,
static nsresult MatchTermsForSearch(nsIMsgDBHdr * msgTomatch, nsMsgSearchTermArray & termList, nsMsgSearchScopeTerm *scope,
nsIMsgDatabase *db);
virtual nsresult BuildSummaryFile ();
@ -48,10 +49,9 @@ public:
nsresult AddResultElement (nsIMsgDBHdr *);
virtual int Abort ();
protected:
static nsresult MatchTerms(nsIMsgDBHdr *msgToMatch,nsMsgSearchTermArray &termList, nsMsgScopeTerm *scope,
static nsresult MatchTerms(nsIMsgDBHdr *msgToMatch,nsMsgSearchTermArray &termList, nsMsgSearchScopeTerm *scope,
nsIMsgDatabase * db,
char * headers, PRUint32 headerSize, PRBool ForFilters);
struct ListContext *m_cursor;
@ -73,7 +73,7 @@ protected:
class nsMsgSearchIMAPOfflineMail : public nsMsgSearchOfflineMail
{
public:
nsMsgSearchIMAPOfflineMail (nsMsgScopeTerm*, nsMsgSearchTermArray&);
nsMsgSearchIMAPOfflineMail (nsMsgSearchScopeTerm*, nsMsgSearchTermArray&);
virtual ~nsMsgSearchIMAPOfflineMail ();
NS_IMETHOD ValidateTerms ();
@ -84,7 +84,7 @@ public:
class nsMsgSearchOfflineNews : public nsMsgSearchOfflineMail
{
public:
nsMsgSearchOfflineNews (nsMsgScopeTerm*, nsMsgSearchTermArray&);
nsMsgSearchOfflineNews (nsMsgSearchScopeTerm*, nsMsgSearchTermArray&);
virtual ~nsMsgSearchOfflineNews ();
NS_IMETHOD ValidateTerms ();

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

@ -0,0 +1,56 @@
/* -*- 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.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "msgCore.h"
#include "nsMsgSearchCore.h"
#include "nsMsgSearchAdapter.h"
NS_IMETHODIMP nsMsgSearchAdapter::FindTargetFolder(nsMsgResultElement *,nsIMsgFolder * *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgSearchAdapter::ModifyResultElement(nsMsgResultElement *, nsMsgSearchValue *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgSearchAdapter::OpenResultElement(nsMsgResultElement *)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsMsgSearchAdapter::nsMsgSearchAdapter(nsMsgSearchScopeTerm *scope, nsMsgSearchTermArray &searchTerms)
: m_searchTerms(searchTerms)
{
}
nsMsgSearchAdapter::~nsMsgSearchAdapter()
{
}
NS_IMETHODIMP nsMsgSearchAdapter::ValidateTerms ()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgSearchAdapter::Abort ()
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -572,7 +572,7 @@ 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 (nsMsgScopeTerm *scope, PRUint32 offset, PRUint32 length /* in lines*/, const char *charset,
nsresult nsMsgSearchTerm::MatchArbitraryHeader (nsMsgSearchScopeTerm *scope, PRUint32 offset, PRUint32 length /* in lines*/, const char *charset,
nsIMsgDBHdr *msg, nsIMsgDatabase* db, char * headers, PRUint32 headersSize, PRBool ForFiltering)
{
nsresult err = NS_COMFALSE;
@ -641,7 +641,7 @@ nsresult nsMsgSearchTerm::MatchArbitraryHeader (nsMsgScopeTerm *scope, PRUint32
}
}
nsresult nsMsgSearchTerm::MatchBody (nsMsgScopeTerm *scope, PRUint32 offset, PRUint32 length /*in lines*/, const char *folderCharset,
nsresult nsMsgSearchTerm::MatchBody (nsMsgSearchScopeTerm *scope, PRUint32 offset, PRUint32 length /*in lines*/, const char *folderCharset,
nsIMsgDBHdr *msg, nsIMsgDatabase* db)
{
nsresult err = NS_COMFALSE;
@ -1081,12 +1081,95 @@ nsresult nsMsgSearchTerm::InitHeaderAddressParser()
return res;
}
//-----------------------------------------------------------------------------
// nsMsgSearchScopeTerm implementation
//-----------------------------------------------------------------------------
nsMsgSearchScopeTerm::nsMsgSearchScopeTerm (nsMsgSearchScopeAttribute attribute, nsIMsgFolder *folder)
{
m_attribute = attribute;
m_folder = folder;
m_searchServer = PR_TRUE;
}
nsMsgSearchScopeTerm::nsMsgSearchScopeTerm ()
{
m_searchServer = PR_TRUE;
}
nsMsgSearchScopeTerm::~nsMsgSearchScopeTerm ()
{
}
// ### purely temporary
static NET_IsOffline()
{
return PR_FALSE;
}
PRBool nsMsgSearchScopeTerm::IsOfflineNews()
{
switch (m_attribute)
{
case nsMsgSearchScopeNewsgroup:
case nsMsgSearchScopeAllSearchableGroups:
if (NET_IsOffline() || !m_searchServer)
return PR_TRUE;
else
return PR_FALSE;
case nsMsgSearchScopeOfflineNewsgroup:
return PR_TRUE;
default:
return PR_FALSE;
}
}
PRBool nsMsgSearchScopeTerm::IsOfflineMail ()
{
// Find out whether "this" mail folder is online or offline
NS_ASSERTION(m_folder, "scope doesn't have folder");
// if (m_folder->GetType() == FOLDER_IMAPMAIL && !NET_IsOffline() && m_searchServer) // make sure we are not in offline IMAP (mscott)
// return PR_FALSE;
return PR_TRUE; // if POP or IMAP in offline mode
}
PRBool nsMsgSearchScopeTerm::IsOfflineIMAPMail()
{
// Find out whether "this" mail folder is an offline IMAP folder
NS_ASSERTION(m_folder, "scope doesn't have folder");
// if (m_folder->GetType() == FOLDER_IMAPMAIL && (NET_IsOffline() || !m_searchServer))
// return PR_TRUE;
return PR_FALSE; // we are not an IMAP folder that is offline
}
const char *nsMsgSearchScopeTerm::GetMailPath()
{
return nsnull;
}
nsresult nsMsgSearchScopeTerm::TimeSlice ()
{
return NS_OK;
}
nsresult nsMsgSearchScopeTerm::InitializeAdapter (nsMsgSearchTermArray &termList)
{
return NS_OK;
}
char *nsMsgSearchScopeTerm::GetStatusBarName ()
{
return nsnull;
}
//-----------------------------------------------------------------------------
// nsMsgResultElement implementation
//-----------------------------------------------------------------------------
nsMsgResultElement::nsMsgResultElement(nsMsgSearchAdapter *adapter)
nsMsgResultElement::nsMsgResultElement(nsIMsgSearchAdapter *adapter)
{
m_adapter = adapter;
}