fix a couple problems with folder selection...

This commit is contained in:
bienvenu%netscape.com 1999-04-15 05:33:33 +00:00
Родитель 94d22cfcc3
Коммит 0d80e5ae5f
5 изменённых файлов: 142 добавлений и 70 удалений

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

@ -75,8 +75,6 @@ public:
// since the following url actions require us to be in the authenticated
// state, the high bit is left blank....
nsImapTest = 0x00000001,
nsImapSelectFolder = 0x00000002,
nsImapLiteSelectFolder = 0x00000003,
nsImapExpungeFolder = 0x00000004,
nsImapCreateFolder = 0x00000005,
nsImapDeleteFolder = 0x00000006,
@ -104,6 +102,8 @@ public:
// nsImapSelectedState urls. Note, the high bit is always set for
// imap actions which require us to be in the selected state
nsImapSelectFolder = 0x10000002,
nsImapLiteSelectFolder = 0x10000003,
nsImapMsgFetch = 0x10000018,
nsImapMsgHeader = 0x10000019,
nsImapSearch = 0x1000001A,

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

@ -583,7 +583,15 @@ char *nsIMAPGenericParser::CreateParenGroup()
#ifdef DEBUG_bienvenu
NS_ASSERTION(fNextToken[0] == '(', "we don't have a paren group!");
#endif
int numOpenParens = 1;
// build up a buffer with the paren group.
// start with an initial chunk, expand later if necessary
nsString2 buf;
nsString2 returnString;
int bytesUsed = 0;
// count the number of parens in the current token
int count, tokenLen = PL_strlen(fNextToken);
for (count = 1; (count < tokenLen) && (numOpenParens > 0); count++)
@ -594,62 +602,132 @@ char *nsIMAPGenericParser::CreateParenGroup()
numOpenParens--;
}
// build up a buffer with the paren group.
int bytesUsed = 0;
nsString2 buf;
nsString2 returnString;
if ((numOpenParens > 0) && ContinueParse())
{
// flush buf
// if (bytesUsed > 0)
// {
// buf[bytesUsed] = 0;
// StrAllocCat(rv, buf);
// bytesUsed = 0;
// }
// First, copy that first token from before
buf += fNextToken;
// Copy that first token from before
returnString =fNextToken;
returnString.Append(" "); // space that got stripped off the token
buf += " "; // space that got stripped off the token
PRBool extractReset = PR_TRUE;
while (extractReset && ContinueParse())
{
extractReset = PR_FALSE;
// Go through the current line and look for the last close paren.
// We're not trying to parse it just yet, just separate it out.
int len = PL_strlen(fCurrentTokenPlaceHolder);
for (count = 0; (count < len) && (numOpenParens > 0) && !extractReset; count++)
{
if (*fCurrentTokenPlaceHolder == '{')
{
fNextToken = GetNextToken();
NS_ASSERTION(fNextToken, "out of memory?or invalid syntax");
if (fNextToken)
{
int tokenLen = PL_strlen(fNextToken);
if (fNextToken[tokenLen-1] == '}')
{
// ok, we're looking at a literal string here
// first, flush buf
if (bytesUsed > 0)
{
buf.SetCharAt(bytesUsed, 0);
returnString.Append(buf);
bytesUsed = 0;
}
// Go through the current line and look for the last close paren.
// We're not trying to parse it just yet, just separate it out.
int len = PL_strlen(fCurrentTokenPlaceHolder);
for (count = 0; (count < len) && (numOpenParens > 0); count++)
{
if (fCurrentTokenPlaceHolder[count] == '(')
numOpenParens++;
else if (fCurrentTokenPlaceHolder[count] == ')')
numOpenParens--;
}
returnString.Append(fNextToken); // append the {xx} to the buffer
returnString.Append(CRLF); // append a CRLF to the buffer
char *lit = CreateLiteral();
fTokenizerAdvanced = PR_FALSE; // force it to use fCurrentTokenPlaceHolder
NS_ASSERTION(lit, "syntax error or out of memory");
if (lit)
{
returnString.Append(lit);
//fCurrentTokenPlaceHolder += XP_STRLEN(lit);
//AdvanceTokenizerStartingPoint(XP_STRLEN(lit));
//fNextToken = GetNextToken();
extractReset = TRUE;
PR_Free(lit);
}
}
else
{
#ifdef DEBUG_bienvenu
NS_ASSERTION(FALSE, "syntax error creating paren group"); // maybe not an error, but definitely a rare condition
#endif
}
}
}
else if (*fCurrentTokenPlaceHolder == '"')
{
// We're looking at a quoted string here.
// Ignore the characters within it.
if (count < len)
{
// we found the last close paren.
// Set fNextToken, fCurrentTokenPlaceHolder, etc.
char oldChar = fCurrentTokenPlaceHolder[count];
fCurrentTokenPlaceHolder[count] = 0;
buf += fCurrentTokenPlaceHolder;
fCurrentTokenPlaceHolder[count] = oldChar;
fCurrentTokenPlaceHolder = fCurrentTokenPlaceHolder + count;
fNextToken = GetNextToken();
}
else
{
// there should always be either a space or CRLF after the response, right?
SetSyntaxError(TRUE);
// first, flush buf
if (bytesUsed > 0)
{
buf.SetCharAt(bytesUsed, 0);
returnString.Append(buf);
bytesUsed = 0;
}
fNextToken = GetNextToken();
NS_ASSERTION(fNextToken, "syntax error or out of memory creating paren group");
if (fNextToken)
{
char *q = CreateQuoted();
fTokenizerAdvanced = FALSE; // force it to use fCurrentTokenPlaceHolder
NS_ASSERTION(q, "syntax error or out of memory creating paren group");
if (q)
{
returnString.Append("\"");
returnString.Append(q);
returnString.Append("\"");
extractReset = TRUE;
PR_Free(q);
}
}
}
else if (*fCurrentTokenPlaceHolder == '(')
numOpenParens++;
else if (*fCurrentTokenPlaceHolder == ')')
numOpenParens--;
if (!extractReset)
{
// append this character to the buffer
buf.SetCharAt(bytesUsed, *fCurrentTokenPlaceHolder);
bytesUsed++;
fCurrentTokenPlaceHolder++;
}
}
}
}
else if ((numOpenParens == 0) && ContinueParse())
{
// the whole paren group response was a single token
buf = fNextToken;
// the whole paren group response was finished in a single token
buf.Append(fNextToken);
}
if (numOpenParens < 0)
SetSyntaxError(TRUE);
return buf.ToNewCString();
if (numOpenParens != 0 || !ContinueParse())
{
SetSyntaxError(TRUE);
returnString.SetLength(0);
}
else
{
// flush buf the final time
if (bytesUsed > 0)
{
buf.SetCharAt(bytesUsed, 0);
returnString.Append(buf);
}
fNextToken = GetNextToken();
}
return returnString.ToNewCString();
}

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

@ -1804,8 +1804,7 @@ void nsImapProtocol::PipelinedFetchMessageParts(const char *uid, nsIMAPMessagePa
// assumes no chunking
// build up a string to fetch
#ifdef HAVE_PORT
char *stringToFetch = NULL, *what = NULL;
nsString2 stringToFetch(eOneByte), what(eOneByte);
int32 currentPartNum = 0;
while ((parts->GetNumParts() > currentPartNum) && !DeathSignalReceived())
{
@ -1815,36 +1814,28 @@ void nsImapProtocol::PipelinedFetchMessageParts(const char *uid, nsIMAPMessagePa
// Do things here depending on the type of message part
// Append it to the fetch string
if (currentPartNum > 0)
StrAllocCat(stringToFetch, " ");
stringToFetch.Append(" ");
switch (currentPart->GetFields())
{
case kMIMEHeader:
what = PR_smprintf("BODY[%s.MIME]",currentPart->GetPartNumberString());
if (what)
{
StrAllocCat(stringToFetch, what);
PR_Free(what);
}
else
HandleMemoryFailure();
what = "BODY[";
what.Append(currentPart->GetPartNumberString());
what.Append(".MIME]");
stringToFetch.Append(what);
break;
case kRFC822HeadersOnly:
if (currentPart->GetPartNumberString())
{
what = PR_smprintf("BODY[%s.HEADER]", currentPart->GetPartNumberString());
if (what)
{
StrAllocCat(stringToFetch, what);
PR_Free(what);
}
else
HandleMemoryFailure();
what = "BODY[";
what.Append(currentPart->GetPartNumberString());
what.Append(".HEADER]");
stringToFetch.Append(what);
}
else
{
// headers for the top-level message
StrAllocCat(stringToFetch, "BODY[HEADER]");
stringToFetch.Append("BODY[HEADER]");
}
break;
default:
@ -1871,7 +1862,6 @@ void nsImapProtocol::PipelinedFetchMessageParts(const char *uid, nsIMAPMessagePa
ParseIMAPandCheckForNewMail(commandString.GetBuffer());
PR_Free(stringToFetch);
}
#endif // HAVE_PORT
}
@ -4095,6 +4085,8 @@ void nsImapProtocol::OnMoveFolderHierarchy(const char * aSourceMailbox)
FolderRenamed(sourceMailbox, newBoxName);
}
}
else
HandleMemoryFailure();
#endif
}
@ -4234,7 +4226,6 @@ void nsImapProtocol::ProcessAuthenticatedStateURL()
PR_FREEIF(sourceMailbox);
}
void nsImapProtocol::ProcessAfterAuthenticated()
{
// mscott: ignore admin url stuff for now...

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

@ -103,6 +103,9 @@ NS_IMETHODIMP nsImapService::SelectFolder(PLEventQueue * aClientEventQueue, nsII
if (NS_SUCCEEDED(rv) && hostName)
{
char * urlSpec = PR_smprintf("imap://%s", hostName);
#ifdef DEBUG_bienvenu
urlSpec = PR_smprintf("imap://%s/Inbox", hostName);
#endif
rv = imapUrl->SetSpec(urlSpec);
PR_Free(hostName);
PR_FREEIF(urlSpec);

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

@ -159,7 +159,7 @@ NS_IMETHODIMP nsImapUrl::GetRequiredImapState(nsImapState * aImapUrlState)
// the imap action determines the state we must be in...check the
// the imap action.
if (m_imapAction & 0x1000000)
if (m_imapAction & 0x10000000)
*aImapUrlState = nsImapSelectedState;
else
*aImapUrlState = nsImapAuthenticatedState;