Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
mimecont.cpp File Reference
#include "prmem.h"
#include "plstr.h"
#include "prlog.h"
#include "nsCRT.h"
#include "prio.h"
#include "mimecont.h"
#include "nsMimeStringResources.h"

Go to the source code of this file.

Defines

#define MIME_SUPERCLASS   mimeObjectClass

Functions

 MimeDefClass (MimeContainer, MimeContainerClass, mimeContainerClass,&MIME_SUPERCLASS)
static int MimeContainer_initialize (MimeObject *)
static void MimeContainer_finalize (MimeObject *)
static int MimeContainer_add_child (MimeObject *, MimeObject *)
static int MimeContainer_parse_eof (MimeObject *, PRBool)
static int MimeContainer_parse_end (MimeObject *, PRBool)
static PRBool MimeContainer_displayable_inline_p (MimeObjectClass *clazz, MimeHeaders *hdrs)
static int MimeContainerClassInitialize (MimeContainerClass *clazz)

Define Documentation

Definition at line 45 of file mimecont.cpp.


Function Documentation

static int MimeContainer_add_child ( MimeObject parent,
MimeObject child 
) [static]

Definition at line 180 of file mimecont.cpp.

{
  MimeContainer *cont = (MimeContainer *) parent;
  MimeObject **old_kids, **new_kids;

  NS_ASSERTION(parent && child, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
  if (!parent || !child) return -1;

  old_kids = cont->children;
  new_kids = (MimeObject **)PR_MALLOC(sizeof(MimeObject *) * (cont->nchildren + 1));
  if (!new_kids) return MIME_OUT_OF_MEMORY;
  
  if (cont->nchildren > 0)
    memcpy(new_kids, old_kids, sizeof(MimeObject *) * cont->nchildren);
  new_kids[cont->nchildren] = child;
  PR_Free(old_kids);
  cont->children = new_kids;
  cont->nchildren++;

  child->parent = parent;

  /* Copy this object's options into the child. */
  child->options = parent->options;

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool MimeContainer_displayable_inline_p ( MimeObjectClass clazz,
MimeHeaders hdrs 
) [static]

Definition at line 208 of file mimecont.cpp.

{
  return PR_TRUE;
}

Here is the caller graph for this function:

static void MimeContainer_finalize ( MimeObject object) [static]

Definition at line 91 of file mimecont.cpp.

{
  MimeContainer *cont = (MimeContainer *) object;

  /* Do this first so that children have their parse_eof methods called
        in forward order (0-N) but are destroyed in backward order (N-0)
   */
  if (!object->closed_p)
       object->clazz->parse_eof (object, PR_FALSE);
  if (!object->parsed_p)
       object->clazz->parse_end (object, PR_FALSE);

  if (cont->children)
       {
         int i;
         for (i = cont->nchildren-1; i >= 0; i--)
              {
                MimeObject *kid = cont->children[i];
                if (kid)
                     mime_free(kid);
                cont->children[i] = 0;
              }
         PR_FREEIF(cont->children);
         cont->nchildren = 0;
       }
  ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int MimeContainer_initialize ( MimeObject object) [static]

Definition at line 82 of file mimecont.cpp.

{
  /* This is an abstract class; it shouldn't be directly instantiated. */
  NS_ASSERTION(object->clazz != (MimeObjectClass *) &mimeContainerClass, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");

  return ((MimeObjectClass*)&MIME_SUPERCLASS)->initialize(object);
}

Here is the caller graph for this function:

static int MimeContainer_parse_end ( MimeObject object,
PRBool  abort_p 
) [static]

Definition at line 150 of file mimecont.cpp.

{
  MimeContainer *cont = (MimeContainer *) object;
  int status;

  /* We must run all of this object's parent methods first, to get all the
        data flushed down its stream, so that the children's parse_eof methods
        can access it.  We do not access *this* object again after doing this,
        only its children.
   */
  status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_end(object, abort_p);
  if (status < 0) return status;

  if (cont->children)
       {
         int i;
         for (i = 0; i < cont->nchildren; i++)
              {
                MimeObject *kid = cont->children[i];
                if (kid && !kid->parsed_p)
                     {
                       int lstatus = kid->clazz->parse_end(kid, abort_p);
                       if (lstatus < 0) return lstatus;
                     }
              }
       }
  return 0;
}

Here is the caller graph for this function:

static int MimeContainer_parse_eof ( MimeObject object,
PRBool  abort_p 
) [static]

Definition at line 120 of file mimecont.cpp.

{
  MimeContainer *cont = (MimeContainer *) object;
  int status;

  /* We must run all of this object's parent methods first, to get all the
        data flushed down its stream, so that the children's parse_eof methods
        can access it.  We do not access *this* object again after doing this,
        only its children.
   */
  status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(object, abort_p);
  if (status < 0) return status;

  if (cont->children)
       {
         int i;
         for (i = 0; i < cont->nchildren; i++)
              {
                MimeObject *kid = cont->children[i];
                if (kid && !kid->closed_p)
                     {
                       int lstatus = kid->clazz->parse_eof(kid, abort_p);
                       if (lstatus < 0) return lstatus;
                     }
              }
       }
  return 0;
}

Here is the caller graph for this function:

static int MimeContainerClassInitialize ( MimeContainerClass clazz) [static]

Definition at line 62 of file mimecont.cpp.

{
  MimeObjectClass *oclass = (MimeObjectClass *) &clazz->object;

  NS_ASSERTION(!oclass->class_initialized, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
  oclass->initialize  = MimeContainer_initialize;
  oclass->finalize    = MimeContainer_finalize;
  oclass->parse_eof   = MimeContainer_parse_eof;
  oclass->parse_end   = MimeContainer_parse_end;
  oclass->displayable_inline_p = MimeContainer_displayable_inline_p;
  clazz->add_child    = MimeContainer_add_child;

#if defined(DEBUG) && defined(XP_UNIX)
  oclass->debug_print = MimeContainer_debug_print;
#endif
  return 0;
}

Here is the call graph for this function:

MimeDefClass ( MimeContainer  ,
MimeContainerClass  ,
mimeContainerClass  ,
MIME_SUPERCLASS 
)