Moving header parser interface

This commit is contained in:
rhp%netscape.com 1999-04-16 19:02:22 +00:00
Родитель a616ac9de1
Коммит 599771aad8
27 изменённых файлов: 1616 добавлений и 140 удалений

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

@ -23,11 +23,6 @@
#include "nsIFactory.h"
#include "nsIComponentManager.h"
#define NS_MSGRFC822PARSER_CID \
{ /* 26D71620-7421-11d2-804A-006008128C4E */ \
0x26d71620, 0x7421, 0x11d2, \
{0x80, 0x4a, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e}}
#define NS_MSGFOLDEREVENT_CID \
{ /* FBFEBE7A-C1DD-11d2-8A40-0060B0FC04D2 */ \
0xfbfebe7a, 0xc1dd, 0x11d2, \

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

@ -35,8 +35,6 @@
#include "nsMsgAppCore.h"
/* Include all of the interfaces our factory can generate components for */
#include "nsIMsgRFC822Parser.h"
#include "nsMsgRFC822Parser.h"
#include "nsIUrlListenerManager.h"
#include "nsUrlListenerManager.h"
@ -55,7 +53,6 @@ static NS_DEFINE_CID(kCUrlListenerManagerCID, NS_URLLISTENERMANAGER_CID);
static NS_DEFINE_CID(kCMessengerCID, NS_MESSENGER_CID);
static NS_DEFINE_CID(kCMessengerBootstrapCID, NS_MESSENGERBOOTSTRAP_CID);
static NS_DEFINE_CID(kCMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
static NS_DEFINE_CID(kCMsgFolderEventCID, NS_MSGFOLDEREVENT_CID);
static NS_DEFINE_CID(kCMsgAppCoreCID, NS_MSGAPPCORE_CID);
@ -162,12 +159,7 @@ nsMsgFactory::CreateInstance(nsISupports *aOuter,
// ClassID check happens here
// Whenever you add a new class that supports an interface, plug it in here!!!
// do they want an RFC822 Parser interface ?
if (mClassID.Equals(kCMsgRFC822ParserCID))
{
return NS_NewRFC822Parser(aIID, aResult);
}
else if (mClassID.Equals(kCMsgFolderEventCID))
if (mClassID.Equals(kCMsgFolderEventCID))
{
NS_NOTREACHED("hello? what happens here?");
return NS_OK;
@ -294,12 +286,6 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
rv = compMgr->RegisterComponent(kCMsgRFC822ParserCID,
"RFC822 Parser",
nsnull,
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
rv = compMgr->RegisterComponent(kCMessengerCID,
"Netscape Messenger",
"component://netscape/messenger/application",
@ -387,8 +373,6 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* path)
rv = compMgr->UnregisterComponent(kCUrlListenerManagerCID, path);
if (NS_FAILED(rv)) goto done;
rv = compMgr->UnregisterComponent(kCMsgRFC822ParserCID, path);
if (NS_FAILED(rv)) goto done;
rv = compMgr->UnregisterComponent(kCMessengerCID, path);
if (NS_FAILED(rv)) goto done;
rv = compMgr->UnregisterComponent(kCMessengerBootstrapCID, path);

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

@ -41,7 +41,6 @@ EXPORTS = \
nsMsgLocalFolderHdrs.h \
nsMsgMD5.h \
nsIMsg.h \
nsIMsgRFC822Parser.h \
nsIMsgHost.h \
nsIFolder.h \
nsIMsgFolder.h \

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

@ -32,7 +32,6 @@ IDLSRCS = \
EXPORTS = \
nsIMessenger.h \
nsIMsgRFC822Parser.h \
msgCore.h \
nsMsgFolderFlags.h \
nsMsgLocalFolderHdrs.h \

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

@ -28,7 +28,6 @@ LIBRARY_NAME=mailnewsbase_s
EXPORTS = \
nsMessenger.h \
nsMsgKeyArray.h \
nsMsgRFC822Parser.h \
nsUrlListenerManager.h \
nsMsgMailSession.h \
nsMsgAppCore.h \
@ -41,7 +40,6 @@ CPPSRCS = \
nsMessenger.cpp \
nsIMessenger.cpp \
nsMessengerNameSet.cpp \
nsMsgRFC822Parser.cpp \
nsMsgKeyArray.cpp \
nsMsgImapMailFolder.cpp \
nsUrlListenerManager.cpp \

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

@ -30,7 +30,6 @@ CPPSRCS= \
nsMessenger.cpp \
nsIMessenger.cpp \
nsMessengerNameSet.cpp \
nsMsgRFC822Parser.cpp \
nsMsgKeyArray.cpp \
nsMsgImapMailFolder.cpp \
nsUrlListenerManager.cpp \
@ -49,7 +48,6 @@ CPP_OBJS= \
.\$(OBJDIR)\nsMessenger.obj \
.\$(OBJDIR)\nsIMessenger.obj \
.\$(OBJDIR)\nsMessengerNameSet.obj \
.\$(OBJDIR)\nsMsgRFC822Parser.obj \
.\$(OBJDIR)\nsMsgKeyArray.obj \
.\$(OBJDIR)\nsMsgImapMailFolder.obj \
.\$(OBJDIR)\nsUrlListenerManager.obj \
@ -65,7 +63,6 @@ CPP_OBJS= \
EXPORTS= \
nsMessenger.h \
nsMsgRFC822Parser.h \
nsMsgKeyArray.h \
nsUrlListenerManager.h \
nsMsgMailSession.h \

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

@ -74,6 +74,7 @@ LLIBS= $(LLIBS) ole32.lib \
LINCS=$(LINCS) -I. \
-I$(PUBLIC)\mailnews \
-I$(PUBLIC)\mime \
-I$(PUBLIC)\xpcom
# clobber and clobber_all will remove the following garbage:

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

@ -1,9 +1,9 @@
#include <stdio.h>
#include "nsIComponentManager.h"
#include "nsMsgBaseCID.h"
#include "nsIMsgRFC822Parser.h"
#include "nsIMsgHeaderParser.h"
static NS_DEFINE_CID(kMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
/* This is just a testing stub added by mscott. All I'm doing is loading a component,
and querying it for a particular interface.
@ -14,22 +14,22 @@ static NS_DEFINE_CID(kMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
int main(int argc, char *argv[])
{
nsIMsgRFC822Parser *sample;
nsIMsgHeaderParser *sample;
// register our dll
nsComponentManager::RegisterComponent(kMsgRFC822ParserCID, NULL, NULL, "mailnews.dll", PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kMsgHeaderParserCID, NULL, NULL, "mailnews.dll", PR_FALSE, PR_FALSE);
nsresult res = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsresult res = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
nsIMsgHeaderParser::GetIID(),
(void **) &sample);
if (res == NS_OK && sample) {
printf("We succesfully obtained a nsIMsgRFC822Parser interface....\n");
printf("We succesfully obtained a nsIMsgHeaderParser interface....\n");
char * names = NULL;
char * addresses = NULL;
PRUint32 numAddresses = 0;
sample->ParseRFC822Addresses(NULL, "Scott MacGregor <mscott@netscape.com>", &names, &addresses, numAddresses);
sample->ParseHeaderAddresses(NULL, "Scott MacGregor <mscott@netscape.com>", &names, &addresses, numAddresses);
if (names)
{
printf(names);

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

@ -11,7 +11,7 @@
#include "xp_time.h"
#include "nsMsgSendFact.h"
#include "nsMsgBaseCID.h"
#include "nsIMsgRFC822Parser.h"
#include "nsIMsgHeaderParser.h"
#include "nsINetService.h"
#include "nsISmtpService.h" // for actually sending the message...
#include "nsMsgCompPrefs.h"
@ -24,7 +24,7 @@
static NS_DEFINE_IID(kIMsgSend, NS_IMSGSEND_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kSmtpServiceCID, NS_SMTPSERVICE_CID);
static NS_DEFINE_CID(kMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
#if 0 //JFD
@ -1638,15 +1638,15 @@ static char * mime_fix_header_1 (const char *string, PRBool addr_p, PRBool news_
return 0;
if (addr_p) {
nsIMsgRFC822Parser * pRfc822;
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsIMsgHeaderParser * pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &pRfc822);
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv)) {
char *n;
pRfc822->ReformatRFC822Addresses(nsnull, string, &n);
pRfc822->Release();
pHeader->ReformatHeaderAddresses(nsnull, string, &n);
pHeader->Release();
if (n)
return n;
}

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

@ -23,8 +23,7 @@
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIMsgRFC822Parser.h"
#include "nsMsgRFC822Parser.h"
#include "nsIMsgHeaderParser.h"
#include "nsFileStream.h"
#include "nsINetService.h"
@ -39,7 +38,7 @@
static NS_DEFINE_CID(kNetServiceCID, NS_NETSERVICE_CID);
static NS_DEFINE_CID(kRFC822ParserCID, NS_MSGRFC822PARSER_CID);
static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
extern "C" {
char * NET_SACopy (char **destination, const char *source);
@ -615,10 +614,10 @@ PRInt32 nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, PRUint32
else
{
/* else send the MAIL FROM: command */
nsIMsgRFC822Parser * parser = nsnull;
nsComponentManager::CreateInstance(kRFC822ParserCID,
nsIMsgHeaderParser * parser = nsnull;
nsComponentManager::CreateInstance(kHeaderParserCID,
nsnull,
nsIMsgRFC822Parser::GetIID(),
nsIMsgHeaderParser::GetIID(),
(void **)&parser);
char * s = nsnull;
@ -1315,10 +1314,10 @@ PRInt32 nsSmtpProtocol::LoadURL(nsIURL * aURL)
*/
char * addresses = nsnull;
nsIMsgRFC822Parser * parser = nsnull;
nsComponentManager::CreateInstance(kRFC822ParserCID,
nsIMsgHeaderParser * parser = nsnull;
nsComponentManager::CreateInstance(kHeaderParserCID,
nsnull,
nsIMsgRFC822Parser::GetIID(),
nsIMsgHeaderParser::GetIID(),
(void **)&parser);
m_runningURL->GetAllRecipients(&addresses);
@ -1334,7 +1333,7 @@ PRInt32 nsSmtpProtocol::LoadURL(nsIURL * aURL)
*/
if (addrs1 && *addrs1)
{
rv = parser->ParseRFC822Addresses(nsnull, addrs1, nsnull, &addrs2, m_addressesLeft);
rv = parser->ParseHeaderAddresses(nsnull, addrs1, nsnull, &addrs2, m_addressesLeft);
PR_FREEIF (addrs1);
}

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

@ -35,7 +35,7 @@ class nsNewsSet;
class nsMsgThread;
class nsIMsgThread;
class nsIDBFolderInfo;
class nsIMsgRFC822Parser;
class nsIMsgHeaderParser;
class nsMsgDatabase : public nsIMsgDatabase
{
@ -191,7 +191,7 @@ public:
nsIMdbEnv *GetEnv() {return m_mdbEnv;}
nsIMdbStore *GetStore() {return m_mdbStore;}
virtual PRUint32 GetCurVersion();
nsIMsgRFC822Parser *GetRFC822Parser();
nsIMsgHeaderParser *GetHeaderParser();
static nsMsgDatabase* FindInCache(nsFileSpec &dbName);
@ -304,7 +304,7 @@ protected:
mdb_token m_threadUnreadChildrenColumnToken;
mdb_token m_messageThreadIdColumnToken;
mdb_token m_numReferencesColumnToken;
nsIMsgRFC822Parser *m_rfc822Parser;
nsIMsgHeaderParser *m_HeaderParser;
};
#endif

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

@ -29,7 +29,7 @@
#include "nsMsgThread.h"
#include "nsFileStream.h"
#include "nsString2.h"
#include "nsIMsgRFC822Parser.h"
#include "nsIMsgHeaderParser.h"
#include "nsMsgBaseCID.h"
#include "nsIMimeConverter.h"
@ -58,7 +58,7 @@ static NS_DEFINE_IID(kILocaleIID, NS_ILOCALE_IID);
static NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID);
static NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
static NS_DEFINE_IID(kICollationFactoryIID, NS_ICOLLATIONFACTORY_IID);
static NS_DEFINE_CID(kMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
#ifdef WE_HAVE_MDBINTERFACES
@ -305,7 +305,7 @@ nsMsgDatabase::nsMsgDatabase()
m_threadUnreadChildrenColumnToken(0),
m_messageThreadIdColumnToken(0),
m_numReferencesColumnToken(0),
m_rfc822Parser(nsnull)
m_HeaderParser(nsnull)
{
NS_INIT_REFCNT();
}
@ -313,10 +313,10 @@ nsMsgDatabase::nsMsgDatabase()
nsMsgDatabase::~nsMsgDatabase()
{
// Close(FALSE); // better have already been closed.
if (m_rfc822Parser)
if (m_HeaderParser)
{
NS_RELEASE(m_rfc822Parser);
m_rfc822Parser = nsnull;
NS_RELEASE(m_HeaderParser);
m_HeaderParser = nsnull;
}
if (m_ChangeListeners)
{
@ -2106,19 +2106,19 @@ nsresult nsMsgDatabase::RowCellColumnToCollationKey(nsIMdbRow *row, mdb_token co
return err;
}
nsIMsgRFC822Parser *nsMsgDatabase::GetRFC822Parser()
nsIMsgHeaderParser *nsMsgDatabase::GetHeaderParser()
{
if (!m_rfc822Parser)
if (!m_HeaderParser)
{
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &m_rfc822Parser);
nsIMsgHeaderParser::GetIID(),
(void **) &m_HeaderParser);
if (!NS_SUCCEEDED(rv))
m_rfc822Parser = nsnull;
m_HeaderParser = nsnull;
}
return m_rfc822Parser;
return m_HeaderParser;
}

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

@ -59,6 +59,7 @@ LINCS= -I$(DEPTH)\mailnews\local\src \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\rdfutil \
-I$(PUBLIC)\netlib \
-I$(PUBLIC)\mime \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -78,6 +78,7 @@ LINCS= -I$(PUBLIC)\xpcom \
-I$(PUBLIC)\rdfutil \
-I$(PUBLIC)\pref \
-I$(PUBLIC)\js \
-I$(PUBLIC)\mime \
$(NULL)
LCFLAGS = \

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

@ -39,7 +39,7 @@
#include "nsRDFCursorUtils.h"
#include "nsIMessage.h"
#include "nsMsgFolder.h"
#include "nsIMsgRFC822Parser.h"
#include "nsIMsgHeaderParser.h"
#include "nsMsgBaseCID.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
@ -58,7 +58,7 @@ typedef struct _nsMsgRDFNotification {
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
// 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
@ -110,7 +110,7 @@ DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, NewFolder);
// The cached service managers
static nsIRDFService* gRDFService = nsnull;
static nsIMsgRFC822Parser *gRFC822Parser = nsnull;
static nsIMsgHeaderParser *gHeaderParser = nsnull;
////////////////////////////////////////////////////////////////////////
// Utilities
@ -228,10 +228,10 @@ nsMSGFolderDataSource::nsMSGFolderDataSource()
nsIRDFService::GetIID(),
(nsISupports**) &gRDFService); // XXX probably need shutdown listener here
rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &gRFC822Parser);
nsIMsgHeaderParser::GetIID(),
(void **) &gHeaderParser);
PR_ASSERT(NS_SUCCEEDED(rv));
}
@ -268,9 +268,9 @@ nsMSGFolderDataSource::~nsMSGFolderDataSource (void)
NS_RELEASE2(kNC_NewFolder, refcnt);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService); // XXX probably need shutdown listener here
if(gRFC822Parser)
NS_RELEASE(gRFC822Parser);
gRFC822Parser = nsnull;
if(gHeaderParser)
NS_RELEASE(gHeaderParser);
gHeaderParser = nsnull;
gRDFService = nsnull;
}
@ -403,11 +403,11 @@ nsresult nsMSGFolderDataSource::GetSenderName(nsAutoString& sender, nsAutoString
{
//XXXOnce we get the csid, use Intl version
nsresult rv = NS_OK;
if(gRFC822Parser)
if(gHeaderParser)
{
char *name;
char *senderStr = sender.ToNewCString();
if(NS_SUCCEEDED(rv = gRFC822Parser->ExtractRFC822AddressName (nsnull, senderStr, &name)))
if(NS_SUCCEEDED(rv = gHeaderParser->ExtractHeaderAddressName (nsnull, senderStr, &name)))
{
*senderUserName = name;
}

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

@ -369,12 +369,12 @@ nsParseMailMessageState::nsParseMailMessageState()
m_state = MBOX_PARSE_BODY;
Clear();
NS_DEFINE_CID(kMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsComponentManager::CreateInstance(kMsgHeaderParserCID,
nsnull,
nsIMsgRFC822Parser::GetIID(),
(void **)&m_rfc822AddressParser);
nsIMsgHeaderParser::GetIID(),
(void **)&m_HeaderAddressParser);
}
nsParseMailMessageState::~nsParseMailMessageState()
@ -382,7 +382,7 @@ nsParseMailMessageState::~nsParseMailMessageState()
ClearAggregateHeader (m_toList);
ClearAggregateHeader (m_ccList);
NS_RELEASE(m_rfc822AddressParser);
NS_RELEASE(m_HeaderAddressParser);
}
void nsParseMailMessageState::Init(PRUint32 fileposition)
@ -939,9 +939,9 @@ nsresult nsParseMailMessageState::InternRfc822 (struct message_header *header,
NS_ASSERTION (header->length == (short) nsCRT::strlen (header->value), "invalid message_header");
NS_ASSERTION (ret_name != NULL, "null ret_name");
if (m_rfc822AddressParser)
if (m_HeaderAddressParser)
{
ret = m_rfc822AddressParser->ExtractRFC822AddressName (nsnull, header->value, &s);
ret = m_HeaderAddressParser->ExtractHeaderAddressName (nsnull, header->value, &s);
if (! s)
return NS_ERROR_OUT_OF_MEMORY;
@ -1094,7 +1094,7 @@ int nsParseMailMessageState::FinalizeHeaders()
char *names;
char *addresses;
ret = m_rfc822AddressParser->ParseRFC822Addresses (nsnull, recipient->value, &names, &addresses, numAddresses);
ret = m_HeaderAddressParser->ParseHeaderAddresses (nsnull, recipient->value, &names, &addresses, numAddresses);
if (ret == NS_OK)
{
m_newMsgHdr->SetRecipientsArray(names, addresses, numAddresses);
@ -1110,7 +1110,7 @@ int nsParseMailMessageState::FinalizeHeaders()
char *names;
char *addresses;
ret = m_rfc822AddressParser->ParseRFC822Addresses (nsnull, ccList->value, &names, &addresses, numAddresses);
ret = m_HeaderAddressParser->ParseHeaderAddresses (nsnull, ccList->value, &names, &addresses, numAddresses);
if (ret == NS_OK)
{
m_newMsgHdr->SetCCListArray(names, addresses, numAddresses);

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

@ -24,7 +24,7 @@
#include "nsIStreamListener.h"
#include "nsITransport.h"
#include "nsMsgLineBuffer.h"
#include "nsMsgRFC822Parser.h"
#include "nsIMsgHeaderParser.h"
class nsFileSpec;
class nsByteArray;
@ -87,7 +87,7 @@ public:
static PRBool msg_StripRE(const char **stringP, PRUint32 *lengthP);
static int msg_UnHex(char C);
nsIMsgRFC822Parser* m_rfc822AddressParser;
nsIMsgHeaderParser* m_HeaderAddressParser;
nsMailDatabase *GetMailDB() {return m_mailDB;}
nsIMessage *m_newMsgHdr; /* current message header we're building */

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

@ -28,6 +28,7 @@ EXPORTS = \
nsIMimeObjectClassAccess.h \
nsIMimeEmitter.h \
nsMailHeaders.h \
nsIMsgHeaderParser.h \
$(NULL)
include $(topsrcdir)/config/config.mk

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

@ -24,6 +24,7 @@ EXPORTS = \
nsIMimeConverter.h \
nsIMimeEmitter.h \
nsMailHeaders.h \
nsIMsgHeaderParser.h \
$(NULL)
MODULE=mime

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

@ -82,6 +82,7 @@ CPPSRCS = \
mimemoz2.cpp \
comi18n.cpp \
nsMimeTransition.cpp \
nsMsgHeaderParser.cpp \
$(NULL)
CSRCS = \

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

@ -95,6 +95,7 @@ OBJS= \
.\$(OBJDIR)\mimebuf.obj \
.\$(OBJDIR)\mimecom.obj \
.\$(OBJDIR)\mimemoz2.obj \
.\$(OBJDIR)\nsMsgHeaderParser.obj \
#
# THIS WILL NEED WORK AFTER WE GET A LIBMSG MORE XP-COM-afied
# .\$(OBJDIR)\mimedrft.obj \

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

@ -20,8 +20,9 @@
#include "prmem.h"
#include "nsMsgBaseCID.h"
#include "nsIMsgRFC822Parser.h"
static NS_DEFINE_CID(kMsgRFC822ParserCID, NS_MSGRFC822PARSER_CID);
#include "nsIMsgHeaderParser.h"
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
extern int MK_OUT_OF_MEMORY;
@ -31,15 +32,15 @@ ParseRFC822Addresses (const char *line,
char **addresses)
{
PRUint32 numAddresses;
nsIMsgRFC822Parser *pRfc822;
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &pRfc822);
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
pRfc822->ParseRFC822Addresses(NULL, line, names, addresses, numAddresses);
pRfc822->Release();
pHeader->ParseHeaderAddresses(NULL, line, names, addresses, numAddresses);
pHeader->Release();
return numAddresses;
}
@ -54,15 +55,15 @@ ParseRFC822Addresses (const char *line,
int
UnquotePhraseOrAddr (char *line, char** lineout)
{
nsIMsgRFC822Parser *pRfc822;
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &pRfc822);
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
pRfc822->UnquotePhraseOrAddr(NULL, line, lineout);
pRfc822->Release();
pHeader->UnquotePhraseOrAddr(NULL, line, lineout);
pHeader->Release();
return NS_OK;
}
@ -76,15 +77,15 @@ char *
ExtractRFC822AddressMailboxes (const char *line)
{
char *retVal = NULL;
nsIMsgRFC822Parser *pRfc822;
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &pRfc822);
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
pRfc822->ExtractRFC822AddressMailboxes(NULL, line, &retVal);
pRfc822->Release();
pHeader->ExtractHeaderAddressMailboxes(NULL, line, &retVal);
pHeader->Release();
}
return retVal;
@ -102,15 +103,15 @@ char *
ExtractRFC822AddressNames (const char *line)
{
char *retVal = NULL;
nsIMsgRFC822Parser *pRfc822;
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &pRfc822);
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
pRfc822->ExtractRFC822AddressNames(NULL, line, &retVal);
pRfc822->Release();
pHeader->ExtractHeaderAddressNames(NULL, line, &retVal);
pHeader->Release();
}
return retVal;
@ -123,15 +124,15 @@ char *
ExtractRFC822AddressName (const char *line)
{
char *retVal = NULL;
nsIMsgRFC822Parser *pRfc822;
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &pRfc822);
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
pRfc822->ExtractRFC822AddressName(NULL, line, &retVal);
pRfc822->Release();
pHeader->ExtractHeaderAddressName(NULL, line, &retVal);
pHeader->Release();
}
return retVal;
@ -145,15 +146,15 @@ char *
ReformatRFC822Addresses (const char *line)
{
char *retVal = NULL;
nsIMsgRFC822Parser *pRfc822;
nsresult rv = nsComponentManager::CreateInstance(kMsgRFC822ParserCID,
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgRFC822Parser::GetIID(),
(void **) &pRfc822);
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
pRfc822->ReformatRFC822Addresses(NULL, line, &retVal);
pRfc822->Release();
pHeader->ReformatHeaderAddresses(NULL, line, &retVal);
pHeader->Release();
}
return retVal;

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

@ -26,6 +26,7 @@
#include "nsINetPlugin.h"
#include "nsIComponentManager.h"
#include "plugin_inst.h"
#include "nsIMsgHeaderParser.h"
/* net.h includes xp_core.h which has trouble with "Bool" */
#ifdef XP_UNIX
@ -49,6 +50,9 @@ static NS_DEFINE_IID(kINetPluginIID, NS_INET_PLUGIN_IID);
static NS_DEFINE_CID(kINetPluginCID, NS_INET_PLUGIN_CID);
static NS_DEFINE_CID(kINetPluginMIMECID, NS_INET_PLUGIN_MIME_CID);
#include "nsMsgHeaderParser.h"
static NS_DEFINE_CID(kCMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////
@ -150,6 +154,11 @@ nsresult nsMimeFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, v
if (res != NS_OK) // was there a problem creating the object ?
return res;
}
// do they want an RFC822 Parser interface ?
else if (mClassID.Equals(kCMsgHeaderParserCID))
{
res = NS_NewHeaderParser((nsIMsgHeaderParser **) &inst);
}
// End of checking the interface ID code....
if (inst)
@ -229,6 +238,13 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *
PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
// Message Header Parser
rv = compMgr->RegisterComponent(kCMsgHeaderParserCID,
"Header Parser",
nsnull,
path, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
// The new interface for stream conversion
rv = compMgr->RegisterComponent(kINetPluginMIMECID, NULL, PROGRAM_ID, path,
PR_TRUE, PR_TRUE);
@ -262,6 +278,8 @@ extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char
if (NS_FAILED(rv)) goto done;
rv = compMgr->UnregisterComponent(kINetPluginMIMECID, path);
if (NS_FAILED(rv)) goto done;
rv = compMgr->UnregisterComponent(kCMsgHeaderParserCID, path);
if (NS_FAILED(rv)) goto done;
done:
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/********************************************************************************************************
Interface for parsing RFC-822 addresses.
*********************************************************************************************************/
#ifndef nsMSGRFCPARSER_h__
#define nsMSGRFCPARSER_h__
#include "msgCore.h"
#include "nsIMsgHeaderParser.h" /* include the interface we are going to support */
/*
* RFC-822 parser
*/
class nsMsgHeaderParser: public nsIMsgHeaderParser
{
public:
nsMsgHeaderParser();
virtual ~nsMsgHeaderParser();
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
/* Given a string which contains a list of Header addresses, parses it into
their component names and mailboxes.
The returned value is the number of addresses, or a negative error code;
the names and addresses are returned into the provided pointers as
consecutive null-terminated strings. It is up to the caller to free them.
Note that some of the strings may be zero-length.
Either of the provided pointers may be NULL if the caller is not interested
in those components.
*/
NS_IMETHOD ParseHeaderAddresses (const char *charset, const char *line, char **names, char **addresses, PRUint32& numAddresses);
/* Given a string which contains a list of Header addresses, returns a
comma-seperated list of just the `mailbox' portions.
Caller must call PL_Free on mailboxes string returned by these calls.
*/
NS_IMETHOD ExtractHeaderAddressMailboxes (const char *charset, const char *line, char ** mailboxes);
/* Given a string which contains a list of Header addresses, returns a
comma-seperated list of just the `user name' portions. If any of
the addresses doesn't have a name, then the mailbox is used instead.
Caller must call PL_Free on userNames
*/
NS_IMETHOD ExtractHeaderAddressNames (const char *charset, const char *line, char ** userNames);
/* Like MSG_ExtractHeaderAddressNames(), but only returns the first name
in the list, if there is more than one.
Caller must call PL_Free on the returned firstName string.
*/
NS_IMETHOD ExtractHeaderAddressName (const char *charset, const char *line, char ** firstName);
/* Given a string which contains a list of Header addresses, returns a new
string with the same data, but inserts missing commas, parses and reformats
it, and wraps long lines with newline-tab.
Caller must call PL_Free on the returned string
*/
NS_IMETHOD ReformatHeaderAddresses (const char *charset, const char *line, char ** reformattedAddress);
/* Returns a copy of ADDRS which may have had some addresses removed.
Addresses are removed if they are already in either ADDRS or OTHER_ADDRS.
(If OTHER_ADDRS contain addresses which are not in ADDRS, they are not
added. That argument is for passing in addresses that were already
mentioned in other header fields.)
Addresses are considered to be the same if they contain the same mailbox
part (case-insensitive.) Real names and other comments are not compared.
removeAliasesToMe allows the address parser to use the preference which
contains regular expressions which also mean 'me' for the purpose of
stripping the user's email address(es) out of addrs
Caller must call PL_Free on outString.
*/
NS_IMETHOD RemoveDuplicateAddresses (const char *charset, const char *addrs, const char *other_addrs, PRBool removeAliasesToMe, char ** outString);
/* Given an e-mail address and a person's name, cons them together into a
single string of the form "name <address>", doing all the necessary quoting.
A new string is returned, which you must free when you're done with it.
Caller must call PL_Free on fullAddress
*/
NS_IMETHOD MakeFullAddress (const char *charset, const char* name, const char* addr, char ** fullAddress);
/* MSG_ParseHeaderAddresses returns quoted parsable addresses
This function removes the quoting if you want to show the
names to users. e.g. summary file, address book
*/
NS_IMETHOD UnquotePhraseOrAddr (const char *charset, const char *line, char** lineout);
private:
};
/* this function will be used by the factory to generate an RFC-822 Parser....*/
extern nsresult NS_NewHeaderParser(nsIMsgHeaderParser ** aInstancePtrResult);
#endif /* nsMSGRFCPARSER_h__ */

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

@ -63,6 +63,7 @@ LINCS= \
-I$(PUBLIC)\netlib \
-I$(PUBLIC)\security \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\mime \
$(NULL)
LCFLAGS = \

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

@ -50,8 +50,7 @@
/* include event sink interfaces for news */
#include "nsIMsgRFC822Parser.h"
#include "nsMsgRFC822Parser.h"
#include "nsIMsgHeaderParser.h"
#include "nsINntpUrl.h"
#include "nsNNTPHost.h"
@ -3446,20 +3445,20 @@ PRInt32 nsNNTPProtocol::Cancel()
rv = m_newsHost->QueryExtension("CANCELCHK",&cancelchk);
if (NS_SUCCEEDED(rv) && cancelchk)
{
nsIMsgRFC822Parser *parser;
nsIMsgHeaderParser *parser;
nsresult rv;
PRBool ok = PR_FALSE;
NS_DEFINE_CID(kCRFC822Parser, NS_MSGRFC822PARSER_CID);
NS_DEFINE_CID(kCHeaderParser, NS_MSGHEADERPARSER_CID);
rv = nsComponentManager::CreateInstance(kCRFC822Parser,
rv = nsComponentManager::CreateInstance(kCHeaderParser,
nsnull,
nsIMsgRFC822Parser::IID(),
nsIMsgHeaderParser::IID(),
(void **)&parser);
if (NS_SUCCEEDED(rv))
{
char *us, *them;
nsresult rv1 = parser->ExtractRFC822AddressMailboxes(nsnull, from, &us);
nsresult rv2 = parser->ExtractRFC822AddressMailboxes(nsnull, old_from, &them);
nsresult rv1 = parser->ExtractHeaderAddressMailboxes(nsnull, from, &us);
nsresult rv2 = parser->ExtractHeaderAddressMailboxes(nsnull, old_from, &them);
ok = (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2) && !PL_strcasecmp(us, them));
if (NS_SUCCEEDED(rv1)) PR_Free(us);