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
Родитель 12ff1a5901
Коммит 6f61c81c3b
2 изменённых файлов: 23 добавлений и 19 удалений

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

@ -29,7 +29,6 @@
#include "nsMsgFolderFlags.h"
#include "nsLocalFolderSummarySpec.h"
#include "nsImapFlagAndUidState.h"
#include "nsParseMailbox.h"
#include "nsIEventQueueService.h"
#include "nsIImapUrl.h"
#include "nsImapUtils.h"
@ -38,6 +37,7 @@
#include "nsImapMessage.h"
#include "nsIWebShell.h"
#include "nsMsgBaseCID.h"
#include "nsMsgLocalCID.h"
// 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
@ -51,6 +51,7 @@ static NS_DEFINE_CID(kCImapDB, NS_IMAPDB_CID);
static NS_DEFINE_CID(kCImapService, NS_IMAPSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kParseMailMsgStateCID, NS_PARSEMAILMSGSTATE_CID);
////////////////////////////////////////////////////////////////////////////////
// for temp message hack
@ -68,7 +69,7 @@ static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
nsImapMailFolder::nsImapMailFolder() :
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_urlRunning(PR_FALSE), m_tempMessageFile(MESSAGE_PATH)
{
@ -82,7 +83,6 @@ nsImapMailFolder::nsImapMailFolder() :
if (NS_SUCCEEDED(rv) && pEventQService)
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),
getter_AddRefs(m_eventQueue));
m_msgParser = nsnull;
}
nsImapMailFolder::~nsImapMailFolder()
@ -1273,16 +1273,16 @@ NS_IMETHODIMP nsImapMailFolder::SetupHeaderParseStream(
m_nextMessageByteLength = aStreamInfo->size;
if (!m_msgParser)
{
m_msgParser = new nsParseMailMessageState;
m_msgParser->SetMailDB(mDatabase);
rv = nsComponentManager::CreateInstance(kParseMailMsgStateCID, nsnull,
nsIMsgParseMailMsgState::GetIID(), (void **) getter_AddRefs(m_msgParser));
if (NS_SUCCEEDED(rv))
m_msgParser->SetMailDB(mDatabase);
}
else
m_msgParser->Clear();
if (m_msgParser)
{
m_msgParser->m_state = MBOX_PARSE_HEADERS;
return NS_OK;
}
return m_msgParser->SetState(MBOX_PARSE_HEADERS);
else
return NS_ERROR_OUT_OF_MEMORY;
return rv;
@ -1295,7 +1295,7 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
// but they never contain partial lines
char *str = aMsgLineInfo->adoptedMessageLine;
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
// it). m_envelope_pos, for
// local folders,
@ -1308,7 +1308,7 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
{
if (currentEOL)
{
m_msgParser->ParseFolderLine(currentLine,
m_msgParser->ParseAFolderLine(currentLine,
(currentEOL + MSG_LINEBREAK_LEN) -
currentLine);
currentLine = currentEOL + MSG_LINEBREAK_LEN;
@ -1316,7 +1316,7 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
}
else
{
m_msgParser->ParseFolderLine(currentLine, PL_strlen(currentLine));
m_msgParser->ParseAFolderLine(currentLine, PL_strlen(currentLine));
currentLine = str + len + 1;
}
}
@ -1326,12 +1326,17 @@ NS_IMETHODIMP nsImapMailFolder::ParseAdoptedHeaderLine(
NS_IMETHODIMP nsImapMailFolder::NormalEndHeaderParseStream(nsIImapProtocol*
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);
TweakHeaderFlags(aProtocol, m_msgParser->m_newMsgHdr);
newMsgHdr->SetMessageKey(m_curMsgUid);
TweakHeaderFlags(aProtocol, newMsgHdr);
// 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();
if (mDatabase)
mDatabase->Commit(kLargeCommit); // don't really want to do this

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

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