mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 02:09:28 +00:00
fix a few race conditions with fe events, add NOOP service
This commit is contained in:
parent
c50da80f83
commit
3796e54a4f
@ -79,6 +79,9 @@ public:
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL,
|
||||
const char *messageIdentifierList,
|
||||
PRBool messageIdsAreUID) = 0;
|
||||
NS_IMETHOD Noop(PLEventQueue * aClientEventQueue,
|
||||
nsIImapMailFolderSink * aImapMailFolder,
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1605,7 +1605,10 @@ void nsImapProtocol::BeginMessageDownLoad(
|
||||
if (GetServerStateParser().GetDownloadingHeaders())
|
||||
{
|
||||
if (m_imapMailFolderSink)
|
||||
{
|
||||
m_imapMailFolderSink->SetupHeaderParseStream(this, si);
|
||||
WaitForFEEventCompletion();
|
||||
}
|
||||
}
|
||||
else if (m_imapMessageSink)
|
||||
{
|
||||
@ -2185,10 +2188,14 @@ nsImapProtocol::PostLineDownLoadEvent(msg_line_info *downloadLineDontDelete)
|
||||
if (GetServerStateParser().GetDownloadingHeaders())
|
||||
{
|
||||
if (m_imapMailFolderSink && downloadLineDontDelete)
|
||||
{
|
||||
m_imapMailFolderSink->ParseAdoptedHeaderLine(this, downloadLineDontDelete);
|
||||
}
|
||||
}
|
||||
else if (m_imapMessageSink && downloadLineDontDelete)
|
||||
{
|
||||
m_imapMessageSink->ParseAdoptedMsgLine(this, downloadLineDontDelete);
|
||||
}
|
||||
|
||||
// ***** We need to handle the psuedo interrupt here *****
|
||||
}
|
||||
|
@ -2116,7 +2116,8 @@ ParseAdoptedHeaderLineProxyEvent::HandleEvent()
|
||||
{
|
||||
nsresult res = m_proxy->m_realImapMailFolderSink->ParseAdoptedHeaderLine(
|
||||
m_proxy->m_protocol, &m_msgLineInfo);
|
||||
m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
// m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
// imap thread is NOT waiting for FEEvent completion, so don't send it.
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2135,7 +2136,8 @@ NormalEndHeaderParseStreamProxyEvent::HandleEvent()
|
||||
{
|
||||
nsresult res = m_proxy->m_realImapMailFolderSink->NormalEndHeaderParseStream(
|
||||
m_proxy->m_protocol);
|
||||
m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
// IMAP thread is NOT waiting for FEEvent Completion.
|
||||
// m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2301,7 +2303,8 @@ AbortMsgWriteStreamProxyEvent::HandleEvent()
|
||||
{
|
||||
nsresult res = m_proxy->m_realImapMessageSink->AbortMsgWriteStream(
|
||||
m_proxy->m_protocol);
|
||||
m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
// IMAP thread is NOT waiting for FEEvent Completion.
|
||||
// m_proxy->m_protocol->NotifyFEEventCompletion();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -158,9 +158,6 @@ NS_IMETHODIMP nsImapService::FetchMessage(PLEventQueue * aClientEventQueue,
|
||||
const char *messageIdentifierList,
|
||||
PRBool messageIdsAreUID)
|
||||
{
|
||||
static const char *formatString = "fetch>%s>%c%s>%s";
|
||||
|
||||
|
||||
// create a protocol instance to handle the request.
|
||||
// NOTE: once we start working with multiple connections, this step will be much more complicated...but for now
|
||||
// just create a connection and process the request.
|
||||
@ -178,20 +175,15 @@ NS_IMETHODIMP nsImapService::FetchMessage(PLEventQueue * aClientEventQueue,
|
||||
rv = imapUrl->SetImapMessageSink(aImapMessage);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsString2 urlSpec(eOneByte);
|
||||
char hierarchySeparator = '/'; // ### fixme - should get from folder
|
||||
|
||||
rv = CreateStartOfImapUrl(*imapUrl, urlSpec);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
urlSpec.Append("/fetch>");
|
||||
urlSpec.Append(messageIdsAreUID ? uidString : sequenceString);
|
||||
urlSpec.Append(">");
|
||||
urlSpec.Append(hierarchySeparator);
|
||||
urlSpec.Append("Inbox>");
|
||||
urlSpec.Append(messageIdentifierList);
|
||||
rv = imapUrl->SetSpec(urlSpec.GetBuffer());
|
||||
}
|
||||
urlSpec.Append("/fetch>");
|
||||
urlSpec.Append(messageIdsAreUID ? uidString : sequenceString);
|
||||
urlSpec.Append(">");
|
||||
urlSpec.Append(hierarchySeparator);
|
||||
urlSpec.Append("Inbox>");
|
||||
urlSpec.Append(messageIdentifierList);
|
||||
rv = imapUrl->SetSpec(urlSpec.GetBuffer());
|
||||
imapUrl->RegisterListener(aUrlListener); // register listener if there is one.
|
||||
protocolInstance->LoadUrl(imapUrl, nsnull);
|
||||
if (aURL)
|
||||
@ -250,6 +242,40 @@ nsresult nsImapService::CreateStartOfImapUrl(nsIImapUrl &imapUrl, nsString2 &url
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Noop, used to update a folder (causes server to send changes).
|
||||
NS_IMETHODIMP nsImapService::Noop(PLEventQueue * aClientEventQueue,
|
||||
nsIImapMailFolderSink * aImapMailFolder,
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL)
|
||||
{
|
||||
nsIImapProtocol * protocolInstance = nsnull;
|
||||
nsIImapUrl * imapUrl = nsnull;
|
||||
nsString2 urlSpec(eOneByte);
|
||||
|
||||
nsresult rv = GetImapConnectionAndUrl(aClientEventQueue, imapUrl, protocolInstance, urlSpec);
|
||||
if (NS_SUCCEEDED(rv) && imapUrl)
|
||||
{
|
||||
|
||||
rv = imapUrl->SetImapAction(nsIImapUrl::nsImapSelectNoopFolder);
|
||||
rv = imapUrl->SetImapMailFolderSink(aImapMailFolder);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
char hierarchySeparator = '/'; // ### fixme - should get from folder
|
||||
|
||||
urlSpec.Append("/selectnoop>");
|
||||
urlSpec.Append(hierarchySeparator);
|
||||
urlSpec.Append("Inbox>");
|
||||
rv = imapUrl->SetSpec(urlSpec.GetBuffer());
|
||||
imapUrl->RegisterListener(aUrlListener); // register listener if there is one.
|
||||
protocolInstance->LoadUrl(imapUrl, nsnull);
|
||||
if (aURL)
|
||||
*aURL = imapUrl;
|
||||
else
|
||||
NS_RELEASE(imapUrl); // release our ref count from the create instance call...
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PORT
|
||||
|
||||
/* fetching the headers of RFC822 messages */
|
||||
|
@ -49,6 +49,9 @@ public:
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL,
|
||||
const char *messageIdentifierList,
|
||||
PRBool messageIdsAreUID);
|
||||
NS_IMETHOD Noop(PLEventQueue * aClientEventQueue,
|
||||
nsIImapMailFolderSink * aImapMailFolder,
|
||||
nsIUrlListener * aUrlListener, nsIURL ** aURL);
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// End support of nsIImapService interface
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -960,7 +960,21 @@ nsIMAP4TestDriver::GetMessageSizeFromDB(nsIImapProtocol* aProtocol,
|
||||
MessageSizeInfo* sizeInfo)
|
||||
{
|
||||
printf("**** nsIMAP4TestDriver::GetMessageSizeFromDB\r\n");
|
||||
return NS_OK;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (sizeInfo && sizeInfo->id)
|
||||
{
|
||||
PRUint32 key = atoi(sizeInfo->id);
|
||||
nsIMessage *mailHdr = nsnull;
|
||||
NS_ASSERTION(sizeInfo->idIsUid, "ids must be uids to get message size");
|
||||
if (sizeInfo->idIsUid)
|
||||
rv = m_mailDB->GetMsgHdrForKey(key, &mailHdr);
|
||||
if (NS_SUCCEEDED(rv) && mailHdr)
|
||||
{
|
||||
rv = mailHdr->GetMessageSize(&sizeInfo->size);
|
||||
NS_RELEASE(mailHdr);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@ -1313,6 +1327,7 @@ nsresult nsIMAP4TestDriver::ListCommands()
|
||||
printf("2) Check identity information.\n");
|
||||
printf("3) Test url parsing. \n");
|
||||
printf("4) Select Folder. \n");
|
||||
printf("5) Download a message. \n");
|
||||
printf("9) Exit the test application. \n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user