Bug 1354011 - Remove useless else blocks in order to reduce complexity in mailnews/imap/ (part 2). r=jorgk
authorSylvestre Ledru <sledru>
Thu, 06 Apr 2017 00:36:00 +0200
changeset 28481 fb6824894528f321f862f7d9eac98c95a53a2417
parent 28480 94c5ad3cebd6a183bb601698f16a2fb465236438
child 28482 f68f48676cfee64de8f8e2050cb10736fb3028ff
push id1986
push userclokep@gmail.com
push dateWed, 02 Aug 2017 14:43:31 +0000
treeherdercomm-beta@b51c9adf2c9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1354011
Bug 1354011 - Remove useless else blocks in order to reduce complexity in mailnews/imap/ (part 2). r=jorgk
mailnews/imap/src/nsIMAPBodyShell.cpp
--- a/mailnews/imap/src/nsIMAPBodyShell.cpp
+++ b/mailnews/imap/src/nsIMAPBodyShell.cpp
@@ -249,35 +249,31 @@ int32_t nsIMAPBodyShell::Generate(char *
       nsresult rv = 
         m_protocolConnection->BeginMessageDownLoad(contentLength, MESSAGE_RFC822);
       if (NS_FAILED(rv))
       {
         m_generatingPart = nullptr;
         m_protocolConnection->AbortMessageDownLoad();
         return 0;
       }
-      else
-      {
-        streamCreated = true;
-      }
+      streamCreated = true;
     }
-    
+
     ////// PASS 3 : GENERATE ///////
     // Generate the message
     if (!GetPseudoInterrupted() && !DeathSignalReceived())
       m_message->Generate(this, true, 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 = false;
   return contentLength;
 }
 
 bool nsIMAPBodyShell::GetPseudoInterrupted()
 {
@@ -395,17 +391,17 @@ void nsIMAPBodypart::QueuePrefetchMIMEHe
 
 int32_t nsIMAPBodypart::GenerateMIMEHeader(nsIMAPBodyShell *aShell, bool stream, bool prefetch)
 {
   if (prefetch && !m_headerData)
   {
     QueuePrefetchMIMEHeader(aShell);
     return 0;
   }
-  else if (m_headerData)
+  if (m_headerData)
   {
     int32_t 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)
@@ -424,49 +420,46 @@ int32_t nsIMAPBodypart::GenerateMIMEHead
     if (stream)
     {
       aShell->GetConnection()->Log("SHELL","GENERATE-MIMEHeader",m_partNumberString);
       aShell->GetConnection()->HandleMessageDownLoadLine(m_headerData, false);  // all one line?  Can we do that?
     }
     
     return mimeHeaderLength;
   }
-  else 
-  {
-    SetIsValid(false);	// prefetch didn't adopt a MIME header
-    return 0;
-  }
+
+  SetIsValid(false);	// prefetch didn't adopt a MIME header
+  return 0;
 }
 
 int32_t nsIMAPBodypart::GeneratePart(nsIMAPBodyShell *aShell, bool stream, bool prefetch)
 {
   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, false);
     }
     return PL_strlen(m_partData);
   }
-  else	// we are fetching and streaming this part's body as we go
+
+  // we are fetching and streaming this part's body as we go
+  if (stream && !aShell->DeathSignalReceived())
   {
-    if (stream && !aShell->DeathSignalReceived())
-    {
-      char *generatingPart = aShell->GetGeneratingPart();
-      bool fetchingSpecificPart = (generatingPart && !PL_strcmp(generatingPart, m_partNumberString));
-      
-      aShell->GetConnection()->Log("SHELL","GENERATE-Part-Inline",m_partNumberString);
-      aShell->GetConnection()->FetchTryChunking(aShell->GetUID(), kMIMEPart, true, m_partNumberString, m_partLength, !fetchingSpecificPart);
-    }
-    return m_partLength;	// the part length has been filled in from the BODYSTRUCTURE response
+    char *generatingPart = aShell->GetGeneratingPart();
+    bool fetchingSpecificPart = (generatingPart && !PL_strcmp(generatingPart, m_partNumberString));
+
+    aShell->GetConnection()->Log("SHELL","GENERATE-Part-Inline",m_partNumberString);
+    aShell->GetConnection()->FetchTryChunking(aShell->GetUID(), kMIMEPart, true, m_partNumberString, m_partLength, !fetchingSpecificPart);
   }
+  return m_partLength;	// the part length has been filled in from the BODYSTRUCTURE response
 }
 
 int32_t nsIMAPBodypart::GenerateBoundary(nsIMAPBodyShell *aShell, bool stream, bool prefetch, bool lastBoundary)
 {
   if (prefetch)
     return 0;	// don't need to prefetch anything
   
   if (m_boundaryData)
@@ -475,39 +468,34 @@ int32_t nsIMAPBodypart::GenerateBoundary
     {
       if (stream)
       {
         aShell->GetConnection()->Log("SHELL","GENERATE-Boundary",m_partNumberString);
         aShell->GetConnection()->HandleMessageDownLoadLine(m_boundaryData, false);
       }
       return PL_strlen(m_boundaryData);
     }
-    else	// the last boundary
+
+    // the last boundary
+    char *lastBoundaryData = PR_smprintf("%s--", m_boundaryData);
+    if (lastBoundaryData)
     {
-      char *lastBoundaryData = PR_smprintf("%s--", m_boundaryData);
-      if (lastBoundaryData)
+      if (stream)
       {
-        if (stream)
-        {
-          aShell->GetConnection()->Log("SHELL","GENERATE-Boundary-Last",m_partNumberString);
-          aShell->GetConnection()->HandleMessageDownLoadLine(lastBoundaryData, false);
-        }
-        int32_t rv = PL_strlen(lastBoundaryData);
-        PR_Free(lastBoundaryData);
-        return rv;
+        aShell->GetConnection()->Log("SHELL","GENERATE-Boundary-Last",m_partNumberString);
+        aShell->GetConnection()->HandleMessageDownLoadLine(lastBoundaryData, false);
       }
-      else
-      {
-        //HandleMemoryFailure();
-        return 0;
-      }
+      int32_t rv = PL_strlen(lastBoundaryData);
+      PR_Free(lastBoundaryData);
+      return rv;
     }
+    //HandleMemoryFailure();
+    return 0;
   }
-  else
-    return 0;
+  return 0;
 }
 
 int32_t nsIMAPBodypart::GenerateEmptyFilling(nsIMAPBodyShell *aShell, bool stream, bool prefetch)
 {
   if (prefetch)
     return 0; // don't need to prefetch anything
 
   const nsString &emptyString = aShell->GetConnection()->
@@ -518,40 +506,36 @@ int32_t nsIMAPBodypart::GenerateEmptyFil
     {
       nsImapProtocol *conn = aShell->GetConnection();
       conn->Log("SHELL", "GENERATE-Filling", m_partNumberString);
       conn->HandleMessageDownLoadLine(NS_ConvertUTF16toUTF8(emptyString).get(),
                                       false);
     }
     return emptyString.Length();
   }
-  else
-    return 0;
+  return 0;
 }
 
-
 // Returns true if the prefs say that this content type should
 // explicitly be kept in when filling in the shell
 bool nsIMAPBodypart::ShouldExplicitlyFetchInline()
 {
 	 return false;
 }
 
-
 // Returns true if the prefs say that this content type should
 // explicitly be left out when filling in the shell
 bool nsIMAPBodypart::ShouldExplicitlyNotFetchInline()
 {
   return false;
 }
 
 
 ///////////// nsIMAPBodypartLeaf /////////////////////////////
 
-
 nsIMAPBodypartLeaf::nsIMAPBodypartLeaf(char *partNum,
                                        nsIMAPBodypart *parentPart,
                                        char *bodyType, char *bodySubType,
                                        char *bodyID, char *bodyDescription,
                                        char *bodyEncoding, int32_t partLength,
                                        bool preferPlainText)
   : nsIMAPBodypart(partNum, parentPart), mPreferPlainText(preferPlainText)
 {
@@ -607,163 +591,151 @@ int32_t nsIMAPBodypartLeaf::Generate(nsI
         len += GenerateEmptyFilling(aShell, stream, prefetch);
       }
     }
   }
   m_contentLength = len;
   return m_contentLength;
 }
 
-
-
 // returns true if this part should be fetched inline for generation.
 bool nsIMAPBodypartLeaf::ShouldFetchInline(nsIMAPBodyShell *aShell)
 {
   char *generatingPart = aShell->GetGeneratingPart();
   if (generatingPart)
   {
     // If we are generating a specific part
     if (!PL_strcmp(generatingPart, m_partNumberString))
     {
       // This is the part we're generating
       return true;
     }
-    else
-    {
-      // If this is the only body part of a message, and that
-      // message is the part being generated, then this leaf should
-      // be inline as well.
-      if ((m_parentPart->GetType() == IMAP_BODY_MESSAGE_RFC822) &&
+
+    // If this is the only body part of a message, and that
+    // message is the part being generated, then this leaf should
+    // be inline as well.
+    if ((m_parentPart->GetType() == IMAP_BODY_MESSAGE_RFC822) &&
         (!PL_strcmp(m_parentPart->GetPartNumberString(), generatingPart)))
-        return true;
-      
-      // The parent of this part is a multipart
-      if (m_parentPart->GetType() == IMAP_BODY_MULTIPART)
-      {
-        // This is the first text part of a forwarded message
-        // with a multipart body, and that message is being generated,
-        // then generate this part.
-        nsIMAPBodypart *grandParent = m_parentPart->GetParentPart();
-        // grandParent must exist, since multiparts need parents
-        NS_ASSERTION(grandParent, "grandparent doesn't exist for multi-part alt");
-        if (grandParent && 
+      return true;
+
+    // The parent of this part is a multipart
+    if (m_parentPart->GetType() == IMAP_BODY_MULTIPART)
+    {
+      // This is the first text part of a forwarded message
+      // with a multipart body, and that message is being generated,
+      // then generate this part.
+      nsIMAPBodypart *grandParent = m_parentPart->GetParentPart();
+      // grandParent must exist, since multiparts need parents
+      NS_ASSERTION(grandParent, "grandparent doesn't exist for multi-part alt");
+      if (grandParent &&
           (grandParent->GetType() == IMAP_BODY_MESSAGE_RFC822) &&
           (!PL_strcmp(grandParent->GetPartNumberString(), generatingPart)) &&
           (m_partNumberString[PL_strlen(m_partNumberString)-1] == '1') &&
           !PL_strcasecmp(m_bodyType, "text"))
-          return true;	// we're downloading it inline
-        
-        
-        // This is a child of a multipart/appledouble attachment,
-        // and that multipart/appledouble attachment is being generated
-        if (m_parentPart &&
+        return true;	// we're downloading it inline
+
+      // This is a child of a multipart/appledouble attachment,
+      // and that multipart/appledouble attachment is being generated
+      if (m_parentPart &&
           !PL_strcasecmp(m_parentPart->GetBodySubType(), "appledouble") &&
           !PL_strcmp(m_parentPart->GetPartNumberString(), generatingPart))
-          return true;	// we're downloading it inline
+        return true;	// we're downloading it inline
       }
-      
-      // Leave out all other leaves if this isn't the one
-      // we're generating.
-      // Maybe change later to check parents, etc.
-      return false;
-    }
+
+    // Leave out all other leaves if this isn't the one
+    // we're generating.
+    // Maybe change later to check parents, etc.
+    return false;
   }
-  else
+
+  // We are generating the whole message, possibly (hopefully)
+  // leaving out non-inline parts
+  if (ShouldExplicitlyFetchInline())
+    return true;
+  if (ShouldExplicitlyNotFetchInline())
+    return false;
+
+  // If the parent is a message (this is the only body part of that
+  // message), and that message should be inline, then its body
+  // should inherit the inline characteristics of that message
+  if (m_parentPart->GetType() == IMAP_BODY_MESSAGE_RFC822)
+    return m_parentPart->ShouldFetchInline(aShell);
+
+  // View Attachments As Links is on.
+  if (!(aShell->GetContentModified() == IMAP_CONTENT_MODIFIED_VIEW_INLINE))
   {
-    // We are generating the whole message, possibly (hopefully)
-    // leaving out non-inline parts
-    
-    if (ShouldExplicitlyFetchInline())
+    // The last text part is still displayed inline,
+    // even if View Attachments As Links is on.
+    nsIMAPBodypart *grandParentPart = m_parentPart->GetParentPart();
+    if ((mPreferPlainText ||
+         !PL_strcasecmp(m_parentPart->GetBodySubType(), "mixed")) &&
+        !PL_strcmp(m_partNumberString, "1") &&
+        !PL_strcasecmp(m_bodyType, "text"))
+      return true;         // we're downloading it inline
+
+    if ((!PL_strcasecmp(m_parentPart->GetBodySubType(), "alternative") ||
+         (grandParentPart &&
+          !PL_strcasecmp(grandParentPart->GetBodySubType(), "alternative"))) &&
+        !PL_strcasecmp(m_bodyType, "text") &&
+        ((!PL_strcasecmp(m_bodySubType, "plain") && mPreferPlainText) ||
+         (!PL_strcasecmp(m_bodySubType, "html") && !mPreferPlainText)))
       return true;
-    if (ShouldExplicitlyNotFetchInline())
-      return false;
-    
-    // If the parent is a message (this is the only body part of that
-    // message), and that message should be inline, then its body
-    // should inherit the inline characteristics of that message
-    if (m_parentPart->GetType() == IMAP_BODY_MESSAGE_RFC822)
-      return m_parentPart->ShouldFetchInline(aShell);
-    
-    // View Attachments As Links is on.
-    if (!(aShell->GetContentModified() == IMAP_CONTENT_MODIFIED_VIEW_INLINE))
-    {
-      // The last text part is still displayed inline,
-      // even if View Attachments As Links is on.
-      nsIMAPBodypart *grandParentPart = m_parentPart->GetParentPart();
-      if ((mPreferPlainText ||
-           !PL_strcasecmp(m_parentPart->GetBodySubType(), "mixed")) &&
-          !PL_strcmp(m_partNumberString, "1") &&
-          !PL_strcasecmp(m_bodyType, "text"))
-        return true;         // we're downloading it inline
-
-      if ((!PL_strcasecmp(m_parentPart->GetBodySubType(), "alternative") ||
-           (grandParentPart &&
-            !PL_strcasecmp(grandParentPart->GetBodySubType(), "alternative"))) &&
-          !PL_strcasecmp(m_bodyType, "text") &&
-          ((!PL_strcasecmp(m_bodySubType, "plain") && mPreferPlainText) ||
-           (!PL_strcasecmp(m_bodySubType, "html") && !mPreferPlainText)))
-        return true;
 
-      // This is the first text part of a top-level multipart.
-      // For instance, a message with multipart body, where the first
-      // part is multipart, and this is the first leaf of that first part.
-      if (m_parentPart->GetType() == IMAP_BODY_MULTIPART &&
-          (PL_strlen(m_partNumberString) >= 2) &&
-          !PL_strcmp(m_partNumberString + PL_strlen(m_partNumberString) - 2, ".1") && // this is the first text type on this level
-          (!PL_strcmp(m_parentPart->GetPartNumberString(), "1") || !PL_strcmp(m_parentPart->GetPartNumberString(), "2")) && 
-          !PL_strcasecmp(m_bodyType, "text"))
-        return true;
-      // This is the first text part of a top-level multipart of the toplevelmessage
-      // This 'assumes' the text body is first leaf. This is not required for valid email.
-      // The only other way is to get content-disposition = attachment and exclude those text parts.
-      if (m_parentPart->GetType() == IMAP_BODY_MULTIPART &&
-          !PL_strcasecmp(m_bodyType, "text") &&
-          !PL_strcmp(m_parentPart->GetPartNumberString(), "0") &&
-          !PL_strcmp(m_partNumberString, "1"))
-         return true;
+    // This is the first text part of a top-level multipart.
+    // For instance, a message with multipart body, where the first
+    // part is multipart, and this is the first leaf of that first part.
+    if (m_parentPart->GetType() == IMAP_BODY_MULTIPART &&
+        (PL_strlen(m_partNumberString) >= 2) &&
+        !PL_strcmp(m_partNumberString + PL_strlen(m_partNumberString) - 2, ".1") && // this is the first text type on this level
+        (!PL_strcmp(m_parentPart->GetPartNumberString(), "1") || !PL_strcmp(m_parentPart->GetPartNumberString(), "2")) &&
+        !PL_strcasecmp(m_bodyType, "text"))
+      return true;
+    // This is the first text part of a top-level multipart of the toplevelmessage
+    // This 'assumes' the text body is first leaf. This is not required for valid email.
+    // The only other way is to get content-disposition = attachment and exclude those text parts.
+    if (m_parentPart->GetType() == IMAP_BODY_MULTIPART &&
+        !PL_strcasecmp(m_bodyType, "text") &&
+        !PL_strcmp(m_parentPart->GetPartNumberString(), "0") &&
+        !PL_strcmp(m_partNumberString, "1"))
+      return true;
 
-      // we may have future problems needing tests here
+    // we may have future problems needing tests here
 
-      return false;  // we can leave it on the server
-    }
+    return false;  // we can leave it on the server
+  }
 #ifdef XP_MACOSX
-    // If it is either applesingle, or a resource fork for appledouble
-    if (!PL_strcasecmp(m_contentType, "application/applefile"))
+  // If it is either applesingle, or a resource fork for appledouble
+  if (!PL_strcasecmp(m_contentType, "application/applefile"))
+  {
+    // if it is appledouble
+    if (m_parentPart->GetType() == IMAP_BODY_MULTIPART &&
+        !PL_strcasecmp(m_parentPart->GetBodySubType(), "appledouble"))
     {
-      // if it is appledouble
-      if (m_parentPart->GetType() == IMAP_BODY_MULTIPART &&
-        !PL_strcasecmp(m_parentPart->GetBodySubType(), "appledouble"))
-      {
-        // This is the resource fork of a multipart/appledouble.
-        // We inherit the inline attributes of the parent,
-        // which was derived from its OTHER child.  (The data fork.)
-        return m_parentPart->ShouldFetchInline(aShell);
-      }
-      else	// it is applesingle
-      {
-        return false;	// we can leave it on the server
-      }
+      // This is the resource fork of a multipart/appledouble.
+      // We inherit the inline attributes of the parent,
+      // which was derived from its OTHER child.  (The data fork.)
+      return m_parentPart->ShouldFetchInline(aShell);
     }
+    // it is applesingle
+    return false;	// we can leave it on the server
+  }
 #endif // XP_MACOSX
-    
-    // Leave out parts with type application/*
-    if (!PL_strcasecmp(m_bodyType, "APPLICATION") &&	// If it is of type "application"
+
+  // Leave out parts with type application/*
+  if (!PL_strcasecmp(m_bodyType, "APPLICATION") &&	// If it is of type "application"
       PL_strncasecmp(m_bodySubType, "x-pkcs7", 7)	// and it's not a signature (signatures are inline)
-      )
-      return false;	// we can leave it on the server
-    if (!PL_strcasecmp(m_bodyType, "AUDIO"))
-      return false;
-    // Here's where we can add some more intelligence -- let's leave out
-    // any other parts that we know we can't display inline.
-    return true;	// we're downloading it inline
-  }
+    )
+    return false;	// we can leave it on the server
+  if (!PL_strcasecmp(m_bodyType, "AUDIO"))
+    return false;
+  // Here's where we can add some more intelligence -- let's leave out
+  // any other parts that we know we can't display inline.
+  return true;	// we're downloading it inline
 }
 
-
-
 bool nsIMAPBodypartMultipart::IsLastTextPart(const char *partNumberString)
 {
  // 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->Length() - 1; i >= 0; i--)
   {
       nsIMAPBodypart *part = m_partList->ElementAt(i);
       if (!PL_strcasecmp(part->GetBodyType(), "text"))
@@ -867,47 +839,41 @@ int32_t nsIMAPBodypartMessage::Generate(
   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;
 }
 
-
-
-
 bool nsIMAPBodypartMessage::ShouldFetchInline(nsIMAPBodyShell *aShell)
 {
   if (m_topLevelMessage)	// the main message should always be defined as "inline"
     return 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 true;
   }
-  else
-  {
-    // Generating whole message
-    
-    if (ShouldExplicitlyFetchInline())
-      return true;
-    if (ShouldExplicitlyNotFetchInline())
-      return false;
-    
-    
-    // Message types are inline, by default.
+
+  // Generating whole message
+  if (ShouldExplicitlyFetchInline())
     return true;
-  }
+  if (ShouldExplicitlyNotFetchInline())
+    return false;
+
+  // Message types are inline, by default.
+  return true;
+
 }
 
 bool nsIMAPBodypartMessage::PreflightCheckAllInline(nsIMAPBodyShell *aShell)
 {
   if (!ShouldFetchInline(aShell))
     return false;
   
   return m_body->PreflightCheckAllInline(aShell);
@@ -937,17 +903,16 @@ nsIMAPBodypart *nsIMAPBodypartMessage::F
   if (!PL_strcasecmp(partNum, m_partNumberString))
     return this;
   
   return m_body->FindPartWithNumber(partNum);
 }
 
 ///////////// nsIMAPBodypartMultipart ////////////////////////
 
-
 nsIMAPBodypartMultipart::nsIMAPBodypartMultipart(char *partNum, nsIMAPBodypart *parentPart) : 
 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)
@@ -984,17 +949,16 @@ nsIMAPBodypartMultipart::SetBodySubType(
 {
   PR_FREEIF(m_bodySubType);
   PR_FREEIF(m_contentType);
   m_bodySubType = bodySubType;
   if (m_bodyType && m_bodySubType)
     m_contentType = PR_smprintf("%s/%s", m_bodyType, m_bodySubType);
 }
 
-
 int32_t nsIMAPBodypartMultipart::Generate(nsIMAPBodyShell *aShell, bool stream, bool prefetch)
 {
   int32_t len = 0;
   
   if (GetIsValid())
   {
     if (stream && !prefetch)
       aShell->GetConnection()->Log("SHELL","GENERATE-Multipart",m_partNumberString);
@@ -1029,62 +993,58 @@ int32_t nsIMAPBodypartMultipart::Generat
       if (!aShell->GetPseudoInterrupted())
         len += GenerateEmptyFilling(aShell, stream, prefetch);
     }
   }
   m_contentLength = len;
   return m_contentLength;
 }
 
-
 bool nsIMAPBodypartMultipart::ShouldFetchInline(nsIMAPBodyShell *aShell)
 {
   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 true;
   }
-  else
-  {
-    // Generating whole message
-    
-    if (ShouldExplicitlyFetchInline())
-      return true;
-    if (ShouldExplicitlyNotFetchInline())
-      return false;
 
-    if (!PL_strcasecmp(m_bodySubType, "alternative"))
-      return true;
+  // Generating whole message
+  if (ShouldExplicitlyFetchInline())
+    return true;
+  if (ShouldExplicitlyNotFetchInline())
+    return false;
 
-    nsIMAPBodypart *grandparentPart = m_parentPart->GetParentPart();
+  if (!PL_strcasecmp(m_bodySubType, "alternative"))
+    return true;
+
+  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 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 : true)
-      : true))
-      return false;
-    
-    // multiparts are always inline (even multipart/appledouble)
-    // (their children might not be, though)
+  // 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 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 : true)
+    : true))
+    return false;
+
+  // multiparts are always inline (even multipart/appledouble)
+  // (their children might not be, though)
+  return true;
 }
 
 bool nsIMAPBodypartMultipart::PreflightCheckAllInline(nsIMAPBodyShell *aShell)
 {
   bool rv = ShouldFetchInline(aShell);
   
   size_t i = 0;
   while (rv && (i < m_partList->Length()))
@@ -1112,21 +1072,18 @@ nsIMAPBodypart	*nsIMAPBodypartMultipart:
       return foundPart;
   }
   
   // not this, or any of this's children
   return NULL;
 }
 
 
-
 ///////////// nsIMAPMessageHeaders ////////////////////////////////////
 
-
-
 nsIMAPMessageHeaders::nsIMAPMessageHeaders(char *partNum, nsIMAPBodypart *parentPart) : 
 nsIMAPBodypart(partNum, parentPart)
 {
   if (!partNum)
   {
     SetIsValid(false);
     return;
   }
@@ -1300,17 +1257,16 @@ nsIMAPBodyShell *nsIMAPBodyShellCache::F
   m_shellList->RemoveElement(foundShell);
   m_shellList->AppendElement(foundShell);// Adds to end
 
   return foundShell;
 }
 
 ///////////// nsIMAPMessagePartID ////////////////////////////////////
 
-
 nsIMAPMessagePartID::nsIMAPMessagePartID(nsIMAPeFetchFields fields, const char *partNumberString)
 : m_partNumberString(partNumberString),
   m_fields(fields)
 {
 }
 
 nsIMAPMessagePartIDArray::nsIMAPMessagePartIDArray()
 {