Back to index

enigmail  1.4.3
Classes | Defines | Typedefs | Functions | Variables
mimeenig.cpp File Reference
#include "mimecth.h"
#include "mimemoz2.h"
#include "mimeenig.h"
#include "nspr.h"
#include "plstr.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIMsgWindow.h"
#include "nsIEnigMimeDecrypt.h"

Go to the source code of this file.

Classes

struct  MimeEnigData

Defines

#define MOZILLA_INTERNAL_API

Typedefs

typedef struct MimeEnigData MimeEnigData

Functions

 MimeDefClass (MimeEncryptedEnig, MimeEncryptedEnigClass, mimeEncryptedEnigClass, NULL)
static void * MimeEnig_init (MimeObject *, int(*output_fn)(const char *, PRInt32, void *), void *)
static int MimeEnig_write (const char *, PRInt32, void *)
static int MimeEnig_eof (void *, EMBool)
static char * MimeEnig_generate (void *)
static void MimeEnig_free (void *)
static int MimeEncryptedEnigClassInitialize (MimeEncryptedEnigClass *clazz)
static void * MimeEnig_init (MimeObject *obj, int(*output_fn)(const char *buf, PRInt32 buf_size, void *output_closure), void *output_closure)

Variables

nsCOMPtr< nsIEnigMimeDecryptmMimeDecrypt

Define Documentation

Definition at line 36 of file mimeenig.cpp.


Typedef Documentation

typedef struct MimeEnigData MimeEnigData

Function Documentation

static int MimeEncryptedEnigClassInitialize ( MimeEncryptedEnigClass clazz) [static]

Definition at line 64 of file mimeenig.cpp.

{
  MimeObjectClass    *oclass = (MimeObjectClass *)    clazz;
  MimeEncryptedClass *eclass = (MimeEncryptedClass *) clazz;

  PR_ASSERT(!oclass->class_initialized);

  eclass->crypto_init          = MimeEnig_init;
  eclass->crypto_write         = MimeEnig_write;
  eclass->crypto_eof           = MimeEnig_eof;
  eclass->crypto_generate_html = MimeEnig_generate;
  eclass->crypto_free          = MimeEnig_free;

  return 0;
}

Here is the call graph for this function:

static int MimeEnig_eof ( void *  output_closure,
EMBool  abort_p 
) [static]

Definition at line 166 of file mimeenig.cpp.

{
  MimeEnigData *data = (MimeEnigData *) output_closure;

  fprintf(stderr, "MimeEnig_eof:\n");

  if (!data || !data->output_fn) {
    return -1;
  }

  if (0) {
    // TEST OUTPUT
    const char content[] = "content-type: multipart/mixed; boundary=\"ABCD\"\r\n\r\nmultipart\r\n--ABCD\r\ncontent-type: text/html \r\n\r\n<html><body><b>TEST CONTENT1<b></body></html>\r\n\r\n--ABCD\r\ncontent-type: text/plain\r\ncontent-disposition: attachment; filename=\"abcd.txt\"\r\n\r\nFILE CONTENTS\r\n--ABCD--\r\n";

    PR_SetError(0,0);
    int status = data->output_fn(content, strlen(content),
                                 data->output_closure);
    if (status < 0) {
      PR_SetError(status, 0);
      data->output_fn = 0;
      return -1;
    }

    return 0;
  }

  // Enigmail stuff
  if (!data->mimeDecrypt)
    return -1;

  mime_stream_data *msd = (mime_stream_data *) (data->self->options->stream_closure);

  nsCOMPtr<nsIURI> uri;
  nsCOMPtr<nsIMsgWindow> msgWindow;

  if (msd && msd->channel) {
    nsIChannel *channel = msd->channel;

    if (channel)
      channel->GetURI(getter_AddRefs(uri));

    nsCOMPtr<nsIMsgMailNewsUrl> msgUrl;
    if (uri)
      msgUrl = do_QueryInterface(uri);

    if (msgUrl)
      msgUrl->GetMsgWindow(getter_AddRefs(msgWindow));
  }

  nsresult rv;
  rv = data->mimeDecrypt->Finish(msgWindow, uri);
  if (NS_FAILED(rv))
    return -1;

  data->mimeDecrypt = nsnull;
  return 0;
}

Here is the caller graph for this function:

static void MimeEnig_free ( void *  output_closure) [static]

Definition at line 238 of file mimeenig.cpp.

{
  fprintf(stderr, "MimeEnig_free:\n");
}

Here is the caller graph for this function:

static char * MimeEnig_generate ( void *  output_closure) [static]

Definition at line 225 of file mimeenig.cpp.

{
  fprintf(stderr, "MimeEnig_generate:\n");

  const char htmlMsg[] = "<html><body><b>GEN MSG<b></body></html>";
  char* msg = (char *) PR_MALLOC(strlen(htmlMsg) + 1);
  if (msg) {
    PL_strcpy(msg, htmlMsg);
  }
  return msg;
}

Here is the caller graph for this function:

static void* MimeEnig_init ( MimeObject *  ,
int(*)(const char *, PRInt32, void *)  output_fn,
void *   
) [static]

Here is the caller graph for this function:

static void* MimeEnig_init ( MimeObject *  obj,
int(*)(const char *buf, PRInt32 buf_size, void *output_closure)  output_fn,
void *  output_closure 
) [static]

Definition at line 103 of file mimeenig.cpp.

{
  MimeEnigData *data;
  MimeDisplayOptions *opts;

  fprintf(stderr, "MimeEnig_init:\n");

  if (!(obj && obj->options && output_fn)) return NULL;

  opts = obj->options;

  data = new MimeEnigData;
  if (!data)
    return NULL;

  data->self = obj;
  data->output_fn = output_fn;
  data->output_closure = output_closure;

  // Enigmail stuff
  nsresult rv;
  data->mimeDecrypt = do_CreateInstance(NS_ENIGMIMEDECRYPT_CONTRACTID, &rv);
  if (NS_FAILED(rv))
    return NULL;

  EMBool verifyOnly = PR_FALSE;
  EMBool rfc2015 = PR_TRUE;
  rv = data->mimeDecrypt->Init(verifyOnly, rfc2015,
                               output_fn, output_closure);
  if (NS_FAILED(rv))
    return NULL;

  return data;
}
static int MimeEnig_write ( const char *  buf,
PRInt32  buf_size,
void *  output_closure 
) [static]

Definition at line 143 of file mimeenig.cpp.

{
  MimeEnigData *data = (MimeEnigData *) output_closure;

  if (!data || !data->output_fn)
    return -1;

  //nsCAutoString temStr(buf, buf_size);
  //fprintf(stderr, "MimeEnig_write:: aBuf='%s'\n", temStr.get());

  // Enigmail stuff
  if (!data->mimeDecrypt)
    return -1;

  nsresult rv;
  rv = data->mimeDecrypt->Write(buf, buf_size);
  if (NS_FAILED(rv))
    return -1;

  return 0;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 61 of file mimeenig.cpp.