Move generic implementations of mimexpcom & nsMimeContentTypeHandler classes into glue library. Modify vcard, calendar & smimestub handlers to use the generic implementations of the base classes. Remove old non-generic copies of mimexpcom & nsMimeContentTypeHandler .

Bug #83544 r=ducarroz sr=waterson
This commit is contained in:
seawood%netscape.com 2001-11-06 05:12:09 +00:00
Родитель 01e4e44199
Коммит a8ea1f42cc
26 изменённых файлов: 158 добавлений и 63 удалений

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

@ -33,19 +33,21 @@ EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsCalendarModule
EXTRA_DSO_LIBS = mimecthglue_s
CPPSRCS = \
mimexpcom.cpp \
mimecal.cpp \
nsMimeContentTypeHandler.cpp \
nsCalendarFactory.cpp \
$(NULL)
EXTRA_DSO_LDOPTS = \
-L$(DIST)/bin \
-L$(DIST)/lib \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = $(srcdir)/../glue

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

@ -47,6 +47,15 @@ MODULE_NAME = nsCalendarModule
# Exported headers here!!!
# $(NULL)
REQUIRES = \
xpcom \
string \
mime \
msgbase \
pref \
necko \
uconv \
$(NULL)
DEFINES= -DEBUG_rhp -D_IMPL_NS_HTML
@ -58,8 +67,6 @@ DEFINES= -DEBUG_rhp -D_IMPL_NS_HTML
OBJS= \
.\$(OBJDIR)\mimecal.obj \
.\$(OBJDIR)\mimexpcom.obj \
.\$(OBJDIR)\nsMimeContentTypeHandler.obj \
.\$(OBJDIR)\nsCalendarFactory.obj \
$(NULL)
@ -96,9 +103,12 @@ LCFLAGS=-DNETSCAPE
MSGLIBS= \
$(NULL)
LINCS= -I..\glue
# These are the libraries we need to link with to create the dll
LLIBS= \
$(LLIBS) \
$(DIST)\lib\mimecthglue_s.lib \
$(LIBNSPR) \
$(DIST)\lib\xpcom.lib \
$(NULL)

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

@ -50,26 +50,14 @@ static int MimeInlineTextCalendar_parse_begin (MimeObject *obj);
extern "C" int CAL_OUT_OF_MEMORY = -1000;
/*
* These functions are the public interface for this content type
* handler and will be called in by the mime component.
*/
#define CAL_CONTENT_TYPE "text/calendar"
/* This is the object definition. Note: we will set the superclass
to NULL and manually set this on the class creation */
MimeDefClass(MimeInlineTextCalendar, MimeInlineTextCalendarClass,
mimeInlineTextCalendarClass, NULL);
extern "C" char *
MIME_GetContentType(void)
{
return CAL_CONTENT_TYPE;
}
extern "C" MimeObjectClass *
MIME_CreateContentTypeHandlerClass(const char *content_type,
contentTypeHandlerInitStruct *initStruct)
MIME_CalendarCreateContentTypeHandlerClass(const char *content_type,
contentTypeHandlerInitStruct *initStruct)
{
MimeObjectClass *clazz = (MimeObjectClass *)&mimeInlineTextCalendarClass;
/*
@ -143,7 +131,7 @@ MimeInlineTextCalendar_parse_line(char *line, PRInt32 length, MimeObject *obj)
if (!obj->output_p) return 0;
if (!obj->options || !obj->options->output_fn) return 0;
if (!obj->options->write_html_p) {
return COM_MimeObject_write(obj, line, length, TRUE);
return COM_MimeObject_write(obj, line, length, PR_TRUE);
}
if (clazz->bufferlen + length >= clazz->buffermax) {
@ -180,7 +168,7 @@ MimeInlineTextCalendar_parse_eof (MimeObject *obj, PRBool abort_p)
clazz->buffer = NULL;
if (status < 0) return status;
status = COM_MimeObject_write(obj, html, PL_strlen(html), TRUE);
status = COM_MimeObject_write(obj, html, PL_strlen(html), PR_TRUE);
PR_Free(html);
if (status < 0) return status;

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

@ -39,6 +39,12 @@
#include "mimetext.h"
/*
* These functions are the public interface for this content type
* handler and will be called in by the mime component.
*/
#define CAL_CONTENT_TYPE "text/calendar"
/* The MimeInlineTextCalendar class implements the text/calendar MIME
content types.
*/

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

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

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

@ -41,6 +41,7 @@
/* Include all of the interfaces our factory can generate components for */
#include "nsMimeContentTypeHandler.h"
#include "mimecal.h"
////////////////////////////////////////////////////////////////////////
// Define the contructor function for the CID
@ -51,7 +52,39 @@
//
// NOTE: This creates an instance by using the default constructor
//
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
extern "C" MimeObjectClass *
MIME_CalendarCreateContentTypeHandlerClass(const char *content_type,
contentTypeHandlerInitStruct *initStruct);
static NS_IMETHODIMP
nsCalendarMimeContentTypeHandlerConstructor(nsISupports *aOuter,
REFNSIID aIID,
void **aResult)
{
nsresult rv;
nsMimeContentTypeHandler *inst = nsnull;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
inst = new nsMimeContentTypeHandler(CAL_CONTENT_TYPE,
&MIME_CalendarCreateContentTypeHandlerClass);
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID,aResult);
NS_RELEASE(inst);
return rv;
}
////////////////////////////////////////////////////////////////////////
// Define a table of CIDs implemented by this module along with other
@ -61,7 +94,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
static nsModuleComponentInfo components[] =
{
{ "MIME Calendar Handler", NS_CALENDAR_CONTENT_TYPE_HANDLER_CID, "@mozilla.org/mimecth;1?type=text/calendar",
nsMimeContentTypeHandlerConstructor, }
nsCalendarMimeContentTypeHandlerConstructor, }
};
////////////////////////////////////////////////////////////////////////
@ -69,3 +102,6 @@ static nsModuleComponentInfo components[] =
// and the entire implementation of the module object.
//
NS_IMPL_NSGETMODULE(nsCalendarModule, components)

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

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

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

@ -42,19 +42,20 @@ REQUIRES = xpcom \
intl \
$(NULL)
EXTRA_DSO_LIBS = mimecthglue_s
CPPSRCS = \
mimexpcom.cpp \
nsSMIMEStub.cpp \
nsMimeContentTypeHandler.cpp \
nsSMIMEStubFactory.cpp \
$(NULL)
EXTRA_DSO_LDOPTS = \
-L$(DIST)/bin \
-L$(DIST)/lib \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = -I$(srcdir)/../glue

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

@ -58,8 +58,6 @@ DEFINES= -DEBUG_rhp -D_IMPL_NS_HTML
OBJS= \
.\$(OBJDIR)\nsSMIMEStub.obj \
.\$(OBJDIR)\mimexpcom.obj \
.\$(OBJDIR)\nsMimeContentTypeHandler.obj \
.\$(OBJDIR)\nsSMIMEStubFactory.obj \
$(NULL)
@ -100,9 +98,12 @@ LCFLAGS=-DNETSCAPE
MSGLIBS= \
$(NULL)
LINCS= -I..\glue
# These are the libraries we need to link with to create the dll
LLIBS= \
$(LLIBS) \
$(DIST)\lib\mimecthglue_s.lib \
$(LIBNSPR) \
$(DIST)\lib\xpcom.lib \
$(NULL)

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

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

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

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

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

@ -116,15 +116,8 @@ static int MimeInlineTextSMIMEStub_parse_begin (MimeObject *obj);
MimeDefClass(MimeInlineTextSMIMEStub, MimeInlineTextSMIMEStubClass, mimeInlineTextSMIMEStubClass, NULL);
extern "C" char *
MIME_GetContentType(void)
{
return SMIME_CONTENT_TYPE;
}
extern "C" MimeObjectClass *
MIME_CreateContentTypeHandlerClass(const char *content_type,
MIME_SMimeCreateContentTypeHandlerClass(const char *content_type,
contentTypeHandlerInitStruct *initStruct)
{
MimeObjectClass *clazz = (MimeObjectClass *)&mimeInlineTextSMIMEStubClass;

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

@ -61,6 +61,7 @@
#include "nsIGenericFactory.h"
/* Include all of the interfaces our factory can generate components for */
#include "nsSMIMEStub.h"
#include "nsMimeContentTypeHandler.h"
////////////////////////////////////////////////////////////////////////
@ -72,7 +73,39 @@
//
// NOTE: This creates an instance by using the default constructor
//
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
extern "C" MimeObjectClass *
MIME_SMimeCreateContentTypeHandlerClass(const char *content_type,
contentTypeHandlerInitStruct *initStruct);
static NS_IMETHODIMP
nsSMimeMimeContentTypeHandlerConstructor(nsISupports *aOuter,
REFNSIID aIID,
void **aResult)
{
nsresult rv;
nsMimeContentTypeHandler *inst = nsnull;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
inst = new nsMimeContentTypeHandler(SMIME_CONTENT_TYPE,
&MIME_SMimeCreateContentTypeHandlerClass);
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID,aResult);
NS_RELEASE(inst);
return rv;
}
////////////////////////////////////////////////////////////////////////
// Define a table of CIDs implemented by this module along with other
@ -82,10 +115,10 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
static nsModuleComponentInfo components[] =
{
{ "MIME SMIMEStubed Mail Handler", NS_SMIME_CONTENT_TYPE_HANDLER_CID, "@mozilla.org/mimecth;1?type=application/x-pkcs7-mime",
nsMimeContentTypeHandlerConstructor, },
nsSMimeMimeContentTypeHandlerConstructor, },
{ "MIME SMIMEStubed Mail Handler", NS_SMIME_CONTENT_TYPE_HANDLER_CID, "@mozilla.org/mimecth;1?type=application/pkcs7-mime",
nsMimeContentTypeHandlerConstructor, }
nsSMimeMimeContentTypeHandlerConstructor, }
};

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

@ -51,13 +51,13 @@ else
EXTRA_DSO_LIBS = msgbaseutil
endif
EXTRA_DSO_LIBS += mimecthglue_s
CPPSRCS = \
mimevcrd.cpp \
mimexpcom.cpp \
nsVCard.cpp \
nsVCardObj.cpp \
nsVCardFactory.cpp \
nsMimeContentTypeHandler.cpp \
$(NULL)
EXTRA_DSO_LDOPTS = \
@ -69,3 +69,4 @@ EXTRA_DSO_LDOPTS = \
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = -I$(srcdir)/../glue

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

@ -72,11 +72,9 @@ DEFINES= -DEBUG_rhp -D_IMPL_NS_HTML
OBJS= \
.\$(OBJDIR)\mimevcrd.obj \
.\$(OBJDIR)\mimexpcom.obj \
.\$(OBJDIR)\nsVCard.obj \
.\$(OBJDIR)\nsVCardObj.obj \
.\$(OBJDIR)\nsVCardFactory.obj \
.\$(OBJDIR)\nsMimeContentTypeHandler.obj \
$(NULL)
#//------------------------------------------------------------------------
@ -107,9 +105,12 @@ LCFLAGS=-DNETSCAPE
MSGLIBS= \
$(NULL)
LINCS= -I..\glue
# These are the libraries we need to link with to create the dll
LLIBS= \
$(LLIBS) \
$(DIST)\lib\mimecthglue_s.lib \
$(LIBNSPR) \
$(DIST)\lib\js32$(VERSION_NUMBER).lib \
$(DIST)\lib\xpcom.lib \

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

@ -101,13 +101,6 @@ typedef struct
// Define CIDs...
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
/*
* These functions are the public interface for this content type
* handler and will be called in by the mime component.
*/
#define VCARD_CONTENT_TYPE "text/x-vcard"
/* This is the next generation string retrieval call */
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
@ -119,14 +112,8 @@ static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
MimeDefClass(MimeInlineTextVCard, MimeInlineTextVCardClass,
mimeInlineTextVCardClass, NULL);
extern "C" char *
MIME_GetContentType(void)
{
return VCARD_CONTENT_TYPE;
}
extern "C" MimeObjectClass *
MIME_CreateContentTypeHandlerClass(const char *content_type,
MIME_VCardCreateContentTypeHandlerClass(const char *content_type,
contentTypeHandlerInitStruct *initStruct)
{
MimeObjectClass *clazz = (MimeObjectClass *)&mimeInlineTextVCardClass;

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

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

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

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

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

@ -40,6 +40,12 @@
/* Include all of the interfaces our factory can generate components for */
#include "nsMimeContentTypeHandler.h"
/*
* These functions are the public interface for this content type
* handler and will be called in by the mime component.
*/
#define VCARD_CONTENT_TYPE "text/x-vcard"
////////////////////////////////////////////////////////////////////////
// Define the contructor function for the CID
//
@ -49,7 +55,39 @@
//
// NOTE: This creates an instance by using the default constructor
//
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
extern "C" MimeObjectClass *
MIME_VCardCreateContentTypeHandlerClass(const char *content_type,
contentTypeHandlerInitStruct *initStruct);
static NS_IMETHODIMP
nsVCardMimeContentTypeHandlerConstructor(nsISupports *aOuter,
REFNSIID aIID,
void **aResult)
{
nsresult rv;
nsMimeContentTypeHandler *inst = nsnull;
if (NULL == aResult) {
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter) {
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
inst = new nsMimeContentTypeHandler(VCARD_CONTENT_TYPE,
&MIME_VCardCreateContentTypeHandlerClass);
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID,aResult);
NS_RELEASE(inst);
return rv;
}
////////////////////////////////////////////////////////////////////////
// Define a table of CIDs implemented by this module along with other
@ -59,7 +97,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMimeContentTypeHandler)
static nsModuleComponentInfo components[] =
{
{ "MIME VCard Handler", NS_VCARD_CONTENT_TYPE_HANDLER_CID, "@mozilla.org/mimecth;1?type=text/x-vcard",
nsMimeContentTypeHandlerConstructor, }
nsVCardMimeContentTypeHandlerConstructor, }
};
////////////////////////////////////////////////////////////////////////

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

@ -20,5 +20,3 @@
LIBRARY vcard.dll
EXPORTS
MIME_GetContentType
MIME_CreateContentTypeHandlerClass