Use nsIMgParseMailMsgState & the component manager so we don't have to link against local to pick up the message parser.

This commit is contained in:
mscott%netscape.com 1999-05-27 22:13:57 +00:00
Родитель 1d2ca0fd69
Коммит 7e8f34dd02
2 изменённых файлов: 23 добавлений и 19 удалений

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

@ -29,7 +29,6 @@
#include "nsMsgFolderFlags.h" #include "nsMsgFolderFlags.h"
#include "nsLocalFolderSummarySpec.h" #include "nsLocalFolderSummarySpec.h"
#include "nsImapFlagAndUidState.h" #include "nsImapFlagAndUidState.h"
#include "nsParseMailbox.h"
#include "nsIEventQueueService.h" #include "nsIEventQueueService.h"
#include "nsIImapUrl.h" #include "nsIImapUrl.h"
#include "nsImapUtils.h" #include "nsImapUtils.h"
@ -38,6 +37,7 @@
#include "nsImapMessage.h" #include "nsImapMessage.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsMsgBaseCID.h" #include "nsMsgBaseCID.h"
#include "nsMsgLocalCID.h"
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug // we need this because of an egcs 1.0 (and possibly gcc) compiler bug
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class // that doesn't allow you to call ::nsISupports::GetIID() inside of a class
@ -51,6 +51,7 @@ static NS_DEFINE_CID(kCImapDB, NS_IMAPDB_CID);
static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID); static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID); static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kParseMailMsgStateCID, NS_PARSEMAILMSGSTATE_CID);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// for temp message hack // for temp message hack
@ -68,7 +69,7 @@ static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
nsImapMailFolder::nsImapMailFolder() : nsImapMailFolder::nsImapMailFolder() :
m_initialized(PR_FALSE),m_haveDiscoverAllFolders(PR_FALSE), m_initialized(PR_FALSE),m_haveDiscoverAllFolders(PR_FALSE),
m_haveReadNameFromDB(PR_FALSE), m_msgParser(nsnull), m_haveReadNameFromDB(PR_FALSE),
m_curMsgUid(0), m_nextMessageByteLength(0), m_curMsgUid(0), m_nextMessageByteLength(0),
m_urlRunning(PR_FALSE), m_tempMessageFile(MESSAGE_PATH) m_urlRunning(PR_FALSE), m_tempMessageFile(MESSAGE_PATH)
{ {
@ -82,7 +83,6 @@ nsImapMailFolder::nsImapMailFolder() :
if (NS_SUCCEEDED(rv) && pEventQService) if (NS_SUCCEEDED(rv) && pEventQService)
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(), pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
getter_AddRefs(m_eventQueue)); getter_AddRefs(m_eventQueue));
m_msgParser = nsnull;
} }
nsImapMailFolder::~nsImapMailFolder() nsImapMailFolder::~nsImapMailFolder()
@ -1273,16 +1273,16 @@ NS_IMETHODIMP nsImapMailFolder::SetupHeaderParseStream(
m_nextMessageByteLength = aStreamInfo->size; m_nextMessageByteLength = aStreamInfo->size;
if (!m_msgParser) if (!m_msgParser)
{ {
m_msgParser = new nsParseMailMessageState; rv = nsComponentManager::CreateInstance(kParseMailMsgStateCID, nsnull,
m_msgParser->SetMailDB(mDatabase); nsIMsgParseMailMsgState::GetIID(), (void **) getter_AddRefs(m_msgParser));
if (NS_SUCCEEDED(rv))
m_msgParser->SetMailDB(mDatabase);
} }
else else
m_msgParser->Clear(); m_msgParser->Clear();
if (m_msgParser) if (m_msgParser)
{ return m_msgParser->SetState(MBOX_PARSE_HEADERS);
m_msgParser->m_state = MBOX_PARSE_HEADERS;
return NS_OK;
}
else else
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
return rv; return rv;
@ -1295,7 +1295,7 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
// but they never contain partial lines // but they never contain partial lines
char *str = aMsgLineInfo->adoptedMessageLine; char *str = aMsgLineInfo->adoptedMessageLine;
m_curMsgUid = aMsgLineInfo->uidOfMessage; m_curMsgUid = aMsgLineInfo->uidOfMessage;
m_msgParser->m_envelope_pos = m_curMsgUid; // OK, this is silly (but m_msgParser->SetEnvelopePos(m_curMsgUid); // OK, this is silly (but
// we'll fix // we'll fix
// it). m_envelope_pos, for // it). m_envelope_pos, for
// local folders, // local folders,
@ -1308,7 +1308,7 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
{ {
if (currentEOL) if (currentEOL)
{ {
m_msgParser->ParseFolderLine(currentLine, m_msgParser->ParseAFolderLine(currentLine,
(currentEOL + MSG_LINEBREAK_LEN) - (currentEOL + MSG_LINEBREAK_LEN) -
currentLine); currentLine);
currentLine = currentEOL + MSG_LINEBREAK_LEN; currentLine = currentEOL + MSG_LINEBREAK_LEN;
@ -1316,7 +1316,7 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
} }
else else
{ {
m_msgParser->ParseFolderLine(currentLine, PL_strlen(currentLine)); m_msgParser->ParseAFolderLine(currentLine, PL_strlen(currentLine));
currentLine = str + len + 1; currentLine = str + len + 1;
} }
} }
@ -1326,12 +1326,17 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
NS_IMETHODIMP nsImapMailFolder::NormalEndHeaderParseStream(nsIImapProtocol* NS_IMETHODIMP nsImapMailFolder::NormalEndHeaderParseStream(nsIImapProtocol*
aProtocol) aProtocol)
{ {
if (m_msgParser && m_msgParser->m_newMsgHdr) nsCOMPtr<nsIMsgDBHdr> newMsgHdr;
nsresult rv = NS_OK;
if (m_msgParser)
m_msgParser->GetNewMsgHdr(getter_AddRefs(newMsgHdr));
if (NS_SUCCEEDED(rv) && newMsgHdr)
{ {
m_msgParser->m_newMsgHdr->SetMessageKey(m_curMsgUid); newMsgHdr->SetMessageKey(m_curMsgUid);
TweakHeaderFlags(aProtocol, m_msgParser->m_newMsgHdr); TweakHeaderFlags(aProtocol, newMsgHdr);
// here we need to tweak flags from uid state.. // here we need to tweak flags from uid state..
mDatabase->AddNewHdrToDB(m_msgParser->m_newMsgHdr, PR_TRUE); mDatabase->AddNewHdrToDB(newMsgHdr, PR_TRUE);
m_msgParser->FinishHeader(); m_msgParser->FinishHeader();
if (mDatabase) if (mDatabase)
mDatabase->Commit(kLargeCommit); // don't really want to do this mDatabase->Commit(kLargeCommit); // don't really want to do this

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

@ -28,14 +28,13 @@
#include "nsIImapService.h" #include "nsIImapService.h"
#include "nsIUrlListener.h" #include "nsIUrlListener.h"
#include "nsIImapIncomingServer.h" // we need this for its IID #include "nsIImapIncomingServer.h" // we need this for its IID
#include "nsIMsgParseMailMsgState.h"
/* fa32d000-f6a0-11d2-af8d-001083002da8 */ /* fa32d000-f6a0-11d2-af8d-001083002da8 */
#define NS_IMAPRESOURCE_CID \ #define NS_IMAPRESOURCE_CID \
{ 0xfa32d000, 0xf6a0, 0x11d2, \ { 0xfa32d000, 0xf6a0, 0x11d2, \
{ 0xaf, 0x8d, 0x00, 0x10, 0x83, 0x00, 0x2d, 0xa8 } } { 0xaf, 0x8d, 0x00, 0x10, 0x83, 0x00, 0x2d, 0xa8 } }
class nsParseMailMessageState;
class nsImapMailFolder : public nsMsgDBFolder, class nsImapMailFolder : public nsMsgDBFolder,
public nsIMsgImapMailFolder, public nsIMsgImapMailFolder,
public nsIImapMailFolderSink, public nsIImapMailFolderSink,
@ -262,7 +261,7 @@ protected:
PRBool m_initialized; PRBool m_initialized;
PRBool m_haveDiscoverAllFolders; PRBool m_haveDiscoverAllFolders;
PRBool m_haveReadNameFromDB; PRBool m_haveReadNameFromDB;
nsParseMailMessageState *m_msgParser; nsCOMPtr<nsIMsgParseMailMsgState> m_msgParser;
nsMsgKey m_curMsgUid; nsMsgKey m_curMsgUid;
PRInt32 m_nextMessageByteLength; PRInt32 m_nextMessageByteLength;
nsCOMPtr<nsIEventQueue> m_eventQueue; nsCOMPtr<nsIEventQueue> m_eventQueue;