Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
nsSimpleMimeConverterStub.cpp File Reference
#include "mimecth.h"
#include "mimeobj.h"
#include "mimetext.h"
#include "mimemoz2.h"
#include "mimecom.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsCategoryManagerUtils.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsISimpleMimeConverter.h"

Go to the source code of this file.

Classes

struct  MimeSimpleStubClass
struct  MimeSimpleStub
class  nsSimpleMimeConverterStub

Typedefs

typedef struct MimeSimpleStub
typedef struct MimeSimpleStubClass

Functions

 MimeDefClass (MimeSimpleStub, MimeSimpleStubClass, mimeSimpleStubClass, NULL)
static int BeginGather (MimeObject *obj)
static int GatherLine (char *line, PRInt32 length, MimeObject *obj)
static int EndGather (MimeObject *obj, PRBool abort_p)
static int Initialize (MimeObject *obj)
static void Finalize (MimeObject *obj)
static int MimeSimpleStubClassInitialize (MimeSimpleStubClass *clazz)
nsresult MIME_NewSimpleMimeConverterStub (const char *aContentType, nsIMimeContentTypeHandler **aResult)

Class Documentation

struct MimeSimpleStubClass

Definition at line 54 of file nsSimpleMimeConverterStub.cpp.

Class Members
MimeInlineTextClass text
struct MimeSimpleStub

Definition at line 58 of file nsSimpleMimeConverterStub.cpp.

Collaboration diagram for MimeSimpleStub:
Class Members
nsCString * buffer
nsCOMPtr< nsISimpleMimeConverter > innerScriptable
MimeInlineText text

Typedef Documentation

typedef struct MimeSimpleStub

Definition at line 51 of file nsSimpleMimeConverterStub.cpp.

typedef struct MimeSimpleStubClass

Definition at line 52 of file nsSimpleMimeConverterStub.cpp.


Function Documentation

static int BeginGather ( MimeObject obj) [static]

Definition at line 67 of file nsSimpleMimeConverterStub.cpp.

{
    MimeSimpleStub *ssobj = (MimeSimpleStub *)obj;
    int status = ((MimeObjectClass *)XPCOM_GetmimeLeafClass())->parse_begin(obj);

    if (status < 0)
        return status;

    if (!obj->output_p ||
        !obj->options ||
        !obj->options->write_html_p) {
        return 0;
    }

    ssobj->buffer->Truncate();
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 104 of file nsSimpleMimeConverterStub.cpp.

{
    MimeSimpleStub *ssobj = (MimeSimpleStub *)obj;

    if (obj->closed_p)
        return 0;
    
    int status = ((MimeObjectClass *)MIME_GetmimeInlineTextClass())->parse_eof(obj, abort_p);
    if (status < 0)
        return status;

    if (ssobj->buffer->IsEmpty())
        return 0;
    
     mime_stream_data  *msd = (mime_stream_data *) (obj->options->stream_closure);
     nsIChannel *channel = msd->channel;  // note the lack of ref counting...
     if (channel)
     {
       nsCOMPtr<nsIURI> uri;
       channel->GetURI(getter_AddRefs(uri));
       ssobj->innerScriptable->SetUri(uri);
     }
    nsCString asHTML;
    nsresult rv = ssobj->innerScriptable->ConvertToHTML(nsDependentCString(obj->content_type),
                                                        *ssobj->buffer,
                                                        asHTML);
    if (NS_FAILED(rv)) {
        NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "converter failure");
        return -1;
    }

    // MimeObject_write wants a non-const string for some reason, but it doesn't mutate it
    status = MimeObject_write(obj, (char *)PromiseFlatCString(asHTML).get(),
                              asHTML.Length(), PR_TRUE);
    if (status < 0)
        return status;
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void Finalize ( MimeObject obj) [static]

Definition at line 157 of file nsSimpleMimeConverterStub.cpp.

{
    MimeSimpleStub *ssobj = (MimeSimpleStub *)obj;
    ssobj->innerScriptable = nsnull;
    delete ssobj->buffer;
}

Here is the caller graph for this function:

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

Definition at line 86 of file nsSimpleMimeConverterStub.cpp.

{
    MimeSimpleStub *ssobj = (MimeSimpleStub *)obj;

    if (!obj->output_p ||
        !obj->options ||
        !obj->options->output_fn) {
        return 0;
    }
    
    if (!obj->options->write_html_p)
        return MimeObject_write(obj, line, length, PR_TRUE);

    ssobj->buffer->Append(line);
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int Initialize ( MimeObject obj) [static]

Definition at line 144 of file nsSimpleMimeConverterStub.cpp.

Here is the call graph for this function:

nsresult MIME_NewSimpleMimeConverterStub ( const char *  aContentType,
nsIMimeContentTypeHandler **  aResult 
)

Definition at line 213 of file nsSimpleMimeConverterStub.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

MimeDefClass ( MimeSimpleStub  ,
MimeSimpleStubClass  ,
mimeSimpleStubClass  ,
NULL   
)

Definition at line 165 of file nsSimpleMimeConverterStub.cpp.

{
    MimeObjectClass *oclass = (MimeObjectClass *)clazz;
    oclass->parse_begin = BeginGather;
    oclass->parse_line = GatherLine;
    oclass->parse_eof = EndGather;
    oclass->initialize = Initialize;
    oclass->finalize = Finalize;
    return 0;
}

Here is the call graph for this function: