mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-31 19:10:36 +00:00
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:
parent
8a2068b530
commit
3d14e64e96
@ -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.
|
||||
*/
|
||||
|
@ -1,158 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsMimeObjectClassAccess.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsMsgMimeCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID);
|
||||
|
||||
/*
|
||||
* These calls are necessary to expose the object class heirarchy
|
||||
* to externally developed content type handlers.
|
||||
*/
|
||||
extern "C" void *
|
||||
COM_GetmimeInlineTextClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeInlineTextClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeLeafClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeLeafClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeObjectClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeObjectClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeContainerClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeContainerClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeMultipartClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeMultipartClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeMultipartSignedClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeMultipartSignedClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length,
|
||||
PRBool user_visible_p)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
PRInt32 rc=-1;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
{
|
||||
if (NS_SUCCEEDED(objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p)))
|
||||
rc = length;
|
||||
else
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This is the definitions for the Content Type Handler plugins to
|
||||
* access internals of libmime via XP-COM calls
|
||||
*/
|
||||
#ifndef _MIMEXPCOM_H_
|
||||
#define _MIMEXPCOM_H_
|
||||
|
||||
/*
|
||||
This header exposes functions that are necessary to access the
|
||||
object heirarchy for the mime chart. The class hierarchy is:
|
||||
|
||||
MimeObject (abstract)
|
||||
|
|
||||
|--- MimeContainer (abstract)
|
||||
| |
|
||||
| |--- MimeMultipart (abstract)
|
||||
| | |
|
||||
| | |--- MimeMultipartMixed
|
||||
| | |
|
||||
| | |--- MimeMultipartDigest
|
||||
| | |
|
||||
| | |--- MimeMultipartParallel
|
||||
| | |
|
||||
| | |--- MimeMultipartAlternative
|
||||
| | |
|
||||
| | |--- MimeMultipartRelated
|
||||
| | |
|
||||
| | |--- MimeMultipartAppleDouble
|
||||
| | |
|
||||
| | |--- MimeSunAttachment
|
||||
| | |
|
||||
| | |--- MimeMultipartSigned (abstract)
|
||||
| | |
|
||||
| | |--- MimeMultipartSigned
|
||||
| |
|
||||
| |--- MimeXlateed (abstract)
|
||||
| | |
|
||||
| | |--- MimeXlateed
|
||||
| |
|
||||
| |--- MimeMessage
|
||||
| |
|
||||
| |--- MimeUntypedText
|
||||
|
|
||||
|--- MimeLeaf (abstract)
|
||||
| |
|
||||
| |--- MimeInlineText (abstract)
|
||||
| | |
|
||||
| | |--- MimeInlineTextPlain
|
||||
| | |
|
||||
| | |--- MimeInlineTextHTML
|
||||
| | |
|
||||
| | |--- MimeInlineTextRichtext
|
||||
| | | |
|
||||
| | | |--- MimeInlineTextEnriched
|
||||
| | |
|
||||
| | |--- MimeInlineTextVCard
|
||||
| | |
|
||||
| | |--- MimeInlineTextCalendar
|
||||
| |
|
||||
| |--- MimeInlineImage
|
||||
| |
|
||||
| |--- MimeExternalObject
|
||||
|
|
||||
|--- MimeExternalBody
|
||||
*/
|
||||
|
||||
/*
|
||||
* These functions are exposed by libmime to be used by content type
|
||||
* handler plugins for processing stream data.
|
||||
*/
|
||||
/*
|
||||
* This is the write call for outputting processed stream data.
|
||||
*/
|
||||
extern "C" int COM_MimeObject_write(void *mimeObject, char *data,
|
||||
PRInt32 length,
|
||||
PRBool user_visible_p);
|
||||
/*
|
||||
* The following group of calls expose the pointers for the object
|
||||
* system within libmime.
|
||||
*/
|
||||
extern "C" void *COM_GetmimeInlineTextClass(void);
|
||||
extern "C" void *COM_GetmimeLeafClass(void);
|
||||
extern "C" void *COM_GetmimeObjectClass(void);
|
||||
extern "C" void *COM_GetmimeContainerClass(void);
|
||||
extern "C" void *COM_GetmimeMultipartClass(void);
|
||||
extern "C" void *COM_GetmimeMultipartSignedClass(void);
|
||||
|
||||
|
||||
#endif /* _MIMEXPCOM_H_ */
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
@ -1,109 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "stdio.h"
|
||||
#include "nscore.h"
|
||||
#include "plstr.h"
|
||||
#include "prtypes.h"
|
||||
//#include "mimecth.h"
|
||||
#include "nsMimeContentTypeHandler.h"
|
||||
|
||||
/*
|
||||
* This function will be used by the factory to generate an
|
||||
* mime object class object....
|
||||
*/
|
||||
nsresult NS_NewMimeContentTypeHandler(nsIMimeContentTypeHandler ** aInstancePtrResult)
|
||||
{
|
||||
/* note this new macro for assertions...they can take
|
||||
a string describing the assertion */
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
|
||||
if (nsnull != aInstancePtrResult)
|
||||
{
|
||||
nsMimeContentTypeHandler *obj = new nsMimeContentTypeHandler();
|
||||
if (obj)
|
||||
return obj->QueryInterface(NS_GET_IID(nsIMimeContentTypeHandler), (void**) aInstancePtrResult);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
|
||||
}
|
||||
|
||||
/*
|
||||
* The following macros actually implement addref, release and
|
||||
* query interface for our component.
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS1(nsMimeContentTypeHandler, nsIMimeContentTypeHandler)
|
||||
|
||||
/*
|
||||
* nsIMimeEmitter definitions....
|
||||
*/
|
||||
nsMimeContentTypeHandler::nsMimeContentTypeHandler()
|
||||
{
|
||||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsMimeContentTypeHandler::~nsMimeContentTypeHandler(void)
|
||||
{
|
||||
}
|
||||
|
||||
extern "C" char *MIME_GetContentType(void);
|
||||
extern "C" MimeObjectClass *MIME_CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct);
|
||||
|
||||
// Get the content type if necessary
|
||||
nsresult
|
||||
nsMimeContentTypeHandler::GetContentType(char **contentType)
|
||||
{
|
||||
*contentType = MIME_GetContentType();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Set the output stream for processed data.
|
||||
nsresult
|
||||
nsMimeContentTypeHandler::CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
MimeObjectClass **objClass)
|
||||
{
|
||||
*objClass = MIME_CreateContentTypeHandlerClass(content_type, initStruct);
|
||||
if (!*objClass)
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This interface is implemented by content type handlers that will be
|
||||
* called upon by libmime to process various attachments types. The primary
|
||||
* purpose of these handlers will be to represent the attached data in a
|
||||
* viewable HTML format that is useful for the user
|
||||
*
|
||||
* Note: These will all register by their content type prefixed by the
|
||||
* following: mimecth:text/vcard
|
||||
*
|
||||
* libmime will then use nsComponentManager::ContractIDToCLSID() to
|
||||
* locate the appropriate Content Type handler
|
||||
*/
|
||||
#ifndef nsMimeContentTypeHandler_h_
|
||||
#define nsMimeContentTypeHandler_h_
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsIMimeContentTypeHandler.h"
|
||||
|
||||
class nsMimeContentTypeHandler : public nsIMimeContentTypeHandler {
|
||||
public:
|
||||
nsMimeContentTypeHandler ();
|
||||
virtual ~nsMimeContentTypeHandler (void);
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetContentType(char **contentType);
|
||||
|
||||
NS_IMETHOD CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
MimeObjectClass **objClass);
|
||||
};
|
||||
|
||||
/* this function will be used by the factory to generate an class access object....*/
|
||||
extern nsresult NS_NewMimeContentTypeHandler(nsIMimeContentTypeHandler **aInstancePtrResult);
|
||||
|
||||
|
||||
#endif /* nsMimeContentTypeHandler_h_ */
|
@ -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)
|
||||
|
@ -1,158 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsMimeObjectClassAccess.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsMsgMimeCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID);
|
||||
|
||||
/*
|
||||
* These calls are necessary to expose the object class heirarchy
|
||||
* to externally developed content type handlers.
|
||||
*/
|
||||
extern "C" void *
|
||||
COM_GetmimeInlineTextClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeInlineTextClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeLeafClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeLeafClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeObjectClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeObjectClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeContainerClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeContainerClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeMultipartClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeMultipartClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeMultipartSignedClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeMultipartSignedClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length,
|
||||
PRBool user_visible_p)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
PRInt32 rc=-1;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
{
|
||||
if (NS_SUCCEEDED(objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p)))
|
||||
rc = length;
|
||||
else
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This is the definitions for the Content Type Handler plugins to
|
||||
* access internals of libmime via XP-COM calls
|
||||
*/
|
||||
#ifndef _MIMEXPCOM_H_
|
||||
#define _MIMEXPCOM_H_
|
||||
|
||||
/*
|
||||
This header exposes functions that are necessary to access the
|
||||
object heirarchy for the mime chart. The class hierarchy is:
|
||||
|
||||
MimeObject (abstract)
|
||||
|
|
||||
|--- MimeContainer (abstract)
|
||||
| |
|
||||
| |--- MimeMultipart (abstract)
|
||||
| | |
|
||||
| | |--- MimeMultipartMixed
|
||||
| | |
|
||||
| | |--- MimeMultipartDigest
|
||||
| | |
|
||||
| | |--- MimeMultipartParallel
|
||||
| | |
|
||||
| | |--- MimeMultipartAlternative
|
||||
| | |
|
||||
| | |--- MimeMultipartRelated
|
||||
| | |
|
||||
| | |--- MimeMultipartAppleDouble
|
||||
| | |
|
||||
| | |--- MimeSunAttachment
|
||||
| | |
|
||||
| | |--- MimeMultipartSigned (abstract)
|
||||
| | |
|
||||
| | |--- MimeMultipartSigned
|
||||
| |
|
||||
| |--- MimeXlateed (abstract)
|
||||
| | |
|
||||
| | |--- MimeXlateed
|
||||
| |
|
||||
| |--- MimeMessage
|
||||
| |
|
||||
| |--- MimeUntypedText
|
||||
|
|
||||
|--- MimeLeaf (abstract)
|
||||
| |
|
||||
| |--- MimeInlineText (abstract)
|
||||
| | |
|
||||
| | |--- MimeInlineTextPlain
|
||||
| | |
|
||||
| | |--- MimeInlineTextHTML
|
||||
| | |
|
||||
| | |--- MimeInlineTextRichtext
|
||||
| | | |
|
||||
| | | |--- MimeInlineTextEnriched
|
||||
| | |
|
||||
| | |--- MimeInlineTextVCard
|
||||
| | |
|
||||
| | |--- MimeInlineTextCalendar
|
||||
| |
|
||||
| |--- MimeInlineImage
|
||||
| |
|
||||
| |--- MimeExternalObject
|
||||
|
|
||||
|--- MimeExternalBody
|
||||
*/
|
||||
|
||||
/*
|
||||
* These functions are exposed by libmime to be used by content type
|
||||
* handler plugins for processing stream data.
|
||||
*/
|
||||
/*
|
||||
* This is the write call for outputting processed stream data.
|
||||
*/
|
||||
extern "C" int COM_MimeObject_write(void *mimeObject, char *data,
|
||||
PRInt32 length,
|
||||
PRBool user_visible_p);
|
||||
/*
|
||||
* The following group of calls expose the pointers for the object
|
||||
* system within libmime.
|
||||
*/
|
||||
extern "C" void *COM_GetmimeInlineTextClass(void);
|
||||
extern "C" void *COM_GetmimeLeafClass(void);
|
||||
extern "C" void *COM_GetmimeObjectClass(void);
|
||||
extern "C" void *COM_GetmimeContainerClass(void);
|
||||
extern "C" void *COM_GetmimeMultipartClass(void);
|
||||
extern "C" void *COM_GetmimeMultipartSignedClass(void);
|
||||
|
||||
|
||||
#endif /* _MIMEXPCOM_H_ */
|
@ -1,109 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "stdio.h"
|
||||
#include "nscore.h"
|
||||
#include "plstr.h"
|
||||
#include "prtypes.h"
|
||||
//#include "mimecth.h"
|
||||
#include "nsMimeContentTypeHandler.h"
|
||||
|
||||
/*
|
||||
* This function will be used by the factory to generate an
|
||||
* mime object class object....
|
||||
*/
|
||||
nsresult NS_NewMimeContentTypeHandler(nsIMimeContentTypeHandler ** aInstancePtrResult)
|
||||
{
|
||||
/* note this new macro for assertions...they can take
|
||||
a string describing the assertion */
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
|
||||
if (nsnull != aInstancePtrResult)
|
||||
{
|
||||
nsMimeContentTypeHandler *obj = new nsMimeContentTypeHandler();
|
||||
if (obj)
|
||||
return obj->QueryInterface(NS_GET_IID(nsIMimeContentTypeHandler), (void**) aInstancePtrResult);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
|
||||
}
|
||||
|
||||
/*
|
||||
* The following macros actually implement addref, release and
|
||||
* query interface for our component.
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS1(nsMimeContentTypeHandler, nsIMimeContentTypeHandler)
|
||||
|
||||
/*
|
||||
* nsIMimeEmitter definitions....
|
||||
*/
|
||||
nsMimeContentTypeHandler::nsMimeContentTypeHandler()
|
||||
{
|
||||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsMimeContentTypeHandler::~nsMimeContentTypeHandler(void)
|
||||
{
|
||||
}
|
||||
|
||||
extern "C" char *MIME_GetContentType(void);
|
||||
extern "C" MimeObjectClass *MIME_CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct);
|
||||
|
||||
// Get the content type if necessary
|
||||
nsresult
|
||||
nsMimeContentTypeHandler::GetContentType(char **contentType)
|
||||
{
|
||||
*contentType = MIME_GetContentType();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Set the output stream for processed data.
|
||||
nsresult
|
||||
nsMimeContentTypeHandler::CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
MimeObjectClass **objClass)
|
||||
{
|
||||
*objClass = MIME_CreateContentTypeHandlerClass(content_type, initStruct);
|
||||
if (!*objClass)
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This interface is implemented by content type handlers that will be
|
||||
* called upon by libmime to process various attachments types. The primary
|
||||
* purpose of these handlers will be to represent the attached data in a
|
||||
* viewable HTML format that is useful for the user
|
||||
*
|
||||
* Note: These will all register by their content type prefixed by the
|
||||
* following: mimecth:text/vcard
|
||||
*
|
||||
* libmime will then use nsComponentManager::ContractIDToCLSID() to
|
||||
* locate the appropriate Content Type handler
|
||||
*/
|
||||
#ifndef nsMimeContentTypeHandler_h_
|
||||
#define nsMimeContentTypeHandler_h_
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsIMimeContentTypeHandler.h"
|
||||
|
||||
class nsMimeContentTypeHandler : public nsIMimeContentTypeHandler {
|
||||
public:
|
||||
nsMimeContentTypeHandler ();
|
||||
virtual ~nsMimeContentTypeHandler (void);
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetContentType(char **contentType);
|
||||
|
||||
NS_IMETHOD CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
MimeObjectClass **objClass);
|
||||
};
|
||||
|
||||
/* this function will be used by the factory to generate an class access object....*/
|
||||
extern nsresult NS_NewMimeContentTypeHandler(nsIMimeContentTypeHandler **aInstancePtrResult);
|
||||
|
||||
|
||||
#endif /* nsMimeContentTypeHandler_h_ */
|
@ -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;
|
||||
|
@ -1,157 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsMimeObjectClassAccess.h"
|
||||
#include "nsMsgMimeCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
static NS_DEFINE_CID(kMimeObjectClassAccessCID, NS_MIME_OBJECT_CLASS_ACCESS_CID);
|
||||
|
||||
/*
|
||||
* These calls are necessary to expose the object class heirarchy
|
||||
* to externally developed content type handlers.
|
||||
*/
|
||||
extern "C" void *
|
||||
COM_GetmimeInlineTextClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeInlineTextClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeLeafClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeLeafClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeObjectClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeObjectClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeContainerClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeContainerClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeMultipartClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeMultipartClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
COM_GetmimeMultipartSignedClass(void)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
void *ptr = NULL;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
objAccess->GetmimeMultipartSignedClass(&ptr);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
COM_MimeObject_write(void *mimeObject, char *data, PRInt32 length,
|
||||
PRBool user_visible_p)
|
||||
{
|
||||
nsCOMPtr<nsIMimeObjectClassAccess> objAccess;
|
||||
PRInt32 rc=-1;
|
||||
|
||||
nsresult res = nsComponentManager::CreateInstance(kMimeObjectClassAccessCID,
|
||||
NULL, NS_GET_IID(nsIMimeObjectClassAccess),
|
||||
(void **) getter_AddRefs(objAccess));
|
||||
if (NS_SUCCEEDED(res) && objAccess)
|
||||
{
|
||||
if (NS_SUCCEEDED(objAccess->MimeObjectWrite(mimeObject, data, length, user_visible_p)))
|
||||
rc = length;
|
||||
else
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This is the definitions for the Content Type Handler plugins to
|
||||
* access internals of libmime via XP-COM calls
|
||||
*/
|
||||
#ifndef _MIMEXPCOM_H_
|
||||
#define _MIMEXPCOM_H_
|
||||
|
||||
/*
|
||||
This header exposes functions that are necessary to access the
|
||||
object heirarchy for the mime chart. The class hierarchy is:
|
||||
|
||||
MimeObject (abstract)
|
||||
|
|
||||
|--- MimeContainer (abstract)
|
||||
| |
|
||||
| |--- MimeMultipart (abstract)
|
||||
| | |
|
||||
| | |--- MimeMultipartMixed
|
||||
| | |
|
||||
| | |--- MimeMultipartDigest
|
||||
| | |
|
||||
| | |--- MimeMultipartParallel
|
||||
| | |
|
||||
| | |--- MimeMultipartAlternative
|
||||
| | |
|
||||
| | |--- MimeMultipartRelated
|
||||
| | |
|
||||
| | |--- MimeMultipartAppleDouble
|
||||
| | |
|
||||
| | |--- MimeSunAttachment
|
||||
| | |
|
||||
| | |--- MimeMultipartSigned (abstract)
|
||||
| | |
|
||||
| | |--- MimeMultipartSigned
|
||||
| |
|
||||
| |--- MimeXlateed (abstract)
|
||||
| | |
|
||||
| | |--- MimeXlateed
|
||||
| |
|
||||
| |--- MimeMessage
|
||||
| |
|
||||
| |--- MimeUntypedText
|
||||
|
|
||||
|--- MimeLeaf (abstract)
|
||||
| |
|
||||
| |--- MimeInlineText (abstract)
|
||||
| | |
|
||||
| | |--- MimeInlineTextPlain
|
||||
| | |
|
||||
| | |--- MimeInlineTextHTML
|
||||
| | |
|
||||
| | |--- MimeInlineTextRichtext
|
||||
| | | |
|
||||
| | | |--- MimeInlineTextEnriched
|
||||
| | |
|
||||
| | |--- MimeInlineTextVCard
|
||||
| | |
|
||||
| | |--- MimeInlineTextCalendar
|
||||
| |
|
||||
| |--- MimeInlineImage
|
||||
| |
|
||||
| |--- MimeExternalObject
|
||||
|
|
||||
|--- MimeExternalBody
|
||||
*/
|
||||
|
||||
/*
|
||||
* These functions are exposed by libmime to be used by content type
|
||||
* handler plugins for processing stream data.
|
||||
*/
|
||||
/*
|
||||
* This is the write call for outputting processed stream data.
|
||||
*/
|
||||
extern "C" int COM_MimeObject_write(void *mimeObject, char *data,
|
||||
PRInt32 length,
|
||||
PRBool user_visible_p);
|
||||
/*
|
||||
* The following group of calls expose the pointers for the object
|
||||
* system within libmime.
|
||||
*/
|
||||
extern "C" void *COM_GetmimeInlineTextClass(void);
|
||||
extern "C" void *COM_GetmimeLeafClass(void);
|
||||
extern "C" void *COM_GetmimeObjectClass(void);
|
||||
extern "C" void *COM_GetmimeContainerClass(void);
|
||||
extern "C" void *COM_GetmimeMultipartClass(void);
|
||||
extern "C" void *COM_GetmimeMultipartSignedClass(void);
|
||||
|
||||
#endif /* _MIMEXPCOM_H_ */
|
@ -1,110 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "stdio.h"
|
||||
#include "nscore.h"
|
||||
#include "plstr.h"
|
||||
#include "prtypes.h"
|
||||
//#include "mimecth.h"
|
||||
#include "nsMimeContentTypeHandler.h"
|
||||
|
||||
/*
|
||||
* This function will be used by the factory to generate an
|
||||
* mime object class object....
|
||||
*/
|
||||
nsresult NS_NewMimeContentTypeHandler(nsIMimeContentTypeHandler ** aInstancePtrResult)
|
||||
{
|
||||
/* note this new macro for assertions...they can take
|
||||
a string describing the assertion */
|
||||
//nsresult result = NS_OK;
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
|
||||
if (nsnull != aInstancePtrResult)
|
||||
{
|
||||
nsMimeContentTypeHandler *obj = new nsMimeContentTypeHandler();
|
||||
if (obj)
|
||||
return obj->QueryInterface(NS_GET_IID(nsIMimeContentTypeHandler), (void**) aInstancePtrResult);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
|
||||
}
|
||||
|
||||
/*
|
||||
* The following macros actually implement addref, release and
|
||||
* query interface for our component.
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS1(nsMimeContentTypeHandler, nsIMimeContentTypeHandler)
|
||||
|
||||
/*
|
||||
* nsIMimeEmitter definitions....
|
||||
*/
|
||||
nsMimeContentTypeHandler::nsMimeContentTypeHandler()
|
||||
{
|
||||
/* the following macro is used to initialize the ref counting data */
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
}
|
||||
|
||||
nsMimeContentTypeHandler::~nsMimeContentTypeHandler(void)
|
||||
{
|
||||
}
|
||||
|
||||
extern "C" char *MIME_GetContentType(void);
|
||||
extern "C" MimeObjectClass *MIME_CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct);
|
||||
|
||||
// Get the content type if necessary
|
||||
nsresult
|
||||
nsMimeContentTypeHandler::GetContentType(char **contentType)
|
||||
{
|
||||
*contentType = MIME_GetContentType();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Set the output stream for processed data.
|
||||
nsresult
|
||||
nsMimeContentTypeHandler::CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
MimeObjectClass **objClass)
|
||||
{
|
||||
*objClass = MIME_CreateContentTypeHandlerClass(content_type, initStruct);
|
||||
if (!*objClass)
|
||||
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||
else
|
||||
return NS_OK;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This interface is implemented by content type handlers that will be
|
||||
* called upon by libmime to process various attachments types. The primary
|
||||
* purpose of these handlers will be to represent the attached data in a
|
||||
* viewable HTML format that is useful for the user
|
||||
*
|
||||
* Note: These will all register by their content type prefixed by the
|
||||
* following: mimecth:text/vcard
|
||||
*
|
||||
* libmime will then use nsComponentManager::ContractIDToCLSID() to
|
||||
* locate the appropriate Content Type handler
|
||||
*/
|
||||
#ifndef nsMimeContentTypeHandler_h_
|
||||
#define nsMimeContentTypeHandler_h_
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsIMimeContentTypeHandler.h"
|
||||
|
||||
class nsMimeContentTypeHandler : public nsIMimeContentTypeHandler {
|
||||
public:
|
||||
nsMimeContentTypeHandler ();
|
||||
virtual ~nsMimeContentTypeHandler (void);
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetContentType(char **contentType);
|
||||
|
||||
NS_IMETHOD CreateContentTypeHandlerClass(const char *content_type,
|
||||
contentTypeHandlerInitStruct *initStruct,
|
||||
MimeObjectClass **objClass);
|
||||
};
|
||||
|
||||
/* this function will be used by the factory to generate an class access object....*/
|
||||
extern nsresult NS_NewMimeContentTypeHandler(nsIMimeContentTypeHandler **aInstancePtrResult);
|
||||
|
||||
|
||||
#endif /* nsMimeContentTypeHandler_h_ */
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user