The Mozilla
Organization
Our Mission
Who We Are
Getting Involved
Community
Editorials
What's New
Newsbot
Development
Roadmap
Module Owners
Blue Sky
Projects
Status
Tools
Products
Source Code
Binaries
Documentation
License Terms
Bug Reports
Quality
Search
Feedback


libmime Content Type Handler Plugins
by Richard H. Pizzarro <rhp@netscape.com>

Contents

Overview
The libmime module implements a general-purpose MIME parser and one of the primary methods provided by the parser is the ability to emit an HTML representation of an input stream. The primary use of  libmime is to parse and render RFC822 messages for use by the Messenger component of Seamonkey.

A necessary capability of this module is to dynamically add the ability to decode and render various content types. This functionality will be accomplished via Content Type Handler Plugins for libmime. libmime has a homegrown object system written in C, and since the content type handler plugins need to exist in this module, a description of the libmime object system should be reviewed and understood.

API's
Content Type Handler Plugins are dynamically loaded and need to access internal pointers, functions that are part of the C based object system. The following XP-COM interface is implemented by libmime and is necessary for Content Type Handler Plugin development.

#ifndef nsIMimeObjectClassAccess_h_
#define nsIMimeObjectClassAccess_h_

#include "prtypes.h"

// {C09EDB23-B7AF-11d2-B35E-525400E2D63A}
#define NS_IMIME_OBJECT_CLASS_ACCESS_IID \
      { 0xc09edb23, 0xb7af, 0x11d2,  \
      { 0xb3, 0x5e, 0x52, 0x54, 0x0, 0xe2, 0xd6, 0x3a } };

class nsIMimeObjectClassAccess : public nsISupports {
public:
  // These methods are all implemented by libmime to be used by
  // content type handler plugins for processing stream data.

  // This is the write call for outputting processed stream data.
  NS_IMETHOD    MimeObjectWrite(void *mimeObject,
                                char *data,
                                PRInt32 length,
                                PRBool user_visible_p) = 0;

  // The following group of calls expose the pointers for the object
  // system within libmime.
  NS_IMETHOD    GetmimeInlineTextClass(void **ptr) = 0;
  NS_IMETHOD    GetmimeLeafClass(void **ptr) = 0;
  NS_IMETHOD    GetmimeObjectClass(void **ptr) = 0;
  NS_IMETHOD    GetmimeContainerClass(void **ptr) = 0;
  NS_IMETHOD    GetmimeMultipartClass(void **ptr) = 0;
  NS_IMETHOD    GetmimeMultipartSignedClass(void **ptr) = 0;
};

#endif /* nsIMimeObjectClassAccess_h_ */

On the other side, are are the functions that need to be implemented by the Content Type Handler Plugin:
 
/*
 * MIME_GetContentType() is called by libmime to identify the content
 * type handled by this plugin.
 */
char            *MIME_GetContentType(void);

/*
 * This will create the MimeObjectClass object to be used by the libmime
 * object system.
 */
MimeObjectClass *MIME_CreateContentTypeHandlerClass(const char *content_type,
                                                    contentTypeHandlerInitStruct *initStruct);

Note: these may migrate to another XP-COM interface, but this would require an additional registry to match content type's to content type handler plugins. For now, this work is being postponed.

Plugin Installation/Location
The installation of these modules will be similar to the that of Navigator plugins. A folder/directory called mimeplugins will be created in the binary release location of the libmime module. libmime will locate the plugins by using this directory and looking for modules prefixed with the string "mimect-".

Sample Content Type Handler Plugin
To see an example of a Content Type Handler Plugin, the source for the handler of the content type "text/calendar" can be viewed at the following link: Calendar plugin Note: This plugin simply creates a blue table in the output stream to identify the fact that it is operational, but the basic constructs of what is needed to build a functional content type handler can be seen.
 



Copyright © 1998 The Mozilla Organization.