Bug #1635 --> if we are downloading the entire message, set total download size based on the RFC822.SIZE response.

r=bienvenu


git-svn-id: svn://10.0.0.236/trunk@75304 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mscott%netscape.com 2000-08-01 02:56:26 +00:00
parent c2a66acc1b
commit 635a8128c2
3 changed files with 48 additions and 34 deletions

View File

@ -2392,36 +2392,38 @@ nsImapProtocol::FetchMessage(const char * messageIds,
switch (whatToFetch) {
case kEveryThingRFC822:
if (m_trackingTime)
AdjustChunkSize(); // we started another segment
m_startTime = PR_Now(); // save start of download time
m_trackingTime = PR_TRUE;
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
{
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
commandString.Append(" %s (XSENDER UID RFC822.SIZE BODY[]");
else
commandString.Append(" %s (UID RFC822.SIZE BODY[]");
}
else
{
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
commandString.Append(" %s (XSENDER UID RFC822.SIZE RFC822");
else
commandString.Append(" %s (UID RFC822.SIZE RFC822");
}
if (endByte > 0)
{
// if we are retrieving chunks
char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
if (byterangeString)
{
commandString.Append(byterangeString);
PR_Free(byterangeString);
}
}
commandString.Append(")");
break;
GetServerStateParser().SetFetchingEverythingRFC822(PR_TRUE);
if (m_trackingTime)
AdjustChunkSize(); // we started another segment
m_startTime = PR_Now(); // save start of download time
m_trackingTime = PR_TRUE;
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
{
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
commandString.Append(" %s (XSENDER UID RFC822.SIZE BODY[]");
else
commandString.Append(" %s (UID RFC822.SIZE BODY[]");
}
else
{
if (GetServerStateParser().GetCapabilityFlag() & kHasXSenderCapability)
commandString.Append(" %s (XSENDER UID RFC822.SIZE RFC822");
else
commandString.Append(" %s (UID RFC822.SIZE RFC822");
}
if (endByte > 0)
{
// if we are retrieving chunks
char *byterangeString = PR_smprintf("<%ld.%ld>",startByte,endByte);
if (byterangeString)
{
commandString.Append(byterangeString);
PR_Free(byterangeString);
}
}
commandString.Append(")");
break;
case kEveryThingRFC822Peek:
{
@ -2451,7 +2453,7 @@ nsImapProtocol::FetchMessage(const char * messageIds,
if (GetServerStateParser().ServerHasIMAP4Rev1Capability())
{
PRUint32 server_capabilityFlags = GetServerStateParser().GetCapabilityFlag();
PRBool aolImapServer = ((server_capabilityFlags & kAOLImapCapability) != 0);
PRBool aolImapServer = ((server_capabilityFlags & kAOLImapCapability) != 0);
PRBool useArbitraryHeaders = GetShouldDownloadArbitraryHeaders(); // checks filter headers, etc.
if (/***** Fix me *** gOptimizedHeaders && */// preference -- able to turn it off
useArbitraryHeaders) // if it's ok -- no filters on any header, etc.
@ -2586,9 +2588,10 @@ nsImapProtocol::FetchMessage(const char * messageIds,
nsresult rv = SendData(protocolString);
nsMemory::Free(cCommandStr);
if (NS_SUCCEEDED(rv))
ParseIMAPandCheckForNewMail(protocolString);
PR_Free(protocolString);
if (NS_SUCCEEDED(rv))
ParseIMAPandCheckForNewMail(protocolString);
PR_Free(protocolString);
GetServerStateParser().SetFetchingEverythingRFC822(PR_FALSE); // always clear this flag after every fetch....
}
else
HandleMemoryFailure();

View File

@ -53,6 +53,7 @@ nsImapServerResponseParser::nsImapServerResponseParser(nsImapProtocol &imapProto
fSelectedMailboxName(nsnull),
fIMAPstate(kNonAuthenticated),
fLastChunk(PR_FALSE),
fFetchEverythingRFC822(PR_FALSE),
fServerIsNetscape3xServer(PR_FALSE),
m_shell(nsnull),
fServerConnection(imapProtocolConnection),
@ -1133,6 +1134,13 @@ void nsImapServerResponseParser::msg_fetch()
if (ContinueParse())
{
fSizeOfMostRecentMessage = atoi(fNextToken);
// if we are in the process of fetching everything RFC822 then we should
// turn around and force the total download size to be set to this value.
// this helps if the server gaves us a bogus size for the message in response to the
// envelope command.
if (fFetchEverythingRFC822)
SetTotalDownloadSize(fSizeOfMostRecentMessage);
if (fSizeOfMostRecentMessage == 0 && CurrentResponseUID())
{

View File

@ -89,6 +89,7 @@ public:
PRBool IsNumericString(const char *string);
PRInt32 SizeOfMostRecentMessage();
void SetTotalDownloadSize(PRInt32 newSize) { fTotalDownloadSize = newSize; }
void SetFetchingEverythingRFC822(PRBool fetchingEverythingRFC822) { fFetchEverythingRFC822 = fetchingEverythingRFC822;}
nsImapSearchResultIterator *CreateSearchResultIterator();
void ResetSearchResultSequence() {fSearchResults->ResetSequence();}
@ -252,6 +253,8 @@ private:
PRInt32 numberOfCharsInThisChunk;
PRInt32 charsReadSoFar;
PRBool fLastChunk;
// when issuing a fetch command, are we fetching everything or just a part?
PRBool fFetchEverythingRFC822;
// Is the server a Netscape 3.x Messaging Server?
PRBool fServerIsNetscape3xServer;