Back to index

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

#include <nsIMAPBodyShell.h>

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

List of all members.

Public Member Functions

 nsIMAPBodypartMultipart (char *partNum, nsIMAPBodypart *parentPart)
virtual nsIMAPBodypartType GetType ()
virtual ~nsIMAPBodypartMultipart ()
virtual PRBool ShouldFetchInline (nsIMAPBodyShell *aShell)
virtual PRBool PreflightCheckAllInline (nsIMAPBodyShell *aShell)
virtual PRInt32 Generate (nsIMAPBodyShell *aShell, PRBool stream, PRBool prefetch)
virtual nsIMAPBodypartFindPartWithNumber (const char *partNum)
virtual PRBool IsLastTextPart (const char *partNumberString)
void AppendPart (nsIMAPBodypart *part)
void SetBodySubType (char *bodySubType)
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 char * GetPartNumberString ()
virtual nsIMAPBodypartGetParentPart ()
virtual nsIMAPBodypartMessageGetnsIMAPBodypartMessage ()
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

nsVoidArraym_partList
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 156 of file nsIMAPBodyShell.h.


Constructor & Destructor Documentation

nsIMAPBodypartMultipart::nsIMAPBodypartMultipart ( char *  partNum,
nsIMAPBodypart parentPart 
)

Definition at line 965 of file nsIMAPBodyShell.cpp.

                                                                                          : 
nsIMAPBodypart(partNum, parentPart)
{
  if (!m_parentPart  || (m_parentPart->GetType() == IMAP_BODY_MESSAGE_RFC822))
  {
    // the multipart (this) will inherit the part number of its parent
    PR_FREEIF(m_partNumberString);
    if (!m_parentPart)
    {
      m_partNumberString = PR_smprintf("0");
    }
    else
    {
      m_partNumberString = nsCRT::strdup(m_parentPart->GetPartNumberString());
    }
  }
  m_partList = new nsVoidArray();
  m_bodyType = nsCRT::strdup("multipart");
  if (m_partList && m_parentPart && m_bodyType)
    SetIsValid(PR_TRUE);
  else
    SetIsValid(PR_FALSE);
}

Here is the call graph for this function:

Definition at line 994 of file nsIMAPBodyShell.cpp.

{
  for (int i = m_partList->Count() - 1; i >= 0; i--)
  {
    delete (nsIMAPBodypart *)(m_partList->ElementAt(i));
  }
  delete m_partList;
}

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:

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:

Definition at line 168 of file nsIMAPBodyShell.h.

{ m_partList->AppendElement(part); }

Here is the caller graph for this function:

Reimplemented from nsIMAPBodypart.

Definition at line 1117 of file nsIMAPBodyShell.cpp.

{
  NS_ASSERTION(partNum, "null part passed into FindPartWithNumber");
  
  // check this
  if (!PL_strcmp(partNum, m_partNumberString))
    return this;
  
  // check children
  for (int i = m_partList->Count() - 1; i >= 0; i--)
  {
    nsIMAPBodypart *foundPart = ((nsIMAPBodypart *)(m_partList->ElementAt(i)))->FindPartWithNumber(partNum);
    if (foundPart)
      return foundPart;
  }
  
  // not this, or any of this's children
  return NULL;
}

Here is the call graph for this function:

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

Reimplemented from nsIMAPBodypart.

Definition at line 1014 of file nsIMAPBodyShell.cpp.

{
  PRInt32 len = 0;
  
  if (GetIsValid())
  {
    if (stream && !prefetch)
      aShell->GetConnection()->Log("SHELL","GENERATE-Multipart",m_partNumberString);
    
    // Stream out the MIME header of this part
    
    PRBool parentIsMessageType = GetParentPart() ? (GetParentPart()->GetType() == IMAP_BODY_MESSAGE_RFC822) : PR_TRUE;
    
    // If this is multipart/signed, then we always want to generate the MIME headers of this multipart.
    // Otherwise, we only want to do it if the parent is not of type "message"
    PRBool needMIMEHeader = !parentIsMessageType;  // !PL_strcasecmp(m_bodySubType, "signed") ? PR_TRUE : !parentIsMessageType;
    if (needMIMEHeader && !aShell->GetPseudoInterrupted())  // not a message body's type
    {
      len += GenerateMIMEHeader(aShell, stream, prefetch);
    }
    
    if (ShouldFetchInline(aShell))
    {
      for (int i = 0; i < m_partList->Count(); i++)
      {
        if (!aShell->GetPseudoInterrupted())
          len += GenerateBoundary(aShell, stream, prefetch, PR_FALSE);
        if (!aShell->GetPseudoInterrupted())
          len += ((nsIMAPBodypart *)(m_partList->ElementAt(i)))->Generate(aShell, stream, prefetch);
      }
      if (!aShell->GetPseudoInterrupted())
        len += GenerateBoundary(aShell, stream, prefetch, PR_TRUE);
    }
    else
    {
      // fill in the filling within the empty part
      if (!aShell->GetPseudoInterrupted())
        len += GenerateEmptyFilling(aShell, stream, prefetch);
    }
  }
  m_contentLength = len;
  return m_contentLength;
}

Here is the call 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 nsIMAPBodypart::GetIsValid ( ) [inline, virtual, inherited]

Definition at line 65 of file nsIMAPBodyShell.h.

{ return m_isValid; }

Here is the caller graph for this function:

virtual nsIMAPBodypartMessage* nsIMAPBodypart::GetnsIMAPBodypartMessage ( ) [inline, virtual, inherited]

Reimplemented in nsIMAPBodypartMessage.

Definition at line 107 of file nsIMAPBodyShell.h.

{ return NULL; }

Here is the caller graph for this function:

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:

Implements nsIMAPBodypart.

Definition at line 989 of file nsIMAPBodyShell.cpp.

{
  return IMAP_BODY_MULTIPART;
}

Here is the caller graph for this function:

PRBool nsIMAPBodypartMultipart::IsLastTextPart ( const char *  partNumberString) [virtual]

Reimplemented from nsIMAPBodypart.

Definition at line 791 of file nsIMAPBodyShell.cpp.

{
 // iterate backwards over the parent's part list and if the part is
  // text, compare it to the part number string
  for (int i = m_partList->Count() - 1; i >= 0; i--)
  {
      nsIMAPBodypart *part = (nsIMAPBodypart *)(m_partList->ElementAt(i));
      if (!PL_strcasecmp(part->GetBodyType(), "text"))
        return !PL_strcasecmp(part->GetPartNumberString(), partNumberString);
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Reimplemented from nsIMAPBodypart.

Definition at line 1103 of file nsIMAPBodyShell.cpp.

{
  PRBool rv = ShouldFetchInline(aShell);
  
  int i = 0;
  while (rv && (i < m_partList->Count()))
  {
    rv = ((nsIMAPBodypart *)(m_partList->ElementAt(i)))->PreflightCheckAllInline(aShell);
    i++;
  }
  
  return rv;
}

Here is the call 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 1004 of file nsIMAPBodyShell.cpp.

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 nsIMAPBodypart.

Definition at line 1059 of file nsIMAPBodyShell.cpp.

{
  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;
    
    nsIMAPBodypart *grandparentPart = m_parentPart->GetParentPart();

    // if we're a multipart sub-part of multipart alternative, we need to 
    // be fetched because mime will always display us.
    if (!PL_strcasecmp(m_parentPart->GetBodySubType(), "alternative") &&
        GetType() == IMAP_BODY_MULTIPART)
      return PR_TRUE;
    // If "Show Attachments as Links" is on, and
    // the parent of this multipart is not a message,
    // then it's not inline.
    if (!(aShell->GetContentModified() == IMAP_CONTENT_MODIFIED_VIEW_INLINE) &&
      (m_parentPart->GetType() != IMAP_BODY_MESSAGE_RFC822) &&
      (m_parentPart->GetType() == IMAP_BODY_MULTIPART ?
      (grandparentPart ? grandparentPart->GetType() != IMAP_BODY_MESSAGE_RFC822 : PR_TRUE)
      : PR_TRUE))
      return PR_FALSE;
    
    // multiparts are always inline (even multipart/appledouble)
    // (their children might not be, though)
    return PR_TRUE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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.

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.

Definition at line 172 of file nsIMAPBodyShell.h.

char* nsIMAPBodypart::m_partNumberString [protected, inherited]

Definition at line 120 of file nsIMAPBodyShell.h.


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