From 2263bd1e296e654a8ec8976e29d5ab1ee8e6b074 Mon Sep 17 00:00:00 2001 From: "rhp%netscape.com" Date: Fri, 22 Jan 1999 01:44:22 +0000 Subject: [PATCH] Adding changes for external modular content type handler plugins. git-svn-id: svn://10.0.0.236/trunk@18244 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mime/cthandlers/calendar/makefile.win | 113 ++++++++++++ .../mime/cthandlers/calendar/mimecal.c | 161 ++++++++++++++++++ .../mime/cthandlers/calendar/mimecal.h | 43 +++++ .../mime/cthandlers/calendar/mimect-cal.def | 20 +++ mozilla/mailnews/mime/cthandlers/makefile.win | 23 +++ .../mime/cthandlers/vcard/makefile.win | 127 ++++++++++++++ .../mime/cthandlers/vcard/mimect-vcard.def | 18 ++ 7 files changed, 505 insertions(+) create mode 100644 mozilla/mailnews/mime/cthandlers/calendar/makefile.win create mode 100644 mozilla/mailnews/mime/cthandlers/calendar/mimecal.c create mode 100644 mozilla/mailnews/mime/cthandlers/calendar/mimecal.h create mode 100644 mozilla/mailnews/mime/cthandlers/calendar/mimect-cal.def create mode 100644 mozilla/mailnews/mime/cthandlers/makefile.win create mode 100644 mozilla/mailnews/mime/cthandlers/vcard/makefile.win create mode 100644 mozilla/mailnews/mime/cthandlers/vcard/mimect-vcard.def diff --git a/mozilla/mailnews/mime/cthandlers/calendar/makefile.win b/mozilla/mailnews/mime/cthandlers/calendar/makefile.win new file mode 100644 index 00000000000..59256c08043 --- /dev/null +++ b/mozilla/mailnews/mime/cthandlers/calendar/makefile.win @@ -0,0 +1,113 @@ +# 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. +# +NODEPEND=1 +IGNORE_MANIFEST = 1 + +# +# mimect-cal.dll +# ================ +# This is a content type handler for calendar entries. This will live externally +# to libmime and be able to render a calendar stream for presentation inline +# + +#//------------------------------------------------------------------------ +#// +#// Specify the depth of the current directory relative to the +#// root of NS +#// +#//------------------------------------------------------------------------ +DEPTH=..\..\..\.. + +#//------------------------------------------------------------------------ +#// +# New build system where zip dll is build indepenant of java stubs. +#// +#//------------------------------------------------------------------------ +MODULE = mimect-cal +REQUIRES= +#EXPORTS = +# Exported headers here!!! +# $(NULL) + + +DEFINES= -DEBUG_rhp -D_IMPL_NS_HTML + +#//------------------------------------------------------------------------ +#// +#// Define the files necessary to build the target (ie. OBJS) +#// +#//------------------------------------------------------------------------ + +OBJS= \ + .\$(OBJDIR)\mimecal.obj \ + $(NULL) + +#//------------------------------------------------------------------------ +#// +#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...) +#// +#//------------------------------------------------------------------------ +DLLNAME=$(MODULE).dll +LIBNAME=$(MODULE).lib +PDBFILE=$(MODULE).pdb +MAPFILE=$(MODULE).map +DEFFILE=$(MODULE).def + +#//------------------------------------------------------------------------ +#// +#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...) +#// (these must be defined before the common makefiles are included) +#// +#//------------------------------------------------------------------------ +# +DLL=.\$(OBJDIR)\$(DLLNAME) + +#//------------------------------------------------------------------------ +#// +#// Define any local options for the make tools +#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS) +#// +#//------------------------------------------------------------------------ +LCFLAGS=-DNETSCAPE + +MSGLIBS= \ + $(NULL) + +# These are the libraries we need to link with to create the dll +LLIBS= \ + $(LLIBS) \ + $(LIBNSPR) \ + $(DIST)\lib\libplc21.lib \ + $(DIST)\lib\xplib.lib \ + $(DIST)\lib\mime.lib \ + $(NULL) + +LINCS=$(LINCS) -I. \ + -I..\..\src \ + $(NULL) + +#//------------------------------------------------------------------------ +#// +#// Include the common makefile rules +#// +#//------------------------------------------------------------------------ +include <$(DEPTH)/config/rules.mak> + +install:: $(DLL) + $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME) $(DIST)\bin\mimeplugins + +clobber:: + rm -f $(DIST)\bin\$(DLLNAME) diff --git a/mozilla/mailnews/mime/cthandlers/calendar/mimecal.c b/mozilla/mailnews/mime/cthandlers/calendar/mimecal.c new file mode 100644 index 00000000000..c25690138ca --- /dev/null +++ b/mozilla/mailnews/mime/cthandlers/calendar/mimecal.c @@ -0,0 +1,161 @@ +/* -*- Mode: C; tab-width: 4; 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. + */ +#include "mimecal.h" +#include "mimecth.h" +#include "xp_core.h" +#include "xp_mem.h" +#include "prmem.h" +#include "plstr.h" + +static int MimeInlineTextCalendar_parse_line (char *, PRInt32, MimeObject *); +static int MimeInlineTextCalendar_parse_eof (MimeObject *, PRBool); +static int MimeInlineTextCalendar_parse_begin (MimeObject *obj); + +extern int MK_OUT_OF_MEMORY; + + +/* + * 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); + +PUBLIC char * +MIME_GetContentType(void) +{ + return CAL_CONTENT_TYPE; +} + +PUBLIC MimeObjectClass * +MIME_CreateContentTypeHandlerClass(const char *content_type) +{ + MimeObjectClass *class = (MimeObjectClass *)&mimeInlineTextCalendarClass; + /* + * Must set the superclass by hand. + */ + class->superclass = (MimeObjectClass *)MIME_GetmimeInlineTextClass(); + return class; +} + +static int +MimeInlineTextCalendarClassInitialize(MimeInlineTextCalendarClass *class) +{ + MimeObjectClass *oclass = (MimeObjectClass *) class; + PR_ASSERT(!oclass->class_initialized); + oclass->parse_begin = MimeInlineTextCalendar_parse_begin; + oclass->parse_line = MimeInlineTextCalendar_parse_line; + oclass->parse_eof = MimeInlineTextCalendar_parse_eof; + + return 0; +} + +int +mime_TranslateCalendar(char* caldata, char** html) +{ + *html = XP_STRDUP("\ +\ +
\ +\ +\ +
This libmime Content Type Handler plugin for the Content-Type text/calendar\ + is functional!
"); + + return 0; +} + +static int +MimeInlineTextCalendar_parse_begin(MimeObject *obj) +{ + MimeInlineTextCalendarClass *class; + int status = ((MimeObjectClass*)MIME_GetmimeLeafClass())->parse_begin(obj); + + if (status < 0) return status; + + if (!obj->output_p) return 0; + if (!obj->options || !obj->options->write_html_p) return 0; + + /* This is a fine place to write out any HTML before the real meat begins. */ + class = ((MimeInlineTextCalendarClass *) obj->class); + /* initialize buffered string to empty; */ + + class->bufferlen = 0; + class->buffermax = 512; + class->buffer = (char*) PR_MALLOC(class->buffermax); + if (class->buffer == NULL) return MK_OUT_OF_MEMORY; + return 0; +} + +static int +MimeInlineTextCalendar_parse_line(char *line, PRInt32 length, MimeObject *obj) +{ + /* + * This routine gets fed each line of data, one at a time. We just buffer + * it all up, to be dealt with all at once at the end. + */ + MimeInlineTextCalendarClass *class = ((MimeInlineTextCalendarClass *) obj->class); + + if (!obj->output_p) return 0; + if (!obj->options || !obj->options->output_fn) return 0; + if (!obj->options->write_html_p) { + return MIME_MimeObject_write(obj, line, length, TRUE); + } + + if (class->bufferlen + length >= class->buffermax) { + do { + class->buffermax += 512; + } while (class->bufferlen + length >= class->buffermax); + class->buffer = XP_REALLOC(class->buffer, class->buffermax); + if (class->buffer == NULL) return MK_OUT_OF_MEMORY; + } + XP_MEMCPY(class->buffer + class->bufferlen, line, length); + class->bufferlen += length; +} + +static int +MimeInlineTextCalendar_parse_eof (MimeObject *obj, PRBool abort_p) +{ + int status = 0; + MimeInlineTextCalendarClass *class = ((MimeInlineTextCalendarClass *) obj->class); + char* html = NULL; + + if (obj->closed_p) return 0; + + /* Run parent method first, to flush out any buffered data. */ + status = ((MimeObjectClass*)MIME_GetmimeInlineTextClass())->parse_eof(obj, abort_p); + if (status < 0) return status; + + if (!class->buffer || class->bufferlen == 0) return 0; + + class->buffer[class->bufferlen] = '\0'; + + status = mime_TranslateCalendar(class->buffer, &html); + PR_Free(class->buffer); + class->buffer = NULL; + if (status < 0) return status; + + status = MIME_MimeObject_write(obj, html, PL_strlen(html), TRUE); + PR_Free(html); + if (status < 0) return status; + + return 0; +} diff --git a/mozilla/mailnews/mime/cthandlers/calendar/mimecal.h b/mozilla/mailnews/mime/cthandlers/calendar/mimecal.h new file mode 100644 index 00000000000..3bbfbfa7534 --- /dev/null +++ b/mozilla/mailnews/mime/cthandlers/calendar/mimecal.h @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 4; 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. + */ +#ifndef _MIMECAL_H_ +#define _MIMECAL_H_ + +#include "mimetext.h" + +/* The MimeInlineTextCalendar class implements the text/calendar MIME + content types. + */ + +typedef struct MimeInlineTextCalendarClass MimeInlineTextCalendarClass; +typedef struct MimeInlineTextCalendar MimeInlineTextCalendar; + +struct MimeInlineTextCalendarClass { + MimeInlineTextClass text; + char* buffer; + PRInt32 bufferlen; + PRInt32 buffermax; +}; + +extern MimeInlineTextCalendarClass mimeInlineTextCalendarClass; + +struct MimeInlineTextCalendar { + MimeInlineText text; +}; + +#endif /* _MIMECAL_H_ */ diff --git a/mozilla/mailnews/mime/cthandlers/calendar/mimect-cal.def b/mozilla/mailnews/mime/cthandlers/calendar/mimect-cal.def new file mode 100644 index 00000000000..8178ca4e35e --- /dev/null +++ b/mozilla/mailnews/mime/cthandlers/calendar/mimect-cal.def @@ -0,0 +1,20 @@ +; 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. + +LIBRARY mimect-cal.dll + +EXPORTS + MIME_GetContentType + MIME_CreateContentTypeHandlerClass diff --git a/mozilla/mailnews/mime/cthandlers/makefile.win b/mozilla/mailnews/mime/cthandlers/makefile.win new file mode 100644 index 00000000000..f1e7ab42775 --- /dev/null +++ b/mozilla/mailnews/mime/cthandlers/makefile.win @@ -0,0 +1,23 @@ +#!nmake +# +# 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. + +DEPTH=..\..\.. +IGNORE_MANIFEST=1 + +DIRS=calendar vcard + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/mailnews/mime/cthandlers/vcard/makefile.win b/mozilla/mailnews/mime/cthandlers/vcard/makefile.win new file mode 100644 index 00000000000..f8ecf1af72f --- /dev/null +++ b/mozilla/mailnews/mime/cthandlers/vcard/makefile.win @@ -0,0 +1,127 @@ +# 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. +# +NODEPEND=1 +IGNORE_MANIFEST = 1 + +# +# mimect-vcard.dll +# ================ +# This is a content type handler for vcards. This will live externally +# to libmime and be able to render a text/vcard stream +# + +#//------------------------------------------------------------------------ +#// +#// Specify the depth of the current directory relative to the +#// root of NS +#// +#//------------------------------------------------------------------------ +DEPTH=..\..\..\.. + +#//------------------------------------------------------------------------ +#// +# New build system where zip dll is build indepenant of java stubs. +#// +#//------------------------------------------------------------------------ +MODULE = mimect-vcard +REQUIRES= +# EXPORTS = +# Put any necessary exported headers here!!! +# $(NULL) + + +DEFINES= -DEBUG_rhp -D_IMPL_NS_HTML + +#//------------------------------------------------------------------------ +#// +#// Define the files necessary to build the target (ie. OBJS) +#// +#//------------------------------------------------------------------------ + +OBJS= \ + .\$(OBJDIR)\mimevcrd.obj \ + .\$(OBJDIR)\oldvcc.obj \ + .\$(OBJDIR)\oldvobj.obj \ + .\$(OBJDIR)\mimeobj.obj \ + $(NULL) + +#//------------------------------------------------------------------------ +#// +#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...) +#// +#//------------------------------------------------------------------------ +DLLNAME=$(MODULE).dll +LIBNAME=$(MODULE).lib +PDBFILE=$(MODULE).pdb +MAPFILE=$(MODULE).map +DEFFILE=$(MODULE).def + +#//------------------------------------------------------------------------ +#// +#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...) +#// (these must be defined before the common makefiles are included) +#// +#//------------------------------------------------------------------------ +# +DLL=.\$(OBJDIR)\$(DLLNAME) + +#//------------------------------------------------------------------------ +#// +#// Define any local options for the make tools +#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS) +#// +#//------------------------------------------------------------------------ +LCFLAGS=-DNETSCAPE + +MSGLIBS= \ + $(NULL) + +# These are the libraries we need to link with to create the dll +LLIBS= \ + $(LLIBS) \ + $(LIBNSPR) \ + $(DIST)\lib\libplc21.lib \ + $(DIST)\lib\js32$(VERSION_NUMBER).lib \ + $(DIST)\lib\netlib.lib \ + $(DIST)\lib\xppref32.lib \ + $(DIST)\lib\mimetype.lib \ + $(DIST)\lib\xplib.lib \ + $(DIST)\lib\raptorbase.lib \ + $(DIST)\lib\xpcom32.lib \ + $(NULL) + +LINCS=$(LINCS) -I. \ + -I$(PUBLIC)\pref \ + -I$(PUBLIC)\js \ + -I$(PUBLIC)\security \ + -I$(PUBLIC)\netlib \ + -I$(PUBLIC)\xpcom \ + -I$(PUBLIC)\raptor \ + -I..\src \ + $(NULL) + +#//------------------------------------------------------------------------ +#// +#// Include the common makefile rules +#// +#//------------------------------------------------------------------------ +include <$(DEPTH)/config/rules.mak> + +install:: $(DLL) + $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME) $(DIST)\bin + +clobber:: + rm -f $(DIST)\bin\$(DLLNAME) diff --git a/mozilla/mailnews/mime/cthandlers/vcard/mimect-vcard.def b/mozilla/mailnews/mime/cthandlers/vcard/mimect-vcard.def new file mode 100644 index 00000000000..144b1f41566 --- /dev/null +++ b/mozilla/mailnews/mime/cthandlers/vcard/mimect-vcard.def @@ -0,0 +1,18 @@ +; 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. + +LIBRARY mimect-vcard.dll + +EXPORTS