Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Enumerations | Functions | Variables
nsMsgSend.cpp File Reference
#include "nsMsgSend.h"
#include "nsCRT.h"
#include "nsMsgLocalFolderHdrs.h"
#include "nsMsgSendPart.h"
#include "nsMsgBaseCID.h"
#include "nsMsgNewsCID.h"
#include "nsIMsgHeaderParser.h"
#include "nsISmtpService.h"
#include "nsINntpService.h"
#include "nsIMsgMailSession.h"
#include "nsIMsgIdentity.h"
#include "nsEscape.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsMsgDeliveryListener.h"
#include "nsMsgComposeStringBundle.h"
#include "nsMsgEncoders.h"
#include "nsMsgCompUtils.h"
#include "nsMsgI18N.h"
#include "nsICharsetConverterManager.h"
#include "nsIMsgSendListener.h"
#include "nsIMsgCopyServiceListener.h"
#include "nsIFileSpec.h"
#include "nsIURL.h"
#include "nsIFileURL.h"
#include "nsMsgCopy.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsMsgPrompts.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsIDOMHTMLLinkElement.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsCExternalHandlerService.h"
#include "nsIMIMEService.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsMsgCompCID.h"
#include "nsIAbAddressCollecter.h"
#include "nsAbBaseCID.h"
#include "nsCOMPtr.h"
#include "mozITXTToHTMLConv.h"
#include "nsIMsgStatusFeedback.h"
#include "nsTextFormatter.h"
#include "nsIPrompt.h"
#include "nsMailHeaders.h"
#include "nsIDocShell.h"
#include "nsMimeTypes.h"
#include "nsISmtpUrl.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIEditorMailSupport.h"
#include "nsIDocumentEncoder.h"
#include "nsILoadGroup.h"
#include "nsMsgSendReport.h"
#include "nsMsgSimulateError.h"
#include "nsNetCID.h"
#include "nsNetError.h"
#include "nsMsgUtils.h"
#include "nsIMsgMdnGenerator.h"
#include "nsISmtpServer.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "nsIMsgAccountManager.h"
#include "nsNativeCharsetUtils.h"
#include "nsIAbCard.h"
#include "nsIMsgProgress.h"
#include "nsIMsgMessageService.h"
#include "nsIMsgHdr.h"
#include "nsIMsgFolder.h"

Go to the source code of this file.

Classes

struct  domSaveStruct

Defines

#define PREF_MAIL_SEND_STRUCT   "mail.send_struct"
#define PREF_MAIL_STRICTLY_MIME   "mail.strictly_mime"
#define PREF_MAIL_MESSAGE_WARNING_SIZE   "mailnews.message_warning_size"
#define PREF_MAIL_COLLECT_EMAIL_ADDRESS_OUTGOING   "mail.collect_email_address_outgoing"
#define PREF_MAIL_DONT_ATTACH_SOURCE   "mail.compose.dont_attach_source_of_local_network_links"
#define ATTR_MOZ_DO_NOT_SEND   "moz-do-not-send"
#define MIME_MULTIPART_BLURB   "This is a multi-part message in MIME format."
#define SNARF(x, y)
#define FROB(X)
#define LINE_BREAK_MAX   990

Enumerations

enum  { kDefaultMode = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE) }

Functions

static NS_DEFINE_CID (kRDFServiceCID, NS_RDFSERVICE_CID)
PRBool UseQuotedPrintable (void)
static nsresult StripOutGroupNames (char *addresses)
char * mime_get_stream_write_buffer (void)
static PRBool isEmpty (const char *aString)
nsresult mime_write_message_body (nsIMsgSend *state, char *buf, PRInt32 size)
nsresult mime_encoder_output_fn (const char *buf, PRInt32 size, void *closure)
nsresult SendDeliveryCallback (nsIURI *aUrl, nsresult aExitCode, nsMsgDeliveryType deliveryType, nsISupports *tagData)
static void strip_nonprintable (char *string)
nsMsgAttachmentDataBuildURLAttachmentData (nsIURI *url)
char * nsMsgGetEnvelopeLine (void)

Variables

static PRBool mime_use_quoted_printable_p = PR_FALSE
static char * mime_mailto_stream_read_buffer = 0
static char * mime_mailto_stream_write_buffer = 0

Class Documentation

struct domSaveStruct

Definition at line 1963 of file nsMsgSend.cpp.

Collaboration diagram for domSaveStruct:
Class Members
nsIDOMNode * node
char * url

Define Documentation

#define ATTR_MOZ_DO_NOT_SEND   "moz-do-not-send"

Definition at line 123 of file nsMsgSend.cpp.

#define FROB (   X)
Value:
if (X && *X) \
    { \
      if (*recipients) PL_strcat(recipients, ","); \
      PL_strcat(recipients, X); \
    }

Definition at line 1340 of file nsMsgSend.cpp.

Definition at line 1883 of file nsMsgSend.cpp.

#define MIME_MULTIPART_BLURB   "This is a multi-part message in MIME format."

Definition at line 553 of file nsMsgSend.cpp.

#define PREF_MAIL_COLLECT_EMAIL_ADDRESS_OUTGOING   "mail.collect_email_address_outgoing"

Definition at line 120 of file nsMsgSend.cpp.

#define PREF_MAIL_DONT_ATTACH_SOURCE   "mail.compose.dont_attach_source_of_local_network_links"

Definition at line 121 of file nsMsgSend.cpp.

#define PREF_MAIL_MESSAGE_WARNING_SIZE   "mailnews.message_warning_size"

Definition at line 119 of file nsMsgSend.cpp.

#define PREF_MAIL_SEND_STRUCT   "mail.send_struct"

Definition at line 117 of file nsMsgSend.cpp.

#define PREF_MAIL_STRICTLY_MIME   "mail.strictly_mime"

Definition at line 118 of file nsMsgSend.cpp.

#define SNARF (   x,
  y 
)
Value:
do { if((y) && *(y) && !(x)) { ((x) = (y)); ((y) = 0); }} \
           while(0)

Enumeration Type Documentation

anonymous enum
Enumerator:
kDefaultMode 

Definition at line 125 of file nsMsgSend.cpp.


Function Documentation

Definition at line 4308 of file nsMsgSend.cpp.

{
  int                 attachCount = 2;  // one entry and one empty entry
  nsMsgAttachmentData *attachments = nsnull;
  const char          *theName = nsnull;

  if (!url)
    return nsnull;    

  attachments = (nsMsgAttachmentData *) PR_Malloc(sizeof(nsMsgAttachmentData) * attachCount);
  if (!attachments)
    return nsnull;

  // Now get a readable name...
  nsCAutoString spec;
  url->GetSpec(spec);
  if (!spec.IsEmpty())
  {
    theName = strrchr(spec.get(), '/');
  }

  if (!theName)
    theName = "Unknown"; // Don't I18N this string...should never happen...
  else
    theName++;

  memset(attachments, 0, sizeof(nsMsgAttachmentData) * attachCount);
  attachments[0].url = url; // The URL to attach. This should be 0 to signify "end of list".
  attachments[0].real_name = (char *)PL_strdup(theName);  // The original name of this document, which will eventually show up in the 

  NS_IF_ADDREF(url);
  return attachments;
}

Here is the call graph for this function:

static PRBool isEmpty ( const char *  aString) [static]

Definition at line 526 of file nsMsgSend.cpp.

{
  return (!aString) || (!*aString);
}

Here is the caller graph for this function:

nsresult mime_encoder_output_fn ( const char *  buf,
PRInt32  size,
void closure 
)

Definition at line 1432 of file nsMsgSend.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 519 of file nsMsgSend.cpp.

Here is the caller graph for this function:

nsresult mime_write_message_body ( nsIMsgSend state,
char *  buf,
PRInt32  size 
)

Definition at line 1404 of file nsMsgSend.cpp.

{
  NS_ENSURE_ARG_POINTER(state);

  nsOutputFileStream * output;
  nsCOMPtr<nsIMsgComposeSecure> crypto_closure;

  state->GetOutputStream(&output);
  if (!output || CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_9))
    return NS_MSG_ERROR_WRITING_FILE;

  state->GetCryptoclosure(getter_AddRefs(crypto_closure));
  if (crypto_closure)
  {
         return crypto_closure->MimeCryptoWriteBlock (buf, size);
       }

  if (PRInt32(output->write(buf, size)) < size) 
  {
    return NS_MSG_ERROR_WRITING_FILE;
  } 
  else 
  {
    return NS_OK;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kRDFServiceCID  ,
NS_RDFSERVICE_CID   
) [static]

Definition at line 4400 of file nsMsgSend.cpp.

{
  static char       result[75] = "";
  PRExplodedTime    now;
  char              buffer[128] = "";

  // Generate envelope line in format of:  From - Sat Apr 18 20:01:49 1998
  //
  // Use PR_FormatTimeUSEnglish() to format the date in US English format,
  // then figure out what our local GMT offset is, and append it (since
  // PR_FormatTimeUSEnglish() can't do that.) Generate four digit years as
  // per RFC 1123 (superceding RFC 822.)
  //
  PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &now);
  PR_FormatTimeUSEnglish(buffer, sizeof(buffer),
               "%a %b %d %H:%M:%S %Y",
               &now);
  
  // This value must be in ctime() format, with English abbreviations.
  // PL_strftime("... %c ...") is no good, because it is localized.
  //
  PL_strcpy(result, "From - ");
  PL_strcpy(result + 7, buffer);
  PL_strcpy(result + 7 + 24, CRLF);
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult SendDeliveryCallback ( nsIURI aUrl,
nsresult  aExitCode,
nsMsgDeliveryType  deliveryType,
nsISupports *  tagData 
)

Definition at line 3384 of file nsMsgSend.cpp.

{
  if (tagData)
  {
    nsCOMPtr<nsIMsgSend> msgSend = do_QueryInterface(tagData);
    if (!msgSend)
      return NS_ERROR_NULL_POINTER;

    if (deliveryType == nsMailDelivery)
    {
      if (NS_FAILED(aExitCode))
        switch (aExitCode)
        {
          case NS_ERROR_UNKNOWN_HOST:
          case NS_ERROR_UNKNOWN_PROXY_HOST:
            aExitCode = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER;
            break;
          default:
            if (aExitCode != NS_ERROR_ABORT && !NS_IS_MSG_ERROR(aExitCode))
              aExitCode = NS_ERROR_SMTP_SEND_FAILED;
            break;
        }
      msgSend->DeliverAsMailExit(aUrl, aExitCode);
    }
    
    else if (deliveryType == nsNewsDelivery)
    {
      if (NS_FAILED(aExitCode))
        if (aExitCode != NS_ERROR_ABORT && !NS_IS_MSG_ERROR(aExitCode))
          aExitCode = NS_ERROR_POST_FAILED;
      
      msgSend->DeliverAsNewsExit(aUrl, aExitCode);
    }

    msgSend->SetRunningRequest(nsnull);
  }

  return aExitCode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void strip_nonprintable ( char *  string) [static]

Definition at line 3505 of file nsMsgSend.cpp.

{
  char *dest, *src;
  
  if ( (!string) || (!*string) ) return;
  dest=src=string;
  while (*src) 
  {
    if  ( (isprint(*src)) && (*src != ' ') )
    {
      (*dest)=(*src);
      src++; dest++;
    } 
    else 
    {
      src++;
    }
  }

  (*dest)='\0';
}

Here is the caller graph for this function:

static nsresult StripOutGroupNames ( char *  addresses) [static]

Definition at line 180 of file nsMsgSend.cpp.

{
  char aChar;
  char * readPtr = addresses;           // current read position
  char * writePtr = addresses;          // current write position
  char * previousSeparator = addresses; // remember last time we wrote a recipient separator
  char * endPtr = addresses + PL_strlen(addresses);

  PRBool quoted = PR_FALSE;   // indicate if we are between double quote
  PRBool group = PR_FALSE;   // indicate if we found a group prefix
  PRBool atFound = PR_FALSE;  // indicate if we found an @ in the current recipient. group name should not have an @

  while (readPtr < endPtr)
  {
    aChar = *readPtr;
    readPtr ++;
    switch(aChar)
    {
      case '\\':
        if (*readPtr == '"') //ignore escaped quote
          readPtr ++;
        continue;

      case '"':
        quoted = !quoted;
        break;

      case '@':
        if (!quoted)
          atFound = PR_TRUE;
        break;

      case ':':
        if (!quoted && !atFound)
        {
          // ok, we found a group name
          // let's backup the write cursor to remove the group name
          writePtr = previousSeparator + 1;
          group = PR_TRUE;
          continue;
        }
        break;

      case ';':
        if (quoted || !group)
          break;
        else
          group = PR_FALSE;
          //end of the group, act like a recipient separator now...
        /* NO BREAK */

      case ',':
        if (!quoted)
        {
          atFound = PR_FALSE;
          //let check if we already have a comma separator in the output string
          if (writePtr > addresses && *(writePtr - 1) == ',')
            writePtr --;
          *writePtr = ',';
          previousSeparator = writePtr;
          writePtr ++;
          continue;
        }
        break;
    }
    *writePtr = aChar;
    writePtr ++;
  }

  if (writePtr > addresses && *(writePtr - 1) == ',')
    writePtr --;
  *writePtr = '\0';

  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 160 of file nsMsgSend.cpp.

Here is the caller graph for this function:


Variable Documentation

char* mime_mailto_stream_read_buffer = 0 [static]

Definition at line 515 of file nsMsgSend.cpp.

char* mime_mailto_stream_write_buffer = 0 [static]

Definition at line 516 of file nsMsgSend.cpp.

Definition at line 154 of file nsMsgSend.cpp.