зеркало из https://github.com/mozilla/pjs.git
fix problem with IMail imap server flag changes not persisting also fixed whitespace and replace PR_FREEIF with PR_Free r=cavin, sr=sspitzer 180001
This commit is contained in:
Родитель
38b3aff109
Коммит
0f226b185a
|
@ -1856,10 +1856,10 @@ static int PR_CALLBACK CompareKey (const void *v1, const void *v2, void *)
|
||||||
nsImapMailFolder::AllocateUidStringFromKeys(nsMsgKey *keys, PRInt32 numKeys, nsCString &msgIds)
|
nsImapMailFolder::AllocateUidStringFromKeys(nsMsgKey *keys, PRInt32 numKeys, nsCString &msgIds)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
PRInt32 startSequence = -1;
|
PRUint32 startSequence; // no need to init; we won't use it unless numKeys > 0
|
||||||
if (numKeys > 0)
|
if (numKeys > 0)
|
||||||
startSequence = keys[0];
|
startSequence = keys[0];
|
||||||
PRInt32 curSequenceEnd = startSequence;
|
PRUint32 curSequenceEnd = startSequence;
|
||||||
PRUint32 total = numKeys;
|
PRUint32 total = numKeys;
|
||||||
// sort keys and then generate ranges instead of singletons!
|
// sort keys and then generate ranges instead of singletons!
|
||||||
NS_QuickSort(keys, numKeys, sizeof(nsMsgKey), CompareKey, nsnull);
|
NS_QuickSort(keys, numKeys, sizeof(nsMsgKey), CompareKey, nsnull);
|
||||||
|
|
|
@ -56,8 +56,8 @@
|
||||||
|
|
||||||
extern PRLogModuleInfo* IMAP;
|
extern PRLogModuleInfo* IMAP;
|
||||||
|
|
||||||
nsImapServerResponseParser::nsImapServerResponseParser(nsImapProtocol &imapProtocolConnection) :
|
nsImapServerResponseParser::nsImapServerResponseParser(nsImapProtocol &imapProtocolConnection)
|
||||||
nsIMAPGenericParser(),
|
: nsIMAPGenericParser(),
|
||||||
fReportingErrors(PR_TRUE),
|
fReportingErrors(PR_TRUE),
|
||||||
fCurrentFolderReadOnly(PR_FALSE),
|
fCurrentFolderReadOnly(PR_FALSE),
|
||||||
fCurrentLineContainedFlagInfo(PR_FALSE),
|
fCurrentLineContainedFlagInfo(PR_FALSE),
|
||||||
|
@ -88,23 +88,24 @@ nsImapServerResponseParser::nsImapServerResponseParser(nsImapProtocol &imapProto
|
||||||
fCapabilityFlag = kCapabilityUndefined;
|
fCapabilityFlag = kCapabilityUndefined;
|
||||||
fLastAlert = nsnull;
|
fLastAlert = nsnull;
|
||||||
fDownloadingHeaders = PR_FALSE;
|
fDownloadingHeaders = PR_FALSE;
|
||||||
|
fGotPermanentFlags = PR_FALSE;
|
||||||
fFolderUIDValidity = 0;
|
fFolderUIDValidity = 0;
|
||||||
fCRAMDigest = nsnull;
|
fCRAMDigest = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsImapServerResponseParser::~nsImapServerResponseParser()
|
nsImapServerResponseParser::~nsImapServerResponseParser()
|
||||||
{
|
{
|
||||||
PR_FREEIF( fCurrentCommandTag );
|
PR_Free( fCurrentCommandTag );
|
||||||
delete fSearchResults;
|
delete fSearchResults;
|
||||||
PR_FREEIF( fMailAccountUrl );
|
PR_Free( fMailAccountUrl );
|
||||||
PR_FREEIF( fFolderAdminUrl );
|
PR_Free( fFolderAdminUrl );
|
||||||
PR_FREEIF( fNetscapeServerVersionString );
|
PR_Free( fNetscapeServerVersionString );
|
||||||
PR_FREEIF( fXSenderInfo );
|
PR_Free( fXSenderInfo );
|
||||||
PR_FREEIF( fLastAlert );
|
PR_Free( fLastAlert );
|
||||||
PR_FREEIF( fManageListsUrl );
|
PR_Free( fManageListsUrl );
|
||||||
PR_FREEIF( fManageFiltersUrl );
|
PR_Free( fManageFiltersUrl );
|
||||||
PR_FREEIF( fSelectedMailboxName );
|
PR_Free( fSelectedMailboxName );
|
||||||
PR_FREEIF(fCRAMDigest);
|
PR_Free(fCRAMDigest);
|
||||||
|
|
||||||
NS_IF_RELEASE (fHostSessionList);
|
NS_IF_RELEASE (fHostSessionList);
|
||||||
fCopyResponseKeyArray.RemoveAll();
|
fCopyResponseKeyArray.RemoveAll();
|
||||||
|
@ -163,7 +164,7 @@ PRInt32 nsImapServerResponseParser::SizeOfMostRecentMessage()
|
||||||
void nsImapServerResponseParser::IncrementNumberOfTaggedResponsesExpected(const char *newExpectedTag)
|
void nsImapServerResponseParser::IncrementNumberOfTaggedResponsesExpected(const char *newExpectedTag)
|
||||||
{
|
{
|
||||||
fNumberOfTaggedResponsesExpected++;
|
fNumberOfTaggedResponsesExpected++;
|
||||||
PR_FREEIF( fCurrentCommandTag );
|
PR_Free( fCurrentCommandTag );
|
||||||
fCurrentCommandTag = PL_strdup(newExpectedTag);
|
fCurrentCommandTag = PL_strdup(newExpectedTag);
|
||||||
if (!fCurrentCommandTag)
|
if (!fCurrentCommandTag)
|
||||||
HandleMemoryFailure();
|
HandleMemoryFailure();
|
||||||
|
@ -204,7 +205,7 @@ void nsImapServerResponseParser::ParseIMAPServerResponse(const char *currentComm
|
||||||
char *commandToken = Imapstrtok_r(nsnull, WHITESPACE,&placeInTokenString);
|
char *commandToken = Imapstrtok_r(nsnull, WHITESPACE,&placeInTokenString);
|
||||||
if (tagToken)
|
if (tagToken)
|
||||||
{
|
{
|
||||||
PR_FREEIF( fCurrentCommandTag );
|
PR_Free( fCurrentCommandTag );
|
||||||
fCurrentCommandTag = PL_strdup(tagToken);
|
fCurrentCommandTag = PL_strdup(tagToken);
|
||||||
if (!fCurrentCommandTag)
|
if (!fCurrentCommandTag)
|
||||||
HandleMemoryFailure();
|
HandleMemoryFailure();
|
||||||
|
@ -280,7 +281,7 @@ void nsImapServerResponseParser::ParseIMAPServerResponse(const char *currentComm
|
||||||
else if (!fServerConnection.DeathSignalReceived())
|
else if (!fServerConnection.DeathSignalReceived())
|
||||||
HandleMemoryFailure();
|
HandleMemoryFailure();
|
||||||
|
|
||||||
PR_FREEIF(copyCurrentCommand);
|
PR_Free(copyCurrentCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsImapServerResponseParser::HandleMemoryFailure()
|
void nsImapServerResponseParser::HandleMemoryFailure()
|
||||||
|
@ -309,7 +310,7 @@ void nsImapServerResponseParser::PreProcessCommandToken(const char *commandToken
|
||||||
{ // ill formed select command
|
{ // ill formed select command
|
||||||
openQuote = PL_strstr(currentCommand, " ");
|
openQuote = PL_strstr(currentCommand, " ");
|
||||||
}
|
}
|
||||||
PR_FREEIF( fSelectedMailboxName);
|
PR_Free( fSelectedMailboxName);
|
||||||
fSelectedMailboxName = PL_strdup(openQuote + 1);
|
fSelectedMailboxName = PL_strdup(openQuote + 1);
|
||||||
if (fSelectedMailboxName)
|
if (fSelectedMailboxName)
|
||||||
{
|
{
|
||||||
|
@ -440,7 +441,7 @@ void nsImapServerResponseParser::ProcessOkCommand(const char *commandToken)
|
||||||
|
|
||||||
fServerConnection.GetCurrentUrl()->GetImapPartToFetch(&imapPart);
|
fServerConnection.GetCurrentUrl()->GetImapPartToFetch(&imapPart);
|
||||||
m_shell->Generate(imapPart);
|
m_shell->Generate(imapPart);
|
||||||
PR_FREEIF(imapPart);
|
PR_Free(imapPart);
|
||||||
|
|
||||||
if ((navCon && navCon->GetPseudoInterrupted())
|
if ((navCon && navCon->GetPseudoInterrupted())
|
||||||
|| fServerConnection.DeathSignalReceived())
|
|| fServerConnection.DeathSignalReceived())
|
||||||
|
@ -763,8 +764,14 @@ This production was changed to accomodate predictive parsing
|
||||||
*/
|
*/
|
||||||
void nsImapServerResponseParser::mailbox_data()
|
void nsImapServerResponseParser::mailbox_data()
|
||||||
{
|
{
|
||||||
if (!PL_strcasecmp(fNextToken, "FLAGS")) {
|
if (!PL_strcasecmp(fNextToken, "FLAGS"))
|
||||||
|
{
|
||||||
|
// this handles the case where we got the permanent flags response
|
||||||
|
// before the flags response, in which case, we want to ignore thes flags.
|
||||||
|
if (fGotPermanentFlags)
|
||||||
skip_to_CRLF();
|
skip_to_CRLF();
|
||||||
|
else
|
||||||
|
parse_folder_flags();
|
||||||
}
|
}
|
||||||
else if (!PL_strcasecmp(fNextToken, "LIST"))
|
else if (!PL_strcasecmp(fNextToken, "LIST"))
|
||||||
{
|
{
|
||||||
|
@ -1475,8 +1482,8 @@ void nsImapServerResponseParser::parse_address(nsCAutoString &addressLine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PR_FREEIF(personalName);
|
PR_Free(personalName);
|
||||||
PR_FREEIF(atDomainList);
|
PR_Free(atDomainList);
|
||||||
|
|
||||||
if (*fNextToken == ')')
|
if (*fNextToken == ')')
|
||||||
fNextToken++;
|
fNextToken++;
|
||||||
|
@ -1689,7 +1696,39 @@ void nsImapServerResponseParser::text()
|
||||||
skip_to_CRLF();
|
skip_to_CRLF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsImapServerResponseParser::parse_folder_flags()
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
fNextToken = GetNextToken();
|
||||||
|
if (*fNextToken == '(')
|
||||||
|
fNextToken++;
|
||||||
|
if (!PL_strncasecmp(fNextToken, "$MDNSent", 8))
|
||||||
|
fSupportsUserDefinedFlags |= kImapMsgSupportMDNSentFlag;
|
||||||
|
else if (!PL_strncasecmp(fNextToken, "$Forwarded", 10))
|
||||||
|
fSupportsUserDefinedFlags |= kImapMsgSupportForwardedFlag;
|
||||||
|
else if (!PL_strncasecmp(fNextToken, "\\Seen", 5))
|
||||||
|
fSettablePermanentFlags |= kImapMsgSeenFlag;
|
||||||
|
else if (!PL_strncasecmp(fNextToken, "\\Answered", 9))
|
||||||
|
fSettablePermanentFlags |= kImapMsgAnsweredFlag;
|
||||||
|
else if (!PL_strncasecmp(fNextToken, "\\Flagged", 8))
|
||||||
|
fSettablePermanentFlags |= kImapMsgFlaggedFlag;
|
||||||
|
else if (!PL_strncasecmp(fNextToken, "\\Deleted", 8))
|
||||||
|
fSettablePermanentFlags |= kImapMsgDeletedFlag;
|
||||||
|
else if (!PL_strncasecmp(fNextToken, "\\Draft", 6))
|
||||||
|
fSettablePermanentFlags |= kImapMsgDraftFlag;
|
||||||
|
else if (!PL_strncasecmp(fNextToken, "\\*", 2))
|
||||||
|
{
|
||||||
|
fSupportsUserDefinedFlags |= kImapMsgSupportUserFlag;
|
||||||
|
fSupportsUserDefinedFlags |= kImapMsgSupportForwardedFlag;
|
||||||
|
fSupportsUserDefinedFlags |= kImapMsgSupportMDNSentFlag;
|
||||||
|
fSupportsUserDefinedFlags |= kImapMsgLabelFlags;
|
||||||
|
}
|
||||||
|
} while (!at_end_of_line() && ContinueParse());
|
||||||
|
|
||||||
|
if (fFlagState)
|
||||||
|
fFlagState->SetSupportedUserFlags(fSupportsUserDefinedFlags);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
resp_text_code ::= "ALERT" / "PARSE" /
|
resp_text_code ::= "ALERT" / "PARSE" /
|
||||||
"PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" /
|
"PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" /
|
||||||
|
@ -1728,7 +1767,7 @@ void nsImapServerResponseParser::resp_text_code()
|
||||||
if (alertMsg && *alertMsg && (!fLastAlert || PL_strcmp(fNextToken, fLastAlert)))
|
if (alertMsg && *alertMsg && (!fLastAlert || PL_strcmp(fNextToken, fLastAlert)))
|
||||||
{
|
{
|
||||||
fServerConnection.AlertUserEvent(alertMsg);
|
fServerConnection.AlertUserEvent(alertMsg);
|
||||||
PR_FREEIF(fLastAlert);
|
PR_Free(fLastAlert);
|
||||||
fLastAlert = PL_strdup(alertMsg);
|
fLastAlert = PL_strdup(alertMsg);
|
||||||
}
|
}
|
||||||
fNextToken = GetNextToken();
|
fNextToken = GetNextToken();
|
||||||
|
@ -1744,53 +1783,10 @@ void nsImapServerResponseParser::resp_text_code()
|
||||||
}
|
}
|
||||||
else if (!PL_strcasecmp(fNextToken,"PERMANENTFLAGS"))
|
else if (!PL_strcasecmp(fNextToken,"PERMANENTFLAGS"))
|
||||||
{
|
{
|
||||||
// do nothing but eat tokens until we see the ] or CRLF
|
|
||||||
// we should see the ] but we don't want to go into an
|
|
||||||
// endless loop if the CRLF is not there
|
|
||||||
|
|
||||||
fSupportsUserDefinedFlags = 0; // assume no unless told
|
fSupportsUserDefinedFlags = 0; // assume no unless told
|
||||||
do {
|
fSettablePermanentFlags = 0; // assume none, unless told otherwise.
|
||||||
fNextToken = GetNextToken();
|
parse_folder_flags();
|
||||||
if (*fNextToken == '(') fNextToken++;
|
fGotPermanentFlags = PR_TRUE;
|
||||||
if (!PL_strncasecmp(fNextToken, "$MDNSent", 8))
|
|
||||||
{
|
|
||||||
fSupportsUserDefinedFlags |= kImapMsgSupportMDNSentFlag;
|
|
||||||
}
|
|
||||||
else if (!PL_strncasecmp(fNextToken, "$Forwarded", 10))
|
|
||||||
{
|
|
||||||
fSupportsUserDefinedFlags |= kImapMsgSupportForwardedFlag;
|
|
||||||
}
|
|
||||||
else if (!PL_strncasecmp(fNextToken, "\\Seen", 5))
|
|
||||||
{
|
|
||||||
fSettablePermanentFlags |= kImapMsgSeenFlag;
|
|
||||||
}
|
|
||||||
else if (!PL_strncasecmp(fNextToken, "\\Answered", 9))
|
|
||||||
{
|
|
||||||
fSettablePermanentFlags |= kImapMsgAnsweredFlag;
|
|
||||||
}
|
|
||||||
else if (!PL_strncasecmp(fNextToken, "\\Flagged", 8))
|
|
||||||
{
|
|
||||||
fSettablePermanentFlags |= kImapMsgFlaggedFlag;
|
|
||||||
}
|
|
||||||
else if (!PL_strncasecmp(fNextToken, "\\Deleted", 8))
|
|
||||||
{
|
|
||||||
fSettablePermanentFlags |= kImapMsgDeletedFlag;
|
|
||||||
}
|
|
||||||
else if (!PL_strncasecmp(fNextToken, "\\Draft", 6))
|
|
||||||
{
|
|
||||||
fSettablePermanentFlags |= kImapMsgDraftFlag;
|
|
||||||
}
|
|
||||||
else if (!PL_strncasecmp(fNextToken, "\\*", 2))
|
|
||||||
{
|
|
||||||
fSupportsUserDefinedFlags |= kImapMsgSupportUserFlag;
|
|
||||||
fSupportsUserDefinedFlags |= kImapMsgSupportForwardedFlag;
|
|
||||||
fSupportsUserDefinedFlags |= kImapMsgSupportMDNSentFlag;
|
|
||||||
fSupportsUserDefinedFlags |= kImapMsgLabelFlags;
|
|
||||||
}
|
|
||||||
} while (!at_end_of_line() && ContinueParse());
|
|
||||||
if (fFlagState)
|
|
||||||
fFlagState->SetSupportedUserFlags(fSupportsUserDefinedFlags);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!PL_strcasecmp(fNextToken,"READ-ONLY]"))
|
else if (!PL_strcasecmp(fNextToken,"READ-ONLY]"))
|
||||||
{
|
{
|
||||||
|
@ -2253,7 +2249,7 @@ void nsImapServerResponseParser::namespace_data()
|
||||||
SetSyntaxError(PR_TRUE);
|
SetSyntaxError(PR_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PR_FREEIF(namespacePrefix);
|
PR_Free(namespacePrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2560,11 +2556,8 @@ PRBool nsImapServerResponseParser::msg_fetch_literal(PRBool chunk, PRInt32 origi
|
||||||
if (lastCRLFwasCRCRLF && (*fCurrentLine == nsCRT::CR))
|
if (lastCRLFwasCRCRLF && (*fCurrentLine == nsCRT::CR))
|
||||||
{
|
{
|
||||||
char *usableCurrentLine = PL_strdup(fCurrentLine + 1);
|
char *usableCurrentLine = PL_strdup(fCurrentLine + 1);
|
||||||
PR_FREEIF(fCurrentLine);
|
PR_Free(fCurrentLine);
|
||||||
if (usableCurrentLine)
|
|
||||||
fCurrentLine = usableCurrentLine;
|
fCurrentLine = usableCurrentLine;
|
||||||
else
|
|
||||||
fCurrentLine = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContinueParse())
|
if (ContinueParse())
|
||||||
|
|
|
@ -172,6 +172,7 @@ protected:
|
||||||
virtual void resp_cond_state();
|
virtual void resp_cond_state();
|
||||||
virtual void text_mime2();
|
virtual void text_mime2();
|
||||||
virtual void text();
|
virtual void text();
|
||||||
|
virtual void parse_folder_flags();
|
||||||
virtual void language_data();
|
virtual void language_data();
|
||||||
virtual void cramResponse_data();
|
virtual void cramResponse_data();
|
||||||
virtual void resp_text_code();
|
virtual void resp_text_code();
|
||||||
|
@ -214,13 +215,22 @@ protected:
|
||||||
virtual void SetSyntaxError(PRBool error);
|
virtual void SetSyntaxError(PRBool error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PRBool fProcessingTaggedResponse;
|
PRPackedBool fProcessingTaggedResponse;
|
||||||
PRBool fCurrentCommandFailed;
|
PRPackedBool fCurrentCommandFailed;
|
||||||
PRBool fReportingErrors;
|
PRPackedBool fReportingErrors;
|
||||||
|
|
||||||
|
|
||||||
PRBool fCurrentFolderReadOnly;
|
PRPackedBool fCurrentFolderReadOnly;
|
||||||
PRBool fCurrentLineContainedFlagInfo;
|
PRPackedBool fCurrentLineContainedFlagInfo;
|
||||||
|
PRPackedBool fFetchingAllFlags;
|
||||||
|
PRPackedBool fWaitingForMoreClientInput;
|
||||||
|
// when issuing a fetch command, are we fetching everything or just a part?
|
||||||
|
PRPackedBool fFetchEverythingRFC822;
|
||||||
|
// Is the server a Netscape 3.x Messaging Server?
|
||||||
|
PRPackedBool fServerIsNetscape3xServer;
|
||||||
|
PRPackedBool fDownloadingHeaders;
|
||||||
|
PRPackedBool fCurrentCommandIsSingleMessageFetch;
|
||||||
|
PRPackedBool fGotPermanentFlags;
|
||||||
imapMessageFlagsType fSavedFlagInfo;
|
imapMessageFlagsType fSavedFlagInfo;
|
||||||
|
|
||||||
|
|
||||||
|
@ -235,7 +245,6 @@ private:
|
||||||
PRUint32 fHighestRecordedUID;
|
PRUint32 fHighestRecordedUID;
|
||||||
PRInt32 fSizeOfMostRecentMessage;
|
PRInt32 fSizeOfMostRecentMessage;
|
||||||
PRInt32 fTotalDownloadSize;
|
PRInt32 fTotalDownloadSize;
|
||||||
PRBool fFetchingAllFlags;
|
|
||||||
|
|
||||||
int fNumberOfTaggedResponsesExpected;
|
int fNumberOfTaggedResponsesExpected;
|
||||||
|
|
||||||
|
@ -250,7 +259,6 @@ private:
|
||||||
nsCOMPtr <nsIImapFlagAndUidState> fFlagState; // NOT owned by us, it's a copy, do not destroy
|
nsCOMPtr <nsIImapFlagAndUidState> fFlagState; // NOT owned by us, it's a copy, do not destroy
|
||||||
|
|
||||||
eIMAPstate fIMAPstate;
|
eIMAPstate fIMAPstate;
|
||||||
PRBool fWaitingForMoreClientInput;
|
|
||||||
|
|
||||||
PRUint32 fCapabilityFlag;
|
PRUint32 fCapabilityFlag;
|
||||||
char *fMailAccountUrl;
|
char *fMailAccountUrl;
|
||||||
|
@ -261,21 +269,13 @@ private:
|
||||||
char *fManageFiltersUrl;
|
char *fManageFiltersUrl;
|
||||||
char *fFolderAdminUrl;
|
char *fFolderAdminUrl;
|
||||||
|
|
||||||
// used for index->uid mapping
|
|
||||||
PRBool fCurrentCommandIsSingleMessageFetch;
|
|
||||||
PRInt32 fUidOfSingleMessageFetch;
|
PRInt32 fUidOfSingleMessageFetch;
|
||||||
PRInt32 fFetchResponseIndex;
|
PRInt32 fFetchResponseIndex;
|
||||||
|
|
||||||
// used for aborting a fetch stream when we're pseudo-Interrupted
|
// used for aborting a fetch stream when we're pseudo-Interrupted
|
||||||
PRBool fDownloadingHeaders;
|
|
||||||
PRInt32 numberOfCharsInThisChunk;
|
PRInt32 numberOfCharsInThisChunk;
|
||||||
PRInt32 charsReadSoFar;
|
PRInt32 charsReadSoFar;
|
||||||
PRBool fLastChunk;
|
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;
|
|
||||||
|
|
||||||
// points to the current body shell, if any
|
// points to the current body shell, if any
|
||||||
nsIMAPBodyShell *m_shell;
|
nsIMAPBodyShell *m_shell;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче