Back to index

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

#include <nsIMAPBodyShell.h>

Collaboration diagram for nsIMAPBodyShell:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsIMAPBodyShell (nsImapProtocol *protocolConnection, nsIMAPBodypartMessage *message, PRUint32 UID, const char *folderName)
virtual ~nsIMAPBodyShell ()
void SetConnection (nsImapProtocol *con)
virtual PRBool GetIsValid ()
virtual void SetIsValid (PRBool valid)
void AddPrefetchToQueue (nsIMAPeFetchFields, const char *partNum)
void FlushPrefetchQueue ()
void AdoptMessageHeaders (char *headers, const char *partNum)
void AdoptMimeHeader (const char *partNum, char *mimeHeader)
virtual PRInt32 Generate (char *partNum)
virtual PRBool GetShowAttachmentsInline ()
PRBool PreflightCheckAllInline ()
nsImapProtocolGetConnection ()
PRBool GetPseudoInterrupted ()
PRBool DeathSignalReceived ()
nsCStringGetUID ()
const char * GetFolderName ()
char * GetGeneratingPart ()
PRBool IsBeingGenerated ()
PRBool IsShellCached ()
void SetIsCached (PRBool isCached)
PRBool GetGeneratingWholeMessage ()
IMAP_ContentModifiedType GetContentModified ()
void SetContentModified (IMAP_ContentModifiedType modType)

Protected Attributes

nsIMAPBodypartMessagem_message
nsIMAPMessagePartIDArraym_prefetchQueue
PRBool m_isValid
nsImapProtocolm_protocolConnection
nsCString m_UID
char * m_folderName
char * m_generatingPart
PRBool m_isBeingGenerated
PRBool m_gotAttachmentPref
PRBool m_showAttachmentsInline
PRBool m_cached
PRBool m_generatingWholeMessage
IMAP_ContentModifiedType m_contentModified

Detailed Description

Definition at line 228 of file nsIMAPBodyShell.h.


Constructor & Destructor Documentation

nsIMAPBodyShell::nsIMAPBodyShell ( nsImapProtocol protocolConnection,
nsIMAPBodypartMessage message,
PRUint32  UID,
const char *  folderName 
)

Definition at line 78 of file nsIMAPBodyShell.cpp.

{
  if (gMaxDepth == 0)
  {
    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
    if (prefBranch) {
      // one-time initialization
      prefBranch->GetIntPref("mail.imap.mime_parts_on_demand_max_depth", &gMaxDepth);
    }
  }
  
  m_isValid = PR_FALSE;
  m_isBeingGenerated = PR_FALSE;
  m_cached = PR_FALSE;
  m_gotAttachmentPref = PR_FALSE;
  m_generatingWholeMessage = PR_FALSE;
  m_generatingPart = NULL;
  m_protocolConnection = protocolConnection;
  m_message = message;
  NS_ASSERTION(m_protocolConnection, "non null connection");
  if (!m_protocolConnection)
    return;
  m_prefetchQueue = new nsIMAPMessagePartIDArray();
  if (!m_prefetchQueue)
    return;
  m_UID = "";
  m_UID.AppendInt(UID);
#ifdef DEBUG_chrisf
  NS_ASSERTION(folderName);
#endif
  if (!folderName)
    return;
  m_folderName = nsCRT::strdup(folderName);
  if (!m_folderName)
    return;
  
  SetContentModified(GetShowAttachmentsInline() ? IMAP_CONTENT_MODIFIED_VIEW_INLINE : IMAP_CONTENT_MODIFIED_VIEW_AS_LINKS);

  SetIsValid(m_message != nsnull);
}

Here is the call graph for this function:

Definition at line 119 of file nsIMAPBodyShell.cpp.


Member Function Documentation

Definition at line 203 of file nsIMAPBodyShell.cpp.

{
  nsIMAPMessagePartID *newPart = new nsIMAPMessagePartID(fields, partNumber);
  if (newPart)
  {
    m_prefetchQueue->AppendElement(newPart);
  }
  else
  {
    // HandleMemoryFailure();
  }
}

Here is the caller graph for this function:

void nsIMAPBodyShell::AdoptMessageHeaders ( char *  headers,
const char *  partNum 
)

Definition at line 146 of file nsIMAPBodyShell.cpp.

{
  if (!GetIsValid())
    return;
  
  if (!partNum)
    partNum = "0";
  
  // we are going to say that a message header object only has
  // part data, and no header data.
  nsIMAPBodypart *foundPart = m_message->FindPartWithNumber(partNum);
  if (foundPart)
  {
    nsIMAPBodypartMessage *messageObj = foundPart->GetnsIMAPBodypartMessage();
    if (messageObj)
    {
      messageObj->AdoptMessageHeaders(headers);
      if (!messageObj->GetIsValid())
        SetIsValid(PR_FALSE);
    }
    else
    {
      // We were filling in message headers for a given part number.
      // We looked up that part number, found an object, but it
      // wasn't of type message/rfc822.
      // Something's wrong.
      NS_ASSERTION(PR_FALSE, "object not of type message rfc822");
    }
  }
  else
    SetIsValid(PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIMAPBodyShell::AdoptMimeHeader ( const char *  partNum,
char *  mimeHeader 
)

Definition at line 181 of file nsIMAPBodyShell.cpp.

{
  if (!GetIsValid())
    return;
  
  NS_ASSERTION(partNum, "null partnum in body shell");
  
  nsIMAPBodypart *foundPart = m_message->FindPartWithNumber(partNum);
  
  if (foundPart)
  {
    foundPart->AdoptHeaderDataBuffer(mimeHeader);
    if (!foundPart->GetIsValid())
      SetIsValid(PR_FALSE);
  }
  else
  {
    SetIsValid(PR_FALSE);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 332 of file nsIMAPBodyShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 218 of file nsIMAPBodyShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsIMAPBodyShell::Generate ( char *  partNum) [virtual]

Definition at line 252 of file nsIMAPBodyShell.cpp.

{
  m_isBeingGenerated = PR_TRUE;
  m_generatingPart = partNum;
  PRInt32 contentLength = 0;
  
  if (!GetIsValid() || PreflightCheckAllInline())
  {
    // We don't have a valid shell, or all parts are going to be inline anyway.  Fall back to fetching the whole message.
#ifdef DEBUG_chrisf
    NS_ASSERTION(GetIsValid());
#endif
    m_generatingWholeMessage = PR_TRUE;
    PRUint32 messageSize = m_protocolConnection->GetMessageSize(GetUID().get(), PR_TRUE);
    m_protocolConnection->SetContentModified(IMAP_CONTENT_NOT_MODIFIED);     // So that when we cache it, we know we have the whole message
    if (!DeathSignalReceived())
      m_protocolConnection->FallbackToFetchWholeMsg(GetUID().get(), messageSize);
    contentLength = (PRInt32) messageSize;       // ugh
  }
  else
  {
    // We have a valid shell.
    PRBool streamCreated = PR_FALSE;
    m_generatingWholeMessage = PR_FALSE;
    
    // First, prefetch any additional headers/data that we need
    if (!GetPseudoInterrupted())
      m_message->Generate(this, PR_FALSE, PR_TRUE); // This queues up everything we need to prefetch
    // Now, run a single pipelined prefetch  (neato!)
    FlushPrefetchQueue();
    
    // Next, figure out the size from the parts that we're going to fill in,
    // plus all of the MIME headers, plus the message header itself
    if (!GetPseudoInterrupted())
      contentLength = m_message->Generate(this, PR_FALSE, PR_FALSE);
    
    // Setup the stream
    if (!GetPseudoInterrupted() && !DeathSignalReceived())
    {
      nsresult rv = 
        m_protocolConnection->BeginMessageDownLoad(contentLength, MESSAGE_RFC822);
      if (NS_FAILED(rv))
      {
        m_generatingPart = nsnull;
        m_protocolConnection->AbortMessageDownLoad();
        return 0;
      }
      else
      {
        streamCreated = PR_TRUE;
      }
    }
    
    // Generate the message
    if (!GetPseudoInterrupted() && !DeathSignalReceived())
      m_message->Generate(this, PR_TRUE, PR_FALSE);
    
    // Close the stream here - normal.  If pseudointerrupted, the connection will abort the download stream
    if (!GetPseudoInterrupted() && !DeathSignalReceived())
      m_protocolConnection->NormalMessageEndDownload();
    else if (streamCreated)
      m_protocolConnection->AbortMessageDownLoad();
    
    m_generatingPart = NULL;
    
  }
  
  m_isBeingGenerated = PR_FALSE;
  return contentLength;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 261 of file nsIMAPBodyShell.h.

Here is the caller graph for this function:

Definition at line 272 of file nsIMAPBodyShell.h.

{ return m_contentModified; }

Here is the caller graph for this function:

Definition at line 265 of file nsIMAPBodyShell.h.

{ return m_folderName; }

Here is the caller graph for this function:

Definition at line 266 of file nsIMAPBodyShell.h.

{ return m_generatingPart; }

Here is the caller graph for this function:

Definition at line 271 of file nsIMAPBodyShell.h.

Here is the caller graph for this function:

virtual PRBool nsIMAPBodyShell::GetIsValid ( ) [inline, virtual]

Definition at line 234 of file nsIMAPBodyShell.h.

{ return m_isValid; }

Here is the caller graph for this function:

Definition at line 326 of file nsIMAPBodyShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 134 of file nsIMAPBodyShell.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 264 of file nsIMAPBodyShell.h.

{ return m_UID; }

Here is the caller graph for this function:

Definition at line 267 of file nsIMAPBodyShell.h.

{ return m_isBeingGenerated; }     // Returns PR_TRUE if this is in the process of being

Here is the caller graph for this function:

Definition at line 269 of file nsIMAPBodyShell.h.

{ return m_cached; }

Here is the caller graph for this function:

Definition at line 227 of file nsIMAPBodyShell.cpp.

{
  PRBool rv = m_message->PreflightCheckAllInline(this);
  //   if (rv)
  //          PR_LOG(IMAP, out, ("BODYSHELL: All parts inline.  Reverting to whole message download."));
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 233 of file nsIMAPBodyShell.h.

{ m_protocolConnection = con; }    // To be used after a shell is uncached

Here is the caller graph for this function:

Definition at line 273 of file nsIMAPBodyShell.h.

{ m_contentModified = modType; }

Here is the caller graph for this function:

void nsIMAPBodyShell::SetIsCached ( PRBool  isCached) [inline]

Definition at line 270 of file nsIMAPBodyShell.h.

{ m_cached = isCached; }

Here is the caller graph for this function:

void nsIMAPBodyShell::SetIsValid ( PRBool  valid) [virtual]

Definition at line 126 of file nsIMAPBodyShell.cpp.

{
  //   if (!valid)
  //          PR_LOG(IMAP, out, ("BODYSHELL: Shell is invalid."));
  m_isValid = valid;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 289 of file nsIMAPBodyShell.h.

Definition at line 292 of file nsIMAPBodyShell.h.

char* nsIMAPBodyShell::m_folderName [protected]

Definition at line 284 of file nsIMAPBodyShell.h.

Definition at line 285 of file nsIMAPBodyShell.h.

Definition at line 290 of file nsIMAPBodyShell.h.

Definition at line 287 of file nsIMAPBodyShell.h.

Definition at line 286 of file nsIMAPBodyShell.h.

Definition at line 281 of file nsIMAPBodyShell.h.

Definition at line 277 of file nsIMAPBodyShell.h.

Definition at line 279 of file nsIMAPBodyShell.h.

Definition at line 282 of file nsIMAPBodyShell.h.

Definition at line 288 of file nsIMAPBodyShell.h.

Definition at line 283 of file nsIMAPBodyShell.h.


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