зеркало из https://github.com/mozilla/gecko-dev.git
More work on search, not run yet
This commit is contained in:
Родитель
6d2b0fba47
Коммит
13b56fbbea
|
@ -350,9 +350,10 @@ nsresult nsMsgSearchSession::GetNextUrl()
|
||||||
|
|
||||||
m_urlQueue.CStringAt(0, nextUrl);
|
m_urlQueue.CStringAt(0, nextUrl);
|
||||||
nsresult rv = GetMessageServiceFromURI(nextUrl.GetBuffer(), getter_AddRefs(msgService));
|
nsresult rv = GetMessageServiceFromURI(nextUrl.GetBuffer(), getter_AddRefs(msgService));
|
||||||
|
nsMsgSearchScopeTerm *currentTerm = GetRunningScope();
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv) && msgService)
|
if (NS_SUCCEEDED(rv) && msgService && currentTerm)
|
||||||
msgService->Search(this, m_window, nextUrl.GetBuffer());
|
msgService->Search(this, m_window, currentTerm->m_folder, nextUrl.GetBuffer());
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,9 @@ interface nsIImapMailFolderSink : nsISupports {
|
||||||
void OnlineCopyCompleted(in nsIImapProtocol aProtocol, in ImapOnlineCopyState aCopyState);
|
void OnlineCopyCompleted(in nsIImapProtocol aProtocol, in ImapOnlineCopyState aCopyState);
|
||||||
void StartMessage(in nsIMsgMailNewsUrl aUrl);
|
void StartMessage(in nsIMsgMailNewsUrl aUrl);
|
||||||
void EndMessage(in nsIMsgMailNewsUrl aUrl, in nsMsgKey uidOfMessage);
|
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
|
// 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
|
// 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.
|
// are only released / destroyed from the UI thread.
|
||||||
|
|
|
@ -48,8 +48,6 @@ public:
|
||||||
return iid;
|
return iid;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHOD AddSearchResult(nsIImapProtocol* aProtocol,
|
|
||||||
const char* searchHitLine) = 0;
|
|
||||||
NS_IMETHOD GetArbitraryHeaders(nsIImapProtocol* aProtocol,
|
NS_IMETHOD GetArbitraryHeaders(nsIImapProtocol* aProtocol,
|
||||||
GenericInfo* aInfo) = 0;
|
GenericInfo* aInfo) = 0;
|
||||||
NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol,
|
NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol,
|
||||||
|
|
|
@ -3308,6 +3308,18 @@ nsImapMailFolder::EndMessage(nsIMsgMailNewsUrl * aUrl, nsMsgKey uidOfMessage)
|
||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsImapMailFolder::SetAppendMsgUid(nsIImapProtocol* aProtocol,
|
nsImapMailFolder::SetAppendMsgUid(nsIImapProtocol* aProtocol,
|
||||||
nsMsgKey aKey,
|
nsMsgKey aKey,
|
||||||
|
|
|
@ -3727,8 +3727,10 @@ nsImapProtocol::NotifyMessageFlags(imapMessageFlagsType flags, nsMsgKey key)
|
||||||
void
|
void
|
||||||
nsImapProtocol::NotifySearchHit(const char * hitLine)
|
nsImapProtocol::NotifySearchHit(const char * hitLine)
|
||||||
{
|
{
|
||||||
if (m_imapMiscellaneousSink)
|
nsresult rv;
|
||||||
m_imapMiscellaneousSink->AddSearchResult(this, hitLine);
|
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningUrl, &rv);
|
||||||
|
if (m_imapMailFolderSink)
|
||||||
|
m_imapMailFolderSink->NotifySearchHit(mailnewsUrl, hitLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsImapProtocol::SetMailboxDiscoveryStatus(EMailboxDiscoverStatus status)
|
void nsImapProtocol::SetMailboxDiscoveryStatus(EMailboxDiscoverStatus status)
|
||||||
|
|
|
@ -356,32 +356,6 @@ nsImapMiscellaneousSinkProxy::~nsImapMiscellaneousSinkProxy()
|
||||||
static NS_DEFINE_IID(kIImapMiscellaneousSinkIID, NS_IIMAPMISCELLANEOUSSINK_IID);
|
static NS_DEFINE_IID(kIImapMiscellaneousSinkIID, NS_IIMAPMISCELLANEOUSSINK_IID);
|
||||||
NS_IMPL_THREADSAFE_ISUPPORTS(nsImapMiscellaneousSinkProxy, kIImapMiscellaneousSinkIID);
|
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
|
NS_IMETHODIMP
|
||||||
nsImapMiscellaneousSinkProxy::GetArbitraryHeaders(nsIImapProtocol* aProtocol,
|
nsImapMiscellaneousSinkProxy::GetArbitraryHeaders(nsIImapProtocol* aProtocol,
|
||||||
GenericInfo* aInfo)
|
GenericInfo* aInfo)
|
||||||
|
@ -1006,33 +980,6 @@ nsImapMiscellaneousSinkProxyEvent::~nsImapMiscellaneousSinkProxyEvent()
|
||||||
NS_IF_RELEASE (m_proxy);
|
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(
|
GetArbitraryHeadersProxyEvent::GetArbitraryHeadersProxyEvent(
|
||||||
nsImapMiscellaneousSinkProxy* aProxy, GenericInfo* aInfo) :
|
nsImapMiscellaneousSinkProxy* aProxy, GenericInfo* aInfo) :
|
||||||
nsImapMiscellaneousSinkProxyEvent(aProxy)
|
nsImapMiscellaneousSinkProxyEvent(aProxy)
|
||||||
|
|
|
@ -97,8 +97,6 @@ public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
NS_IMETHOD AddSearchResult(nsIImapProtocol* aProtocol,
|
|
||||||
const char* searchHitLine);
|
|
||||||
NS_IMETHOD GetArbitraryHeaders(nsIImapProtocol* aProtocol,
|
NS_IMETHOD GetArbitraryHeaders(nsIImapProtocol* aProtocol,
|
||||||
GenericInfo* aInfo);
|
GenericInfo* aInfo);
|
||||||
NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol,
|
NS_IMETHOD GetShouldDownloadArbitraryHeaders(nsIImapProtocol* aProtocol,
|
||||||
|
@ -230,15 +228,6 @@ struct nsImapMiscellaneousSinkProxyEvent : public nsImapEvent
|
||||||
nsImapMiscellaneousSinkProxy* m_proxy;
|
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
|
struct GetArbitraryHeadersProxyEvent : public nsImapMiscellaneousSinkProxyEvent
|
||||||
{
|
{
|
||||||
GetArbitraryHeadersProxyEvent(nsImapMiscellaneousSinkProxy* aProxy,
|
GetArbitraryHeadersProxyEvent(nsImapMiscellaneousSinkProxy* aProxy,
|
||||||
|
|
|
@ -630,9 +630,52 @@ nsImapService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStr
|
||||||
return rv;
|
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....
|
// just a helper method to break down imap message URIs....
|
||||||
|
|
Загрузка…
Ссылка в новой задаче