Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
mimecal.cpp File Reference
#include "mimecal.h"
#include "prmem.h"
#include "plstr.h"
#include "mimexpcom.h"
#include "mimecth.h"
#include "mimeobj.h"
#include "nsCRT.h"

Go to the source code of this file.

Functions

static int MimeInlineTextCalendar_parse_line (char *, PRInt32, MimeObject *)
static int MimeInlineTextCalendar_parse_eof (MimeObject *, PRBool)
static int MimeInlineTextCalendar_parse_begin (MimeObject *obj)
 MimeDefClass (MimeInlineTextCalendar, MimeInlineTextCalendarClass, mimeInlineTextCalendarClass, NULL)
MimeObjectClassMIME_CalendarCreateContentTypeHandlerClass (const char *content_type, contentTypeHandlerInitStruct *initStruct)
static int MimeInlineTextCalendarClassInitialize (MimeInlineTextCalendarClass *clazz)
int mime_TranslateCalendar (char *caldata, char **html)

Variables

int CAL_OUT_OF_MEMORY = -1000

Function Documentation

Definition at line 57 of file mimecal.cpp.

{
  MimeObjectClass *clazz = (MimeObjectClass *)&mimeInlineTextCalendarClass;
  /*
   * Must set the superclass by hand.
   */
  if (!COM_GetmimeInlineTextClass())
    return NULL;

  clazz->superclass = (MimeObjectClass *)COM_GetmimeInlineTextClass();
  initStruct->force_inline_display = PR_TRUE;
  return clazz;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int mime_TranslateCalendar ( char *  caldata,
char **  html 
)

Definition at line 85 of file mimecal.cpp.

{
  *html = nsCRT::strdup("\
<text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FF0000\" vlink=\"#800080\" alink=\"#0000FF\">\
<center><table BORDER=1 BGCOLOR=\"#CCFFFF\" ><tr>\
<td>This libmime Content Type Handler plugin for the Content-Type <b>text/calendar\
</b> is functional!</td>\
</tr>\
</table></center>");

  return 0;
}

Here is the caller graph for this function:

Definition at line 99 of file mimecal.cpp.

{
  MimeInlineTextCalendarClass *clazz;
  int status = ((MimeObjectClass*)COM_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. */  
  clazz = ((MimeInlineTextCalendarClass *) obj->clazz);
  /* initialize buffered string to empty; */
  
  clazz->bufferlen = 0;
  clazz->buffermax = 512;
  clazz->buffer = (char*) PR_MALLOC(clazz->buffermax);
  if (clazz->buffer == NULL) return CAL_OUT_OF_MEMORY;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int MimeInlineTextCalendar_parse_eof ( MimeObject obj,
PRBool  abort_p 
) [static]

Definition at line 148 of file mimecal.cpp.

{
  int status = 0;
  MimeInlineTextCalendarClass *clazz = ((MimeInlineTextCalendarClass *) obj->clazz);
  char* html = NULL;
  
  if (obj->closed_p) return 0;
  
  /* Run parent method first, to flush out any buffered data. */
  status = ((MimeObjectClass*)COM_GetmimeInlineTextClass())->parse_eof(obj, abort_p);
  if (status < 0) return status;
  
  if (!clazz->buffer || clazz->bufferlen == 0) return 0;
  
  clazz->buffer[clazz->bufferlen] = '\0';
  
  status = mime_TranslateCalendar(clazz->buffer, &html);
  PR_Free(clazz->buffer);
  clazz->buffer = NULL;
  if (status < 0) return status;
  
  status = COM_MimeObject_write(obj, html, PL_strlen(html), PR_TRUE);
  PR_Free(html);
  if (status < 0) return status;
  
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int MimeInlineTextCalendar_parse_line ( char *  line,
PRInt32  length,
MimeObject obj 
) [static]

Definition at line 121 of file mimecal.cpp.

{
 /* 
  * 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 *clazz = ((MimeInlineTextCalendarClass *) obj->clazz);
  
  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, PR_TRUE);
  }
  
  if (clazz->bufferlen + length >= clazz->buffermax) {
    do {
      clazz->buffermax += 512;
    } while (clazz->bufferlen + length >= clazz->buffermax);
    clazz->buffer = (char *)PR_Realloc(clazz->buffer, clazz->buffermax);
    if (clazz->buffer == NULL) return CAL_OUT_OF_MEMORY;
  }
  memcpy(clazz->buffer + clazz->bufferlen, line, length);
  clazz->bufferlen += length;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file mimecal.cpp.

{
  MimeObjectClass *oclass = (MimeObjectClass *) clazz;
  NS_ASSERTION(!oclass->class_initialized, "1.1 <rhp@netscape.com> 19 Mar 1999 12:01");
  oclass->parse_begin = MimeInlineTextCalendar_parse_begin;
  oclass->parse_line  = MimeInlineTextCalendar_parse_line;
  oclass->parse_eof   = MimeInlineTextCalendar_parse_eof;

  return 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 49 of file mimecal.cpp.