Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
mimeeobj.cpp File Reference
#include "nsCOMPtr.h"
#include "mimeeobj.h"
#include "prmem.h"
#include "plstr.h"
#include "prlog.h"
#include "nsMimeStringResources.h"
#include "mimemoz2.h"
#include "nsCRT.h"
#include "mimemapl.h"
#include "nsMimeTypes.h"

Go to the source code of this file.

Defines

#define MIME_SUPERCLASS   mimeLeafClass

Functions

 MimeDefClass (MimeExternalObject, MimeExternalObjectClass, mimeExternalObjectClass,&MIME_SUPERCLASS)
static int MimeExternalObject_initialize (MimeObject *)
static void MimeExternalObject_finalize (MimeObject *)
static int MimeExternalObject_parse_begin (MimeObject *)
static int MimeExternalObject_parse_buffer (const char *, PRInt32, MimeObject *)
static int MimeExternalObject_parse_line (char *, PRInt32, MimeObject *)
static int MimeExternalObject_parse_decoded_buffer (const char *, PRInt32, MimeObject *)
static PRBool MimeExternalObject_displayable_inline_p (MimeObjectClass *clazz, MimeHeaders *hdrs)
static int MimeExternalObjectClassInitialize (MimeExternalObjectClass *clazz)

Define Documentation

Definition at line 50 of file mimeeobj.cpp.


Function Documentation

Definition at line 272 of file mimeeobj.cpp.

{
  return PR_FALSE;
}

Here is the caller graph for this function:

static void MimeExternalObject_finalize ( MimeObject object) [static]

Definition at line 88 of file mimeeobj.cpp.

{
  ((MimeObjectClass*)&MIME_SUPERCLASS)->finalize(object);
}

Here is the caller graph for this function:

static int MimeExternalObject_initialize ( MimeObject object) [static]

Definition at line 82 of file mimeeobj.cpp.

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

Here is the caller graph for this function:

static int MimeExternalObject_parse_begin ( MimeObject obj) [static]

Definition at line 95 of file mimeeobj.cpp.

{
  int status;
  
  status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj);
  if (status < 0) return status;
  
  // If we're writing this object, and we're doing it in raw form, then
  // now is the time to inform the backend what the type of this data is.
  //
  if (obj->output_p &&
    obj->options &&
    !obj->options->write_html_p &&
    !obj->options->state->first_data_written_p)
  {
    status = MimeObject_output_init(obj, 0);
    if (status < 0) return status;
    NS_ASSERTION(obj->options->state->first_data_written_p, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
  }
    
  //
  // If we're writing this object as HTML, do all the work now -- just write
  // out a table with a link in it.  (Later calls to the `parse_buffer' method
  // will simply discard the data of the object itself.)
  //
  if (obj->options &&
      obj->output_p &&
      obj->options->write_html_p &&
      obj->options->output_fn)
  {
    MimeDisplayOptions newopt = *obj->options;  // copy it 
    char *id = 0;
    char *id_url = 0;
    char *id_name = 0;
    nsXPIDLCString id_imap;
    PRBool all_headers_p = obj->options->headers == MimeHeadersAll;
    
    id = mime_part_address (obj);
    if (obj->options->missing_parts)
      id_imap.Adopt(mime_imap_part_address (obj));
    if (! id) return MIME_OUT_OF_MEMORY;
    
    if (obj->options && obj->options->url)
    {
      const char *url = obj->options->url;
      if (id_imap && id)
      {
        // if this is an IMAP part. 
        id_url = mime_set_url_imap_part(url, id_imap.get(), id);
      }
      else
      {
        // This is just a normal MIME part as usual. 
        id_url = mime_set_url_part(url, id, PR_TRUE);
      }
      if (!id_url)
      {
        PR_Free(id);
        return MIME_OUT_OF_MEMORY;
      }
    }
    if (!nsCRT::strcmp (id, "0"))
    {
      PR_Free(id);
      id = MimeGetStringByID(MIME_MSG_ATTACHMENT);
    }
    else
    {
      const char *p = "Part ";  
      PRUint32 slen = strlen(p) + strlen(id) + 1;
      char *s = (char *)PR_MALLOC(slen);
      if (!s)
      {
        PR_Free(id);
        PR_Free(id_url);
        return MIME_OUT_OF_MEMORY;
      }
      // we have a valid id
      if (id)
        id_name = mime_find_suggested_name_of_part(id, obj);
      PL_strncpyz(s, p, slen);
      PL_strcatn(s, slen, id);
      PR_Free(id);
      id = s;
    }
    
    if (all_headers_p &&
    // Don't bother showing all headers on this part if it's the only
    // part in the message: in that case, we've already shown these
    // headers.
    obj->options->state &&
    obj->options->state->root == obj->parent)
    all_headers_p = PR_FALSE;
    
    newopt.fancy_headers_p = PR_TRUE;
    newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);    

/******    
RICHIE SHERRY
GOTTA STILL DO THIS FOR QUOTING!
     status = MimeHeaders_write_attachment_box (obj->headers, &newopt,
                                                 obj->content_type,
                                                 obj->encoding,
                                                 id_name? id_name : id, id_url, 0)
*****/

    // obj->options really owns the storage for this.
    newopt.part_to_load = nsnull;
    newopt.default_charset = nsnull;
    PR_FREEIF(id);
    PR_FREEIF(id_url);
    PR_FREEIF(id_name);
    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 MimeExternalObject_parse_buffer ( const char *  buffer,
PRInt32  size,
MimeObject obj 
) [static]

Definition at line 214 of file mimeeobj.cpp.

{
  NS_ASSERTION(!obj->closed_p, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
  if (obj->closed_p) return -1;

  if (obj->output_p &&
         obj->options &&
         !obj->options->write_html_p)
       {
         /* The data will be base64-decoded and passed to
               MimeExternalObject_parse_decoded_buffer. */
         return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_buffer(buffer, size,
                                                                                                                obj);
       }
  else
       {
         /* Otherwise, simply ignore the data. */
         return 0;
       }
}

Here is the caller graph for this function:

static int MimeExternalObject_parse_decoded_buffer ( const char *  buf,
PRInt32  size,
MimeObject obj 
) [static]

Definition at line 237 of file mimeeobj.cpp.

{
  /* This is called (by MimeLeafClass->parse_buffer) with blocks of data
        that have already been base64-decoded.  This will only be called in
        the case where we're not emitting HTML, and want access to the raw
        data itself.

        We override the `parse_decoded_buffer' method provided by MimeLeaf
        because, unlike most children of MimeLeaf, we do not want to line-
        buffer the decoded data -- we want to simply pass it along to the
        backend, without going through our `parse_line' method.
   */
  if (!obj->output_p ||
         !obj->options ||
         obj->options->write_html_p)
       {
         NS_ASSERTION(0, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
         return -1;
       }

  return MimeObject_write(obj, buf, size, PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 263 of file mimeeobj.cpp.

{
  /* This method should never be called (externals do no line buffering).
   */
  NS_ASSERTION(0, "1.1 <rhp@netscape.com> 19 Mar 1999 12:00");
  return -1;
}

Here is the caller graph for this function:

Definition at line 64 of file mimeeobj.cpp.

Here is the call graph for this function: