More work on search, not run yet

This commit is contained in:
bienvenu%netscape.com 2000-04-19 01:01:51 +00:00
Родитель 6d2b0fba47
Коммит 13b56fbbea
8 изменённых файлов: 67 добавлений и 72 удалений

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

@ -350,9 +350,10 @@ nsresult nsMsgSearchSession::GetNextUrl()
m_urlQueue.CStringAt(0, nextUrl);
nsresult rv = GetMessageServiceFromURI(nextUrl.GetBuffer(), getter_AddRefs(msgService));
nsMsgSearchScopeTerm *currentTerm = GetRunningScope();
if (NS_SUCCEEDED(rv) && msgService)
msgService->Search(this, m_window, nextUrl.GetBuffer());
if (NS_SUCCEEDED(rv) && msgService && currentTerm)
msgService->Search(this, m_window, currentTerm->m_folder, nextUrl.GetBuffer());
return rv;

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

@ -73,6 +73,9 @@ interface nsIImapMailFolderSink : nsISupports {
void OnlineCopyCompleted(in nsIImapProtocol aProtocol, in ImapOnlineCopyState aCopyState);
void StartMessage(in nsIMsgMailNewsUrl aUrl);
void EndMessage(in nsIMsgMailNewsUrl aUrl, in nsMsgKey uidOfMessage);
void NotifySearchHit(in nsIMsgMailNewsUrl aUrl, in string hitLine);
// these two hokey methods are needed so we can try to make sure the imap url is released
// on the UI thread. This in turn ensures that the objects the imap url holds on to
// are only released / destroyed from the UI thread.

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

@ -48,8 +48,6 @@ public:
return iid;
}
NS_IMETHOD AddSearchResult(nsIImapProtocol* aProtocol,
const char* searchHitLine) = 0;
NS_IMETHOD GetArbitraryHeaders(nsIImapProtocol* aProtocol,
GenericInfo* aInfo) = 0;
NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol,

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

@ -3308,6 +3308,18 @@ nsImapMailFolder::EndMessage(nsIMsgMailNewsUrl * aUrl, nsMsgKey uidOfMessage)
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::NotifySearchHit(nsIMsgMailNewsUrl * aUrl,
const char* searchHitLine)
{
#ifdef DEBUG_bienvenu
printf("search hit %s\n", searchHitLine);
#endif
// get the search session from the url.
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::SetAppendMsgUid(nsIImapProtocol* aProtocol,
nsMsgKey aKey,

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

@ -3727,8 +3727,10 @@ nsImapProtocol::NotifyMessageFlags(imapMessageFlagsType flags, nsMsgKey key)
void
nsImapProtocol::NotifySearchHit(const char * hitLine)
{
if (m_imapMiscellaneousSink)
m_imapMiscellaneousSink->AddSearchResult(this, hitLine);
nsresult rv;
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningUrl, &rv);
if (m_imapMailFolderSink)
m_imapMailFolderSink->NotifySearchHit(mailnewsUrl, hitLine);
}
void nsImapProtocol::SetMailboxDiscoveryStatus(EMailboxDiscoverStatus status)

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

@ -356,32 +356,6 @@ nsImapMiscellaneousSinkProxy::~nsImapMiscellaneousSinkProxy()
static NS_DEFINE_IID(kIImapMiscellaneousSinkIID, NS_IIMAPMISCELLANEOUSSINK_IID);
NS_IMPL_THREADSAFE_ISUPPORTS(nsImapMiscellaneousSinkProxy, kIImapMiscellaneousSinkIID);
NS_IMETHODIMP
nsImapMiscellaneousSinkProxy::AddSearchResult(nsIImapProtocol* aProtocol,
const char* searchHitLine)
{
nsresult res = NS_OK;
NS_PRECONDITION (searchHitLine, "Oops... null searchHitLine");
if(!searchHitLine)
return NS_ERROR_NULL_POINTER;
NS_ASSERTION (m_protocol == aProtocol, "Ooh ooh, wrong protocol");
if (PR_GetCurrentThread() == m_thread)
{
AddSearchResultProxyEvent *ev =
new AddSearchResultProxyEvent(this, searchHitLine);
if(nsnull == ev)
res = NS_ERROR_OUT_OF_MEMORY;
else
ev->PostEvent(m_eventQueue);
}
else
{
res = m_realImapMiscellaneousSink->AddSearchResult(aProtocol, searchHitLine);
}
return res;
}
NS_IMETHODIMP
nsImapMiscellaneousSinkProxy::GetArbitraryHeaders(nsIImapProtocol* aProtocol,
GenericInfo* aInfo)
@ -1006,33 +980,6 @@ nsImapMiscellaneousSinkProxyEvent::~nsImapMiscellaneousSinkProxyEvent()
NS_IF_RELEASE (m_proxy);
}
AddSearchResultProxyEvent::AddSearchResultProxyEvent(
nsImapMiscellaneousSinkProxy* aProxy, const char* searchHitLine) :
nsImapMiscellaneousSinkProxyEvent(aProxy)
{
NS_ASSERTION (searchHitLine, "Oops... a null search hit line");
if (searchHitLine)
m_searchHitLine = PL_strdup(searchHitLine);
else
m_searchHitLine = nsnull;
}
AddSearchResultProxyEvent::~AddSearchResultProxyEvent()
{
if (m_searchHitLine)
PL_strfree(m_searchHitLine);
}
NS_IMETHODIMP
AddSearchResultProxyEvent::HandleEvent()
{
nsresult res = m_proxy->m_realImapMiscellaneousSink->AddSearchResult(
m_proxy->m_protocol, m_searchHitLine);
if (m_notifyCompletion)
m_proxy->m_protocol->NotifyFEEventCompletion();
return res;
}
GetArbitraryHeadersProxyEvent::GetArbitraryHeadersProxyEvent(
nsImapMiscellaneousSinkProxy* aProxy, GenericInfo* aInfo) :
nsImapMiscellaneousSinkProxyEvent(aProxy)

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

@ -97,8 +97,6 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD AddSearchResult(nsIImapProtocol* aProtocol,
const char* searchHitLine);
NS_IMETHOD GetArbitraryHeaders(nsIImapProtocol* aProtocol,
GenericInfo* aInfo);
NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol,
@ -230,15 +228,6 @@ struct nsImapMiscellaneousSinkProxyEvent : public nsImapEvent
nsImapMiscellaneousSinkProxy* m_proxy;
};
struct AddSearchResultProxyEvent : public nsImapMiscellaneousSinkProxyEvent
{
AddSearchResultProxyEvent(nsImapMiscellaneousSinkProxy* aProxy,
const char* searchHitLine);
virtual ~AddSearchResultProxyEvent();
NS_IMETHOD HandleEvent();
char* m_searchHitLine;
};
struct GetArbitraryHeadersProxyEvent : public nsImapMiscellaneousSinkProxyEvent
{
GetArbitraryHeadersProxyEvent(nsImapMiscellaneousSinkProxy* aProxy,

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

@ -630,9 +630,52 @@ nsImapService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStr
return rv;
}
NS_IMETHODIMP nsImapService::Search(nsIMsgSearchSession *aSearchSession, nsIMsgWindow *aMsgWindow, const char *aMessageUri)
NS_IMETHODIMP nsImapService::Search(nsIMsgSearchSession *aSearchSession, nsIMsgWindow *aMsgWindow, nsIMsgFolder *aMsgFolder, const char *aSearchUri)
{
return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv = NS_OK;
nsCAutoString folderURI;
nsMsgKey key;
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString urlSpec;
PRUnichar hierarchySeparator = GetHierarchyDelimiter(aMsgFolder);
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aMsgFolder, nsnull, urlSpec, hierarchySeparator);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
msgurl->SetMsgWindow(aMsgWindow);
imapUrl->AddChannelToLoadGroup();
rv = SetImapUrlSink(aMsgFolder, imapUrl);
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString folderName;
GetFolderName(aMsgFolder, getter_Copies(folderName));
nsCOMPtr <nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(imapUrl);
urlSpec.Append("search>UID>");
urlSpec.Append(hierarchySeparator);
urlSpec.Append('>');
urlSpec.Append((const char *) folderName);
urlSpec.Append('>');
urlSpec.Append(aSearchUri);
rv = mailNewsUrl->SetSpec((char *) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIEventQueue> queue;
// get the Event Queue for this thread...
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
if (NS_FAILED(rv)) return rv;
rv = GetImapConnectionAndLoadUrl(queue, imapUrl, nsnull, nsnull);
}
}
return rv;
}
// just a helper method to break down imap message URIs....