This commit is contained in:
rhp%netscape.com 1999-05-12 22:08:22 +00:00
Родитель 5236b01cef
Коммит 5e245a6980
15 изменённых файлов: 351 добавлений и 318 удалений

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

@ -17,7 +17,7 @@
*/
#include "nsIComponentManager.h"
#include "nsMimeObjectClassAccess.h"
#include "nsCOMPtr.h"
static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID);
/*
@ -27,17 +27,14 @@ static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID)
extern "C" void *
COM_GetmimeInlineTextClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeInlineTextClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -45,17 +42,14 @@ COM_GetmimeInlineTextClass(void)
extern "C" void *
COM_GetmimeLeafClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeLeafClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -63,17 +57,14 @@ COM_GetmimeLeafClass(void)
extern "C" void *
COM_GetmimeObjectClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeObjectClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -81,17 +72,14 @@ COM_GetmimeObjectClass(void)
extern "C" void *
COM_GetmimeContainerClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeContainerClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -99,17 +87,14 @@ COM_GetmimeContainerClass(void)
extern "C" void *
COM_GetmimeMultipartClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeMultipartClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -117,17 +102,14 @@ COM_GetmimeMultipartClass(void)
extern "C" void *
COM_GetmimeMultipartSignedClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeMultipartSignedClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -136,37 +118,20 @@ extern "C" int
COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length,
PRBool user_visible_p)
{
nsMimeObjectClassAccess *objAccess;
int rc = -1;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
PRInt32 rc;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
{
if (objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p) == NS_OK)
rc = length;
else
rc = -1;
objAccess->Release();
}
return rc;
}
/**
// NOTE: Need to do these in the global registry
// register our dll
nsComponentManager::RegisterFactory(kRFC822toHTMLStreamConverterCID,
"mime.dll", PR_FALSE, PR_FALSE);
nsComponentManager::RegisterFactory(kMimeObjectClassAccessCID,
"mime.dll", PR_FALSE, PR_FALSE);
*/

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

@ -17,7 +17,7 @@
*/
#include "nsIComponentManager.h"
#include "nsMimeObjectClassAccess.h"
#include "nsCOMPtr.h"
static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID);
/*
@ -27,17 +27,14 @@ static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID)
extern "C" void *
COM_GetmimeInlineTextClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeInlineTextClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -45,17 +42,14 @@ COM_GetmimeInlineTextClass(void)
extern "C" void *
COM_GetmimeLeafClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeLeafClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -63,17 +57,14 @@ COM_GetmimeLeafClass(void)
extern "C" void *
COM_GetmimeObjectClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeObjectClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -81,17 +72,14 @@ COM_GetmimeObjectClass(void)
extern "C" void *
COM_GetmimeContainerClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeContainerClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -99,17 +87,14 @@ COM_GetmimeContainerClass(void)
extern "C" void *
COM_GetmimeMultipartClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeMultipartClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -117,17 +102,14 @@ COM_GetmimeMultipartClass(void)
extern "C" void *
COM_GetmimeMultipartSignedClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeMultipartSignedClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -136,37 +118,20 @@ extern "C" int
COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length,
PRBool user_visible_p)
{
nsMimeObjectClassAccess *objAccess;
int rc = -1;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
PRInt32 rc;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
{
if (objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p) == NS_OK)
rc = length;
else
rc = -1;
objAccess->Release();
}
return rc;
}
/**
// NOTE: Need to do these in the global registry
// register our dll
nsComponentManager::RegisterFactory(kRFC822toHTMLStreamConverterCID,
"mime.dll", PR_FALSE, PR_FALSE);
nsComponentManager::RegisterFactory(kMimeObjectClassAccessCID,
"mime.dll", PR_FALSE, PR_FALSE);
*/

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

@ -17,7 +17,7 @@
*/
#include "nsIComponentManager.h"
#include "nsMimeObjectClassAccess.h"
#include "nsCOMPtr.h"
static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID);
/*
@ -27,17 +27,14 @@ static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID)
extern "C" void *
COM_GetmimeInlineTextClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeInlineTextClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -45,17 +42,14 @@ COM_GetmimeInlineTextClass(void)
extern "C" void *
COM_GetmimeLeafClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeLeafClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -63,17 +57,14 @@ COM_GetmimeLeafClass(void)
extern "C" void *
COM_GetmimeObjectClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeObjectClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -81,17 +72,14 @@ COM_GetmimeObjectClass(void)
extern "C" void *
COM_GetmimeContainerClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeContainerClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -99,17 +87,14 @@ COM_GetmimeContainerClass(void)
extern "C" void *
COM_GetmimeMultipartClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeMultipartClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -117,17 +102,14 @@ COM_GetmimeMultipartClass(void)
extern "C" void *
COM_GetmimeMultipartSignedClass(void)
{
nsMimeObjectClassAccess *objAccess;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
{
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
objAccess->GetmimeMultipartSignedClass(&ptr);
objAccess->Release();
}
return ptr;
}
@ -136,37 +118,20 @@ extern "C" int
COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length,
PRBool user_visible_p)
{
nsMimeObjectClassAccess *objAccess;
int rc = -1;
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
void *ptr = NULL;
PRInt32 rc;
int res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
NULL, nsIMimeObjectClassAccess::GetIID(),
(void **) &objAccess);
if (res == NS_OK && objAccess)
(void **) getter_AddRefs(objAccess));
if (NS_SUCCEEDED(res) && objAccess)
{
if (objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p) == NS_OK)
rc = length;
else
rc = -1;
objAccess->Release();
}
return rc;
}
/**
// NOTE: Need to do these in the global registry
// register our dll
nsComponentManager::RegisterFactory(kRFC822toHTMLStreamConverterCID,
"mime.dll", PR_FALSE, PR_FALSE);
nsComponentManager::RegisterFactory(kMimeObjectClassAccessCID,
"mime.dll", PR_FALSE, PR_FALSE);
*/

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

@ -21,6 +21,7 @@
#include HG01966
#endif
#include "nsCOMPtr.h"
#include "modmime.h"
#include "mimeobj.h" /* MimeObject (abstract) */
#include "mimecont.h" /* |--- MimeContainer (abstract) */
@ -67,7 +68,6 @@
#include "nsIMimeContentTypeHandler.h"
#include "nsIComponentManager.h"
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_IID(kIMimeContentTypeHandlerIID, NS_IMIME_CONTENT_TYPE_HANDLER_IID);

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

@ -15,6 +15,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCOMPtr.h"
#include "modlmime.h"
#include "libi18n.h"
#include "nsCRT.h"

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

@ -100,6 +100,7 @@
= free all the cached data
*/
#include "nsCOMPtr.h"
#include "mimemrel.h"
#include "prmem.h"
#include "prprf.h"
@ -110,7 +111,6 @@
#include "nsIURL.h"
#include "nsCRT.h"
#include "msgCore.h"
#include "nsCOMPtr.h"
#include "nsMimeURLUtils.h"
extern "C" int MK_UNABLE_TO_OPEN_TMP_FILE;

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

@ -16,16 +16,17 @@
* Reserved.
*/
#include "nsCOMPtr.h"
#include "nsIMimeEmitter.h"
#include "mimerosetta.h"
#include "mimemsg.h"
#include "mimemoz2.h"
#include "nsIMimeEmitter.h"
#include "prmem.h"
#include "prio.h"
#include "plstr.h"
#include "nsCRT.h"
#include "msgCore.h"
#include "prlog.h"
#include "nsCRT.h"
#define MIME_SUPERCLASS mimeContainerClass
MimeDefClass(MimeMessage, MimeMessageClass, mimeMessageClass,

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

@ -15,6 +15,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCOMPtr.h"
#include "mimepbuf.h"
#include "mimemoz2.h"
#include "prmem.h"

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

@ -21,6 +21,7 @@
#include "nsMsgBaseCID.h"
#include "nsIMsgHeaderParser.h"
#include "nsCOMPtr.h"
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
@ -32,15 +33,14 @@ ParseRFC822Addresses (const char *line,
char **addresses)
{
PRUint32 numAddresses;
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
nsCOMPtr<nsIMsgHeaderParser> pHeader;
nsresult res = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL, nsIMsgHeaderParser::GetIID(),
(void **) getter_AddRefs(pHeader));
if (NS_SUCCEEDED(res) && pHeader)
{
pHeader->ParseHeaderAddresses(NULL, line, names, addresses, numAddresses);
pHeader->Release();
return numAddresses;
}
@ -55,15 +55,14 @@ ParseRFC822Addresses (const char *line,
int
UnquotePhraseOrAddr (char *line, char** lineout)
{
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
nsCOMPtr<nsIMsgHeaderParser> pHeader;
nsresult res = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL, nsIMsgHeaderParser::GetIID(),
(void **) getter_AddRefs(pHeader));
if (NS_SUCCEEDED(res) && pHeader)
{
pHeader->UnquotePhraseOrAddr(NULL, line, lineout);
pHeader->Release();
return NS_OK;
}
@ -77,16 +76,13 @@ char *
ExtractRFC822AddressMailboxes (const char *line)
{
char *retVal = NULL;
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgHeaderParser> pHeader;
nsresult res = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL, nsIMsgHeaderParser::GetIID(),
(void **) getter_AddRefs(pHeader));
if (NS_SUCCEEDED(res) && pHeader)
pHeader->ExtractHeaderAddressMailboxes(NULL, line, &retVal);
pHeader->Release();
}
return retVal;
}
@ -103,16 +99,13 @@ char *
ExtractRFC822AddressNames (const char *line)
{
char *retVal = NULL;
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgHeaderParser> pHeader;
nsresult res = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL, nsIMsgHeaderParser::GetIID(),
(void **) getter_AddRefs(pHeader));
if (NS_SUCCEEDED(res) && pHeader)
pHeader->ExtractHeaderAddressNames(NULL, line, &retVal);
pHeader->Release();
}
return retVal;
}
@ -124,16 +117,13 @@ char *
ExtractRFC822AddressName (const char *line)
{
char *retVal = NULL;
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgHeaderParser> pHeader;
nsresult res = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL, nsIMsgHeaderParser::GetIID(),
(void **) getter_AddRefs(pHeader));
if (NS_SUCCEEDED(res) && pHeader)
pHeader->ExtractHeaderAddressName(NULL, line, &retVal);
pHeader->Release();
}
return retVal;
}
@ -146,16 +136,13 @@ char *
ReformatRFC822Addresses (const char *line)
{
char *retVal = NULL;
nsIMsgHeaderParser *pHeader;
nsresult rv = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL,
nsIMsgHeaderParser::GetIID(),
(void **) &pHeader);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMsgHeaderParser> pHeader;
nsresult res = nsComponentManager::CreateInstance(kMsgHeaderParserCID,
NULL, nsIMsgHeaderParser::GetIID(),
(void **) getter_AddRefs(pHeader));
if (NS_SUCCEEDED(res) && pHeader)
pHeader->ReformatHeaderAddresses(NULL, line, &retVal);
pHeader->Release();
}
return retVal;
}

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

@ -41,9 +41,9 @@ static NS_DEFINE_CID(kCMimeMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCE
static NS_DEFINE_CID(kCMimeConverterCID, NS_MIME_CONVERTER_CID);
// These are necessary for the new stream converter/plugin interface...
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);
static NS_DEFINE_IID(kINetPluginIID, NS_INET_PLUGIN_IID);
#include "nsMsgHeaderParser.h"
static NS_DEFINE_CID(kCMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
@ -256,6 +256,11 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *
PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
// The interface for URL utils
rv = compMgr->RegisterComponent(kCIMimeURLUtilsCID, NULL, NULL, path,
PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) goto done;
done:
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
@ -286,6 +291,8 @@ extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char
if (NS_FAILED(rv)) goto done;
rv = compMgr->UnregisterComponent(kCMsgHeaderParserCID, path);
if (NS_FAILED(rv)) goto done;
rv = compMgr->UnregisterComponent(kCIMimeURLUtilsCID, path);
if (NS_FAILED(rv)) goto done;
done:
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);

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

@ -31,7 +31,7 @@
// {403B0540-B7C3-11d2-B35E-525400E2D63A}
#define NS_MIME_OBJECT_CLASS_ACCESS_CID \
{ 0x403b0540, 0xb7c3, 0x11d2, \
{ 0xb3, 0x5e, 0x52, 0x54, 0x0, 0xe2, 0xd6, 0x3a } };
{ 0xb3, 0x5e, 0x52, 0x54, 0x0, 0xe2, 0xd6, 0x3a } }
class nsMimeObjectClassAccess : public nsIMimeObjectClassAccess {
public:

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

@ -27,22 +27,7 @@
#include "mimebuf.h"
#include "nsMimeURLUtils.h"
nsMimeURLUtils::nsMimeURLUtils()
{
/* the following macro is used to initialize the ref counting data */
NS_INIT_REFCNT();
}
nsMimeURLUtils::~nsMimeURLUtils()
{
}
/* the following macros actually implement addref, release and query interface for our component. */
NS_IMPL_ADDREF(nsMimeURLUtils)
NS_IMPL_RELEASE(nsMimeURLUtils)
NS_IMPL_QUERY_INTERFACE(nsMimeURLUtils, nsIMimeURLUtils::GetIID()); /* we need to pass in the interface ID of this interface */
/* this function will be used by the factory to generate an RFC-822 Parser....*/
/* this function will be used by the factory to generate an RFC-822 Parser....*/
nsresult NS_NewMimeURLUtils(nsIMimeURLUtils ** aInstancePtrResult)
{
/* note this new macro for assertions...they can take a string describing the assertion */
@ -59,6 +44,21 @@ nsresult NS_NewMimeURLUtils(nsIMimeURLUtils ** aInstancePtrResult)
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
}
/* the following macros actually implement addref, release and query interface for our component. */
NS_IMPL_ADDREF(nsMimeURLUtils)
NS_IMPL_RELEASE(nsMimeURLUtils)
NS_IMPL_QUERY_INTERFACE(nsMimeURLUtils, nsIMimeURLUtils::GetIID()); /* we need to pass in the interface ID of this interface */
nsMimeURLUtils::nsMimeURLUtils()
{
/* the following macro is used to initialize the ref counting data */
NS_INIT_REFCNT();
}
nsMimeURLUtils::~nsMimeURLUtils()
{
}
/* from libnet/mkutils.c */
nsresult
nsMimeURLUtils::URLType(const char *URL, PRInt32 *retType)
@ -929,3 +929,143 @@ nsMimeURLUtils::MakeAbsoluteURL(char * absolute_url, char * relative_url, char *
return ReduceURL(ret_url, retURL);
}
static void
Append(char** output, int32* output_max, char** curoutput, const char* buf, int32 length)
{
if (length + (*curoutput) - (*output) >= *output_max) {
int offset = (*curoutput) - (*output);
do {
(*output_max) += 1024;
} while (length + (*curoutput) - (*output) >= *output_max);
*output = (char *)PR_Realloc(*output, *output_max);
if (!*output) return;
*curoutput = *output + offset;
}
nsCRT::memcpy(*curoutput, buf, length);
*curoutput += length;
}
nsresult
nsMimeURLUtils::ScanHTMLForURLs(const char* input, char **retBuf)
{
char* output = NULL;
char* curoutput;
int32 output_max;
char* tmpbuf = NULL;
int32 tmpbuf_max;
int32 inputlength;
const char* inputend;
const char* linestart;
const char* lineend;
PR_ASSERT(input);
if (!input)
{
*retBuf = NULL;
return NS_OK;
}
inputlength = PL_strlen(input);
output_max = inputlength + 1024; /* 1024 bytes ought to be enough to quote
several URLs, which ought to be as many
as most docs use. */
output = (char *)PR_Malloc(output_max);
if (!output) goto FAIL;
tmpbuf_max = 1024;
tmpbuf = (char *)PR_Malloc(tmpbuf_max);
if (!tmpbuf) goto FAIL;
inputend = input + inputlength;
linestart = input;
curoutput = output;
/* Here's the strategy. We find a chunk of plainish looking text -- no
embedded CR or LF, no "<" or "&". We feed that off to ScanForURLs,
and append the result. Then we skip to the next bit of plain text. If
we stopped at an "&", go to the terminating ";". If we stopped at a
"<", well, if it was a "<A>" tag, then skip to the closing "</A>".
Otherwise, skip to the end of the tag.
*/
lineend = linestart;
while (linestart < inputend && lineend <= inputend) {
switch (*lineend) {
case '<':
case '>':
case '&':
case CR:
case LF:
case '\0':
if (lineend > linestart) {
int length = lineend - linestart;
if (length * 3 > tmpbuf_max) {
tmpbuf_max = length * 3 + 512;
PR_Free(tmpbuf);
tmpbuf = (char *)PR_Malloc(tmpbuf_max);
if (!tmpbuf) goto FAIL;
}
if (ScanForURLs(linestart, length,
tmpbuf, tmpbuf_max, TRUE) != NS_OK) {
goto FAIL;
}
length = PL_strlen(tmpbuf);
Append(&output, &output_max, &curoutput, tmpbuf, length);
if (!output) goto FAIL;
}
linestart = lineend;
lineend = NULL;
if (inputend - linestart < 5) {
/* Too little to worry about; shove the rest out. */
lineend = inputend;
} else {
switch (*linestart) {
case '<':
if ((linestart[1] == 'a' || linestart[1] == 'A') &&
linestart[2] == ' ') {
lineend = PL_strcasestr(linestart, "</a");
if (lineend) {
lineend = PL_strchr(lineend, '>');
if (lineend) lineend++;
}
} else {
lineend = PL_strchr(linestart, '>');
if (lineend) lineend++;
}
break;
case '&':
lineend = PL_strchr(linestart, ';');
if (lineend) lineend++;
break;
default:
lineend = linestart + 1;
break;
}
}
if (!lineend) lineend = inputend;
Append(&output, &output_max, &curoutput, linestart,
lineend - linestart);
if (!output) goto FAIL;
linestart = lineend;
break;
default:
lineend++;
}
}
PR_Free(tmpbuf);
tmpbuf = NULL;
*curoutput = '\0';
*retBuf = output;
FAIL:
if (tmpbuf) PR_Free(tmpbuf);
if (output) PR_Free(output);
*retBuf = NULL;
return NS_OK;
}

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

@ -35,7 +35,7 @@ public:
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
static const nsIID& IID(void) { static nsIID iid = NS_IMIME_URLUTILS_IID; return iid; }
static const nsIID& GetIID(void) { static nsIID iid = NS_IMIME_URLUTILS_IID; return iid; }
NS_IMETHOD URLType(const char *URL, PRInt32 *retType);
@ -45,6 +45,8 @@ public:
char *output, int output_size, PRBool urls_only);
NS_IMETHOD MakeAbsoluteURL(char * absolute_url, char * relative_url, char **retURL);
NS_IMETHOD ScanHTMLForURLs(const char* input, char **retBuf);
};

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

@ -15,13 +15,13 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "plugin_inst.h"
#include <stdio.h>
#include <string.h>
#include "plstr.h"
#include "prmem.h"
#include "prprf.h"
#include "mimemoz2.h"
#include "plugin_inst.h"
#include "nsIMimeEmitter.h"
#include "nsRepository.h"
@ -213,20 +213,20 @@ MimePluginInstance::Initialize(nsINetOStream* stream, const char *stream_name)
{
res = nsRepository::CreateInstance(kMimeXMLEmitterCID,
NULL, nsIMimeEmitter::GetIID(),
(void **) &mEmitter);
(void **) getter_AddRefs(mEmitter));
}
else if (PL_strcmp(mOutputFormat, "text/html") == 0)
{
res = nsRepository::CreateInstance(kMimeHTMLEmitterCID,
NULL, nsIMimeEmitter::GetIID(),
(void **) &mEmitter);
(void **) getter_AddRefs(mEmitter));
}
else
{
// Need to create a raw emitter here!
res = nsRepository::CreateInstance(kMimeRawEmitterCID,
NULL, nsIMimeEmitter::GetIID(),
(void **) &mEmitter);
(void **) getter_AddRefs(mEmitter));
}
if ((NS_OK != res) || (!mEmitter))
@ -238,7 +238,6 @@ MimePluginInstance::Initialize(nsINetOStream* stream, const char *stream_name)
mBridgeStream = mime_bridge_create_stream(this, mEmitter, stream_name, format_out);
if (!mBridgeStream)
{
mEmitter->Release();
return NS_ERROR_OUT_OF_MEMORY;
}
@ -312,7 +311,6 @@ nsresult MimePluginInstance::InternalCleanup(void)
if (mEmitter)
{
mEmitter->Complete();
mEmitter->Release();
}
PR_FREEIF(mOutputFormat);

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

@ -21,6 +21,7 @@
#include "nsIMimeEmitter.h"
#include "nsINetOStream.h"
#include "nsINetPluginInstance.h"
#include "nsCOMPtr.h"
// The ProgID for message/rfc822 messages
#define PROGRAM_ID "message/rfc822"
@ -28,7 +29,7 @@
// {B21EDB21-D10C-11d2-B373-525400E2D63A}
#define NS_INET_PLUGIN_MIME_CID \
{ 0xb21edb21, 0xd10c, 0x11d2, \
{ 0xb3, 0x73, 0x52, 0x54, 0x0, 0xe2, 0xd6, 0x3a } };
{ 0xb3, 0x73, 0x52, 0x54, 0x0, 0xe2, 0xd6, 0x3a } }
class MimePluginInstance : public nsINetPluginInstance, public nsINetOStream {
public:
@ -77,7 +78,7 @@ public:
nsINetOStream *mOutStream;
void *mBridgeStream;
nsIMimeEmitter *mEmitter;
nsCOMPtr<nsIMimeEmitter> mEmitter;
// Type of output, entire message, header only, body only
char *mOutputFormat;