From cdbcefa2555c8120ec831a6462b55d4798e7150b Mon Sep 17 00:00:00 2001 From: "bienvenu%netscape.com" Date: Mon, 19 Apr 1999 02:13:23 +0000 Subject: [PATCH] make protocol use imapMailFolder header parse stuff when getting headers --- mailnews/imap/src/nsImapProtocol.cpp | 30 ++++++++++++++++--- .../imap/src/nsImapServerResponseParser.cpp | 5 ++++ .../imap/src/nsImapServerResponseParser.h | 1 + .../imap/tests/harness/imapProtocolTest.cpp | 14 +++++++-- mailnews/imap/tests/harness/makefile.win | 2 ++ 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index 67dcc8bb1645..9664bb4f6ad7 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -1601,7 +1601,13 @@ void nsImapProtocol::BeginMessageDownLoad( si->content_type = PL_strdup(content_type); if (si->content_type) { - if (m_imapMessage) + + if (GetServerStateParser().GetDownloadingHeaders()) + { + if (m_imapMailFolder) + m_imapMailFolder->SetupHeaderParseStream(this, si); + } + else if (m_imapMessage) { m_imapMessage->SetupMsgWriteStream(this, si); WaitForFEEventCompletion(); @@ -2175,7 +2181,13 @@ nsImapProtocol::PostLineDownLoadEvent(msg_line_info *downloadLineDontDelete) { NS_ASSERTION(downloadLineDontDelete, "Oops... null msg line info not good"); - if (m_imapMessage && downloadLineDontDelete) + + if (GetServerStateParser().GetDownloadingHeaders()) + { + if (m_imapMailFolder && downloadLineDontDelete) + m_imapMailFolder->ParseAdoptedHeaderLine(this, downloadLineDontDelete); + } + else if (m_imapMessage && downloadLineDontDelete) m_imapMessage->ParseAdoptedMsgLine(this, downloadLineDontDelete); // ***** We need to handle the psuedo interrupt here ***** @@ -2310,7 +2322,12 @@ void nsImapProtocol::NormalMessageEndDownload() m_downloadLineCache.ResetCache(); } - if (m_imapMessage) + if (GetServerStateParser().GetDownloadingHeaders()) + { + if (m_imapMailFolder) + m_imapMailFolder->NormalEndHeaderParseStream(this); + } + else if (m_imapMessage) m_imapMessage->NormalEndMsgWriteStream(this); } @@ -2328,7 +2345,12 @@ void nsImapProtocol::AbortMessageDownLoad() m_downloadLineCache.ResetCache(); } - if (m_imapMessage) + if (GetServerStateParser().GetDownloadingHeaders()) + { + if (m_imapMailFolder) + m_imapMailFolder->AbortHeaderParseStream(this); + } + else if (m_imapMessage) m_imapMessage->AbortMsgWriteStream(this); } diff --git a/mailnews/imap/src/nsImapServerResponseParser.cpp b/mailnews/imap/src/nsImapServerResponseParser.cpp index 4d47b3bb9087..e76361fbfecb 100644 --- a/mailnews/imap/src/nsImapServerResponseParser.cpp +++ b/mailnews/imap/src/nsImapServerResponseParser.cpp @@ -2034,6 +2034,11 @@ PRBool nsImapServerResponseParser::GetFillingInShell() return (m_shell != nsnull); } +PRBool nsImapServerResponseParser::GetDownloadingHeaders() +{ + return fDownloadingHeaders; +} + // Tells the server state parser to use a previously cached shell. void nsImapServerResponseParser::UseCachedShell(nsIMAPBodyShell *cachedShell) { diff --git a/mailnews/imap/src/nsImapServerResponseParser.h b/mailnews/imap/src/nsImapServerResponseParser.h index af8cec2e752a..c059dd4cfcb4 100644 --- a/mailnews/imap/src/nsImapServerResponseParser.h +++ b/mailnews/imap/src/nsImapServerResponseParser.h @@ -125,6 +125,7 @@ public: virtual PRUint16 SettablePermanentFlags() { return fSettablePermanentFlags;}; void SetFlagState(nsImapFlagAndUidState *state); + PRBool GetDownloadingHeaders(); PRBool GetFillingInShell(); void UseCachedShell(nsIMAPBodyShell *cachedShell); void SetHostSessionList(nsIImapHostSessionList *aHostSession); diff --git a/mailnews/imap/tests/harness/imapProtocolTest.cpp b/mailnews/imap/tests/harness/imapProtocolTest.cpp index 64adb2460727..708498d6de7d 100644 --- a/mailnews/imap/tests/harness/imapProtocolTest.cpp +++ b/mailnews/imap/tests/harness/imapProtocolTest.cpp @@ -57,6 +57,7 @@ #include "nsMsgDatabase.h" #include "nsImapFlagAndUidState.h" +#include "nsParseMailbox.h" #ifdef XP_PC #define NETLIB_DLL "netlib.dll" @@ -267,6 +268,7 @@ protected: nsIImapUrl * m_url; nsIImapProtocol * m_IMAP4Protocol; // running protocol instance + nsParseMailMessageState *m_msgParser ; PRBool m_runTestHarness; PRBool m_runningURL; // are we currently running a url? this flag is set to false when the url finishes... @@ -622,7 +624,7 @@ void nsIMAP4TestDriver::PrepareToAddHeadersToMailDB(nsIImapProtocol* aProtocol, aProtocol->NotifyHdrsToDownload(theKeys, total /*keysToFetch.GetSize() */); // now, tell it we don't need any bodies. if (aProtocol) - aProtocol->NotifyHdrsToDownload(NULL, 0); + aProtocol->NotifyBodysToDownload(NULL, 0); } else { @@ -700,13 +702,21 @@ NS_IMETHODIMP nsIMAP4TestDriver::SetupHeaderParseStream(nsIImapProtocol* aProtoc StreamInfo* aStreamInfo) { printf("**** nsIMAP4TestDriver::SetupHeaderParseStream\r\n"); - return NS_OK; + m_msgParser = new nsParseMailMessageState; + if (m_msgParser) + { + m_msgParser->m_state = MBOX_PARSE_HEADERS; + return NS_OK; + } + else + return NS_ERROR_OUT_OF_MEMORY; } NS_IMETHODIMP nsIMAP4TestDriver::ParseAdoptedHeaderLine(nsIImapProtocol* aProtocol, msg_line_info* aMsgLineInfo) { printf("**** nsIMAP4TestDriver::ParseAdoptedHeaderLine\r\n"); + m_msgParser->ParseFolderLine(aMsgLineInfo->adoptedMessageLine, PL_strlen(aMsgLineInfo->adoptedMessageLine)); return NS_OK; } diff --git a/mailnews/imap/tests/harness/makefile.win b/mailnews/imap/tests/harness/makefile.win index 09836a2b97a9..e8d6994c631f 100644 --- a/mailnews/imap/tests/harness/makefile.win +++ b/mailnews/imap/tests/harness/makefile.win @@ -71,6 +71,7 @@ LLIBS= $(LLIBS) ole32.lib \ $(DIST)\lib\plc3.lib \ $(DIST)\lib\raptorbase.lib \ $(DIST)\lib\msgcoreutil.lib \ + $(DIST)\lib\msglocal.lib \ $(DIST)\lib\xpcom32.lib @@ -82,6 +83,7 @@ LINCS=$(LINCS) -I. \ -I$(PUBLIC)\js \ -I$(PUBLIC)\rdfutil \ -I$(PUBLIC)\rdf \ + -I$(PUBLIC)\mime \ -I$(PUBLIC)\xpcom # clobber and clobber_all will remove the following garbage: