more work on search backend, r=alecf,jefft 33100

This commit is contained in:
bienvenu%netscape.com 2000-06-06 23:28:17 +00:00
Родитель 074869ecb1
Коммит cebff3c5d2
9 изменённых файлов: 70 добавлений и 22 удалений

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

@ -26,6 +26,7 @@
interface nsMsgResultElement;
interface nsIMsgSearchAdapter;
interface nsIMsgSearchTerm;
//////////////////////////////////////////////////////////////////////////////
// The Msg Search Session is an interface designed to make constructing
@ -42,6 +43,10 @@ interface nsIMsgSearchSession : nsISupports {
in boolean BooleanAND, /* set to true if associated boolean operator is AND */
in string arbitraryHeader); /* user defined arbitrary header. ignored unless attrib = attribOtherHeader */
void AddSearchTermArray (in nsISupportsArray searchTerms);
void CreateSearchTerm (out nsIMsgSearchTerm searchTerm);
readonly attribute unsigned long numSearchTerms;
readonly attribute nsIMsgSearchAdapter runningAdapter;

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

@ -23,12 +23,7 @@
#include "nsISupports.idl"
#include "nsMsgSearchCore.idl"
[byref] native nsMsgSearchTermArray(nsMsgSearchTermArray&);
%{C++
#include "nsMsgSearchArray.h"
%}
interface nsISupportsArray;
[scriptable, uuid(b07f1cb6-fae9-4d92-9edb-03f9ad249c66)]
interface nsIMsgSearchValidityTable : nsISupports {
@ -47,7 +42,7 @@ interface nsIMsgSearchValidityTable : nsISupports {
boolean getValidButNotShown(in nsMsgSearchAttribValue attrib,
in nsMsgSearchOpValue op);
[noscript] void validateTerms(in nsMsgSearchTermArray terms);
[noscript] void validateTerms(in nsISupportsArray terms);
readonly attribute long numAvailAttribs;

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

@ -30,12 +30,6 @@ class nsMsgSearchTerm;
class nsMsgSearchScopeTerm;
struct nsMsgSearchValue;
class nsMsgSearchTermArray : public nsVoidArray
{
public:
nsMsgSearchTerm *ElementAt(PRUint32 i) const { return (nsMsgSearchTerm*) nsVoidArray::ElementAt(i); }
};
class nsMsgSearchValueArray : public nsVoidArray
{
public:

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

@ -126,7 +126,7 @@ void nsMsgBodyHandler::OpenLocalFolder()
if (NS_FAILED(rv) || !scopeFileStream)
{
nsCOMPtr <nsIFileSpec> fileSpec;
nsresult rv = m_scope->GetMailPath(getter_AddRefs(fileSpec));
rv = m_scope->GetMailPath(getter_AddRefs(fileSpec));
if (NS_SUCCEEDED(rv) && fileSpec)
{
nsFileSpec path;

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

@ -135,6 +135,8 @@ NS_IMETHODIMP nsMsgSearchOnlineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
err = m_scope->GetFolder(getter_AddRefs(folder));
if (NS_SUCCEEDED(err) && folder)
folder->GetName(getter_Copies(folderName));
pValue->u.folder = folder;
NS_ADDREF(pValue->u.folder);
// pValue->u.wString = nsCRT::strdup((const PRUnichar *) folderName);
newResult->AddValue (pValue);
}
@ -265,7 +267,7 @@ nsresult nsMsgSearchOnlineMail::Encode (nsCString& pEncoding,
pTerm->GetAttrib(&attribute);
if (IsStringAttribute(attribute))
{
PRUnichar *pchar;
PRUnichar *pchar, *savepChar;
nsCOMPtr <nsIMsgSearchValue> searchValue;
nsresult rv = pTerm->GetValue(getter_AddRefs(searchValue));
@ -276,6 +278,7 @@ nsresult nsMsgSearchOnlineMail::Encode (nsCString& pEncoding,
rv = searchValue->GetStr(&pchar);
if (!NS_SUCCEEDED(rv) || !pchar)
continue;
savepChar = pchar;
for (; *pchar ; pchar++)
{
if (*pchar & 0xFF80)
@ -284,7 +287,7 @@ nsresult nsMsgSearchOnlineMail::Encode (nsCString& pEncoding,
break;
}
}
nsCRT::free(pchar);
nsCRT::free(savepChar);
}
}
}

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

@ -785,6 +785,9 @@ NS_IMETHODIMP nsMsgSearchOfflineMail::AddResultElement (nsIMsgDBHdr *pHeaders)
if (pValue)
{
pValue->attribute = nsMsgSearchAttrib::Location;
m_scope->GetFolder(&pValue->u.folder);
// pValue->u.folder = m_scope->m_folder;
// NS_IF_ADDREF(pValue->u.folder); // use nsIMsgFolder, not string
#ifdef HAVE_SEARCH_PORT
pValue->u.string = PL_strdup(m_scope->m_folder->GetName());
#endif

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

@ -395,6 +395,9 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
nsCOMPtr <nsIMsgSearchValue> searchValue;
nsresult rv = term->GetValue(getter_AddRefs(searchValue));
if (!NS_SUCCEEDED(rv))
return rv;
nsMsgSearchOpValue op;
term->GetOp(&op);
@ -536,7 +539,13 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
// we need to adjust the date so we get greater than and not greater than or equal to which
// is what the IMAP server wants to search on
// won't work on Mac.
// adjustedDate += 60 * 60 * 24; // bump up to the day after this one...
// ack, is this right? is PRTime seconds or microseconds?
PRInt64 microSecondsPerSecond, secondsInDay, microSecondsInDay;
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
LL_UI2L(secondsInDay, 60 * 60 * 24);
LL_MUL(microSecondsInDay, secondsInDay, microSecondsPerSecond);
LL_ADD(adjustedDate, adjustedDate, microSecondsInDay); // bump up to the day after this one...
}
PRExplodedTime exploded;
@ -551,9 +560,20 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
{
// okay, take the current date, subtract off the age in days, then do an appropriate Date search on
// the resulting day.
PRUint32 ageInDays;
searchValue->GetAge(&ageInDays);
PRTime now = PR_Now();
PRTime matchDay;
LL_I2L(matchDay, 0); // = now ; - term->m_value.u.age * 60 * 60 * 24; won't work on the mac
PRInt64 microSecondsPerSecond, secondsInDays, microSecondsInDay;
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
LL_UI2L(secondsInDays, 60 * 60 * 24 * ageInDays);
LL_MUL(microSecondsInDay, secondsInDays, microSecondsPerSecond);
LL_SUB(matchDay, now, microSecondsInDay); // = now - term->m_value.u.age * 60 * 60 * 24;
PRExplodedTime exploded;
PR_ExplodeTime(matchDay, PR_LocalTimeParameters, &exploded);
PR_FormatTimeUSEnglish(dateBuf, sizeof(dateBuf), "%d-%b-%Y", &exploded);
@ -853,13 +873,22 @@ nsMsgSearchValidityTable::GetNumAvailAttribs(PRInt32 *aResult)
}
nsresult
nsMsgSearchValidityTable::ValidateTerms (nsMsgSearchTermArray &termList)
nsMsgSearchValidityTable::ValidateTerms (nsISupportsArray *searchTerms)
{
nsresult err = NS_OK;
PRUint32 count;
for (int i = 0; i < termList.Count(); i++)
NS_ENSURE_ARG(searchTerms);
searchTerms->Count(&count);
for (PRUint32 i = 0; i < count; i++)
{
nsMsgSearchTerm *term = termList.ElementAt(i);
nsCOMPtr<nsIMsgSearchTerm> pTerm;
searchTerms->QueryElementAt(i, NS_GET_IID(nsIMsgSearchTerm),
(void **)getter_AddRefs(pTerm));
nsIMsgSearchTerm *iTerm = pTerm;
nsMsgSearchTerm *term = NS_STATIC_CAST(nsMsgSearchTerm *, iTerm);
// XP_ASSERT(term->IsValid());
PRBool enabled;
PRBool available;

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

@ -424,6 +424,7 @@ void nsMsgSearchNews::ReportHits ()
}
#endif // OLDWAY
// ### this should take an nsIMsgFolder instead of a string location.
void nsMsgSearchNews::ReportHit (nsIMsgDBHdr *pHeaders, const char *location)
{
// this is totally filched from msg_SearchOfflineMail until I decide whether the

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

@ -70,6 +70,24 @@ nsMsgSearchSession::AddSearchTerm(nsMsgSearchAttribValue attrib,
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::AddSearchTermArray(nsISupportsArray *searchTerms)
{
m_termList = searchTerms;
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::CreateSearchTerm(nsIMsgSearchTerm **aResult)
{
nsMsgSearchTerm *term = new nsMsgSearchTerm;
NS_ENSURE_TRUE(term, NS_ERROR_OUT_OF_MEMORY);
*aResult = NS_STATIC_CAST(nsIMsgSearchTerm*,term);
NS_ADDREF(*aResult);
return NS_OK;
}
/* readonly attribute long numSearchTerms; */
NS_IMETHODIMP nsMsgSearchSession::GetNumSearchTerms(PRUint32 *aNumSearchTerms)
{
@ -498,7 +516,7 @@ void nsMsgSearchSession::DestroyScopeList()
void nsMsgSearchSession::DestroyTermList ()
{
m_termList->Clear();
m_termList = nsnull; // don't really need this now that caller owns term list.
}
nsMsgSearchScopeTerm *nsMsgSearchSession::GetRunningScope()