Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsIMAPBodypartMessage Class Reference

#include <nsIMAPBodyShell.h>

Inheritance diagram for nsIMAPBodypartMessage:
Inheritance graph
[legend]
Collaboration diagram for nsIMAPBodypartMessage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsIMAPBodypartMessage (char *partNum, nsIMAPBodypart *parentPart, PRBool topLevelMessage, char *bodyType, char *bodySubType, char *bodyID, char *bodyDescription, char *bodyEncoding, PRInt32 partLength)
void SetBody (nsIMAPBodypart *body)
virtual nsIMAPBodypartType GetType ()
virtual ~nsIMAPBodypartMessage ()
virtual PRInt32 Generate (nsIMAPBodyShell *aShell, PRBool stream, PRBool prefetch)
virtual PRBool ShouldFetchInline (nsIMAPBodyShell *aShell)
virtual PRBool PreflightCheckAllInline (nsIMAPBodyShell *aShell)
virtual nsIMAPBodypartFindPartWithNumber (const char *partNum)
void AdoptMessageHeaders (char *headers)
virtual nsIMAPBodypartMessageGetnsIMAPBodypartMessage ()
virtual PRBool GetIsTopLevelMessage ()
virtual PRBool GetIsValid ()
virtual void SetIsValid (PRBool valid)
virtual void AdoptPartDataBuffer (char *buf)
virtual void AdoptHeaderDataBuffer (char *buf)
virtual PRBool ShouldExplicitlyFetchInline ()
virtual PRBool ShouldExplicitlyNotFetchInline ()
virtual PRBool IsLastTextPart (const char *partNumberString)
virtual char * GetPartNumberString ()
virtual nsIMAPBodypartGetParentPart ()
const char * GetBodyType ()
const char * GetBodySubType ()
void SetBoundaryData (char *boundaryData)

Protected Member Functions

virtual PRInt32 GeneratePart (nsIMAPBodyShell *aShell, PRBool stream, PRBool prefetch)
virtual PRInt32 GenerateMIMEHeader (nsIMAPBodyShell *aShell, PRBool stream, PRBool prefetch)
virtual PRInt32 GenerateBoundary (nsIMAPBodyShell *aShell, PRBool stream, PRBool prefetch, PRBool lastBoundary)
virtual PRInt32 GenerateEmptyFilling (nsIMAPBodyShell *aShell, PRBool stream, PRBool prefetch)
virtual void QueuePrefetchMIMEHeader (nsIMAPBodyShell *aShell)

Protected Attributes

nsIMAPMessageHeadersm_headers
nsIMAPBodypartm_body
PRBool m_topLevelMessage
PRBool m_isValid
char * m_partNumberString
char * m_partData
char * m_headerData
char * m_boundaryData
PRInt32 m_partLength
PRInt32 m_contentLength
nsIMAPBodypartm_parentPart
char * m_contentType
char * m_bodyType
char * m_bodySubType
char * m_bodyID
char * m_bodyDescription
char * m_bodyEncoding

Detailed Description

Definition at line 192 of file nsIMAPBodyShell.h.


Constructor & Destructor Documentation

nsIMAPBodypartMessage::nsIMAPBodypartMessage ( char *  partNum,
nsIMAPBodypart parentPart,
PRBool  topLevelMessage,
char *  bodyType,
char *  bodySubType,
char *  bodyID,
char *  bodyDescription,
char *  bodyEncoding,
PRInt32  partLength 
)

Definition at line 813 of file nsIMAPBodyShell.cpp.

                                                                                                                                          : nsIMAPBodypartLeaf(partNum, parentPart, bodyType, bodySubType, bodyID, bodyDescription, bodyEncoding, partLength)
{
  m_topLevelMessage = topLevelMessage;
  if (m_topLevelMessage)
  {
    m_partNumberString = PR_smprintf("0");
    if (!m_partNumberString)
    {
      SetIsValid(PR_FALSE);
      return;
    }
  }
  m_body = NULL;
  m_headers = new nsIMAPMessageHeaders(m_partNumberString, this);  // We always have a Headers object
  if (!m_headers || !m_headers->GetIsValid())
  {
    SetIsValid(PR_FALSE);
    return;
  }
  SetIsValid(PR_TRUE);
}

Here is the call graph for this function:

Definition at line 849 of file nsIMAPBodyShell.cpp.

{
  delete m_headers;
  delete m_body;
}

Member Function Documentation

void nsIMAPBodypart::AdoptHeaderDataBuffer ( char *  buf) [virtual, inherited]

Definition at line 394 of file nsIMAPBodyShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 936 of file nsIMAPBodyShell.cpp.

{
  if (!GetIsValid())
    return;
  
  // we are going to say that the message headers only have
  // part data, and no header data.
  m_headers->AdoptPartDataBuffer(headers);
  if (!m_headers->GetIsValid())
    SetIsValid(PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMAPBodypart::AdoptPartDataBuffer ( char *  buf) [virtual, inherited]

Definition at line 384 of file nsIMAPBodyShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from nsIMAPBodypart.

Definition at line 951 of file nsIMAPBodyShell.cpp.

{
  // either brute force, or do it the smart way - look at the number.
  // (the parts should be ordered, and hopefully indexed by their number)
  
  if (!PL_strcasecmp(partNum, m_partNumberString))
    return this;
  
  return m_body->FindPartWithNumber(partNum);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsIMAPBodypartMessage::Generate ( nsIMAPBodyShell aShell,
PRBool  stream,
PRBool  prefetch 
) [virtual]

Reimplemented from nsIMAPBodypartLeaf.

Definition at line 855 of file nsIMAPBodyShell.cpp.

{
  if (!GetIsValid())
    return 0;
  
  m_contentLength = 0;
  
  if (stream && !prefetch)
    aShell->GetConnection()->Log("SHELL","GENERATE-MessageRFC822",m_partNumberString);
  
  if (!m_topLevelMessage && !aShell->GetPseudoInterrupted())  // not the top-level message - we need the MIME header as well as the message header
  {
    // but we don't need the MIME headers of a message/rfc822 part if this content
    // type is in (part of) the main msg header. In other words, we still need
    // these MIME headers if this message/rfc822 body part is enclosed in the msg
    // body (most likely as a body part of a multipart/mixed msg).
    //       Don't fetch (bug 128888)              Do fetch (bug 168097)
    //  ----------------------------------  -----------------------------------
    //  message/rfc822  (parent part)       message/rfc822
    //   message/rfc822 <<<---               multipart/mixed  (parent part)
    //    multipart/mixed                     message/rfc822  <<<---
    //     text/html   (body text)             multipart/mixed
    //     text/plain  (attachment)             text/html   (body text)
    //     application/msword (attachment)      text/plain  (attachment)
    //                                          application/msword (attachment)
    // "<<<---" points to the part we're examining here.
    if ( PL_strcasecmp(m_bodyType, "message") || PL_strcasecmp(m_bodySubType, "rfc822") ||
      PL_strcasecmp(m_parentPart->GetBodyType(), "message") || PL_strcasecmp(m_parentPart->GetBodySubType(), "rfc822") )
      m_contentLength += GenerateMIMEHeader(aShell, stream, prefetch);
  }
  
  if (!aShell->GetPseudoInterrupted())
    m_contentLength += m_headers->Generate(aShell, stream, prefetch);
  if (!aShell->GetPseudoInterrupted())
    m_contentLength += m_body->Generate(aShell, stream, prefetch);
  
  return m_contentLength;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsIMAPBodypart::GenerateBoundary ( nsIMAPBodyShell aShell,
PRBool  stream,
PRBool  prefetch,
PRBool  lastBoundary 
) [protected, virtual, inherited]

Definition at line 511 of file nsIMAPBodyShell.cpp.

{
  if (prefetch)
    return 0; // don't need to prefetch anything
  
  if (m_boundaryData)
  {
    if (!lastBoundary)
    {
      if (stream)
      {
        aShell->GetConnection()->Log("SHELL","GENERATE-Boundary",m_partNumberString);
        aShell->GetConnection()->HandleMessageDownLoadLine(m_boundaryData, PR_FALSE);
      }
      return PL_strlen(m_boundaryData);
    }
    else      // the last boundary
    {
      char *lastBoundaryData = PR_smprintf("%s--", m_boundaryData);
      if (lastBoundaryData)
      {
        if (stream)
        {
          aShell->GetConnection()->Log("SHELL","GENERATE-Boundary-Last",m_partNumberString);
          aShell->GetConnection()->HandleMessageDownLoadLine(lastBoundaryData, PR_FALSE);
        }
        PRInt32 rv = PL_strlen(lastBoundaryData);
        PR_Free(lastBoundaryData);
        return rv;
      }
      else
      {
        //HandleMemoryFailure();
        return 0;
      }
    }
  }
  else
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsIMAPBodypart::GenerateEmptyFilling ( nsIMAPBodyShell aShell,
PRBool  stream,
PRBool  prefetch 
) [protected, virtual, inherited]

Definition at line 552 of file nsIMAPBodyShell.cpp.

{
  if (prefetch)
    return 0; // don't need to prefetch anything
  
  const char emptyString[] = "This body part will be downloaded on demand.";
  // XP_GetString(MK_IMAP_EMPTY_MIME_PART);  ### need to be able to localize
  if (emptyString)
  {
    if (stream)
    {
      aShell->GetConnection()->Log("SHELL","GENERATE-Filling",m_partNumberString);
      aShell->GetConnection()->HandleMessageDownLoadLine(emptyString, PR_FALSE);
    }
    return PL_strlen(emptyString);
  }
  else
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsIMAPBodypart::GenerateMIMEHeader ( nsIMAPBodyShell aShell,
PRBool  stream,
PRBool  prefetch 
) [protected, virtual, inherited]

Definition at line 440 of file nsIMAPBodyShell.cpp.

{
  if (prefetch && !m_headerData)
  {
    QueuePrefetchMIMEHeader(aShell);
    return 0;
  }
  else if (m_headerData)
  {
    PRInt32 mimeHeaderLength = 0;
    
    if (!ShouldFetchInline(aShell))
    {
      // if this part isn't inline, add the X-Mozilla-IMAP-Part header
      char *xPartHeader = PR_smprintf("%s: %s", IMAP_EXTERNAL_CONTENT_HEADER, m_partNumberString);
      if (xPartHeader)
      {
        if (stream)
        {
          aShell->GetConnection()->Log("SHELL","GENERATE-XHeader",m_partNumberString);
          aShell->GetConnection()->HandleMessageDownLoadLine(xPartHeader, PR_FALSE);
        }
        mimeHeaderLength += PL_strlen(xPartHeader);
        PR_Free(xPartHeader);
      }
    }
    
    mimeHeaderLength += PL_strlen(m_headerData);
    if (stream)
    {
      aShell->GetConnection()->Log("SHELL","GENERATE-MIMEHeader",m_partNumberString);
      aShell->GetConnection()->HandleMessageDownLoadLine(m_headerData, PR_FALSE);  // all one line?  Can we do that?
    }
    
    return mimeHeaderLength;
  }
  else 
  {
    SetIsValid(PR_FALSE);   // prefetch didn't adopt a MIME header
    return 0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsIMAPBodypart::GeneratePart ( nsIMAPBodyShell aShell,
PRBool  stream,
PRBool  prefetch 
) [protected, virtual, inherited]

Definition at line 483 of file nsIMAPBodyShell.cpp.

{
  if (prefetch)
    return 0; // don't need to prefetch anything
  
  if (m_partData)    // we have prefetched the part data
  {
    if (stream)
    {
      aShell->GetConnection()->Log("SHELL","GENERATE-Part-Prefetched",m_partNumberString);
      aShell->GetConnection()->HandleMessageDownLoadLine(m_partData, PR_FALSE);
    }
    return PL_strlen(m_partData);
  }
  else // we are fetching and streaming this part's body as we go
  {
    if (stream && !aShell->DeathSignalReceived())
    {
      char *generatingPart = aShell->GetGeneratingPart();
      PRBool fetchingSpecificPart = (generatingPart && !PL_strcmp(generatingPart, m_partNumberString));
      
      aShell->GetConnection()->Log("SHELL","GENERATE-Part-Inline",m_partNumberString);
      aShell->GetConnection()->FetchTryChunking(aShell->GetUID().get(), kMIMEPart, PR_TRUE, m_partNumberString, m_partLength, !fetchingSpecificPart);
    }
    return m_partLength;    // the part length has been filled in from the BODYSTRUCTURE response
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* nsIMAPBodypart::GetBodySubType ( ) [inline, inherited]

Definition at line 110 of file nsIMAPBodyShell.h.

{ return m_bodySubType; }

Here is the caller graph for this function:

const char* nsIMAPBodypart::GetBodyType ( ) [inline, inherited]

Definition at line 109 of file nsIMAPBodyShell.h.

{ return m_bodyType; }

Here is the caller graph for this function:

virtual PRBool nsIMAPBodypartMessage::GetIsTopLevelMessage ( ) [inline, virtual]

Definition at line 208 of file nsIMAPBodyShell.h.

{ return m_topLevelMessage; }

Here is the caller graph for this function:

virtual PRBool nsIMAPBodypart::GetIsValid ( ) [inline, virtual, inherited]

Definition at line 65 of file nsIMAPBodyShell.h.

{ return m_isValid; }

Here is the caller graph for this function:

Reimplemented from nsIMAPBodypart.

Definition at line 207 of file nsIMAPBodyShell.h.

{ return this; }
virtual nsIMAPBodypart* nsIMAPBodypart::GetParentPart ( ) [inline, virtual, inherited]

Definition at line 98 of file nsIMAPBodyShell.h.

{ return m_parentPart; }    // Returns the parent of this part.

Here is the caller graph for this function:

virtual char* nsIMAPBodypart::GetPartNumberString ( ) [inline, virtual, inherited]

Definition at line 96 of file nsIMAPBodyShell.h.

{ return m_partNumberString; }

Here is the caller graph for this function:

Reimplemented from nsIMAPBodypartLeaf.

Definition at line 844 of file nsIMAPBodyShell.cpp.

virtual PRBool nsIMAPBodypart::IsLastTextPart ( const char *  partNumberString) [inline, virtual, inherited]

Reimplemented in nsIMAPBodypartMultipart.

Definition at line 79 of file nsIMAPBodyShell.h.

{return PR_TRUE;}

Here is the caller graph for this function:

Reimplemented from nsIMAPBodypartLeaf.

Definition at line 927 of file nsIMAPBodyShell.cpp.

{
  if (!ShouldFetchInline(aShell))
    return PR_FALSE;
  
  return m_body->PreflightCheckAllInline(aShell);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMAPBodypart::QueuePrefetchMIMEHeader ( nsIMAPBodyShell aShell) [protected, virtual, inherited]

Definition at line 435 of file nsIMAPBodyShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 836 of file nsIMAPBodyShell.cpp.

{
  if (m_body)
    delete m_body;
  m_body = body;
}

Here is the caller graph for this function:

void nsIMAPBodypart::SetBoundaryData ( char *  boundaryData) [inline, inherited]

Definition at line 111 of file nsIMAPBodyShell.h.

{ m_boundaryData = boundaryData; }

Here is the caller graph for this function:

void nsIMAPBodypart::SetIsValid ( PRBool  valid) [virtual, inherited]

Definition at line 374 of file nsIMAPBodyShell.cpp.

{
  m_isValid = valid;
  if (!m_isValid)
  {
    //PR_LOG(IMAP, out, ("BODYSHELL: Part is invalid.  Part Number: %s Content-Type: %s", m_partNumberString, m_contentType));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 575 of file nsIMAPBodyShell.cpp.

{
        return PR_FALSE;
}

Here is the caller graph for this function:

Definition at line 583 of file nsIMAPBodyShell.cpp.

{
  return PR_FALSE;
}

Here is the caller graph for this function:

Reimplemented from nsIMAPBodypartLeaf.

Definition at line 897 of file nsIMAPBodyShell.cpp.

{
  if (m_topLevelMessage)    // the main message should always be defined as "inline"
    return PR_TRUE;
  
  char *generatingPart = aShell->GetGeneratingPart();
  if (generatingPart)
  {
    // If we are generating a specific part
    // Always generate containers (just don't fill them in)
    // because it is low cost (everything is cached)
    // and it gives the message its full MIME structure,
    // to avoid any potential mishap.
    return PR_TRUE;
  }
  else
  {
    // Generating whole message
    
    if (ShouldExplicitlyFetchInline())
      return PR_TRUE;
    if (ShouldExplicitlyNotFetchInline())
      return PR_FALSE;
    
    
    // Message types are inline, by default.
    return PR_TRUE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 212 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_bodyDescription [protected, inherited]

Definition at line 133 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_bodyEncoding [protected, inherited]

Definition at line 134 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_bodyID [protected, inherited]

Definition at line 132 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_bodySubType [protected, inherited]

Definition at line 131 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_bodyType [protected, inherited]

Definition at line 130 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_boundaryData [protected, inherited]

Definition at line 123 of file nsIMAPBodyShell.h.

PRInt32 nsIMAPBodypart::m_contentLength [protected, inherited]

Definition at line 125 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_contentType [protected, inherited]

Definition at line 129 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_headerData [protected, inherited]

Definition at line 122 of file nsIMAPBodyShell.h.

Definition at line 211 of file nsIMAPBodyShell.h.

PRBool nsIMAPBodypart::m_isValid [protected, inherited]

Definition at line 119 of file nsIMAPBodyShell.h.

Definition at line 126 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_partData [protected, inherited]

Definition at line 121 of file nsIMAPBodyShell.h.

PRInt32 nsIMAPBodypart::m_partLength [protected, inherited]

Definition at line 124 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_partNumberString [protected, inherited]

Definition at line 120 of file nsIMAPBodyShell.h.

Definition at line 213 of file nsIMAPBodyShell.h.


The documentation for this class was generated from the following files: