Bug 1546364 - Reformat to Google coding style in mailnews/compose (part 1). rs=reformat
authorJorg K <jorgk@jorgk.com>
Fri, 10 May 2019 00:07:32 +0200
changeset 34458 979340ae8f89293f500436482bf22088deaa20ca
parent 34457 a2639232172060e4a9e5467ed6d7ea1e8a602a7a
child 34459 46fb17116c05ee14f6c5ccb440e77f2fff6f04f2
push id2407
push userclokep@gmail.com
push dateMon, 20 May 2019 17:11:26 +0000
treeherdercomm-beta@193428fd6fd4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersreformat
bugs1546364
Bug 1546364 - Reformat to Google coding style in mailnews/compose (part 1). rs=reformat # ignore-this-changeset
mailnews/compose/public/nsMsgAttachmentData.h
mailnews/compose/public/nsMsgCompCID.h
mailnews/compose/src/nsComposeStrings.cpp
mailnews/compose/src/nsComposeStrings.h
mailnews/compose/src/nsMsgAppleCodes.h
mailnews/compose/src/nsMsgAppleDouble.h
mailnews/compose/src/nsMsgAppleDoubleEncode.cpp
mailnews/compose/src/nsMsgAppleEncode.cpp
mailnews/compose/src/nsMsgAttachment.cpp
mailnews/compose/src/nsMsgAttachment.h
mailnews/compose/src/nsMsgAttachmentHandler.cpp
mailnews/compose/src/nsMsgAttachmentHandler.h
mailnews/compose/src/nsMsgCompFields.cpp
mailnews/compose/src/nsMsgCompFields.h
mailnews/compose/src/nsMsgCompUtils.cpp
mailnews/compose/src/nsMsgCompUtils.h
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgCompose.h
mailnews/compose/src/nsMsgComposeContentHandler.cpp
mailnews/compose/src/nsMsgComposeContentHandler.h
mailnews/compose/src/nsMsgComposeParams.cpp
mailnews/compose/src/nsMsgComposeParams.h
mailnews/compose/src/nsMsgComposeProgressParams.cpp
mailnews/compose/src/nsMsgComposeProgressParams.h
mailnews/compose/src/nsMsgComposeService.cpp
mailnews/compose/src/nsMsgComposeService.h
mailnews/compose/src/nsMsgCopy.cpp
mailnews/compose/src/nsMsgCopy.h
mailnews/compose/src/nsMsgPrompts.cpp
mailnews/compose/src/nsMsgPrompts.h
mailnews/compose/src/nsMsgQuote.cpp
mailnews/compose/src/nsMsgQuote.h
mailnews/compose/src/nsMsgSend.cpp
mailnews/compose/src/nsMsgSend.h
mailnews/compose/src/nsMsgSendLater.cpp
mailnews/compose/src/nsMsgSendLater.h
mailnews/compose/src/nsMsgSendPart.cpp
mailnews/compose/src/nsMsgSendPart.h
mailnews/compose/src/nsMsgSendReport.cpp
mailnews/compose/src/nsMsgSendReport.h
--- a/mailnews/compose/public/nsMsgAttachmentData.h
+++ b/mailnews/compose/public/nsMsgAttachmentData.h
@@ -6,110 +6,126 @@
 #ifndef __MSGATTACHMENTDATA_H__
 #define __MSGATTACHMENTDATA_H__
 
 #include "nsIURL.h"
 #include "nsString.h"
 #include "nsIMsgSend.h"
 
 // Attachment file/URL structures - we're letting libmime use this directly
-class nsMsgAttachmentData final : public nsIMsgAttachmentData
-{
-public:
+class nsMsgAttachmentData final : public nsIMsgAttachmentData {
+ public:
   NS_DECL_NSIMSGATTACHMENTDATA
   NS_DECL_ISUPPORTS
 
   nsMsgAttachmentData();
   virtual ~nsMsgAttachmentData();
 
-  nsCOMPtr<nsIURI> m_url;   // The URL to attach.
+  nsCOMPtr<nsIURI> m_url;  // The URL to attach.
 
   nsCString m_desiredType;  // The type to which this document should be
                             // converted.  Legal values are NULL, TEXT_PLAIN
                             // and APPLICATION_POSTSCRIPT (which are macros
                             // defined in net.h); other values are ignored.
 
-  nsCString m_realType;     // The type of the URL if known, otherwise NULL. For example, if
-                            // you were attaching a temp file which was known to contain HTML data,
-                            // you would pass in TEXT_HTML as the real_type, to override whatever type
-                            // the name of the tmp file might otherwise indicate.
+  nsCString
+      m_realType;  // The type of the URL if known, otherwise NULL. For example,
+                   // if you were attaching a temp file which was known to
+                   // contain HTML data, you would pass in TEXT_HTML as the
+                   // real_type, to override whatever type the name of the tmp
+                   // file might otherwise indicate.
 
-  nsCString m_realEncoding; // Goes along with real_type
+  nsCString m_realEncoding;  // Goes along with real_type
 
-  nsCString m_realName;     // The original name of this document, which will eventually show up in the
-                            // Content-Disposition header. For example, if you had copied a document to a
-                            // tmp file, this would be the original, human-readable name of the document.
+  nsCString
+      m_realName;  // The original name of this document, which will eventually
+                   // show up in the Content-Disposition header. For example, if
+                   // you had copied a document to a tmp file, this would be the
+                   // original, human-readable name of the document.
 
-  nsCString m_description;  // If you put a string here, it will show up as the Content-Description header.
-                            // This can be any explanatory text; it's not a file name.
+  nsCString m_description;  // If you put a string here, it will show up as the
+                            // Content-Description header. This can be any
+                            // explanatory text; it's not a file name.
 
-  nsCString m_disposition;  // The Content-Disposition header (if any). a
-                            // nsMsgAttachmentData can very well have
-                            // Content-Disposition: inline value, instead of
-                            // "attachment".
-  nsCString m_cloudPartInfo; // For X-Mozilla-Cloud-Part header, if any
+  nsCString m_disposition;    // The Content-Disposition header (if any). a
+                              // nsMsgAttachmentData can very well have
+                              // Content-Disposition: inline value, instead of
+                              // "attachment".
+  nsCString m_cloudPartInfo;  // For X-Mozilla-Cloud-Part header, if any
 
   // Mac-specific data that should show up as optional parameters
   // to the content-type header.
   nsCString m_xMacType;
   nsCString m_xMacCreator;
 
-  int32_t m_size;                  // The size of the attachment. May be 0.
-  nsCString m_sizeExternalStr;     // The reported size of an external attachment. Originally set at "-1" to mean an unknown value.
-  bool    m_isExternalAttachment;  // Flag for determining if the attachment is external
-  bool    m_isExternalLinkAttachment;  // Flag for determining if the attachment is external and an http link.
-  bool    m_isDownloaded;          // Flag for determining if the attachment has already been downloaded
-  bool    m_hasFilename;           // Tells whether the name is provided by us or if it's a Part 1.2-like attachment
-  bool    m_displayableInline;     // Tells whether the attachment could be displayed inline
+  int32_t m_size;  // The size of the attachment. May be 0.
+  nsCString
+      m_sizeExternalStr;  // The reported size of an external attachment.
+                          // Originally set at "-1" to mean an unknown value.
+  bool m_isExternalAttachment;      // Flag for determining if the attachment is
+                                    // external
+  bool m_isExternalLinkAttachment;  // Flag for determining if the attachment is
+                                    // external and an http link.
+  bool m_isDownloaded;  // Flag for determining if the attachment has already
+                        // been downloaded
+  bool m_hasFilename;   // Tells whether the name is provided by us or if it's a
+                        // Part 1.2-like attachment
+  bool m_displayableInline;  // Tells whether the attachment could be displayed
+                             // inline
 };
 
-class nsMsgAttachedFile final : public nsIMsgAttachedFile
-{
-public:
+class nsMsgAttachedFile final : public nsIMsgAttachedFile {
+ public:
   NS_DECL_NSIMSGATTACHEDFILE
   NS_DECL_ISUPPORTS
 
   nsMsgAttachedFile();
   virtual ~nsMsgAttachedFile();
 
-  nsCOMPtr<nsIURI> m_origUrl; // Where it came from on the network (or even elsewhere on the local disk.)
+  nsCOMPtr<nsIURI> m_origUrl;  // Where it came from on the network (or even
+                               // elsewhere on the local disk.)
 
-  nsCOMPtr<nsIFile>  m_tmpFile;    // The tmp file in which the (possibly converted) data now resides.
+  nsCOMPtr<nsIFile> m_tmpFile;  // The tmp file in which the (possibly
+                                // converted) data now resides.
 
-  nsCString m_type;        // The type of the data in file_name (not necessarily the same as the type of orig_url.)
+  nsCString m_type;  // The type of the data in file_name (not necessarily the
+                     // same as the type of orig_url.)
 
-  nsCString m_encoding;    // Likewise, the encoding of the tmp file. This will be set only if the original
-                            // document had an encoding already; we don't do base64 encoding and so forth until
-                            // it's time to assemble a full MIME message of all parts.
-
+  nsCString
+      m_encoding;  // Likewise, the encoding of the tmp file. This will be set
+                   // only if the original document had an encoding already; we
+                   // don't do base64 encoding and so forth until it's time to
+                   // assemble a full MIME message of all parts.
 
   nsCString m_description;    // For Content-Description header
-  nsCString m_cloudPartInfo; // For X-Mozilla-Cloud-Part header, if any
-  nsCString m_xMacType;    // mac-specific info
-  nsCString m_xMacCreator; // mac-specific info
-  nsCString m_realName;      // The real name of the file.
+  nsCString m_cloudPartInfo;  // For X-Mozilla-Cloud-Part header, if any
+  nsCString m_xMacType;       // mac-specific info
+  nsCString m_xMacCreator;    // mac-specific info
+  nsCString m_realName;       // The real name of the file.
 
   // Some statistics about the data that was written to the file, so that when
   // it comes time to compose a MIME message, we can make an informed decision
   // about what Content-Transfer-Encoding would be best for this attachment.
   // (If it's encoded already, we ignore this information and ship it as-is.)
-  uint32_t    m_size;
-  uint32_t    m_unprintableCount;
-  uint32_t    m_highbitCount;
-  uint32_t    m_ctlCount;
-  uint32_t    m_nullCount;
-  uint32_t    m_maxLineLength;
+  uint32_t m_size;
+  uint32_t m_unprintableCount;
+  uint32_t m_highbitCount;
+  uint32_t m_ctlCount;
+  uint32_t m_nullCount;
+  uint32_t m_maxLineLength;
 };
 
 #undef MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING
 #ifdef MOZ_IS_DESTRUCTIBLE
-#define MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(X) \
-  static_assert(!MOZ_IS_DESTRUCTIBLE(X) || \
-                mozilla::IsSame<X, nsMsgAttachmentData>::value || \
-                mozilla::IsSame<X, nsMsgAttachedFile>::value, \
-                "Reference-counted class " #X " should not have a public destructor. " \
-                "Try to make this class's destructor non-public. If that is really " \
-                "not possible, you can whitelist this class by providing a " \
-                "HasDangerousPublicDestructor specialization for it.");
+#  define MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(X)                              \
+    static_assert(                                                           \
+        !MOZ_IS_DESTRUCTIBLE(X) ||                                           \
+            mozilla::IsSame<X, nsMsgAttachmentData>::value ||                \
+            mozilla::IsSame<X, nsMsgAttachedFile>::value,                    \
+        "Reference-counted class " #X                                        \
+        " should not have a public destructor. "                             \
+        "Try to make this class's destructor non-public. If that is really " \
+        "not possible, you can whitelist this class by providing a "         \
+        "HasDangerousPublicDestructor specialization for it.");
 #else
-#define MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(X)
+#  define MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(X)
 #endif
 #endif
--- a/mailnews/compose/public/nsMsgCompCID.h
+++ b/mailnews/compose/public/nsMsgCompCID.h
@@ -8,240 +8,269 @@
 
 #include "nsISupports.h"
 #include "nsIFactory.h"
 #include "nsIComponentManager.h"
 
 //
 // nsMsgComposeService
 //
-#define NS_MSGCOMPOSESERVICE_CID          \
-{ /* 588595FE-1ADA-11d3-A715-0060B0EB39B5 */      \
- 0x588595fe, 0x1ada, 0x11d3,                      \
- {0xa7, 0x15, 0x0, 0x60, 0xb0, 0xeb, 0x39, 0xb5}}
+#define NS_MSGCOMPOSESERVICE_CID                    \
+  { /* 588595FE-1ADA-11d3-A715-0060B0EB39B5 */      \
+    0x588595fe, 0x1ada, 0x11d3, {                   \
+      0xa7, 0x15, 0x0, 0x60, 0xb0, 0xeb, 0x39, 0xb5 \
+    }                                               \
+  }
 
-#define NS_MSGCOMPOSESERVICE_CONTRACTID     \
-  "@mozilla.org/messengercompose;1"
+#define NS_MSGCOMPOSESERVICE_CONTRACTID "@mozilla.org/messengercompose;1"
 #define NS_MSGCOMPOSESTARTUPHANDLER_CONTRACTID \
   "@mozilla.org/commandlinehandler/general-startup;1?type=compose"
 
 //
 // nsMsgComposeContentHandler
 //
-#define NS_MSGCOMPOSECONTENTHANDLER_CID         \
-{ /* 0B63FB80-BBBA-11D4-9DAA-91B657EB313C */    \
-0x0b63fb80, 0xbbba, 0x11d4,                     \
- {0x9d, 0xaa, 0x91, 0xb6, 0x57, 0xeb, 0x31, 0x3c}}
+#define NS_MSGCOMPOSECONTENTHANDLER_CID              \
+  { /* 0B63FB80-BBBA-11D4-9DAA-91B657EB313C */       \
+    0x0b63fb80, 0xbbba, 0x11d4, {                    \
+      0x9d, 0xaa, 0x91, 0xb6, 0x57, 0xeb, 0x31, 0x3c \
+    }                                                \
+  }
 
-#define NS_MSGCOMPOSECONTENTHANDLER_CONTRACTID  \
-  NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/x-mailto"
+#define NS_MSGCOMPOSECONTENTHANDLER_CONTRACTID \
+  NS_CONTENT_HANDLER_CONTRACTID_PREFIX "application/x-mailto"
 
 //
 // nsMsgCompose
 //
-#define NS_MSGCOMPOSE_CONTRACTID \
-  "@mozilla.org/messengercompose/compose;1"
+#define NS_MSGCOMPOSE_CONTRACTID "@mozilla.org/messengercompose/compose;1"
 
-#define NS_MSGCOMPOSE_CID             \
-{ /* EB5BDAF8-BBC6-11d2-A6EC-0060B0EB39B5 */      \
- 0xeb5bdaf8, 0xbbc6, 0x11d2,                      \
- {0xa6, 0xec, 0x0, 0x60, 0xb0, 0xeb, 0x39, 0xb5}}
+#define NS_MSGCOMPOSE_CID                           \
+  { /* EB5BDAF8-BBC6-11d2-A6EC-0060B0EB39B5 */      \
+    0xeb5bdaf8, 0xbbc6, 0x11d2, {                   \
+      0xa6, 0xec, 0x0, 0x60, 0xb0, 0xeb, 0x39, 0xb5 \
+    }                                               \
+  }
 
 //
 // nsMsgComposeSecure
 //
 #define NS_MSGCOMPOSESECURE_CONTRACTID \
   "@mozilla.org/messengercompose/composesecure;1"
 
 //
 // nsMsgComposeParams
 //
 #define NS_MSGCOMPOSEPARAMS_CONTRACTID \
   "@mozilla.org/messengercompose/composeparams;1"
 
-#define NS_MSGCOMPOSEPARAMS_CID             \
-{ /* CB998A00-C079-11D4-9DAA-8DF64BAB2EFC */      \
- 0xcb998a00, 0xc079, 0x11d4,                      \
- {0x9d, 0xaa, 0x8d, 0xf6, 0x4b, 0xab, 0x2e, 0xfc}}
+#define NS_MSGCOMPOSEPARAMS_CID                      \
+  { /* CB998A00-C079-11D4-9DAA-8DF64BAB2EFC */       \
+    0xcb998a00, 0xc079, 0x11d4, {                    \
+      0x9d, 0xaa, 0x8d, 0xf6, 0x4b, 0xab, 0x2e, 0xfc \
+    }                                                \
+  }
 
 //
 // nsMsgComposeSendListener
 //
 #define NS_MSGCOMPOSESENDLISTENER_CONTRACTID \
   "@mozilla.org/messengercompose/composesendlistener;1"
 
-#define NS_MSGCOMPOSESENDLISTENER_CID             \
-{ /* acc72781-2cea-11d5-9daa-bacdeac1eefc */      \
- 0xacc72781, 0x2cea, 0x11d5,                      \
- {0x9d, 0xaa, 0xba, 0xcd, 0xea, 0xc1, 0xee, 0xfc}}
+#define NS_MSGCOMPOSESENDLISTENER_CID                \
+  { /* acc72781-2cea-11d5-9daa-bacdeac1eefc */       \
+    0xacc72781, 0x2cea, 0x11d5, {                    \
+      0x9d, 0xaa, 0xba, 0xcd, 0xea, 0xc1, 0xee, 0xfc \
+    }                                                \
+  }
 
 //
 // nsMsgComposeProgressParams
 //
 #define NS_MSGCOMPOSEPROGRESSPARAMS_CONTRACTID \
   "@mozilla.org/messengercompose/composeprogressparameters;1"
 
-#define NS_MSGCOMPOSEPROGRESSPARAMS_CID             \
-{ /* 1e0e7c01-3e4c-11d5-9daa-f88d288130fc */      \
- 0x1e0e7c01, 0x3e4c, 0x11d5,                      \
- {0x9d, 0xaa, 0xf8, 0x8d, 0x28, 0x81, 0x30, 0xfc}}
+#define NS_MSGCOMPOSEPROGRESSPARAMS_CID              \
+  { /* 1e0e7c01-3e4c-11d5-9daa-f88d288130fc */       \
+    0x1e0e7c01, 0x3e4c, 0x11d5, {                    \
+      0x9d, 0xaa, 0xf8, 0x8d, 0x28, 0x81, 0x30, 0xfc \
+    }                                                \
+  }
 
 //
 // nsMsgCompFields
 //
 #define NS_MSGCOMPFIELDS_CONTRACTID \
   "@mozilla.org/messengercompose/composefields;1"
 
-#define NS_MSGCOMPFIELDS_CID                    \
-{ /* e64b0f51-0d7b-4e2f-8c60-3862ee8c174f */      \
- 0xe64b0f51, 0x0d7b, 0x4e2f,                      \
- {0x8c, 0x60, 0x38, 0x62, 0xee, 0x8c, 0x17, 0x4f}}
+#define NS_MSGCOMPFIELDS_CID                         \
+  { /* e64b0f51-0d7b-4e2f-8c60-3862ee8c174f */       \
+    0xe64b0f51, 0x0d7b, 0x4e2f, {                    \
+      0x8c, 0x60, 0x38, 0x62, 0xee, 0x8c, 0x17, 0x4f \
+    }                                                \
+  }
 
 //
 // nsMsgAttachment
 //
-#define NS_MSGATTACHMENT_CONTRACTID \
-  "@mozilla.org/messengercompose/attachment;1"
+#define NS_MSGATTACHMENT_CONTRACTID "@mozilla.org/messengercompose/attachment;1"
 
-#define NS_MSGATTACHMENT_CID                    \
-{ /* 27B8D045-8D9F-4fa8-BFB6-8A0F8D09CE89 */    \
- 0x27b8d045, 0x8d9f, 0x4fa8,                    \
- {0xbf, 0xb6, 0x8a, 0xf, 0x8d, 0x9, 0xce, 0x89}}
+#define NS_MSGATTACHMENT_CID                       \
+  { /* 27B8D045-8D9F-4fa8-BFB6-8A0F8D09CE89 */     \
+    0x27b8d045, 0x8d9f, 0x4fa8, {                  \
+      0xbf, 0xb6, 0x8a, 0xf, 0x8d, 0x9, 0xce, 0x89 \
+    }                                              \
+  }
 
 //
 // nsMsgAttachmentData
 //
 #define NS_MSGATTACHMENTDATA_CONTRACTID \
   "@mozilla.org/messengercompose/attachmentdata;1"
 
-#define NS_MSGATTACHMENTDATA_CID                    \
-{ /* 9e16958d-d9e9-4cae-b723-a5bccf104998 */ \
- 0x9e16958d, 0xd9e9, 0x4cae, \
- {0xb7, 0x23, 0xa5, 0xbc, 0xcf, 0x10, 0x49, 0x98}}
+#define NS_MSGATTACHMENTDATA_CID                     \
+  { /* 9e16958d-d9e9-4cae-b723-a5bccf104998 */       \
+    0x9e16958d, 0xd9e9, 0x4cae, {                    \
+      0xb7, 0x23, 0xa5, 0xbc, 0xcf, 0x10, 0x49, 0x98 \
+    }                                                \
+  }
 
 //
 // nsMsgAttachedFile
 //
 #define NS_MSGATTACHEDFILE_CONTRACTID \
   "@mozilla.org/messengercompose/attachedfile;1"
 
-#define NS_MSGATTACHEDFILE_CID                    \
-{ /* ef173501-4e14-42b9-ae1f-7770de235c29 */ \
- 0xef173501, 0x4e14, 0x42b9, \
- {0xae, 0x1f, 0x77, 0x70, 0xde, 0x23, 0x5c, 0x29}}
+#define NS_MSGATTACHEDFILE_CID                       \
+  { /* ef173501-4e14-42b9-ae1f-7770de235c29 */       \
+    0xef173501, 0x4e14, 0x42b9, {                    \
+      0xae, 0x1f, 0x77, 0x70, 0xde, 0x23, 0x5c, 0x29 \
+    }                                                \
+  }
 
 //
 // nsMsgSend
 //
-#define NS_MSGSEND_CONTRACTID \
-  "@mozilla.org/messengercompose/send;1"
+#define NS_MSGSEND_CONTRACTID "@mozilla.org/messengercompose/send;1"
 
-#define NS_MSGSEND_CID                \
-{ /* 935284E0-C5D8-11d2-8297-000000000000 */      \
- 0x935284e0, 0xc5d8, 0x11d2,                      \
- {0x82, 0x97, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
+#define NS_MSGSEND_CID                                                       \
+  { /* 935284E0-C5D8-11d2-8297-000000000000 */                               \
+    0x935284e0, 0xc5d8, 0x11d2, { 0x82, 0x97, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } \
+  }
 
 //
 // nsMsgSendLater
 //
-#define NS_MSGSENDLATER_CONTRACTID                            \
-  "@mozilla.org/messengercompose/sendlater;1"
+#define NS_MSGSENDLATER_CONTRACTID "@mozilla.org/messengercompose/sendlater;1"
 
-#define NS_MSGSENDLATER_CID                           \
-{ /* E15C83F1-1CF4-11d3-8EF0-00A024A7D144 */      \
- 0xe15c83f1, 0x1cf4, 0x11d3,                      \
- {0x8e, 0xf0, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 }}
+#define NS_MSGSENDLATER_CID                         \
+  { /* E15C83F1-1CF4-11d3-8EF0-00A024A7D144 */      \
+    0xe15c83f1, 0x1cf4, 0x11d3, {                   \
+      0x8e, 0xf0, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 \
+    }                                               \
+  }
 
 //
 // nsSmtpUrl
 //
-#define NS_SMTPURL_CONTRACTID \
-  "@mozilla.org/messengercompose/smtpurl;1"
+#define NS_SMTPURL_CONTRACTID "@mozilla.org/messengercompose/smtpurl;1"
 
-#define NS_SMTPURL_CID                            \
-{ /* BE59DBF0-2812-11d3-80A3-006008128C4E} */      \
- 0xbe59dbf0, 0x2812, 0x11d3,                      \
- {0x80, 0xa3, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e}}
+#define NS_SMTPURL_CID                             \
+  { /* BE59DBF0-2812-11d3-80A3-006008128C4E} */    \
+    0xbe59dbf0, 0x2812, 0x11d3, {                  \
+      0x80, 0xa3, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e \
+    }                                              \
+  }
 
 //
 // nsMailtoUrl
 //
-#define NS_MAILTOURL_CONTRACTID \
-  "@mozilla.org/messengercompose/mailtourl;1"
+#define NS_MAILTOURL_CONTRACTID "@mozilla.org/messengercompose/mailtourl;1"
 
-#define NS_MAILTOURL_CID                            \
-{ /* 05BAB5E7-9C7D-11d3-98A3-001083010E9B} */       \
- 0x5bab5e7, 0x9c7d, 0x11d3,                         \
- {0x98, 0xa3, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b}}
+#define NS_MAILTOURL_CID                                                       \
+  { /* 05BAB5E7-9C7D-11d3-98A3-001083010E9B} */                                \
+    0x5bab5e7, 0x9c7d, 0x11d3, { 0x98, 0xa3, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } \
+  }
 
 //
 // nsSmtpServer
 //
-#define NS_SMTPSERVER_CONTRACTID \
-  "@mozilla.org/messenger/smtp/server;1"
+#define NS_SMTPSERVER_CONTRACTID "@mozilla.org/messenger/smtp/server;1"
 
-#define NS_SMTPSERVER_CID                      \
-{ /* 60dc861a-56ce-11d3-9118-00a0c900d445 */   \
-  0x60dc861a,0x56ce,0x11d3,                   \
-  {0x91,0x18, 0x0, 0xa0, 0xc9, 0x0, 0xd4, 0x45 }}
+#define NS_SMTPSERVER_CID                          \
+  { /* 60dc861a-56ce-11d3-9118-00a0c900d445 */     \
+    0x60dc861a, 0x56ce, 0x11d3, {                  \
+      0x91, 0x18, 0x0, 0xa0, 0xc9, 0x0, 0xd4, 0x45 \
+    }                                              \
+  }
 
 //
 // nsSmtpService
 //
-#define NS_SMTPSERVICE_CONTRACTID \
-  "@mozilla.org/messengercompose/smtp;1"
+#define NS_SMTPSERVICE_CONTRACTID "@mozilla.org/messengercompose/smtp;1"
 
 #define NS_MAILTOHANDLER_CONTRACTID \
   NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "mailto"
 
-#define NS_SMTPSERVICE_CID              \
-{ /* 5B6419F1-CA9B-11d2-8063-006008128C4E */      \
- 0x5b6419f1, 0xca9b, 0x11d2,                      \
- {0x80, 0x63, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e}}
+#define NS_SMTPSERVICE_CID                         \
+  { /* 5B6419F1-CA9B-11d2-8063-006008128C4E */     \
+    0x5b6419f1, 0xca9b, 0x11d2, {                  \
+      0x80, 0x63, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e \
+    }                                              \
+  }
 
 //
 // nsMsgQuote
 //
-#define NS_MSGQUOTE_CONTRACTID \
-  "@mozilla.org/messengercompose/quoting;1"
-#define NS_MSGQUOTE_CID \
-  {0x1C7ABF0C, 0x21E5, 0x11d3, \
-    { 0x8E, 0xF1, 0x00, 0xA0, 0x24, 0xA7, 0xD1, 0x44 }}
+#define NS_MSGQUOTE_CONTRACTID "@mozilla.org/messengercompose/quoting;1"
+#define NS_MSGQUOTE_CID                              \
+  {                                                  \
+    0x1C7ABF0C, 0x21E5, 0x11d3, {                    \
+      0x8E, 0xF1, 0x00, 0xA0, 0x24, 0xA7, 0xD1, 0x44 \
+    }                                                \
+  }
 
 #define NS_MSGQUOTELISTENER_CONTRACTID \
   "@mozilla.org/messengercompose/quotinglistener;1"
-#define NS_MSGQUOTELISTENER_CID \
-  {0x683728ac, 0x88df, 0x11d3, \
-    { 0x98, 0x9d, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b }}
+#define NS_MSGQUOTELISTENER_CID                   \
+  {                                               \
+    0x683728ac, 0x88df, 0x11d3, {                 \
+      0x98, 0x9d, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b \
+    }                                             \
+  }
 
 //
 // nsMsgDraft
 //
-#define NS_MSGDRAFT_CONTRACTID \
-  "@mozilla.org/messengercompose/drafts;1"
-#define NS_MSGDRAFT_CID \
-  { 0xa623746c, 0x453b, 0x11d3, \
-  { 0x8f, 0xf, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
+#define NS_MSGDRAFT_CONTRACTID "@mozilla.org/messengercompose/drafts;1"
+#define NS_MSGDRAFT_CID                            \
+  {                                                \
+    0xa623746c, 0x453b, 0x11d3, {                  \
+      0x8f, 0xf, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 \
+    }                                              \
+  }
 
 //
 // nsURLFetcher
 //
-#define NS_URLFETCHER_CONTRACTID  \
-  "@mozilla.org/messengercompose/urlfetcher;1"
+#define NS_URLFETCHER_CONTRACTID "@mozilla.org/messengercompose/urlfetcher;1"
 
 // {01B8A701-2F52-11D5-9DAA-F78DA781A1FC}
-#define NS_URLFETCHER_CID \
-{ 0x01b8a701, 0x2f52, 0x11d5, \
- { 0x9d, 0xaa, 0xf7, 0x8d, 0xa7, 0x81, 0xa1, 0xfc } }
+#define NS_URLFETCHER_CID                            \
+  {                                                  \
+    0x01b8a701, 0x2f52, 0x11d5, {                    \
+      0x9d, 0xaa, 0xf7, 0x8d, 0xa7, 0x81, 0xa1, 0xfc \
+    }                                                \
+  }
 
 //
 // nsMsgCompUtils
 //
-#define NS_MSGCOMPUTILS_CONTRACTID  \
-  "@mozilla.org/messengercompose/computils;1"
+#define NS_MSGCOMPUTILS_CONTRACTID "@mozilla.org/messengercompose/computils;1"
 
 // {ceb0dca2-5e7d-4204-94d4-2ab925921fae}
-#define NS_MSGCOMPUTILS_CID \
-{ 0xceb0dca2, 0x5e7d, 0x4204, \
-  { 0x94, 0xd4, 0x2a, 0xb9, 0x25, 0x92, 0x1f, 0xae } }
+#define NS_MSGCOMPUTILS_CID                          \
+  {                                                  \
+    0xceb0dca2, 0x5e7d, 0x4204, {                    \
+      0x94, 0xd4, 0x2a, 0xb9, 0x25, 0x92, 0x1f, 0xae \
+    }                                                \
+  }
 
-
-#endif // nsMessageCompCID_h__
+#endif  // nsMessageCompCID_h__
--- a/mailnews/compose/src/nsComposeStrings.cpp
+++ b/mailnews/compose/src/nsComposeStrings.cpp
@@ -1,23 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsComposeStrings.h"
 
-const char* errorStringNameForErrorCode(nsresult aCode)
-{
+const char* errorStringNameForErrorCode(nsresult aCode) {
 #ifdef __GNUC__
 // Temporary workaround until bug 783526 is fixed.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wswitch"
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wswitch"
 #endif
-  switch(aCode)
-  {
+  switch (aCode) {
     case NS_MSG_UNABLE_TO_OPEN_FILE:
       return "unableToOpenFile";
     case NS_MSG_UNABLE_TO_OPEN_TMP_FILE:
       return "unableToOpenTmpFile";
     case NS_MSG_UNABLE_TO_SAVE_TEMPLATE:
       return "unableToSaveTemplate";
     case NS_MSG_UNABLE_TO_SAVE_DRAFT:
       return "unableToSaveDraft";
@@ -100,11 +98,11 @@ const char* errorStringNameForErrorCode(
     case NS_ERROR_CLIENTID:
       return "smtpClientid";
     case NS_ERROR_CLIENTID_PERMISSION:
       return "smtpClientidPermission";
     default:
       return "sendFailed";
   }
 #ifdef __GNUC__
-#pragma GCC diagnostic pop
+#  pragma GCC diagnostic pop
 #endif
 }
--- a/mailnews/compose/src/nsComposeStrings.h
+++ b/mailnews/compose/src/nsComposeStrings.h
@@ -1,12 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+// clang-format off
 /**
   String Ids used by mailnews\compose
   To Do: Convert the callers to use names instead of ids and then make this file obsolete.
  */
 
 #ifndef _nsComposeStrings_H__
 #define _nsComposeStrings_H__
 
@@ -67,8 +68,10 @@
 #define NS_ERROR_ILLEGAL_LOCALPART                  NS_MSG_GENERATE_FAILURE(12601)
 
 #define NS_ERROR_CLIENTID                           NS_MSG_GENERATE_FAILURE(12610)
 #define NS_ERROR_CLIENTID_PERMISSION                NS_MSG_GENERATE_FAILURE(12611)
 
 const char* errorStringNameForErrorCode(nsresult aCode);
 
 #endif /* _nsComposeStrings_H__ */
+
+// clang-format on
--- a/mailnews/compose/src/nsMsgAppleCodes.h
+++ b/mailnews/compose/src/nsMsgAppleCodes.h
@@ -16,91 +16,94 @@
 
 #ifndef ad_codes_h
 #define ad_codes_h
 
 /*
 ** applefile definitions used
 */
 #if PRAGMA_STRUCT_ALIGN
-  #pragma options align=mac68k
+#  pragma options align = mac68k
 #endif
 
 #define APPLESINGLE_MAGIC 0x00051600L
 #define APPLEDOUBLE_MAGIC 0x00051607L
 #define APPLEDOUBLE_VERSION 0x00020000
 
-#define NUM_ENTRIES  6
+#define NUM_ENTRIES 6
 
-#define ENT_DFORK    1L
-#define ENT_RFORK    2L
-#define ENT_NAME     3L
-#define ENT_COMMENT  4L
-#define ENT_DATES    8L
-#define ENT_FINFO    9L
+#define ENT_DFORK 1L
+#define ENT_RFORK 2L
+#define ENT_NAME 3L
+#define ENT_COMMENT 4L
+#define ENT_DATES 8L
+#define ENT_FINFO 9L
 #define CONVERT_TIME 1265437696L
 
 /*
 ** data type used in the encoder/decoder.
 */
-typedef struct ap_header
-{
-  int32_t   magic;
-  int32_t   version;
-  char      fill[16];
-  int16_t   entries;
+typedef struct ap_header {
+  int32_t magic;
+  int32_t version;
+  char fill[16];
+  int16_t entries;
 
 } ap_header;
 
-typedef struct ap_entry
-{
-  int32_t  id;
-  int32_t  offset;
-  int32_t  length;
+typedef struct ap_entry {
+  int32_t id;
+  int32_t offset;
+  int32_t length;
 
 } ap_entry;
 
-typedef struct ap_dates
-{
+typedef struct ap_dates {
   int32_t create, modify, backup, access;
 
 } ap_dates;
 
-typedef struct myFInfo      /* the mac FInfo structure for the cross platform. */
+typedef struct myFInfo /* the mac FInfo structure for the cross platform. */
 {
-  int32_t  fdType, fdCreator;
-  int16_t  fdFlags;
-  int32_t  fdLocation;      /* it really should  be a pointer, but just a place-holder  */
-  int16_t  fdFldr;
+  int32_t fdType, fdCreator;
+  int16_t fdFlags;
+  int32_t
+      fdLocation; /* it really should  be a pointer, but just a place-holder  */
+  int16_t fdFldr;
 
-}  myFInfo;
+} myFInfo;
 
 PR_BEGIN_EXTERN_C
 /*
 **  string utils.
 */
-int write_stream(appledouble_encode_object *p_ap_encode_obj, const char *s,int len);
+int write_stream(appledouble_encode_object* p_ap_encode_obj, const char* s,
+                 int len);
 
-int fill_apple_mime_header(appledouble_encode_object *p_ap_encode_obj);
-int ap_encode_file_infor(appledouble_encode_object *p_ap_encode_obj);
-int ap_encode_header(appledouble_encode_object* p_ap_encode_obj, bool firstTime);
+int fill_apple_mime_header(appledouble_encode_object* p_ap_encode_obj);
+int ap_encode_file_infor(appledouble_encode_object* p_ap_encode_obj);
+int ap_encode_header(appledouble_encode_object* p_ap_encode_obj,
+                     bool firstTime);
 int ap_encode_data(appledouble_encode_object* p_ap_encode_obj, bool firstTime);
 
 /*
 **  the prototypes for the ap_decoder.
 */
-int  fetch_a_line(appledouble_decode_object* p_ap_decode_obj, char *buff);
-int  ParseFileHeader(appledouble_decode_object* p_ap_decode_obj);
-int  ap_seek_part_start(appledouble_decode_object* p_ap_decode_obj);
-void parse_param(char *p, char **param, char**define, char **np);
-int  ap_seek_to_boundary(appledouble_decode_object* p_ap_decode_obj, bool firstime);
-int  ap_parse_header(appledouble_decode_object* p_ap_decode_obj,bool firstime);
-int  ap_decode_file_infor(appledouble_decode_object* p_ap_decode_obj);
-int  ap_decode_process_header(appledouble_decode_object* p_ap_decode_obj, bool firstime);
-int  ap_decode_process_data(  appledouble_decode_object* p_ap_decode_obj, bool firstime);
+int fetch_a_line(appledouble_decode_object* p_ap_decode_obj, char* buff);
+int ParseFileHeader(appledouble_decode_object* p_ap_decode_obj);
+int ap_seek_part_start(appledouble_decode_object* p_ap_decode_obj);
+void parse_param(char* p, char** param, char** define, char** np);
+int ap_seek_to_boundary(appledouble_decode_object* p_ap_decode_obj,
+                        bool firstime);
+int ap_parse_header(appledouble_decode_object* p_ap_decode_obj, bool firstime);
+int ap_decode_file_infor(appledouble_decode_object* p_ap_decode_obj);
+int ap_decode_process_header(appledouble_decode_object* p_ap_decode_obj,
+                             bool firstime);
+int ap_decode_process_data(appledouble_decode_object* p_ap_decode_obj,
+                           bool firstime);
 
 PR_END_EXTERN_C
 
 #if PRAGMA_STRUCT_ALIGN
-  #pragma options align=reset
+#  pragma options align = reset
 #endif
 
 #endif /* ad_codes_h */
--- a/mailnews/compose/src/nsMsgAppleDouble.h
+++ b/mailnews/compose/src/nsMsgAppleDouble.h
@@ -19,182 +19,144 @@
 
 #include "msgCore.h"
 #include "nsComposeStrings.h"
 #include "nsIOutputStream.h"
 #include "nsCOMPtr.h"
 
 #include <CoreServices/CoreServices.h>
 
-#define NOERR            0
-#define errDone          1  /* Done with current operation. */
-#define errEOB           2  /* End of a buffer.             */
-#define errEOP           3  /* End of a Part.               */
+#define NOERR 0
+#define errDone 1 /* Done with current operation. */
+#define errEOB 2  /* End of a buffer.             */
+#define errEOP 3  /* End of a Part.               */
 
-
-#define errFileOpen    NS_ERROR_GET_CODE(NS_MSG_UNABLE_TO_OPEN_TMP_FILE)
-#define errFileWrite   -202  /* Error writing temporary file. */
-#define errUsrCancel     -2  /* MK_INTERRUPTED */
-#define errDecoding      -1
+#define errFileOpen NS_ERROR_GET_CODE(NS_MSG_UNABLE_TO_OPEN_TMP_FILE)
+#define errFileWrite -202 /* Error writing temporary file. */
+#define errUsrCancel -2   /* MK_INTERRUPTED */
+#define errDecoding -1
 
 /*
  ** The envirment block data type.
  */
-enum
-{
+enum {
   kInit,
   kDoingHeaderPortion,
   kDoneHeaderPortion,
   kDoingDataPortion,
   kDoneDataPortion
 };
 
-typedef struct _appledouble_encode_object
-{
-  char    fname[256];
-  FSIORefNum fileId;         /* the id for the open file (data/resource fork) */
+typedef struct _appledouble_encode_object {
+  char fname[256];
+  FSIORefNum fileId; /* the id for the open file (data/resource fork) */
 
-  int     state;
-  int     text_file_type;    /* if the file has a text file type with it.     */
-  char    *boundary;         /* the boundary string.                          */
+  int state;
+  int text_file_type; /* if the file has a text file type with it.     */
+  char* boundary;     /* the boundary string.                          */
 
-  int     status;            /* the error code if anyerror happens.           */
-  char    b_overflow[200];
-  int     s_overflow;
+  int status; /* the error code if anyerror happens.           */
+  char b_overflow[200];
+  int s_overflow;
 
-  int     state64;           /* the left over state of base64 enocding        */
-  int     ct;                /* the character count of base64 encoding        */
-  int     c1, c2;            /* the left of the last base64 encoding          */
+  int state64; /* the left over state of base64 enocding        */
+  int ct;      /* the character count of base64 encoding        */
+  int c1, c2;  /* the left of the last base64 encoding          */
 
-  char    *outbuff;          /* the outbuff by the caller.                    */
-  int     s_outbuff;         /* the size of the buffer.                       */
-  int     pos_outbuff;       /* the offset in the current buffer.             */
+  char* outbuff;   /* the outbuff by the caller.                    */
+  int s_outbuff;   /* the size of the buffer.                       */
+  int pos_outbuff; /* the offset in the current buffer.             */
 } appledouble_encode_object;
 
 /* The possible content transfer encodings */
 
-enum
-{
-  kEncodeNone,
-  kEncodeQP,
-  kEncodeBase64,
-  kEncodeUU
-};
+enum { kEncodeNone, kEncodeQP, kEncodeBase64, kEncodeUU };
+
+enum { kGeneralMine, kAppleDouble, kAppleSingle };
 
-enum
-{
-  kGeneralMine,
-  kAppleDouble,
-  kAppleSingle
-};
+enum { kInline, kDontCare };
 
-enum
-{
-  kInline,
-  kDontCare
-};
-
-enum
-{
-  kHeaderPortion,
-  kDataPortion
-};
+enum { kHeaderPortion, kDataPortion };
 
 /* the decode states. */
-enum
-{
+enum {
   kBeginParseHeader = 3,
   kParsingHeader,
   kBeginSeekBoundary,
   kSeekingBoundary,
   kBeginHeaderPortion,
   kProcessingHeaderPortion,
   kBeginDataPortion,
   kProcessingDataPortion,
   kFinishing
 };
 
 /* uuencode states */
-enum
-{
-  kWaitingForBegin = (int) 0,
-  kBegin,
-  kMainBody,
-  kEnd
-};
+enum { kWaitingForBegin = (int)0, kBegin, kMainBody, kEnd };
+
+typedef struct _appledouble_decode_object {
+  int is_binary;
+  int is_apple_single; /* if the object encoded is in apple single  */
+  int write_as_binhex;
 
-typedef struct _appledouble_decode_object
-{
-  int     is_binary;
-  int     is_apple_single;    /* if the object encoded is in apple single  */
-  int     write_as_binhex;
+  int messagetype;
+  char* boundary0; /* the boundary for the enclosure.           */
+  int deposition;  /* the deposition.                           */
+  int encoding;    /* the encoding method.                      */
+  int which_part;
 
-  int     messagetype;
-  char*   boundary0;          /* the boundary for the enclosure.           */
-  int     deposition;         /* the deposition.                           */
-  int     encoding;           /* the encoding method.                      */
-  int     which_part;
+  char fname[256];
+  // nsIOFileStream *fileSpec;   /* the stream for data fork work.            */
 
-  char    fname[256];
-// nsIOFileStream *fileSpec;   /* the stream for data fork work.            */
+  int state;
 
-  int     state;
+  int rksize; /* the resource fork size count.             */
+  int dksize; /* the data fork size count.                 */
 
-  int     rksize;             /* the resource fork size count.             */
-  int     dksize;             /* the data fork size count.                 */
-
-  int      status;            /* the error code if anyerror happens.       */
-  char     b_leftover[256];
-  int      s_leftover;
+  int status; /* the error code if anyerror happens.       */
+  char b_leftover[256];
+  int s_leftover;
 
-  int      encode;            /* the encode type of the message.           */
-  int      state64;           /* the left over state of base64 enocding    */
-  int      left;              /* the character count of base64 encoding    */
-  int      c[4];              /* the left of the last base64 encoding      */
-  int      uu_starts_line;    /* is decoder at the start of a line? (uuencode) */
-  int      uu_state;          /* state w/r/t the uuencode body */
-  int      uu_bytes_written;  /* bytes written from the current tuple (uuencode) */
-  int      uu_line_bytes;     /* encoded bytes remaining in the current line (uuencode) */
+  int encode;           /* the encode type of the message.           */
+  int state64;          /* the left over state of base64 enocding    */
+  int left;             /* the character count of base64 encoding    */
+  int c[4];             /* the left of the last base64 encoding      */
+  int uu_starts_line;   /* is decoder at the start of a line? (uuencode) */
+  int uu_state;         /* state w/r/t the uuencode body */
+  int uu_bytes_written; /* bytes written from the current tuple (uuencode) */
+  int uu_line_bytes; /* encoded bytes remaining in the current line (uuencode)
+                      */
 
-  char     *inbuff;           /* the outbuff by the caller.                */
-  int      s_inbuff;          /* the size of the buffer.                   */
-  int      pos_inbuff;        /* the offset in the current buffer.         */
+  char* inbuff;   /* the outbuff by the caller.                */
+  int s_inbuff;   /* the size of the buffer.                   */
+  int pos_inbuff; /* the offset in the current buffer.         */
 
-  nsCOMPtr <nsIFile> tmpFile; /* the temp file to hold the decode data fork */
-                              /* when doing the binhex exporting.          */
-  nsCOMPtr <nsIOutputStream> tmpFileStream; /* The output File Stream      */
-  int32_t  data_size;         /* the size of the data in the tmp file.     */
+  nsCOMPtr<nsIFile> tmpFile; /* the temp file to hold the decode data fork */
+                             /* when doing the binhex exporting.          */
+  nsCOMPtr<nsIOutputStream> tmpFileStream; /* The output File Stream      */
+  int32_t data_size; /* the size of the data in the tmp file.     */
 } appledouble_decode_object;
 
-
 /*
  ** The protypes.
  */
 
 PR_BEGIN_EXTERN_C
 
-int ap_encode_init(appledouble_encode_object *p_ap_encode_obj,
-                   const char* fname,
-                   char* separator);
+int ap_encode_init(appledouble_encode_object* p_ap_encode_obj,
+                   const char* fname, char* separator);
 
-int ap_encode_next(appledouble_encode_object* p_ap_encode_obj,
-                   char     *to_buff,
-                   int32_t  buff_size,
-                   int32_t* real_size);
+int ap_encode_next(appledouble_encode_object* p_ap_encode_obj, char* to_buff,
+                   int32_t buff_size, int32_t* real_size);
 
-int ap_encode_end(appledouble_encode_object* p_ap_encode_obj,
-                   bool is_aborting);
+int ap_encode_end(appledouble_encode_object* p_ap_encode_obj, bool is_aborting);
 
 int ap_decode_init(appledouble_decode_object* p_ap_decode_obj,
-                   bool is_apple_single,
-                   bool write_as_bin_hex,
-                   void *closure);
+                   bool is_apple_single, bool write_as_bin_hex, void* closure);
 
-int ap_decode_next(appledouble_decode_object* p_ap_decode_obj,
-                   char    *in_buff,
+int ap_decode_next(appledouble_decode_object* p_ap_decode_obj, char* in_buff,
                    int32_t buff_size);
 
-int ap_decode_end(appledouble_decode_object* p_ap_decode_obj,
-                  bool is_aborting);
+int ap_decode_end(appledouble_decode_object* p_ap_decode_obj, bool is_aborting);
 
 PR_END_EXTERN_C
 
 #endif
--- a/mailnews/compose/src/nsMsgAppleDoubleEncode.cpp
+++ b/mailnews/compose/src/nsMsgAppleDoubleEncode.cpp
@@ -21,59 +21,51 @@
 #include "nsMsgAppleCodes.h"
 #include "nsMsgCompUtils.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIMIMEService.h"
 #include "nsMimeTypes.h"
 #include "prmem.h"
 #include "nsNetUtil.h"
 
-
-void
-MacGetFileType(nsIFile *fs,
-               bool    *useDefault,
-               char    **fileType,
-               char    **encoding)
-{
-  if ((fs == NULL) || (fileType == NULL) || (encoding == NULL))
-    return;
+void MacGetFileType(nsIFile *fs, bool *useDefault, char **fileType,
+                    char **encoding) {
+  if ((fs == NULL) || (fileType == NULL) || (encoding == NULL)) return;
 
   bool exists = false;
   fs->Exists(&exists);
-  if (!exists)
-    return;
+  if (!exists) return;
 
   *useDefault = TRUE;
   *fileType = NULL;
   *encoding = NULL;
 
   nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(fs);
   FSRef fsRef;
   FSCatalogInfo catalogInfo;
   OSErr err = errFileOpen;
   if (NS_SUCCEEDED(macFile->GetFSRef(&fsRef)))
-    err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catalogInfo, nullptr, nullptr, nullptr);
+    err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catalogInfo,
+                             nullptr, nullptr, nullptr);
 
-  if ( (err != noErr) || (((FileInfo*)(&catalogInfo.finderInfo))->fileType == 'TEXT') )
+  if ((err != noErr) ||
+      (((FileInfo *)(&catalogInfo.finderInfo))->fileType == 'TEXT'))
     *fileType = strdup(APPLICATION_OCTET_STREAM);
-  else
-  {
+  else {
     // At this point, we should call the mime service and
     // see what we can find out?
-    nsresult      rv;
-    nsCOMPtr <nsIURI> tURI;
-    if (NS_SUCCEEDED(NS_NewFileURI(getter_AddRefs(tURI), fs)) && tURI)
-    {
-      nsCOMPtr<nsIMIMEService> mimeFinder(do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
-      if (NS_SUCCEEDED(rv) && mimeFinder)
-      {
+    nsresult rv;
+    nsCOMPtr<nsIURI> tURI;
+    if (NS_SUCCEEDED(NS_NewFileURI(getter_AddRefs(tURI), fs)) && tURI) {
+      nsCOMPtr<nsIMIMEService> mimeFinder(
+          do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
+      if (NS_SUCCEEDED(rv) && mimeFinder) {
         nsAutoCString mimeType;
         rv = mimeFinder->GetTypeFromURI(tURI, mimeType);
-        if (NS_SUCCEEDED(rv))
-        {
+        if (NS_SUCCEEDED(rv)) {
           *fileType = ToNewCString(mimeType);
           return;
         }
       }
     }
 
     // If we hit here, return something...default to this...
     *fileType = strdup(APPLICATION_OCTET_STREAM);
@@ -85,24 +77,22 @@ MacGetFileType(nsIFile *fs,
 /*
  *  ap_encode_init
  *  --------------
  *
  *  Setup the encode envirment
  */
 
 int ap_encode_init(appledouble_encode_object *p_ap_encode_obj,
-                   const char                *fname,
-                   char                      *separator)
-{
-  nsCOMPtr <nsIFile> myFile;
-  NS_NewNativeLocalFile(nsDependentCString(fname), true, getter_AddRefs(myFile));
+                   const char *fname, char *separator) {
+  nsCOMPtr<nsIFile> myFile;
+  NS_NewNativeLocalFile(nsDependentCString(fname), true,
+                        getter_AddRefs(myFile));
   bool exists;
-  if (myFile && NS_SUCCEEDED(myFile->Exists(&exists)) && !exists)
-    return -1;
+  if (myFile && NS_SUCCEEDED(myFile->Exists(&exists)) && !exists) return -1;
 
   nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(myFile);
   nsAutoCString path;
   macFile->GetNativePath(path);
 
   memset(p_ap_encode_obj, 0, sizeof(appledouble_encode_object));
 
   /*
@@ -119,148 +109,128 @@ int ap_encode_init(appledouble_encode_ob
 **  ap_encode_next
 **  --------------
 **
 **  return :
 **  noErr  :  everything is ok
 **  errDone:  when encoding is done.
 **  errors :  otherwise.
 */
-int ap_encode_next(
-  appledouble_encode_object* p_ap_encode_obj,
-  char     *to_buff,
-  int32_t  buff_size,
-  int32_t* real_size)
-{
+int ap_encode_next(appledouble_encode_object *p_ap_encode_obj, char *to_buff,
+                   int32_t buff_size, int32_t *real_size) {
   int status;
 
   /*
   **   install the out buff now.
   */
   p_ap_encode_obj->outbuff = to_buff;
   p_ap_encode_obj->s_outbuff = buff_size;
   p_ap_encode_obj->pos_outbuff = 0;
 
   /*
   **  first copy the outstandind data in the overflow buff to the out buffer.
   */
-  if (p_ap_encode_obj->s_overflow)
-  {
+  if (p_ap_encode_obj->s_overflow) {
     status = write_stream(p_ap_encode_obj,
-                          (const char*)(p_ap_encode_obj->b_overflow),
+                          (const char *)(p_ap_encode_obj->b_overflow),
                           p_ap_encode_obj->s_overflow);
-    if (status != noErr)
-      return status;
+    if (status != noErr) return status;
 
     p_ap_encode_obj->s_overflow = 0;
   }
 
   /*
   ** go the next processing stage based on the current state.
   */
-  switch (p_ap_encode_obj->state)
-  {
+  switch (p_ap_encode_obj->state) {
     case kInit:
       /*
       ** We are in the  starting position, fill out the header.
       */
       status = fill_apple_mime_header(p_ap_encode_obj);
-      if (status != noErr)
-        break;          /* some error happens */
+      if (status != noErr) break; /* some error happens */
 
       p_ap_encode_obj->state = kDoingHeaderPortion;
       status = ap_encode_header(p_ap_encode_obj, true);
-                    /* it is the first time to calling     */
-      if (status == errDone)
-      {
+      /* it is the first time to calling     */
+      if (status == errDone) {
         p_ap_encode_obj->state = kDoneHeaderPortion;
-      }
-      else
-      {
-        break;          /* we need more work on header portion.  */
+      } else {
+        break; /* we need more work on header portion.  */
       }
 
       /*
       ** we are done with the header, so let's go to the data port.
       */
       p_ap_encode_obj->state = kDoingDataPortion;
-      status = ap_encode_data(p_ap_encode_obj, true);     
-                    /* it is first time call do data portion */
+      status = ap_encode_data(p_ap_encode_obj, true);
+      /* it is first time call do data portion */
 
-      if (status == errDone)
-      {
-        p_ap_encode_obj->state  = kDoneDataPortion;
+      if (status == errDone) {
+        p_ap_encode_obj->state = kDoneDataPortion;
         status = noErr;
       }
       break;
 
     case kDoingHeaderPortion:
 
-      status = ap_encode_header(p_ap_encode_obj, false); 
-                    /* continue with the header portion.  */
-      if (status == errDone)
-      {
+      status = ap_encode_header(p_ap_encode_obj, false);
+      /* continue with the header portion.  */
+      if (status == errDone) {
         p_ap_encode_obj->state = kDoneHeaderPortion;
-      }
-      else
-      {
-        break;          /* we need more work on header portion.  */
+      } else {
+        break; /* we need more work on header portion.  */
       }
 
       /*
       ** start the data portion.
       */
       p_ap_encode_obj->state = kDoingDataPortion;
-      status = ap_encode_data(p_ap_encode_obj, true); 
-                    /* it is the first time calling     */
-      if (status == errDone)
-      {
-        p_ap_encode_obj->state  = kDoneDataPortion;
+      status = ap_encode_data(p_ap_encode_obj, true);
+      /* it is the first time calling     */
+      if (status == errDone) {
+        p_ap_encode_obj->state = kDoneDataPortion;
         status = noErr;
       }
       break;
 
     case kDoingDataPortion:
 
-      status = ap_encode_data(p_ap_encode_obj, false); 
-                    /* it is not the first time        */
+      status = ap_encode_data(p_ap_encode_obj, false);
+      /* it is not the first time        */
 
-      if (status == errDone)
-      {
+      if (status == errDone) {
         p_ap_encode_obj->state = kDoneDataPortion;
         status = noErr;
       }
       break;
 
     case kDoneDataPortion:
-      status = errDone;    /* we are really done.          */
+      status = errDone; /* we are really done.          */
 
       break;
   }
 
   *real_size = p_ap_encode_obj->pos_outbuff;
   return status;
 }
 
 /*
 **  ap_encode_end
 **  -------------
 **
 **  clear the apple encoding.
 */
 
-int ap_encode_end(
-  appledouble_encode_object *p_ap_encode_obj,
-  bool is_aborting)
-{
+int ap_encode_end(appledouble_encode_object *p_ap_encode_obj,
+                  bool is_aborting) {
   /*
   ** clear up the apple doubler.
   */
-  if (p_ap_encode_obj == NULL)
-    return noErr;
+  if (p_ap_encode_obj == NULL) return noErr;
 
-  if (p_ap_encode_obj->fileId)      /* close the file if it is open.  */
+  if (p_ap_encode_obj->fileId) /* close the file if it is open.  */
     ::FSCloseFork(p_ap_encode_obj->fileId);
 
-  PR_FREEIF(p_ap_encode_obj->boundary);    /* the boundary string.        */
+  PR_FREEIF(p_ap_encode_obj->boundary); /* the boundary string.        */
 
   return noErr;
 }
--- a/mailnews/compose/src/nsMsgAppleEncode.cpp
+++ b/mailnews/compose/src/nsMsgAppleEncode.cpp
@@ -23,66 +23,53 @@
 #include "nsServiceManagerUtils.h"
 #include "nsMsgAppleDouble.h"
 #include "nsMsgAppleCodes.h"
 #include "nsILocalFileMac.h"
 
 /*
 **  Local Functions prototypes.
 */
-static int output64chunk(appledouble_encode_object* p_ap_encode_obj,
-                         int c1, int c2, int c3, int pads);
+static int output64chunk(appledouble_encode_object *p_ap_encode_obj, int c1,
+                         int c2, int c3, int pads);
 
-static int to64(appledouble_encode_object* p_ap_encode_obj,
-                char *p,
-                int  in_size);
+static int to64(appledouble_encode_object *p_ap_encode_obj, char *p,
+                int in_size);
 
-static int finish64(appledouble_encode_object* p_ap_encode_obj);
+static int finish64(appledouble_encode_object *p_ap_encode_obj);
 
-
-#define BUFF_LEFT(p)  ((p)->s_outbuff - (p)->pos_outbuff)
+#define BUFF_LEFT(p) ((p)->s_outbuff - (p)->pos_outbuff)
 
 /*
 **  write_stream.
 */
-int write_stream(
-  appledouble_encode_object *p_ap_encode_obj,
-  const char *out_string,
-  int len)
-{
-  if (p_ap_encode_obj->pos_outbuff + len < p_ap_encode_obj->s_outbuff)
-  {
-    memcpy(p_ap_encode_obj->outbuff + p_ap_encode_obj->pos_outbuff,
-           out_string,
+int write_stream(appledouble_encode_object *p_ap_encode_obj,
+                 const char *out_string, int len) {
+  if (p_ap_encode_obj->pos_outbuff + len < p_ap_encode_obj->s_outbuff) {
+    memcpy(p_ap_encode_obj->outbuff + p_ap_encode_obj->pos_outbuff, out_string,
            len);
     p_ap_encode_obj->pos_outbuff += len;
     return noErr;
-  }
-  else
-  {
+  } else {
     /*
     **  If the buff doesn't have enough space, use the overflow buffer then.
     */
     int s_len = p_ap_encode_obj->s_outbuff - p_ap_encode_obj->pos_outbuff;
 
-    memcpy(p_ap_encode_obj->outbuff + p_ap_encode_obj->pos_outbuff,
-           out_string,
+    memcpy(p_ap_encode_obj->outbuff + p_ap_encode_obj->pos_outbuff, out_string,
            s_len);
     memcpy(p_ap_encode_obj->b_overflow + p_ap_encode_obj->s_overflow,
-           out_string + s_len,
-           p_ap_encode_obj->s_overflow += (len - s_len));
+           out_string + s_len, p_ap_encode_obj->s_overflow += (len - s_len));
     p_ap_encode_obj->pos_outbuff += s_len;
     return errEOB;
   }
 }
 
-int fill_apple_mime_header(
-  appledouble_encode_object *p_ap_encode_obj)
-{
-  int  status;
+int fill_apple_mime_header(appledouble_encode_object *p_ap_encode_obj) {
+  int status;
 
   char tmpstr[266];
 
 #if 0
 //  strcpy(tmpstr, "Content-Type: multipart/mixed; boundary=\"-\"\n\n---\n");
 //  status = write_stream(p_ap_encode_env,
 //            tmpstr,
 //            strlen(tmpstr));
@@ -101,603 +88,504 @@ int fill_apple_mime_header(
   if (status != noErr)
     return status;
 
   PR_snprintf(tmpstr, sizeof(tmpstr),
               "\"\r\nContent-Disposition: inline; filename=\"%s\"\r\n\r\n\r\n--=\r\n",
               p_ap_encode_obj->fname);
 #endif /* 0 */
   PR_snprintf(tmpstr, sizeof(tmpstr), "--%s" CRLF, p_ap_encode_obj->boundary);
-  status = write_stream(p_ap_encode_obj, (const char*)tmpstr, strlen(tmpstr));
+  status = write_stream(p_ap_encode_obj, (const char *)tmpstr, strlen(tmpstr));
   return status;
 }
 
-int ap_encode_file_infor(
-  appledouble_encode_object *p_ap_encode_obj)
-{
-  ap_header  head;
-  ap_entry   entries[NUM_ENTRIES];
-  ap_dates   dates;
-  short      i;
-  long       comlen;
-  char       comment[256];
-  int        status;
+int ap_encode_file_infor(appledouble_encode_object *p_ap_encode_obj) {
+  ap_header head;
+  ap_entry entries[NUM_ENTRIES];
+  ap_dates dates;
+  short i;
+  long comlen;
+  char comment[256];
+  int status;
 
-  nsCOMPtr <nsIFile> resFile;
+  nsCOMPtr<nsIFile> resFile;
   NS_NewNativeLocalFile(nsDependentCString(p_ap_encode_obj->fname), true,
                         getter_AddRefs(resFile));
-  if (!resFile)
-      return errFileOpen;
+  if (!resFile) return errFileOpen;
 
   FSRef ref;
-  nsCOMPtr <nsILocalFileMac> macFile = do_QueryInterface(resFile);
-  if (NS_FAILED(macFile->GetFSRef(&ref)))
-      return errFileOpen;
+  nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(resFile);
+  if (NS_FAILED(macFile->GetFSRef(&ref))) return errFileOpen;
 
   FSCatalogInfo catalogInfo;
-  if (::FSGetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catalogInfo, nullptr, nullptr, nullptr) != noErr)
-  {
+  if (::FSGetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catalogInfo, nullptr,
+                         nullptr, nullptr) != noErr) {
     return errFileOpen;
   }
 
   /* get a file comment, if possible */
 #if 1
   // Carbon doesn't support GetWDInfo(). (Bug 555684)
 
   // not sure why working directories are needed here...
   comlen = 0;
 #else
-  long     procID;
+  long procID;
   procID = 0;
   GetWDInfo(p_ap_encode_obj->vRefNum, &fpb->ioVRefNum, &fpb->ioDirID, &procID);
-  IOParam   vinfo;
-  memset((void *) &vinfo, '\0', sizeof (vinfo));
+  IOParam vinfo;
+  memset((void *)&vinfo, '\0', sizeof(vinfo));
   GetVolParmsInfoBuffer vp;
-  vinfo.ioCompletion  = nil;
-  vinfo.ioVRefNum   = fpb->ioVRefNum;
-  vinfo.ioBuffer     = (Ptr) &vp;
-  vinfo.ioReqCount   = sizeof (vp);
+  vinfo.ioCompletion = nil;
+  vinfo.ioVRefNum = fpb->ioVRefNum;
+  vinfo.ioBuffer = (Ptr)&vp;
+  vinfo.ioReqCount = sizeof(vp);
   comlen = 0;
-  if (PBHGetVolParmsSync((HParmBlkPtr) &vinfo) == noErr &&
-    ((vp.vMAttrib >> bHasDesktopMgr) & 1))
-  {
-    DTPBRec   dtp;
-    memset((void *) &dtp, '\0', sizeof (dtp));
+  if (PBHGetVolParmsSync((HParmBlkPtr)&vinfo) == noErr &&
+      ((vp.vMAttrib >> bHasDesktopMgr) & 1)) {
+    DTPBRec dtp;
+    memset((void *)&dtp, '\0', sizeof(dtp));
     dtp.ioVRefNum = fpb->ioVRefNum;
-    if (PBDTGetPath(&dtp) == noErr)
-    {
+    if (PBDTGetPath(&dtp) == noErr) {
       dtp.ioCompletion = nil;
-      dtp.ioDTBuffer = (Ptr) comment;
-      dtp.ioNamePtr  = fpb->ioNamePtr;
-      dtp.ioDirID    = fpb->ioFlParID;
-      if (PBDTGetCommentSync(&dtp) == noErr)
-        comlen = dtp.ioDTActCount;
+      dtp.ioDTBuffer = (Ptr)comment;
+      dtp.ioNamePtr = fpb->ioNamePtr;
+      dtp.ioDirID = fpb->ioFlParID;
+      if (PBDTGetCommentSync(&dtp) == noErr) comlen = dtp.ioDTActCount;
     }
   }
 #endif /* ! 1 */
 
   /* write header */
-//  head.magic = dfork ? APPLESINGLE_MAGIC : APPLEDOUBLE_MAGIC;
-  head.magic   = APPLEDOUBLE_MAGIC;    /* always do apple double */
+  //  head.magic = dfork ? APPLESINGLE_MAGIC : APPLEDOUBLE_MAGIC;
+  head.magic = APPLEDOUBLE_MAGIC; /* always do apple double */
   head.version = APPLEDOUBLE_VERSION;
-  memset(head.fill, '\0', sizeof (head.fill));
+  memset(head.fill, '\0', sizeof(head.fill));
   head.entries = NUM_ENTRIES - 1;
-  status = to64(p_ap_encode_obj,
-                (char *) &head,
-                sizeof (head));
-  if (status != noErr)
-    return status;
+  status = to64(p_ap_encode_obj, (char *)&head, sizeof(head));
+  if (status != noErr) return status;
 
   /* write entry descriptors */
   nsAutoCString leafname;
   macFile->GetNativeLeafName(leafname);
-  entries[0].offset = sizeof (head) + sizeof (ap_entry) * head.entries;
-  entries[0].id   = ENT_NAME;
+  entries[0].offset = sizeof(head) + sizeof(ap_entry) * head.entries;
+  entries[0].id = ENT_NAME;
   entries[0].length = leafname.Length();
-  entries[1].id   = ENT_FINFO;
-  entries[1].length = sizeof (FInfo) + sizeof (FXInfo);
-  entries[2].id   = ENT_DATES;
-  entries[2].length = sizeof (ap_dates);
-  entries[3].id   = ENT_COMMENT;
+  entries[1].id = ENT_FINFO;
+  entries[1].length = sizeof(FInfo) + sizeof(FXInfo);
+  entries[2].id = ENT_DATES;
+  entries[2].length = sizeof(ap_dates);
+  entries[3].id = ENT_COMMENT;
   entries[3].length = comlen;
-  entries[4].id   = ENT_RFORK;
+  entries[4].id = ENT_RFORK;
   entries[4].length = catalogInfo.rsrcLogicalSize;
-  entries[5].id   = ENT_DFORK;
+  entries[5].id = ENT_DFORK;
   entries[5].length = catalogInfo.dataLogicalSize;
 
   /* correct the link in the entries. */
-  for (i = 1; i < NUM_ENTRIES; ++i)
-  {
-    entries[i].offset = entries[i-1].offset + entries[i-1].length;
+  for (i = 1; i < NUM_ENTRIES; ++i) {
+    entries[i].offset = entries[i - 1].offset + entries[i - 1].length;
   }
-  status = to64(p_ap_encode_obj,
-                (char *) entries,
-                sizeof (ap_entry) * head.entries);
-  if (status != noErr)
-    return status;
+  status =
+      to64(p_ap_encode_obj, (char *)entries, sizeof(ap_entry) * head.entries);
+  if (status != noErr) return status;
 
   /* write name */
-  status = to64(p_ap_encode_obj,
-                (char *) leafname.get(),
-                leafname.Length());
-  if (status != noErr)
-    return status;
+  status = to64(p_ap_encode_obj, (char *)leafname.get(), leafname.Length());
+  if (status != noErr) return status;
 
   /* write finder info */
-  status = to64(p_ap_encode_obj,
-                (char *) &catalogInfo.finderInfo,
-                sizeof (FInfo));
-  if (status != noErr)
-    return status;
+  status =
+      to64(p_ap_encode_obj, (char *)&catalogInfo.finderInfo, sizeof(FInfo));
+  if (status != noErr) return status;
 
-  status = to64(p_ap_encode_obj,
-                (char *) &catalogInfo.extFinderInfo,
-                sizeof (FXInfo));
-  if (status != noErr)
-    return status;
+  status =
+      to64(p_ap_encode_obj, (char *)&catalogInfo.extFinderInfo, sizeof(FXInfo));
+  if (status != noErr) return status;
 
   /* write dates */
   dates.create = catalogInfo.createDate.lowSeconds + CONVERT_TIME;
   dates.modify = catalogInfo.contentModDate.lowSeconds + CONVERT_TIME;
   dates.backup = catalogInfo.backupDate.lowSeconds + CONVERT_TIME;
   dates.access = catalogInfo.accessDate.lowSeconds + CONVERT_TIME;
-  status = to64(p_ap_encode_obj,
-                (char *) &dates,
-                sizeof (ap_dates));
-  if (status != noErr)
-    return status;
+  status = to64(p_ap_encode_obj, (char *)&dates, sizeof(ap_dates));
+  if (status != noErr) return status;
 
   /* write comment */
-  if (comlen)
-  {
-    status = to64(p_ap_encode_obj,
-                  comment,
-                  comlen * sizeof(char));
+  if (comlen) {
+    status = to64(p_ap_encode_obj, comment, comlen * sizeof(char));
   }
   /*
   **  Get some help information on deciding the file type.
   */
-  if (((FileInfo*)(&catalogInfo.finderInfo))->fileType == 'TEXT' ||
-      ((FileInfo*)(&catalogInfo.finderInfo))->fileType == 'text')
-  {
+  if (((FileInfo *)(&catalogInfo.finderInfo))->fileType == 'TEXT' ||
+      ((FileInfo *)(&catalogInfo.finderInfo))->fileType == 'text') {
     p_ap_encode_obj->text_file_type = true;
   }
 
   return status;
 }
 /*
 **  ap_encode_header
 **
 **    encode the file header and the resource fork.
 **
 */
-int ap_encode_header(
-  appledouble_encode_object* p_ap_encode_obj,
-  bool    firstime)
-{
-  char     rd_buff[256];
+int ap_encode_header(appledouble_encode_object *p_ap_encode_obj,
+                     bool firstime) {
+  char rd_buff[256];
   FSIORefNum fileId;
-  OSErr  retval = noErr;
-  int      status;
+  OSErr retval = noErr;
+  int status;
   ByteCount inCount;
 
-  if (firstime)
-  {
-    PL_strcpy(rd_buff,
-      "Content-Type: application/applefile\r\nContent-Transfer-Encoding: base64\r\n\r\n");
-    status = write_stream(p_ap_encode_obj, (const char*)rd_buff, strlen(rd_buff));
-    if (status != noErr)
-      return status;
+  if (firstime) {
+    PL_strcpy(
+        rd_buff,
+        "Content-Type: application/applefile\r\nContent-Transfer-Encoding: "
+        "base64\r\n\r\n");
+    status =
+        write_stream(p_ap_encode_obj, (const char *)rd_buff, strlen(rd_buff));
+    if (status != noErr) return status;
 
     status = ap_encode_file_infor(p_ap_encode_obj);
-    if (status != noErr)
-      return status;
+    if (status != noErr) return status;
 
     /*
     ** preparing to encode the resource fork.
     */
-    nsCOMPtr <nsIFile> myFile;
-    NS_NewNativeLocalFile(nsDependentCString(p_ap_encode_obj->fname), true, getter_AddRefs(myFile));
-    if (!myFile)
-      return errFileOpen;
+    nsCOMPtr<nsIFile> myFile;
+    NS_NewNativeLocalFile(nsDependentCString(p_ap_encode_obj->fname), true,
+                          getter_AddRefs(myFile));
+    if (!myFile) return errFileOpen;
 
     FSRef ref;
-    nsCOMPtr <nsILocalFileMac> macFile = do_QueryInterface(myFile);
-    if (NS_FAILED(macFile->GetFSRef(&ref)))
-      return errFileOpen;
+    nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(myFile);
+    if (NS_FAILED(macFile->GetFSRef(&ref))) return errFileOpen;
 
     HFSUniStr255 forkName;
     ::FSGetResourceForkName(&forkName);
-    retval = ::FSOpenFork(&ref, forkName.length, forkName.unicode, fsRdPerm, &p_ap_encode_obj->fileId);
-    if (retval != noErr)
-      return retval;
+    retval = ::FSOpenFork(&ref, forkName.length, forkName.unicode, fsRdPerm,
+                          &p_ap_encode_obj->fileId);
+    if (retval != noErr) return retval;
   }
 
   fileId = p_ap_encode_obj->fileId;
-  while (retval == noErr)
-  {
-    if (BUFF_LEFT(p_ap_encode_obj) < 400)
-      break;
+  while (retval == noErr) {
+    if (BUFF_LEFT(p_ap_encode_obj) < 400) break;
 
     inCount = 0;
     retval = ::FSReadFork(fileId, fsAtMark, 0, 256, rd_buff, &inCount);
-    if (inCount)
-    {
-      status = to64(p_ap_encode_obj,
-                    rd_buff,
-                    inCount);
-      if (status != noErr)
-        return status;
+    if (inCount) {
+      status = to64(p_ap_encode_obj, rd_buff, inCount);
+      if (status != noErr) return status;
     }
   }
 
-  if (retval == eofErr)
-  {
+  if (retval == eofErr) {
     ::FSCloseFork(fileId);
     p_ap_encode_obj->fileId = 0;
 
     status = finish64(p_ap_encode_obj);
-    if (status != noErr)
-      return status;
+    if (status != noErr) return status;
 
     /*
     ** write out the boundary
     */
-    PR_snprintf(rd_buff, sizeof(rd_buff),
-                CRLF "--%s" CRLF,
+    PR_snprintf(rd_buff, sizeof(rd_buff), CRLF "--%s" CRLF,
                 p_ap_encode_obj->boundary);
 
-    status = write_stream(p_ap_encode_obj, (const char*)rd_buff, strlen(rd_buff));
-    if (status == noErr)
-      status = errDone;
+    status =
+        write_stream(p_ap_encode_obj, (const char *)rd_buff, strlen(rd_buff));
+    if (status == noErr) status = errDone;
   }
   return status;
 }
 
 #if 0
 // This is unused for now and Clang complains about that is it is ifdefed out
 static void replace(char *p, int len, char frm, char to)
 {
   for (; len > 0; len--, p++)
     if (*p == frm)  *p = to;
 }
 #endif
 
 /* Description of the various file formats and their magic numbers     */
-struct magic
-{
-    const char *name;    /* Name of the file format */
-    const char *num;     /* The magic number */
-    int        len;      /* Length (0 means strlen(magicnum)) */
+struct magic {
+  const char *name; /* Name of the file format */
+  const char *num;  /* The magic number */
+  int len;          /* Length (0 means strlen(magicnum)) */
 };
 
 /* The magic numbers of the file formats we know about */
-static struct magic magic[] =
-{
-    { "image/gif",   "GIF",         0 },
-    { "image/jpeg", "\377\330\377",   0 },
-    { "video/mpeg", "\0\0\001\263",    4 },
-    { "application/postscript", "%!", 0 },
+static struct magic magic[] = {
+    {"image/gif", "GIF", 0},
+    {"image/jpeg", "\377\330\377", 0},
+    {"video/mpeg", "\0\0\001\263", 4},
+    {"application/postscript", "%!", 0},
 };
 static int num_magic = MOZ_ARRAY_LENGTH(magic);
 
-static const char *text_type    = TEXT_PLAIN;          /* the text file type. */
+static const char *text_type = TEXT_PLAIN; /* the text file type. */
 static const char *default_type = APPLICATION_OCTET_STREAM;
 
-
 /*
  * Determines the format of the file "inputf".  The name
  * of the file format (or NULL on error) is returned.
  */
-static const char *magic_look(char *inbuff, int numread)
-{
+static const char *magic_look(char *inbuff, int numread) {
   int i, j;
 
-  for (i=0; i<num_magic; i++)
-  {
-    if (magic[i].len == 0)
-      magic[i].len = strlen(magic[i].num);
+  for (i = 0; i < num_magic; i++) {
+    if (magic[i].len == 0) magic[i].len = strlen(magic[i].num);
   }
 
-  for (i=0; i<num_magic; i++)
-  {
-    if (numread >= magic[i].len)
-    {
-      for (j=0; j<magic[i].len; j++)
-      {
+  for (i = 0; i < num_magic; i++) {
+    if (numread >= magic[i].len) {
+      for (j = 0; j < magic[i].len; j++) {
         if (inbuff[j] != magic[i].num[j]) break;
       }
-      
-      if (j == magic[i].len)
-        return magic[i].name;
+
+      if (j == magic[i].len) return magic[i].name;
     }
   }
 
   return default_type;
 }
 /*
 **  ap_encode_data
 **
 **  ---------------
 **
 **    encode on the data fork.
 **
 */
-int ap_encode_data(
-  appledouble_encode_object* p_ap_encode_obj,
-  bool firstime)
-{
-  char       rd_buff[256];
+int ap_encode_data(appledouble_encode_object *p_ap_encode_obj, bool firstime) {
+  char rd_buff[256];
   FSIORefNum fileId;
-  OSErr      retval = noErr;
-  ByteCount  in_count;
-  int        status;
+  OSErr retval = noErr;
+  ByteCount in_count;
+  int status;
 
-  if (firstime)
-  {
-    const char* magic_type;
+  if (firstime) {
+    const char *magic_type;
 
     /*
     ** preparing to encode the data fork.
     */
-    nsCOMPtr <nsIFile> resFile;
+    nsCOMPtr<nsIFile> resFile;
     NS_NewNativeLocalFile(nsDependentCString(p_ap_encode_obj->fname), true,
                           getter_AddRefs(resFile));
-    if (!resFile)
-        return errFileOpen;
+    if (!resFile) return errFileOpen;
 
     FSRef ref;
-    nsCOMPtr <nsILocalFileMac> macFile = do_QueryInterface(resFile);
-    if (NS_FAILED(macFile->GetFSRef(&ref)))
-        return errFileOpen;
+    nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(resFile);
+    if (NS_FAILED(macFile->GetFSRef(&ref))) return errFileOpen;
 
     HFSUniStr255 forkName;
     ::FSGetDataForkName(&forkName);
-    retval = ::FSOpenFork(&ref, forkName.length, forkName.unicode, fsRdPerm, &fileId);
-    if (retval != noErr)
-        return retval;
+    retval = ::FSOpenFork(&ref, forkName.length, forkName.unicode, fsRdPerm,
+                          &fileId);
+    if (retval != noErr) return retval;
 
     p_ap_encode_obj->fileId = fileId;
 
-    if (!p_ap_encode_obj->text_file_type)
-    {
+    if (!p_ap_encode_obj->text_file_type) {
       /*
       **  do a smart check for the file type.
       */
       in_count = 0;
       retval = ::FSReadFork(fileId, fsFromStart, 0, 256, rd_buff, &in_count);
       magic_type = magic_look(rd_buff, in_count);
 
       /* don't forget to rewind the index to start point. */
       ::FSSetForkPosition(fileId, fsFromStart, 0);
       /* and reset retVal just in case... */
-      if (retval == eofErr)
-        retval = noErr;
-    }
-    else
-    {
-      magic_type = text_type;    /* we already know it is a text type.  */
+      if (retval == eofErr) retval = noErr;
+    } else {
+      magic_type = text_type; /* we already know it is a text type.  */
     }
 
     /*
     **  the data portion header information.
     */
-        nsAutoCString leafName;
-        resFile->GetNativeLeafName(leafName);
+    nsAutoCString leafName;
+    resFile->GetNativeLeafName(leafName);
     PR_snprintf(rd_buff, sizeof(rd_buff),
-      "Content-Type: %s; name=\"%s\"" CRLF "Content-Transfer-Encoding: base64" CRLF "Content-Disposition: inline; filename=\"%s\"" CRLF CRLF,
-      magic_type,
-      leafName.get(),
-      leafName.get());
+                "Content-Type: %s; name=\"%s\"" CRLF
+                "Content-Transfer-Encoding: base64" CRLF
+                "Content-Disposition: inline; filename=\"%s\"" CRLF CRLF,
+                magic_type, leafName.get(), leafName.get());
 
-    status = write_stream(p_ap_encode_obj, (const char*)rd_buff, strlen(rd_buff));
-    if (status != noErr)
-      return status;
+    status =
+        write_stream(p_ap_encode_obj, (const char *)rd_buff, strlen(rd_buff));
+    if (status != noErr) return status;
   }
 
-  while (retval == noErr)
-  {
-    if (BUFF_LEFT(p_ap_encode_obj) < 400)
-      break;
+  while (retval == noErr) {
+    if (BUFF_LEFT(p_ap_encode_obj) < 400) break;
 
     in_count = 0;
-    retval = ::FSReadFork(p_ap_encode_obj->fileId, fsAtMark, 0, 256, rd_buff, &in_count);
-    if (in_count)
-    {
+    retval = ::FSReadFork(p_ap_encode_obj->fileId, fsAtMark, 0, 256, rd_buff,
+                          &in_count);
+    if (in_count) {
 #if 0
 /*      replace(rd_buff, in_count, '\r', '\n');               */
 #endif
-/* ** may be need to do character set conversion here for localization.  **  */
-      status = to64(p_ap_encode_obj,
-                    rd_buff,
-                    in_count);
-      if (status != noErr)
-        return status;
+      /* ** may be need to do character set conversion here for localization.
+       * **  */
+      status = to64(p_ap_encode_obj, rd_buff, in_count);
+      if (status != noErr) return status;
     }
   }
 
-  if (retval == eofErr)
-  {
+  if (retval == eofErr) {
     ::FSCloseFork(p_ap_encode_obj->fileId);
     p_ap_encode_obj->fileId = 0;
 
     status = finish64(p_ap_encode_obj);
-    if (status != noErr)
-      return status;
+    if (status != noErr) return status;
 
     /* write out the boundary   */
 
-    PR_snprintf(rd_buff, sizeof(rd_buff),
-                CRLF "--%s--" CRLF CRLF,
+    PR_snprintf(rd_buff, sizeof(rd_buff), CRLF "--%s--" CRLF CRLF,
                 p_ap_encode_obj->boundary);
 
-    status = write_stream(p_ap_encode_obj, (const char*)rd_buff, strlen(rd_buff));
+    status =
+        write_stream(p_ap_encode_obj, (const char *)rd_buff, strlen(rd_buff));
 
-    if (status == noErr)
-      status = errDone;
+    if (status == noErr) status = errDone;
   }
   return status;
 }
 
 static char basis_64[] =
-   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 /*
 **  convert the stream in the inbuff to 64 format and put it in the out buff.
-**  To make the life easier, the caller will responcable of the checking of the outbuff's bundary.
+**  To make the life easier, the caller will responcable of the checking of the
+*outbuff's bundary.
 */
-static int
-to64(appledouble_encode_object* p_ap_encode_obj,
-  char  *p,
-  int   in_size)
-{
-  int   status;
+static int to64(appledouble_encode_object *p_ap_encode_obj, char *p,
+                int in_size) {
+  int status;
   int c1, c2, c3, ct;
-  unsigned char *inbuff = (unsigned char*)p;
+  unsigned char *inbuff = (unsigned char *)p;
 
-  ct = p_ap_encode_obj->ct;      /* the char count left last time. */
+  ct = p_ap_encode_obj->ct; /* the char count left last time. */
 
   /*
   **   resume the left state of the last conversion.
   */
-  switch (p_ap_encode_obj->state64)
-  {
+  switch (p_ap_encode_obj->state64) {
     case 0:
-      p_ap_encode_obj->c1 = c1 = *inbuff ++;
-      if (--in_size <= 0)
-      {
+      p_ap_encode_obj->c1 = c1 = *inbuff++;
+      if (--in_size <= 0) {
         p_ap_encode_obj->state64 = 1;
         return noErr;
       }
-      p_ap_encode_obj->c2 = c2 = *inbuff ++;
-      if (--in_size <= 0)
-      {
+      p_ap_encode_obj->c2 = c2 = *inbuff++;
+      if (--in_size <= 0) {
         p_ap_encode_obj->state64 = 2;
         return noErr;
       }
-      c3 = *inbuff ++;    --in_size;
+      c3 = *inbuff++;
+      --in_size;
       break;
     case 1:
       c1 = p_ap_encode_obj->c1;
-      p_ap_encode_obj->c2 = c2 = *inbuff ++;
-      if (--in_size <= 0)
-      {
+      p_ap_encode_obj->c2 = c2 = *inbuff++;
+      if (--in_size <= 0) {
         p_ap_encode_obj->state64 = 2;
         return noErr;
       }
-      c3 = *inbuff ++;    --in_size;
+      c3 = *inbuff++;
+      --in_size;
       break;
     case 2:
       c1 = p_ap_encode_obj->c1;
       c2 = p_ap_encode_obj->c2;
-      c3 = *inbuff ++;    --in_size;
+      c3 = *inbuff++;
+      --in_size;
       break;
   }
 
-  while (in_size >= 0)
-  {
-    status = output64chunk(p_ap_encode_obj,
-                           c1,
-                           c2,
-                           c3,
-                           0);
-    if (status != noErr)
-      return status;
-  
+  while (in_size >= 0) {
+    status = output64chunk(p_ap_encode_obj, c1, c2, c3, 0);
+    if (status != noErr) return status;
+
     ct += 4;
-    if (ct > 71)
-    {
-      status = write_stream(p_ap_encode_obj,
-                CRLF,
-                2);
-      if (status != noErr)
-        return status;
-    
+    if (ct > 71) {
+      status = write_stream(p_ap_encode_obj, CRLF, 2);
+      if (status != noErr) return status;
+
       ct = 0;
     }
 
-    if (in_size <= 0)
-    {
+    if (in_size <= 0) {
       p_ap_encode_obj->state64 = 0;
       break;
     }
 
     c1 = (int)*inbuff++;
-    if (--in_size <= 0)
-    {
+    if (--in_size <= 0) {
       p_ap_encode_obj->c1 = c1;
       p_ap_encode_obj->state64 = 1;
       break;
     }
     c2 = *inbuff++;
-    if (--in_size <= 0)
-    {
-      p_ap_encode_obj->c1    = c1;
-      p_ap_encode_obj->c2    = c2;
+    if (--in_size <= 0) {
+      p_ap_encode_obj->c1 = c1;
+      p_ap_encode_obj->c2 = c2;
       p_ap_encode_obj->state64 = 2;
       break;
     }
     c3 = *inbuff++;
     in_size--;
   }
   p_ap_encode_obj->ct = ct;
   return status;
 }
 
 /*
 ** clear the left base64 encodes.
 */
-static int
-finish64(appledouble_encode_object* p_ap_encode_obj)
-{
+static int finish64(appledouble_encode_object *p_ap_encode_obj) {
   int status;
 
-  switch (p_ap_encode_obj->state64)
-  {
+  switch (p_ap_encode_obj->state64) {
     case 0:
       break;
     case 1:
-      status = output64chunk(p_ap_encode_obj,
-                             p_ap_encode_obj->c1,
-                             0,
-                             0,
-                             2);
+      status = output64chunk(p_ap_encode_obj, p_ap_encode_obj->c1, 0, 0, 2);
       break;
     case 2:
-      status = output64chunk(p_ap_encode_obj,
-                             p_ap_encode_obj->c1,
-                             p_ap_encode_obj->c2,
-                             0,
-                             1);
+      status = output64chunk(p_ap_encode_obj, p_ap_encode_obj->c1,
+                             p_ap_encode_obj->c2, 0, 1);
       break;
   }
   status = write_stream(p_ap_encode_obj, CRLF, 2);
   p_ap_encode_obj->state64 = 0;
-  p_ap_encode_obj->ct       = 0;
+  p_ap_encode_obj->ct = 0;
   return status;
 }
 
-static int output64chunk(
-  appledouble_encode_object* p_ap_encode_obj,
-  int c1, int c2, int c3, int pads)
-{
+static int output64chunk(appledouble_encode_object *p_ap_encode_obj, int c1,
+                         int c2, int c3, int pads) {
   char tmpstr[32];
   char *p = tmpstr;
 
-  *p++ = basis_64[c1>>2];
-  *p++ = basis_64[((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)];
-  if (pads == 2)
-  {
-      *p++ = '=';
-      *p++ = '=';
+  *p++ = basis_64[c1 >> 2];
+  *p++ = basis_64[((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)];
+  if (pads == 2) {
+    *p++ = '=';
+    *p++ = '=';
+  } else if (pads) {
+    *p++ = basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)];
+    *p++ = '=';
+  } else {
+    *p++ = basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)];
+    *p++ = basis_64[c3 & 0x3F];
   }
-  else if (pads)
-  {
-      *p++ = basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)];
-      *p++ = '=';
-  }
-  else
-  {
-      *p++ = basis_64[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)];
-      *p++ = basis_64[c3 & 0x3F];
-  }
-  return write_stream(p_ap_encode_obj, (const char*) tmpstr, p-tmpstr);
+  return write_stream(p_ap_encode_obj, (const char *)tmpstr, p - tmpstr);
 }
--- a/mailnews/compose/src/nsMsgAttachment.cpp
+++ b/mailnews/compose/src/nsMsgAttachment.cpp
@@ -4,259 +4,226 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsMsgAttachment.h"
 #include "nsIFile.h"
 #include "nsNetUtil.h"
 
 NS_IMPL_ISUPPORTS(nsMsgAttachment, nsIMsgAttachment)
 
-nsMsgAttachment::nsMsgAttachment()
-{
+nsMsgAttachment::nsMsgAttachment() {
   mTemporary = false;
   mSendViaCloud = false;
   mSize = -1;
 }
 
-nsMsgAttachment::~nsMsgAttachment()
-{
-  if (mTemporary && !mSendViaCloud)
-    (void)DeleteAttachment();
+nsMsgAttachment::~nsMsgAttachment() {
+  if (mTemporary && !mSendViaCloud) (void)DeleteAttachment();
 }
 
 /* attribute wstring name; */
-NS_IMETHODIMP nsMsgAttachment::GetName(nsAString & aName)
-{
+NS_IMETHODIMP nsMsgAttachment::GetName(nsAString &aName) {
   aName = mName;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::SetName(const nsAString & aName)
-{
+NS_IMETHODIMP nsMsgAttachment::SetName(const nsAString &aName) {
   mName = aName;
   return NS_OK;
 }
 
 /* attribute string url; */
-NS_IMETHODIMP nsMsgAttachment::GetUrl(nsACString & aUrl)
-{
+NS_IMETHODIMP nsMsgAttachment::GetUrl(nsACString &aUrl) {
   aUrl = mUrl;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::SetUrl(const nsACString & aUrl)
-{
+NS_IMETHODIMP nsMsgAttachment::SetUrl(const nsACString &aUrl) {
   mUrl = aUrl;
   return NS_OK;
 }
 
 /* attribute string urlCharset; */
-NS_IMETHODIMP nsMsgAttachment::GetUrlCharset(nsACString & aUrlCharset)
-{
+NS_IMETHODIMP nsMsgAttachment::GetUrlCharset(nsACString &aUrlCharset) {
   aUrlCharset = mUrlCharset;
   return NS_OK;
 }
-NS_IMETHODIMP nsMsgAttachment::SetUrlCharset(const nsACString & aUrlCharset)
-{
+NS_IMETHODIMP nsMsgAttachment::SetUrlCharset(const nsACString &aUrlCharset) {
   mUrlCharset = aUrlCharset;
   return NS_OK;
 }
 
 /* attribute boolean temporary; */
-NS_IMETHODIMP nsMsgAttachment::GetTemporary(bool *aTemporary)
-{
+NS_IMETHODIMP nsMsgAttachment::GetTemporary(bool *aTemporary) {
   NS_ENSURE_ARG_POINTER(aTemporary);
 
   *aTemporary = mTemporary;
   return NS_OK;
 }
-NS_IMETHODIMP nsMsgAttachment::SetTemporary(bool aTemporary)
-{
+NS_IMETHODIMP nsMsgAttachment::SetTemporary(bool aTemporary) {
   mTemporary = aTemporary;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::GetSendViaCloud(bool *aSendViaCloud)
-{
+NS_IMETHODIMP nsMsgAttachment::GetSendViaCloud(bool *aSendViaCloud) {
   NS_ENSURE_ARG_POINTER(aSendViaCloud);
 
   *aSendViaCloud = mSendViaCloud;
   return NS_OK;
 }
-NS_IMETHODIMP nsMsgAttachment::SetSendViaCloud(bool aSendViaCloud)
-{
+NS_IMETHODIMP nsMsgAttachment::SetSendViaCloud(bool aSendViaCloud) {
   mSendViaCloud = aSendViaCloud;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::SetHtmlAnnotation(const nsAString &aAnnotation)
-{
+NS_IMETHODIMP nsMsgAttachment::SetHtmlAnnotation(const nsAString &aAnnotation) {
   mHtmlAnnotation = aAnnotation;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::GetHtmlAnnotation(nsAString &aAnnotation)
-{
+NS_IMETHODIMP nsMsgAttachment::GetHtmlAnnotation(nsAString &aAnnotation) {
   aAnnotation = mHtmlAnnotation;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAttachment::SetCloudFileAccountKey(const nsACString &aCloudFileAccountKey)
-{
+nsMsgAttachment::SetCloudFileAccountKey(
+    const nsACString &aCloudFileAccountKey) {
   mCloudFileAccountKey = aCloudFileAccountKey;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAttachment::GetCloudFileAccountKey(nsACString &aCloudFileAccountKey)
-{
+nsMsgAttachment::GetCloudFileAccountKey(nsACString &aCloudFileAccountKey) {
   aCloudFileAccountKey = mCloudFileAccountKey;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::GetContentLocation(nsACString &aContentLocation)
-{
+NS_IMETHODIMP nsMsgAttachment::GetContentLocation(
+    nsACString &aContentLocation) {
   aContentLocation = mContentLocation;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::SetContentLocation(const nsACString &aContentLocation)
-{
+NS_IMETHODIMP nsMsgAttachment::SetContentLocation(
+    const nsACString &aContentLocation) {
   mContentLocation = aContentLocation;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::GetContentType(char * *aContentType)
-{
+NS_IMETHODIMP nsMsgAttachment::GetContentType(char **aContentType) {
   NS_ENSURE_ARG_POINTER(aContentType);
 
   *aContentType = ToNewCString(mContentType);
   return (*aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
 }
 
-NS_IMETHODIMP nsMsgAttachment::SetContentType(const char * aContentType)
-{
+NS_IMETHODIMP nsMsgAttachment::SetContentType(const char *aContentType) {
   mContentType = aContentType;
   /* a full content type could also contains parameters but we need to
      keep only the content type alone. Therefore we need to cleanup it.
   */
   int32_t offset = mContentType.FindChar(';');
-  if (offset >= 0)
-    mContentType.SetLength(offset);
+  if (offset >= 0) mContentType.SetLength(offset);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachment::GetContentTypeParam(char * *aContentTypeParam)
-{
+NS_IMETHODIMP nsMsgAttachment::GetContentTypeParam(char **aContentTypeParam) {
   NS_ENSURE_ARG_POINTER(aContentTypeParam);
 
   *aContentTypeParam = ToNewCString(mContentTypeParam);
   return (*aContentTypeParam ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
 }
 
-NS_IMETHODIMP nsMsgAttachment::SetContentTypeParam(const char * aContentTypeParam)
-{
+NS_IMETHODIMP nsMsgAttachment::SetContentTypeParam(
+    const char *aContentTypeParam) {
   if (aContentTypeParam)
     while (*aContentTypeParam == ';' || *aContentTypeParam == ' ')
-      aContentTypeParam ++;
+      aContentTypeParam++;
   mContentTypeParam = aContentTypeParam;
 
   return NS_OK;
 }
 
 /* attribute string charset; */
-NS_IMETHODIMP nsMsgAttachment::GetCharset(char * *aCharset)
-{
+NS_IMETHODIMP nsMsgAttachment::GetCharset(char **aCharset) {
   NS_ENSURE_ARG_POINTER(aCharset);
 
   *aCharset = ToNewCString(mCharset);
   return (*aCharset ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
 }
-NS_IMETHODIMP nsMsgAttachment::SetCharset(const char * aCharset)
-{
+NS_IMETHODIMP nsMsgAttachment::SetCharset(const char *aCharset) {
   mCharset = aCharset;
   return NS_OK;
 }
 
 /* attribute string macType; */
-NS_IMETHODIMP nsMsgAttachment::GetMacType(char * *aMacType)
-{
+NS_IMETHODIMP nsMsgAttachment::GetMacType(char **aMacType) {
   NS_ENSURE_ARG_POINTER(aMacType);
 
   *aMacType = ToNewCString(mMacType);
   return (*aMacType ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
 }
-NS_IMETHODIMP nsMsgAttachment::SetMacType(const char * aMacType)
-{
+NS_IMETHODIMP nsMsgAttachment::SetMacType(const char *aMacType) {
   mMacType = aMacType;
   return NS_OK;
 }
 
 /* attribute string macCreator; */
-NS_IMETHODIMP nsMsgAttachment::GetMacCreator(char * *aMacCreator)
-{
+NS_IMETHODIMP nsMsgAttachment::GetMacCreator(char **aMacCreator) {
   NS_ENSURE_ARG_POINTER(aMacCreator);
 
   *aMacCreator = ToNewCString(mMacCreator);
   return (*aMacCreator ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
 }
-NS_IMETHODIMP nsMsgAttachment::SetMacCreator(const char * aMacCreator)
-{
+NS_IMETHODIMP nsMsgAttachment::SetMacCreator(const char *aMacCreator) {
   mMacCreator = aMacCreator;
   return NS_OK;
 }
 
 /* attribute int64_t size; */
-NS_IMETHODIMP nsMsgAttachment::GetSize(int64_t *aSize)
-{
+NS_IMETHODIMP nsMsgAttachment::GetSize(int64_t *aSize) {
   NS_ENSURE_ARG_POINTER(aSize);
 
   *aSize = mSize;
   return NS_OK;
 }
-NS_IMETHODIMP nsMsgAttachment::SetSize(int64_t aSize)
-{
+NS_IMETHODIMP nsMsgAttachment::SetSize(int64_t aSize) {
   mSize = aSize;
   return NS_OK;
 }
 
 /* boolean equalsUrl (in nsIMsgAttachment attachment); */
-NS_IMETHODIMP nsMsgAttachment::EqualsUrl(nsIMsgAttachment *attachment, bool *_retval)
-{
+NS_IMETHODIMP nsMsgAttachment::EqualsUrl(nsIMsgAttachment *attachment,
+                                         bool *_retval) {
   NS_ENSURE_ARG_POINTER(attachment);
   NS_ENSURE_ARG_POINTER(_retval);
 
   nsAutoCString url;
   attachment->GetUrl(url);
 
   *_retval = mUrl.Equals(url);
   return NS_OK;
 }
 
-
-nsresult nsMsgAttachment::DeleteAttachment()
-{
+nsresult nsMsgAttachment::DeleteAttachment() {
   nsresult rv;
   bool isAFile = false;
 
   nsCOMPtr<nsIFile> urlFile;
   rv = NS_GetFileFromURLSpec(mUrl, getter_AddRefs(urlFile));
   NS_ASSERTION(NS_SUCCEEDED(rv), "Can't nsIFile from URL string");
-  if (NS_SUCCEEDED(rv))
-  {
+  if (NS_SUCCEEDED(rv)) {
     bool bExists = false;
     rv = urlFile->Exists(&bExists);
     NS_ASSERTION(NS_SUCCEEDED(rv), "Exists() call failed!");
-    if (NS_SUCCEEDED(rv) && bExists)
-    {
+    if (NS_SUCCEEDED(rv) && bExists) {
       rv = urlFile->IsFile(&isAFile);
       NS_ASSERTION(NS_SUCCEEDED(rv), "IsFile() call failed!");
     }
   }
 
   // remove it if it's a valid file
-  if (isAFile)
-    rv = urlFile->Remove(false);
+  if (isAFile) rv = urlFile->Remove(false);
 
   return rv;
 }
--- a/mailnews/compose/src/nsMsgAttachment.h
+++ b/mailnews/compose/src/nsMsgAttachment.h
@@ -4,38 +4,36 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _nsMsgAttachment_H_
 #define _nsMsgAttachment_H_
 
 #include "nsIMsgAttachment.h"
 #include "nsString.h"
 
-class nsMsgAttachment : public nsIMsgAttachment
-{
-public:
+class nsMsgAttachment : public nsIMsgAttachment {
+ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMSGATTACHMENT
 
   nsMsgAttachment();
 
-private:
+ private:
   virtual ~nsMsgAttachment();
   nsresult DeleteAttachment();
 
-  nsString    mName;
-  nsCString   mUrl;
-  nsCString   mUrlCharset;
-  bool        mTemporary;
-  bool        mSendViaCloud;
-  nsCString   mCloudFileAccountKey;
-  nsCString   mContentLocation;
-  nsCString   mContentType;
-  nsCString   mContentTypeParam;
-  nsCString   mCharset;
-  nsCString   mMacType;
-  nsCString   mMacCreator;
-  nsString    mHtmlAnnotation;
-  int64_t     mSize;
+  nsString mName;
+  nsCString mUrl;
+  nsCString mUrlCharset;
+  bool mTemporary;
+  bool mSendViaCloud;
+  nsCString mCloudFileAccountKey;
+  nsCString mContentLocation;
+  nsCString mContentType;
+  nsCString mContentTypeParam;
+  nsCString mCharset;
+  nsCString mMacType;
+  nsCString mMacCreator;
+  nsString mHtmlAnnotation;
+  int64_t mSize;
 };
 
-
 #endif /* _nsMsgAttachment_H_ */
--- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp
+++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp
@@ -38,367 +38,314 @@
 #include "nsIPrincipal.h"
 #include "nsIURIMutator.h"
 
 ///////////////////////////////////////////////////////////////////////////
 // Mac Specific Attachment Handling for AppleDouble Encoded Files
 ///////////////////////////////////////////////////////////////////////////
 #ifdef XP_MACOSX
 
-#define AD_WORKING_BUFF_SIZE FILE_IO_BUFFER_SIZE
+#  define AD_WORKING_BUFF_SIZE FILE_IO_BUFFER_SIZE
 
-extern void         MacGetFileType(nsIFile *fs, bool *useDefault, char **type, char **encoding);
+extern void MacGetFileType(nsIFile *fs, bool *useDefault, char **type,
+                           char **encoding);
 
-#include "nsILocalFileMac.h"
+#  include "nsILocalFileMac.h"
 
 /* static */
-nsresult nsSimpleZipper::Zip(nsIFile *aInputFile, nsIFile *aOutputFile)
-{
+nsresult nsSimpleZipper::Zip(nsIFile *aInputFile, nsIFile *aOutputFile) {
   // create zipwriter object
   nsresult rv;
-  nsCOMPtr<nsIZipWriter> zipWriter = do_CreateInstance("@mozilla.org/zipwriter;1", &rv);
+  nsCOMPtr<nsIZipWriter> zipWriter =
+      do_CreateInstance("@mozilla.org/zipwriter;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = zipWriter->Open(aOutputFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = AddToZip(zipWriter, aInputFile, EmptyCString());
   NS_ENSURE_SUCCESS(rv, rv);
 
   // we're done.
   zipWriter->Close();
   return rv;
 }
 
 /* static */
-nsresult nsSimpleZipper::AddToZip(nsIZipWriter *aZipWriter,
-                                  nsIFile *aFile,
-                                  const nsACString &aPath)
-{
+nsresult nsSimpleZipper::AddToZip(nsIZipWriter *aZipWriter, nsIFile *aFile,
+                                  const nsACString &aPath) {
   // find out the path this file/dir should have in the zip
   nsCString leafName;
   aFile->GetNativeLeafName(leafName);
   nsCString currentPath(aPath);
   currentPath += leafName;
 
   bool isDirectory;
   aFile->IsDirectory(&isDirectory);
   // append slash for a directory entry
-  if (isDirectory)
-    currentPath.Append('/');
+  if (isDirectory) currentPath.Append('/');
 
   // add the file or directory entry to the zip
-  nsresult rv = aZipWriter->AddEntryFile(currentPath, nsIZipWriter::COMPRESSION_DEFAULT, aFile, false);
+  nsresult rv = aZipWriter->AddEntryFile(
+      currentPath, nsIZipWriter::COMPRESSION_DEFAULT, aFile, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // if it's a directory, add all its contents too
   if (isDirectory) {
     nsCOMPtr<nsIDirectoryEnumerator> dirEnumerator;
     nsresult rv = aFile->GetDirectoryEntries(getter_AddRefs(dirEnumerator));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIFile> currentFile;
-    while (NS_SUCCEEDED(dirEnumerator->GetNextFile(getter_AddRefs(currentFile))) && currentFile) {
+    while (
+        NS_SUCCEEDED(dirEnumerator->GetNextFile(getter_AddRefs(currentFile))) &&
+        currentFile) {
       rv = AddToZip(aZipWriter, currentFile, currentPath);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   return NS_OK;
 }
-#endif // XP_MACOSX
+#endif  // XP_MACOSX
 
 //
 // Class implementation...
 //
-nsMsgAttachmentHandler::nsMsgAttachmentHandler() :
-  mRequest(nullptr),
-  mCompFields(nullptr),   // Message composition fields for the sender
-  m_bogus_attachment(false),
-  m_done(false),
-  m_already_encoded_p(false),
-  m_decrypted_p(false),
-  mDeleteFile(false),
-  mMHTMLPart(false),
-  mPartUserOmissionOverride(false),
-  mMainBody(false),
-  mSendViaCloud(false),
-  mNodeIndex(-1),
-  // For analyzing the attachment file...
-  m_size(0),
-  m_unprintable_count(0),
-  m_highbit_count(0),
-  m_ctl_count(0),
-  m_null_count(0),
-  m_have_cr(0),
-  m_have_lf(0),
-  m_have_crlf(0),
-  m_prev_char_was_cr(false),
-  m_current_column(0),
-  m_max_column(0),
-  m_lines(0),
-  m_file_analyzed(false),
+nsMsgAttachmentHandler::nsMsgAttachmentHandler()
+    : mRequest(nullptr),
+      mCompFields(nullptr),  // Message composition fields for the sender
+      m_bogus_attachment(false),
+      m_done(false),
+      m_already_encoded_p(false),
+      m_decrypted_p(false),
+      mDeleteFile(false),
+      mMHTMLPart(false),
+      mPartUserOmissionOverride(false),
+      mMainBody(false),
+      mSendViaCloud(false),
+      mNodeIndex(-1),
+      // For analyzing the attachment file...
+      m_size(0),
+      m_unprintable_count(0),
+      m_highbit_count(0),
+      m_ctl_count(0),
+      m_null_count(0),
+      m_have_cr(0),
+      m_have_lf(0),
+      m_have_crlf(0),
+      m_prev_char_was_cr(false),
+      m_current_column(0),
+      m_max_column(0),
+      m_lines(0),
+      m_file_analyzed(false),
 
-  // Mime
-  m_encoder(nullptr)
-{
-}
+      // Mime
+      m_encoder(nullptr) {}
 
-nsMsgAttachmentHandler::~nsMsgAttachmentHandler()
-{
-  if (mTmpFile && mDeleteFile)
-    mTmpFile->Remove(false);
+nsMsgAttachmentHandler::~nsMsgAttachmentHandler() {
+  if (mTmpFile && mDeleteFile) mTmpFile->Remove(false);
 
-  if (mOutFile)
-    mOutFile->Close();
+  if (mOutFile) mOutFile->Close();
 
   CleanupTempFile();
 }
 
 NS_IMPL_ISUPPORTS(nsMsgAttachmentHandler, nsIMsgAttachmentHandler)
 
 // nsIMsgAttachmentHandler implementation.
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetType(nsACString& aType)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetType(nsACString &aType) {
   aType.Assign(m_type);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetUri(nsACString& aUri)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetUri(nsACString &aUri) {
   nsAutoCString turl;
-  if (!mURL)
-  {
-    if (!m_uri.IsEmpty())
-      turl = m_uri;
-  }
-  else
-  {
+  if (!mURL) {
+    if (!m_uri.IsEmpty()) turl = m_uri;
+  } else {
     nsresult rv = mURL->GetSpec(turl);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   aUri.Assign(turl);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetTmpFile(nsIFile **aTmpFile)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetTmpFile(nsIFile **aTmpFile) {
   NS_ENSURE_ARG_POINTER(aTmpFile);
-  if (!mTmpFile)
-    return NS_ERROR_FAILURE;
+  if (!mTmpFile) return NS_ERROR_FAILURE;
   NS_ADDREF(*aTmpFile = mTmpFile);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetName(nsACString& aName)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetName(nsACString &aName) {
   aName.Assign(m_realName);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetSize(uint32_t *aSize)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetSize(uint32_t *aSize) {
   NS_ENSURE_ARG_POINTER(aSize);
   *aSize = m_size;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetContentId(nsACString& aContentId)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetContentId(nsACString &aContentId) {
   aContentId.Assign(m_contentId);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetSendViaCloud(bool* aSendViaCloud)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetSendViaCloud(bool *aSendViaCloud) {
   NS_ENSURE_ARG_POINTER(aSendViaCloud);
   *aSendViaCloud = mSendViaCloud;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetCharset(nsACString& aCharset)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetCharset(nsACString &aCharset) {
   aCharset.Assign(m_charset);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetEncoding(nsACString& aEncoding)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetEncoding(nsACString &aEncoding) {
   aEncoding.Assign(m_encoding);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAttachmentHandler::GetAlreadyEncoded(bool* aAlreadyEncoded)
-{
+NS_IMETHODIMP nsMsgAttachmentHandler::GetAlreadyEncoded(bool *aAlreadyEncoded) {
   NS_ENSURE_ARG_POINTER(aAlreadyEncoded);
   *aAlreadyEncoded = m_already_encoded_p;
   return NS_OK;
 }
 
 // Local methods.
 
-void
-nsMsgAttachmentHandler::CleanupTempFile()
-{
+void nsMsgAttachmentHandler::CleanupTempFile() {
 #ifdef XP_MACOSX
   if (mEncodedWorkingFile) {
     mEncodedWorkingFile->Remove(false);
     mEncodedWorkingFile = nullptr;
   }
-#endif // XP_MACOSX
+#endif  // XP_MACOSX
 }
 
-void
-nsMsgAttachmentHandler::AnalyzeDataChunk(const char *chunk, int32_t length)
-{
-  unsigned char *s = (unsigned char *) chunk;
+void nsMsgAttachmentHandler::AnalyzeDataChunk(const char *chunk,
+                                              int32_t length) {
+  unsigned char *s = (unsigned char *)chunk;
   unsigned char *end = s + length;
-  for (; s < end; s++)
-  {
-    if (*s > 126)
-    {
+  for (; s < end; s++) {
+    if (*s > 126) {
       m_highbit_count++;
       m_unprintable_count++;
-    }
-    else if (*s < ' ' && *s != '\t' && *s != '\r' && *s != '\n')
-    {
+    } else if (*s < ' ' && *s != '\t' && *s != '\r' && *s != '\n') {
       m_unprintable_count++;
       m_ctl_count++;
-      if (*s == 0)
-        m_null_count++;
+      if (*s == 0) m_null_count++;
     }
 
-    if (*s == '\r' || *s == '\n')
-    {
-      if (*s == '\r')
-      {
+    if (*s == '\r' || *s == '\n') {
+      if (*s == '\r') {
         if (m_prev_char_was_cr)
           m_have_cr = 1;
         else
           m_prev_char_was_cr = true;
-      }
-      else
-      {
-        if (m_prev_char_was_cr)
-        {
-          if (m_current_column == 0)
-          {
+      } else {
+        if (m_prev_char_was_cr) {
+          if (m_current_column == 0) {
             m_have_crlf = 1;
             m_lines--;
-          }
-          else
+          } else
             m_have_cr = m_have_lf = 1;
           m_prev_char_was_cr = false;
-        }
-        else
+        } else
           m_have_lf = 1;
       }
-      if (m_max_column < m_current_column)
-        m_max_column = m_current_column;
+      if (m_max_column < m_current_column) m_max_column = m_current_column;
       m_current_column = 0;
       m_lines++;
-    }
-    else
-    {
+    } else {
       m_current_column++;
     }
   }
   // Check one last time for the last line. This is also important if there
   // is only one line that doesn't terminate in \n.
-  if (m_max_column < m_current_column)
-    m_max_column = m_current_column;
+  if (m_max_column < m_current_column) m_max_column = m_current_column;
 }
 
-void
-nsMsgAttachmentHandler::AnalyzeSnarfedFile(void)
-{
+void nsMsgAttachmentHandler::AnalyzeSnarfedFile(void) {
   char chunk[1024];
   uint32_t numRead = 0;
 
-  if (m_file_analyzed)
-    return;
+  if (m_file_analyzed) return;
 
-  if (mTmpFile)
-  {
+  if (mTmpFile) {
     int64_t fileSize;
     mTmpFile->GetFileSize(&fileSize);
-    m_size = (uint32_t) fileSize;
-    nsCOMPtr <nsIInputStream> inputFile;
-    nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputFile), mTmpFile);
-    if (NS_FAILED(rv))
-      return;
+    m_size = (uint32_t)fileSize;
+    nsCOMPtr<nsIInputStream> inputFile;
+    nsresult rv =
+        NS_NewLocalFileInputStream(getter_AddRefs(inputFile), mTmpFile);
+    if (NS_FAILED(rv)) return;
     {
-      do
-      {
+      do {
         rv = inputFile->Read(chunk, sizeof(chunk), &numRead);
-        if (numRead)
-          AnalyzeDataChunk(chunk, numRead);
-      }
-      while (numRead && NS_SUCCEEDED(rv));
-      if (m_prev_char_was_cr)
-        m_have_cr = 1;
+        if (numRead) AnalyzeDataChunk(chunk, numRead);
+      } while (numRead && NS_SUCCEEDED(rv));
+      if (m_prev_char_was_cr) m_have_cr = 1;
 
       inputFile->Close();
       m_file_analyzed = true;
     }
   }
 }
 
 //
 // Given a content-type and some info about the contents of the document,
 // decide what encoding it should have.
 //
-nsresult
-nsMsgAttachmentHandler::PickEncoding(const char *charset, nsIMsgSend *mime_delivery_state)
-{
+nsresult nsMsgAttachmentHandler::PickEncoding(const char *charset,
+                                              nsIMsgSend *mime_delivery_state) {
   nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
 
   bool needsB64 = false;
   bool forceB64 = false;
   bool isUsingQP = false;
 
-  if (mSendViaCloud)
-  {
+  if (mSendViaCloud) {
     m_encoding = ENCODING_7BIT;
     return NS_OK;
   }
-  if (m_already_encoded_p)
-    goto DONE;
+  if (m_already_encoded_p) goto DONE;
 
   AnalyzeSnarfedFile();
 
   // Allow users to override our percentage-wise guess on whether
   // the file is text or binary.
   if (pPrefBranch)
-    pPrefBranch->GetBoolPref ("mail.file_attach_binary", &forceB64);
+    pPrefBranch->GetBoolPref("mail.file_attach_binary", &forceB64);
 
   // If the content-type is "image/" or something else known to be binary or
   // several flavors of newlines are present, use base64 unless we're attaching
   // a message (so that we don't get confused by newline conversions).
   if (!mMainBody &&
       (forceB64 || mime_type_requires_b64_p(m_type.get()) ||
-                   m_have_cr + m_have_lf + m_have_crlf != 1) &&
-      !m_type.LowerCaseEqualsLiteral(MESSAGE_RFC822))
-  {
+       m_have_cr + m_have_lf + m_have_crlf != 1) &&
+      !m_type.LowerCaseEqualsLiteral(MESSAGE_RFC822)) {
     needsB64 = true;
-  }
-  else
-  {
+  } else {
     // Otherwise, we need to pick an encoding based on the contents of the
     // document.
     bool encode_p;
     bool force_p = false;
 
     // Force quoted-printable if the sender does not allow conversion to 7bit.
     if (mCompFields) {
-      if (mCompFields->GetForceMsgEncoding())
-        force_p = true;
+      if (mCompFields->GetForceMsgEncoding()) force_p = true;
     } else if (mime_delivery_state) {
-      if (((nsMsgComposeAndSend *)mime_delivery_state)->mCompFields->GetForceMsgEncoding()) {
+      if (((nsMsgComposeAndSend *)mime_delivery_state)
+              ->mCompFields->GetForceMsgEncoding()) {
         force_p = true;
       }
     }
 
     if (force_p || (m_max_column > LINELENGTH_ENCODING_THRESHOLD)) {
       encode_p = true;
     } else if (UseQuotedPrintable() && m_unprintable_count) {
       encode_p = true;
@@ -409,83 +356,77 @@ nsMsgAttachmentHandler::PickEncoding(con
     } else {
       encode_p = false;
     }
 
     // MIME requires a special case that these types never be encoded.
     if (StringBeginsWith(m_type, NS_LITERAL_CSTRING("message"),
                          nsCaseInsensitiveCStringComparator()) ||
         StringBeginsWith(m_type, NS_LITERAL_CSTRING("multipart"),
-                         nsCaseInsensitiveCStringComparator()))
-    {
+                         nsCaseInsensitiveCStringComparator())) {
       encode_p = false;
       if (m_desiredType.LowerCaseEqualsLiteral(TEXT_PLAIN))
         m_desiredType.Truncate();
     }
 
-    // If the Mail charset is multibyte, we force it to use Base64 for attachments.
+    // If the Mail charset is multibyte, we force it to use Base64 for
+    // attachments.
     if ((!mMainBody && charset && nsMsgI18Nmultibyte_charset(charset)) &&
         (m_type.LowerCaseEqualsLiteral(TEXT_HTML) ||
          m_type.LowerCaseEqualsLiteral(TEXT_MDL) ||
          m_type.LowerCaseEqualsLiteral(TEXT_PLAIN) ||
          m_type.LowerCaseEqualsLiteral(TEXT_RICHTEXT) ||
          m_type.LowerCaseEqualsLiteral(TEXT_ENRICHED) ||
          m_type.LowerCaseEqualsLiteral(TEXT_VCARD) ||
-         m_type.LowerCaseEqualsLiteral(APPLICATION_DIRECTORY) || /* text/x-vcard synonym */
+         m_type.LowerCaseEqualsLiteral(
+             APPLICATION_DIRECTORY) || /* text/x-vcard synonym */
          m_type.LowerCaseEqualsLiteral(TEXT_CSS) ||
          m_type.LowerCaseEqualsLiteral(TEXT_JSSS))) {
       needsB64 = true;
     } else if (charset && nsMsgI18Nstateful_charset(charset)) {
       m_encoding = ENCODING_7BIT;
-    } else if (encode_p &&
-      m_unprintable_count > (m_size / 10)) {
+    } else if (encode_p && m_unprintable_count > (m_size / 10)) {
       // If the document contains more than 10% unprintable characters,
       // then that seems like a good candidate for base64 instead of
       // quoted-printable.
       needsB64 = true;
     } else if (encode_p) {
       m_encoding = ENCODING_QUOTED_PRINTABLE;
       isUsingQP = true;
     } else if (m_highbit_count > 0) {
       m_encoding = ENCODING_8BIT;
     } else {
       m_encoding = ENCODING_7BIT;
     }
   }
 
   // Always base64 binary data.
-  if (needsB64)
-    m_encoding = ENCODING_BASE64;
+  if (needsB64) m_encoding = ENCODING_BASE64;
 
   // According to RFC 821 we must always have lines shorter than 998 bytes.
   // To encode "long lines" use a CTE that will transmit shorter lines.
   // Switch to base64 if we are not already using "quoted printable".
 
   // We don't do this for message/rfc822 attachments, since we can't
   // change the original Content-Transfer-Encoding of the message we're
   // attaching. We rely on the original message complying with RFC 821,
   // if it doesn't we won't either. Not ideal.
   if (!m_type.LowerCaseEqualsLiteral(MESSAGE_RFC822) &&
       m_max_column > LINELENGTH_ENCODING_THRESHOLD && !isUsingQP)
     m_encoding = ENCODING_BASE64;
 
   // Now that we've picked an encoding, initialize the filter.
   NS_ASSERTION(!m_encoder, "not-null m_encoder");
-  if (m_encoding.LowerCaseEqualsLiteral(ENCODING_BASE64))
-  {
+  if (m_encoding.LowerCaseEqualsLiteral(ENCODING_BASE64)) {
     m_encoder = MimeEncoder::GetBase64Encoder(mime_encoder_output_fn,
-      mime_delivery_state);
-  }
-  else if (m_encoding.LowerCaseEqualsLiteral(ENCODING_QUOTED_PRINTABLE))
-  {
-    m_encoder = MimeEncoder::GetQPEncoder(mime_encoder_output_fn,
-      mime_delivery_state);
-  }
-  else
-  {
+                                              mime_delivery_state);
+  } else if (m_encoding.LowerCaseEqualsLiteral(ENCODING_QUOTED_PRINTABLE)) {
+    m_encoder =
+        MimeEncoder::GetQPEncoder(mime_encoder_output_fn, mime_delivery_state);
+  } else {
     m_encoder = nullptr;
   }
 
   /*
     Do some cleanup for documents with unknown content type.
     There are two issues: how they look to MIME users, and how they look to
     non-MIME users.
 
@@ -501,262 +442,234 @@ nsMsgAttachmentHandler::PickEncoding(con
     bad charset things happen as well.
 
     So, the heuristic we use is, if the type is unknown, then the type is
     set to application/octet-stream for data which needs base64 (binary data)
     and is set to text/plain for data which didn't need base64 (unencoded or
     lightly encoded data.)
   */
 DONE:
-  if (m_type.IsEmpty() || m_type.LowerCaseEqualsLiteral(UNKNOWN_CONTENT_TYPE))
-  {
+  if (m_type.IsEmpty() || m_type.LowerCaseEqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
     if (m_already_encoded_p)
       m_type = APPLICATION_OCTET_STREAM;
     else if (m_encoding.LowerCaseEqualsLiteral(ENCODING_BASE64) ||
              m_encoding.LowerCaseEqualsLiteral(ENCODING_UUENCODE))
       m_type = APPLICATION_OCTET_STREAM;
     else
       m_type = TEXT_PLAIN;
   }
   return NS_OK;
 }
 
-nsresult
-nsMsgAttachmentHandler::PickCharset()
-{
+nsresult nsMsgAttachmentHandler::PickCharset() {
   if (!m_charset.IsEmpty() || !m_type.LowerCaseEqualsLiteral(TEXT_PLAIN))
     return NS_OK;
 
-  if (!mTmpFile)
-    return NS_OK;
+  if (!mTmpFile) return NS_OK;
 
   return MsgDetectCharsetFromFile(mTmpFile, m_charset);
 }
 
-static nsresult
-FetcherURLDoneCallback(nsresult aStatus,
-                       const nsACString &aContentType,
-                       const nsACString &aCharset,
-                       int32_t totalSize,
-                       const char16_t* aMsg, void *tagData)
-{
-  nsMsgAttachmentHandler *ma = (nsMsgAttachmentHandler *) tagData;
+static nsresult FetcherURLDoneCallback(nsresult aStatus,
+                                       const nsACString &aContentType,
+                                       const nsACString &aCharset,
+                                       int32_t totalSize, const char16_t *aMsg,
+                                       void *tagData) {
+  nsMsgAttachmentHandler *ma = (nsMsgAttachmentHandler *)tagData;
   NS_ASSERTION(ma != nullptr, "not-null mime attachment");
 
-  if (ma != nullptr)
-  {
+  if (ma != nullptr) {
     ma->m_size = totalSize;
-    if (!aContentType.IsEmpty())
-    {
+    if (!aContentType.IsEmpty()) {
 #ifdef XP_MACOSX
-      //Do not change the type if we are dealing with an encoded (e.g., appledouble or zip) file
+      // Do not change the type if we are dealing with an encoded (e.g.,
+      // appledouble or zip) file
       if (!ma->mEncodedWorkingFile)
 #else
-        // can't send appledouble on non-macs
+      // can't send appledouble on non-macs
       if (!aContentType.EqualsLiteral("multipart/appledouble"))
 #endif
         ma->m_type = aContentType;
     }
 
-    if (!aCharset.IsEmpty())
-      ma->m_charset = aCharset;
+    if (!aCharset.IsEmpty()) ma->m_charset = aCharset;
 
     return ma->UrlExit(aStatus, aMsg);
-  }
-  else
+  } else
     return NS_OK;
 }
 
-nsresult
-nsMsgAttachmentHandler::SnarfMsgAttachment(nsMsgCompFields *compFields)
-{
+nsresult nsMsgAttachmentHandler::SnarfMsgAttachment(
+    nsMsgCompFields *compFields) {
   nsresult rv = NS_ERROR_INVALID_ARG;
-  nsCOMPtr <nsIMsgMessageService> messageService;
+  nsCOMPtr<nsIMsgMessageService> messageService;
 
-  if (m_uri.Find("-message:", /* ignoreCase = */ true) != -1)
-  {
-    nsCOMPtr <nsIFile> tmpFile;
+  if (m_uri.Find("-message:", /* ignoreCase = */ true) != -1) {
+    nsCOMPtr<nsIFile> tmpFile;
     rv = nsMsgCreateTempFile("nsmail.tmp", getter_AddRefs(tmpFile));
     NS_ENSURE_SUCCESS(rv, rv);
     mTmpFile = tmpFile;
     mDeleteFile = true;
     mCompFields = compFields;
     m_type = MESSAGE_RFC822;
     m_overrideType = MESSAGE_RFC822;
-    if (!mTmpFile)
-    {
+    if (!mTmpFile) {
       rv = NS_ERROR_FAILURE;
       goto done;
     }
 
-    rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mOutFile), mTmpFile, -1, 00600);
-    if (NS_FAILED(rv) || !mOutFile)
-    {
-      if (m_mime_delivery_state)
-      {
+    rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mOutFile), mTmpFile, -1,
+                                        00600);
+    if (NS_FAILED(rv) || !mOutFile) {
+      if (m_mime_delivery_state) {
         nsCOMPtr<nsIMsgSendReport> sendReport;
         m_mime_delivery_state->GetSendReport(getter_AddRefs(sendReport));
-        if (sendReport)
-        {
+        if (sendReport) {
           nsAutoString error_msg;
           nsMsgBuildMessageWithTmpFile(mTmpFile, error_msg);
-          sendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), false);
+          sendReport->SetMessage(nsIMsgSendReport::process_Current,
+                                 error_msg.get(), false);
         }
       }
-      rv =  NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
+      rv = NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
       goto done;
     }
 
-    nsCOMPtr<nsIURLFetcher> fetcher = do_CreateInstance(NS_URLFETCHER_CONTRACTID, &rv);
-    if (NS_FAILED(rv) || !fetcher)
-    {
-      if (NS_SUCCEEDED(rv))
-        rv =  NS_ERROR_UNEXPECTED;
+    nsCOMPtr<nsIURLFetcher> fetcher =
+        do_CreateInstance(NS_URLFETCHER_CONTRACTID, &rv);
+    if (NS_FAILED(rv) || !fetcher) {
+      if (NS_SUCCEEDED(rv)) rv = NS_ERROR_UNEXPECTED;
       goto done;
     }
 
     rv = fetcher->Initialize(mTmpFile, mOutFile, FetcherURLDoneCallback, this);
     rv = GetMessageServiceFromURI(m_uri, getter_AddRefs(messageService));
-    if (NS_SUCCEEDED(rv) && messageService)
-    {
+    if (NS_SUCCEEDED(rv) && messageService) {
       nsAutoCString uri(m_uri);
       uri += (uri.FindChar('?') == kNotFound) ? '?' : '&';
       uri.AppendLiteral("fetchCompleteMessage=true");
       nsCOMPtr<nsIStreamListener> strListener = do_QueryInterface(fetcher);
 
-      // initialize a new stream converter, that uses the strListener as its input
-      // obtain the input stream listener from the new converter,
-      // and pass the converter's input stream listener to DisplayMessage
+      // initialize a new stream converter, that uses the strListener as its
+      // input obtain the input stream listener from the new converter, and pass
+      // the converter's input stream listener to DisplayMessage
 
-      m_mime_parser = do_CreateInstance(NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID, &rv);
-      if (NS_FAILED(rv))
-        goto done;
+      m_mime_parser =
+          do_CreateInstance(NS_MAILNEWS_MIME_STREAM_CONVERTER_CONTRACTID, &rv);
+      if (NS_FAILED(rv)) goto done;
 
       // Set us as the output stream for HTML data from libmime...
-      nsCOMPtr<nsIMimeStreamConverter> mimeConverter = do_QueryInterface(m_mime_parser);
-      if (mimeConverter)
-      {
+      nsCOMPtr<nsIMimeStreamConverter> mimeConverter =
+          do_QueryInterface(m_mime_parser);
+      if (mimeConverter) {
         mimeConverter->SetMimeOutputType(nsMimeOutput::nsMimeMessageDecrypt);
         mimeConverter->SetForwardInline(false);
         mimeConverter->SetIdentity(nullptr);
         mimeConverter->SetOriginalMsgURI(nullptr);
       }
 
       nsCOMPtr<nsIURI> aURL;
-      rv = messageService->GetUrlForUri(uri.get(), getter_AddRefs(aURL), nullptr);
-      if (NS_FAILED(rv))
-        goto done;
-
+      rv = messageService->GetUrlForUri(uri.get(), getter_AddRefs(aURL),
+                                        nullptr);
+      if (NS_FAILED(rv)) goto done;
 
       nsCOMPtr<nsIPrincipal> nullPrincipal =
-        do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
+          do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
       NS_ASSERTION(NS_SUCCEEDED(rv), "CreateInstance of nullprincipal failed.");
-      if (NS_FAILED(rv))
-        goto done;
+      if (NS_FAILED(rv)) goto done;
 
-      rv = NS_NewInputStreamChannel(getter_AddRefs(m_converter_channel),
-                                    aURL,
-                                    nullptr,
-                                    nullPrincipal,
-                                    nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                                    nsIContentPolicy::TYPE_OTHER);
-      if (NS_FAILED(rv))
-        goto done;
+      rv = NS_NewInputStreamChannel(
+          getter_AddRefs(m_converter_channel), aURL, nullptr, nullPrincipal,
+          nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+          nsIContentPolicy::TYPE_OTHER);
+      if (NS_FAILED(rv)) goto done;
 
       rv = m_mime_parser->AsyncConvertData("message/rfc822", "message/rfc822",
                                            strListener, m_converter_channel);
-      if (NS_FAILED(rv))
-        goto done;
+      if (NS_FAILED(rv)) goto done;
 
       nsCOMPtr<nsIURI> dummyNull;
-      rv = messageService->DisplayMessage(uri.get(), m_mime_parser, nullptr, nullptr, nullptr,
+      rv = messageService->DisplayMessage(uri.get(), m_mime_parser, nullptr,
+                                          nullptr, nullptr,
                                           getter_AddRefs(dummyNull));
     }
   }
 done:
-  if (NS_FAILED(rv))
-  {
-      if (mOutFile)
-      {
-        mOutFile->Close();
-        mOutFile = nullptr;
-      }
+  if (NS_FAILED(rv)) {
+    if (mOutFile) {
+      mOutFile->Close();
+      mOutFile = nullptr;
+    }
 
-      if (mTmpFile)
-      {
-        mTmpFile->Remove(false);
-        mTmpFile = nullptr;
-      }
+    if (mTmpFile) {
+      mTmpFile->Remove(false);
+      mTmpFile = nullptr;
+    }
   }
 
   return rv;
 }
 
 #ifdef XP_MACOSX
-bool nsMsgAttachmentHandler::HasResourceFork(FSRef *fsRef)
-{
+bool nsMsgAttachmentHandler::HasResourceFork(FSRef *fsRef) {
   FSCatalogInfo catalogInfo;
-  OSErr err = FSGetCatalogInfo(fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes, &catalogInfo, nullptr, nullptr, nullptr);
+  OSErr err = FSGetCatalogInfo(fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes,
+                               &catalogInfo, nullptr, nullptr, nullptr);
   return (err == noErr && catalogInfo.rsrcLogicalSize != 0);
 }
 #endif
 
-nsresult
-nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
-{
-  NS_ASSERTION (! m_done, "Already done");
+nsresult nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields) {
+  NS_ASSERTION(!m_done, "Already done");
 
-  if (!mURL)
-    return SnarfMsgAttachment(compFields);
+  if (!mURL) return SnarfMsgAttachment(compFields);
 
   mCompFields = compFields;
 
   // First, get as file spec and create the stream for the
   // temp file where we will save this data
-  nsCOMPtr <nsIFile> tmpFile;
+  nsCOMPtr<nsIFile> tmpFile;
   nsresult rv = nsMsgCreateTempFile("nsmail.tmp", getter_AddRefs(tmpFile));
   NS_ENSURE_SUCCESS(rv, rv);
   mTmpFile = tmpFile;
   mDeleteFile = true;
 
-  rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mOutFile), mTmpFile, -1, 00600);
-  if (NS_FAILED(rv) || !mOutFile)
-  {
-    if (m_mime_delivery_state)
-    {
+  rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mOutFile), mTmpFile, -1,
+                                      00600);
+  if (NS_FAILED(rv) || !mOutFile) {
+    if (m_mime_delivery_state) {
       nsCOMPtr<nsIMsgSendReport> sendReport;
       m_mime_delivery_state->GetSendReport(getter_AddRefs(sendReport));
-      if (sendReport)
-      {
+      if (sendReport) {
         nsAutoString error_msg;
         nsMsgBuildMessageWithTmpFile(mTmpFile, error_msg);
-        sendReport->SetMessage(nsIMsgSendReport::process_Current, error_msg.get(), false);
+        sendReport->SetMessage(nsIMsgSendReport::process_Current,
+                               error_msg.get(), false);
       }
     }
     mTmpFile->Remove(false);
     mTmpFile = nullptr;
     return NS_MSG_UNABLE_TO_OPEN_TMP_FILE;
   }
 
   nsCString sourceURISpec;
   rv = mURL->GetSpec(sourceURISpec);
   NS_ENSURE_SUCCESS(rv, rv);
 #ifdef XP_MACOSX
-  if (!m_bogus_attachment && StringBeginsWith(sourceURISpec, NS_LITERAL_CSTRING("file://")))
-  {
+  if (!m_bogus_attachment &&
+      StringBeginsWith(sourceURISpec, NS_LITERAL_CSTRING("file://"))) {
     // Unescape the path (i.e. un-URLify it) before making a FSSpec
     nsAutoCString filePath;
     filePath.Adopt(nsMsgGetLocalFileFromURL(sourceURISpec.get()));
     nsAutoCString unescapedFilePath;
     MsgUnescapeString(filePath, 0, unescapedFilePath);
 
     nsCOMPtr<nsIFile> sourceFile;
     NS_NewNativeLocalFile(unescapedFilePath, true, getter_AddRefs(sourceFile));
-    if (!sourceFile)
-      return NS_ERROR_FAILURE;
+    if (!sourceFile) return NS_ERROR_FAILURE;
 
     // check if it is a bundle. if it is, we'll zip it.
     // if not, we'll apple encode it (applesingle or appledouble)
     nsCOMPtr<nsILocalFileMac> macFile(do_QueryInterface(sourceFile));
     bool isPackage;
     macFile->IsPackage(&isPackage);
     if (isPackage)
       rv = ConvertToZipFile(macFile);
@@ -768,40 +681,40 @@ nsMsgAttachmentHandler::SnarfAttachment(
 #endif /* XP_MACOSX */
 
   //
   // Ok, here we are, we need to fire the URL off and get the data
   // in the temp file
   //
   // Create a fetcher for the URL attachment...
 
-  nsCOMPtr<nsIURLFetcher> fetcher = do_CreateInstance(NS_URLFETCHER_CONTRACTID, &rv);
-  if (NS_FAILED(rv) || !fetcher)
-  {
+  nsCOMPtr<nsIURLFetcher> fetcher =
+      do_CreateInstance(NS_URLFETCHER_CONTRACTID, &rv);
+  if (NS_FAILED(rv) || !fetcher) {
     if (NS_SUCCEEDED(rv))
       return NS_ERROR_UNEXPECTED;
     else
       return rv;
   }
 
-  return fetcher->FireURLRequest(mURL, mTmpFile, mOutFile, FetcherURLDoneCallback, this);
+  return fetcher->FireURLRequest(mURL, mTmpFile, mOutFile,
+                                 FetcherURLDoneCallback, this);
 }
 
 #ifdef XP_MACOSX
-nsresult
-nsMsgAttachmentHandler::ConvertToZipFile(nsILocalFileMac *aSourceFile)
-{
+nsresult nsMsgAttachmentHandler::ConvertToZipFile(
+    nsILocalFileMac *aSourceFile) {
   // append ".zip" to the real file name
   nsAutoCString zippedName;
   nsresult rv = aSourceFile->GetNativeLeafName(zippedName);
   NS_ENSURE_SUCCESS(rv, rv);
   zippedName.AppendLiteral(".zip");
 
   // create a temporary file that we'll work on
-  nsCOMPtr <nsIFile> tmpFile;
+  nsCOMPtr<nsIFile> tmpFile;
   rv = nsMsgCreateTempFile(zippedName.get(), getter_AddRefs(tmpFile));
   NS_ENSURE_SUCCESS(rv, rv);
   mEncodedWorkingFile = tmpFile;
 
   // point our URL at the zipped temp file
   NS_NewFileURI(getter_AddRefs(mURL), mEncodedWorkingFile);
 
   // zip it!
@@ -810,111 +723,105 @@ nsMsgAttachmentHandler::ConvertToZipFile
 
   // set some metadata for this attachment, that will affect the MIME headers.
   m_type = APPLICATION_ZIP;
   m_realName = zippedName.get();
 
   return NS_OK;
 }
 
-nsresult
-nsMsgAttachmentHandler::ConvertToAppleEncoding(const nsCString &aFileURI,
-                                               const nsCString &aFilePath,
-                                               nsILocalFileMac *aSourceFile)
-{
+nsresult nsMsgAttachmentHandler::ConvertToAppleEncoding(
+    const nsCString &aFileURI, const nsCString &aFilePath,
+    nsILocalFileMac *aSourceFile) {
   // convert the apple file to AppleDouble first, and then patch the
   // address in the url.
 
-  //We need to retrieve the file type and creator...
+  // We need to retrieve the file type and creator...
 
   char fileInfo[32];
   OSType type, creator;
 
   nsresult rv = aSourceFile->GetFileType(&type);
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
   PR_snprintf(fileInfo, sizeof(fileInfo), "%X", type);
   m_xMacType = fileInfo;
 
   rv = aSourceFile->GetFileCreator(&creator);
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
   PR_snprintf(fileInfo, sizeof(fileInfo), "%X", creator);
   m_xMacCreator = fileInfo;
 
   FSRef fsRef;
   aSourceFile->GetFSRef(&fsRef);
   bool sendResourceFork = HasResourceFork(&fsRef);
 
-  // if we have a resource fork, check the filename extension, maybe we don't need the resource fork!
-  if (sendResourceFork)
-  {
+  // if we have a resource fork, check the filename extension, maybe we don't
+  // need the resource fork!
+  if (sendResourceFork) {
     nsCOMPtr<nsIURL> fileUrl;
-    rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID).SetSpec(aFileURI).Finalize(fileUrl);
-    if (NS_SUCCEEDED(rv))
-    {
+    rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
+             .SetSpec(aFileURI)
+             .Finalize(fileUrl);
+    if (NS_SUCCEEDED(rv)) {
       nsAutoCString ext;
       rv = fileUrl->GetFileExtension(ext);
       if (NS_SUCCEEDED(rv) && !ext.IsEmpty()) {
-        // Check the preference to see whether AppleDouble was requested for this extension.
+        // Check the preference to see whether AppleDouble was requested for
+        // this extension.
         nsAutoCString extensionWhitelist;
-        mozilla::Preferences::GetCString("mailnews.extensions_using_appledouble", extensionWhitelist);
+        mozilla::Preferences::GetCString(
+            "mailnews.extensions_using_appledouble", extensionWhitelist);
         if (extensionWhitelist.IsEmpty() ||
             (!extensionWhitelist.Equals("*") &&
-             extensionWhitelist.Find(ext, /* ignoreCase = */ true) == kNotFound))
-          sendResourceFork = false;  // Ignore resource fork and don't use AppleDouble.
+             extensionWhitelist.Find(ext, /* ignoreCase = */ true) ==
+                 kNotFound))
+          sendResourceFork =
+              false;  // Ignore resource fork and don't use AppleDouble.
       }
     }
   }
 
   // Only use appledouble if we aren't uuencoding.
-  if( sendResourceFork )
-  {
+  if (sendResourceFork) {
     char *separator;
 
     separator = mime_make_separator("ad");
-    if (!separator)
-      return NS_ERROR_OUT_OF_MEMORY;
+    if (!separator) return NS_ERROR_OUT_OF_MEMORY;
 
-    nsCOMPtr <nsIFile> tmpFile;
+    nsCOMPtr<nsIFile> tmpFile;
     nsresult rv = nsMsgCreateTempFile("appledouble", getter_AddRefs(tmpFile));
-    if (NS_SUCCEEDED(rv))
-      mEncodedWorkingFile = tmpFile;
-    if (!mEncodedWorkingFile)
-    {
+    if (NS_SUCCEEDED(rv)) mEncodedWorkingFile = tmpFile;
+    if (!mEncodedWorkingFile) {
       PR_FREEIF(separator);
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     //
     // RICHIE_MAC - ok, here's the deal, we have a file that we need
     // to encode in appledouble encoding for the resource fork and put that
-    // into the mEncodedWorkingFile location. Then, we need to patch the new file
-    // spec into the array and send this as part of the 2 part appledouble/mime
-    // encoded mime part.
+    // into the mEncodedWorkingFile location. Then, we need to patch the new
+    // file spec into the array and send this as part of the 2 part
+    // appledouble/mime encoded mime part.
     //
-    AppleDoubleEncodeObject     *obj = new (AppleDoubleEncodeObject);
-    if (obj == NULL)
-    {
+    AppleDoubleEncodeObject *obj = new (AppleDoubleEncodeObject);
+    if (obj == NULL) {
       mEncodedWorkingFile = nullptr;
       PR_FREEIF(separator);
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     rv = MsgGetFileStream(mEncodedWorkingFile, getter_AddRefs(obj->fileStream));
-    if (NS_FAILED(rv) || !obj->fileStream)
-    {
+    if (NS_FAILED(rv) || !obj->fileStream) {
       PR_FREEIF(separator);
       delete obj;
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    char *working_buff = (char *) PR_Malloc(AD_WORKING_BUFF_SIZE);
-    if (!working_buff)
-    {
+    char *working_buff = (char *)PR_Malloc(AD_WORKING_BUFF_SIZE);
+    if (!working_buff) {
       PR_FREEIF(separator);
       delete obj;
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     obj->buff = working_buff;
     obj->s_buff = AD_WORKING_BUFF_SIZE;
 
@@ -922,172 +829,155 @@ nsMsgAttachmentHandler::ConvertToAppleEn
     //  Setup all the need information on the apple double encoder.
     //
     ap_encode_init(&(obj->ap_encode_obj), aFilePath.get(), separator);
 
     int32_t count;
 
     OSErr status = noErr;
     m_size = 0;
-    while (status == noErr)
-    {
-      status = ap_encode_next(&(obj->ap_encode_obj), obj->buff, obj->s_buff, &count);
-      if (status == noErr || status == errDone)
-      {
+    while (status == noErr) {
+      status =
+          ap_encode_next(&(obj->ap_encode_obj), obj->buff, obj->s_buff, &count);
+      if (status == noErr || status == errDone) {
         //
-        // we got the encode data, so call the next stream to write it to the disk.
+        // we got the encode data, so call the next stream to write it to the
+        // disk.
         //
         uint32_t bytesWritten;
         obj->fileStream->Write(obj->buff, count, &bytesWritten);
-        if (bytesWritten != (uint32_t) count)
-          status = errFileWrite;
+        if (bytesWritten != (uint32_t)count) status = errFileWrite;
       }
     }
 
-    ap_encode_end(&(obj->ap_encode_obj), (status >= 0)); // if this is true, ok, false abort
-    if (obj->fileStream)
-      obj->fileStream->Close();
+    ap_encode_end(&(obj->ap_encode_obj),
+                  (status >= 0));  // if this is true, ok, false abort
+    if (obj->fileStream) obj->fileStream->Close();
 
-    PR_FREEIF(obj->buff);               /* free the working buff.   */
+    PR_FREEIF(obj->buff); /* free the working buff.   */
     PR_FREEIF(obj);
 
-    nsCOMPtr <nsIURI> fileURI;
+    nsCOMPtr<nsIURI> fileURI;
     NS_NewFileURI(getter_AddRefs(fileURI), mEncodedWorkingFile);
 
     nsCOMPtr<nsIFileURL> theFileURL = do_QueryInterface(fileURI, &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsCString newURLSpec;
     rv = fileURI->GetSpec(newURLSpec);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    if (newURLSpec.IsEmpty())
-    {
+    if (newURLSpec.IsEmpty()) {
       PR_FREEIF(separator);
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    if (NS_FAILED(nsMsgNewURL(getter_AddRefs(mURL), newURLSpec)))
-    {
+    if (NS_FAILED(nsMsgNewURL(getter_AddRefs(mURL), newURLSpec))) {
       PR_FREEIF(separator);
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     // Now after conversion, also patch the types.
-    char        tmp[128];
-    PR_snprintf(tmp, sizeof(tmp), MULTIPART_APPLEDOUBLE ";\r\n boundary=\"%s\"", separator);
+    char tmp[128];
+    PR_snprintf(tmp, sizeof(tmp), MULTIPART_APPLEDOUBLE ";\r\n boundary=\"%s\"",
+                separator);
     PR_FREEIF(separator);
     m_type = tmp;
-  }
-  else
-  {
-    bool      useDefault;
-    char      *macType, *macEncoding;
-    if (m_type.IsEmpty() || m_type.LowerCaseEqualsLiteral(TEXT_PLAIN))
-    {
-# define TEXT_TYPE  0x54455854  /* the characters 'T' 'E' 'X' 'T' */
-# define text_TYPE  0x74657874  /* the characters 't' 'e' 'x' 't' */
+  } else {
+    bool useDefault;
+    char *macType, *macEncoding;
+    if (m_type.IsEmpty() || m_type.LowerCaseEqualsLiteral(TEXT_PLAIN)) {
+#  define TEXT_TYPE 0x54455854 /* the characters 'T' 'E' 'X' 'T' */
+#  define text_TYPE 0x74657874 /* the characters 't' 'e' 'x' 't' */
 
-      if (type != TEXT_TYPE && type != text_TYPE)
-      {
+      if (type != TEXT_TYPE && type != text_TYPE) {
         MacGetFileType(aSourceFile, &useDefault, &macType, &macEncoding);
         m_type = macType;
       }
     }
     // don't bother to set the types if we failed in getting the file info.
   }
 
   return NS_OK;
 }
-#endif // XP_MACOSX
+#endif  // XP_MACOSX
 
-nsresult
-nsMsgAttachmentHandler::LoadDataFromFile(nsIFile *file, nsString &sigData, bool charsetConversion)
-{
-  int32_t       readSize;
-  char          *readBuf;
+nsresult nsMsgAttachmentHandler::LoadDataFromFile(nsIFile *file,
+                                                  nsString &sigData,
+                                                  bool charsetConversion) {
+  int32_t readSize;
+  char *readBuf;
 
-  nsCOMPtr <nsIInputStream> inputFile;
+  nsCOMPtr<nsIInputStream> inputFile;
   nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputFile), file);
-  if (NS_FAILED(rv))
-    return NS_MSG_ERROR_WRITING_FILE;
+  if (NS_FAILED(rv)) return NS_MSG_ERROR_WRITING_FILE;
 
   int64_t fileSize;
   file->GetFileSize(&fileSize);
-  readSize = (uint32_t) fileSize;
+  readSize = (uint32_t)fileSize;
 
   readBuf = (char *)PR_Malloc(readSize + 1);
-  if (!readBuf)
-    return NS_ERROR_OUT_OF_MEMORY;
+  if (!readBuf) return NS_ERROR_OUT_OF_MEMORY;
   memset(readBuf, 0, readSize + 1);
 
   uint32_t bytesRead;
   inputFile->Read(readBuf, readSize, &bytesRead);
   inputFile->Close();
 
   nsDependentCString cstringReadBuf(readBuf, bytesRead);
-  if (charsetConversion)
-  {
-    if (NS_FAILED(nsMsgI18NConvertToUnicode(m_charset, cstringReadBuf, sigData)))
+  if (charsetConversion) {
+    if (NS_FAILED(
+            nsMsgI18NConvertToUnicode(m_charset, cstringReadBuf, sigData)))
       CopyASCIItoUTF16(cstringReadBuf, sigData);
-  }
-  else
+  } else
     CopyASCIItoUTF16(cstringReadBuf, sigData);
 
   PR_FREEIF(readBuf);
   return NS_OK;
 }
 
-nsresult
-nsMsgAttachmentHandler::Abort()
-{
+nsresult nsMsgAttachmentHandler::Abort() {
   nsCOMPtr<nsIRequest> saveRequest;
   saveRequest.swap(mRequest);
 
-  if (mTmpFile)
-  {
-    if (mDeleteFile)
-      mTmpFile->Remove(false);
+  if (mTmpFile) {
+    if (mDeleteFile) mTmpFile->Remove(false);
     mTmpFile = nullptr;
   }
 
-  NS_ASSERTION(m_mime_delivery_state != nullptr, "not-null m_mime_delivery_state");
+  NS_ASSERTION(m_mime_delivery_state != nullptr,
+               "not-null m_mime_delivery_state");
 
-  if (m_done)
-    return NS_OK;
+  if (m_done) return NS_OK;
 
   if (saveRequest)
     return saveRequest->Cancel(NS_ERROR_ABORT);
-  else
-    if (m_mime_delivery_state)
-    {
-      m_mime_delivery_state->SetStatus(NS_ERROR_ABORT);
-      m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, NS_ERROR_ABORT, 0, nullptr);
-    }
+  else if (m_mime_delivery_state) {
+    m_mime_delivery_state->SetStatus(NS_ERROR_ABORT);
+    m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, NS_ERROR_ABORT,
+                                                       0, nullptr);
+  }
   return NS_OK;
-
 }
 
-nsresult
-nsMsgAttachmentHandler::UrlExit(nsresult status, const char16_t* aMsg)
-{
-  NS_ASSERTION(m_mime_delivery_state != nullptr, "not-null m_mime_delivery_state");
+nsresult nsMsgAttachmentHandler::UrlExit(nsresult status,
+                                         const char16_t *aMsg) {
+  NS_ASSERTION(m_mime_delivery_state != nullptr,
+               "not-null m_mime_delivery_state");
 
   // Close the file, but don't delete the disk file (or the file spec.)
-  if (mOutFile)
-  {
+  if (mOutFile) {
     mOutFile->Close();
     mOutFile = nullptr;
   }
   // this silliness is because Windows nsIFile caches its file size
   // so if an output stream writes to it, it will still return the original
   // cached size.
-  if (mTmpFile)
-  {
-    nsCOMPtr <nsIFile> tmpFile;
+  if (mTmpFile) {
+    nsCOMPtr<nsIFile> tmpFile;
     mTmpFile->Clone(getter_AddRefs(tmpFile));
     mTmpFile = tmpFile;
   }
   mRequest = nullptr;
 
   // First things first, we are now going to see if this is an HTML
   // Doc and if it is, we need to see if we can determine the charset
   // for this part by sniffing the HTML file.
@@ -1096,255 +986,237 @@ nsMsgAttachmentHandler::UrlExit(nsresult
   //
   if (!m_type.IsEmpty() && m_charset.IsEmpty() &&
       m_type.LowerCaseEqualsLiteral(TEXT_HTML))
     m_charset = nsMsgI18NParseMetaCharset(mTmpFile);
 
   nsresult mimeDeliveryStatus;
   m_mime_delivery_state->GetStatus(&mimeDeliveryStatus);
 
-  if (mimeDeliveryStatus == NS_ERROR_ABORT)
-    status = NS_ERROR_ABORT;
+  if (mimeDeliveryStatus == NS_ERROR_ABORT) status = NS_ERROR_ABORT;
 
   // If the attachment is empty, let's call that a failure.
-  if (!m_size)
-    status = NS_ERROR_FAILURE;
+  if (!m_size) status = NS_ERROR_FAILURE;
 
-  if (NS_FAILED(status) && status != NS_ERROR_ABORT && NS_SUCCEEDED(mimeDeliveryStatus))
-  {
+  if (NS_FAILED(status) && status != NS_ERROR_ABORT &&
+      NS_SUCCEEDED(mimeDeliveryStatus)) {
     // At this point, we should probably ask a question to the user
     // if we should continue without this attachment.
     //
-    bool              keepOnGoing = true;
-    nsCString    turl;
-    nsString     msg;
+    bool keepOnGoing = true;
+    nsCString turl;
+    nsString msg;
     nsresult rv;
     nsCOMPtr<nsIStringBundleService> bundleService =
-      mozilla::services::GetStringBundleService();
+        mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
     nsCOMPtr<nsIStringBundle> bundle;
-    rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
+    rv = bundleService->CreateBundle(
+        "chrome://messenger/locale/messengercompose/composeMsgs.properties",
+        getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, rv);
     nsMsgDeliverMode mode = nsIMsgSend::nsMsgDeliverNow;
     m_mime_delivery_state->GetDeliveryMode(&mode);
     nsCString params;
     if (!m_realName.IsEmpty())
       params = m_realName;
-    else if (NS_SUCCEEDED(mURL->GetSpec(turl)) && !turl.IsEmpty())
-    {
+    else if (NS_SUCCEEDED(mURL->GetSpec(turl)) && !turl.IsEmpty()) {
       nsAutoCString unescapedUrl;
       MsgUnescapeString(turl, 0, unescapedUrl);
       if (unescapedUrl.IsEmpty())
         params = turl;
       else
         params = unescapedUrl;
-    }
-    else
+    } else
       params.Assign('?');
 
     NS_ConvertUTF8toUTF16 UTF16params(params);
-    const char16_t* formatParams[] = { UTF16params.get() };
-    if (mode == nsIMsgSend::nsMsgSaveAsDraft || mode == nsIMsgSend::nsMsgSaveAsTemplate)
+    const char16_t *formatParams[] = {UTF16params.get()};
+    if (mode == nsIMsgSend::nsMsgSaveAsDraft ||
+        mode == nsIMsgSend::nsMsgSaveAsTemplate)
       bundle->FormatStringFromName("failureOnObjectEmbeddingWhileSaving",
                                    formatParams, 1, msg);
     else
       bundle->FormatStringFromName("failureOnObjectEmbeddingWhileSending",
                                    formatParams, 1, msg);
 
     nsCOMPtr<nsIPrompt> aPrompt;
     if (m_mime_delivery_state)
       m_mime_delivery_state->GetDefaultPrompt(getter_AddRefs(aPrompt));
     nsMsgAskBooleanQuestionByString(aPrompt, msg.get(), &keepOnGoing);
 
-    if (keepOnGoing)
-    {
+    if (keepOnGoing) {
       status = NS_OK;
-      m_bogus_attachment = true; //That will cause this attachment to be ignored.
-    }
-    else
-    {
+      m_bogus_attachment =
+          true;  // That will cause this attachment to be ignored.
+    } else {
       status = NS_ERROR_ABORT;
       m_mime_delivery_state->SetStatus(status);
       nsresult ignoreMe;
       m_mime_delivery_state->Fail(status, nullptr, &ignoreMe);
-      m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status, 0, nullptr);
+      m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status, 0,
+                                                         nullptr);
       SetMimeDeliveryState(nullptr);
       return status;
     }
   }
 
   m_done = true;
 
   //
   // Ok, now that we have the file here on disk, we need to see if there was
   // a need to do conversion to plain text...if so, the magic happens here,
   // otherwise, just move on to other attachments...
   //
   if (NS_SUCCEEDED(status) && !m_type.LowerCaseEqualsLiteral(TEXT_PLAIN) &&
-      m_desiredType.LowerCaseEqualsLiteral(TEXT_PLAIN))
-  {
+      m_desiredType.LowerCaseEqualsLiteral(TEXT_PLAIN)) {
     //
     // Conversion to plain text desired.
     // Now use the converter service here to do the right
     // thing and convert this data to plain text for us!
     //
-    nsAutoString      conData;
+    nsAutoString conData;
 
-    if (NS_SUCCEEDED(LoadDataFromFile(mTmpFile, conData, true)))
-    {
+    if (NS_SUCCEEDED(LoadDataFromFile(mTmpFile, conData, true))) {
       bool flowed, delsp, formatted, disallowBreaks;
-      GetSerialiserFlags(m_charset.get(), &flowed, &delsp, &formatted, &disallowBreaks);
+      GetSerialiserFlags(m_charset.get(), &flowed, &delsp, &formatted,
+                         &disallowBreaks);
 
-      if (NS_SUCCEEDED(ConvertBufToPlainText(conData, flowed, delsp, formatted, disallowBreaks)))
-      {
-        if (mDeleteFile)
-          mTmpFile->Remove(false);
+      if (NS_SUCCEEDED(ConvertBufToPlainText(conData, flowed, delsp, formatted,
+                                             disallowBreaks))) {
+        if (mDeleteFile) mTmpFile->Remove(false);
 
         nsCOMPtr<nsIOutputStream> outputStream;
-        nsresult rv = MsgNewBufferedFileOutputStream(getter_AddRefs(outputStream), mTmpFile,
-                                                     PR_WRONLY | PR_CREATE_FILE, 00600);
+        nsresult rv = MsgNewBufferedFileOutputStream(
+            getter_AddRefs(outputStream), mTmpFile, PR_WRONLY | PR_CREATE_FILE,
+            00600);
 
-        if (NS_SUCCEEDED(rv))
-        {
+        if (NS_SUCCEEDED(rv)) {
           nsAutoCString tData;
           if (NS_FAILED(nsMsgI18NConvertFromUnicode(m_charset, conData, tData)))
             LossyCopyUTF16toASCII(conData, tData);
-          if (!tData.IsEmpty())
-          {
+          if (!tData.IsEmpty()) {
             uint32_t bytesWritten;
-            (void) outputStream->Write(tData.get(), tData.Length(), &bytesWritten);
+            (void)outputStream->Write(tData.get(), tData.Length(),
+                                      &bytesWritten);
           }
           outputStream->Close();
           // this silliness is because Windows nsIFile caches its file size
-          // so if an output stream writes to it, it will still return the original
-          // cached size.
-          if (mTmpFile)
-          {
-            nsCOMPtr <nsIFile> tmpFile;
+          // so if an output stream writes to it, it will still return the
+          // original cached size.
+          if (mTmpFile) {
+            nsCOMPtr<nsIFile> tmpFile;
             mTmpFile->Clone(getter_AddRefs(tmpFile));
             mTmpFile = tmpFile;
           }
-
         }
       }
     }
 
     m_type = m_desiredType;
     m_desiredType.Truncate();
     m_encoding.Truncate();
   }
 
   uint32_t pendingAttachmentCount = 0;
   m_mime_delivery_state->GetPendingAttachmentCount(&pendingAttachmentCount);
-  NS_ASSERTION (pendingAttachmentCount > 0, "no more pending attachment");
+  NS_ASSERTION(pendingAttachmentCount > 0, "no more pending attachment");
 
   m_mime_delivery_state->SetPendingAttachmentCount(pendingAttachmentCount - 1);
 
   bool processAttachmentsSynchronously = false;
-  m_mime_delivery_state->GetProcessAttachmentsSynchronously(&processAttachmentsSynchronously);
-  if (NS_SUCCEEDED(status) && processAttachmentsSynchronously)
-  {
+  m_mime_delivery_state->GetProcessAttachmentsSynchronously(
+      &processAttachmentsSynchronously);
+  if (NS_SUCCEEDED(status) && processAttachmentsSynchronously) {
     /* Find the next attachment which has not yet been loaded,
      if any, and start it going.
      */
     uint32_t i;
     nsMsgAttachmentHandler *next = 0;
     nsTArray<RefPtr<nsMsgAttachmentHandler>> *attachments;
 
     m_mime_delivery_state->GetAttachmentHandlers(&attachments);
 
-    for (i = 0; i < attachments->Length(); i++)
-    {
-      if (!(*attachments)[i]->m_done)
-      {
+    for (i = 0; i < attachments->Length(); i++) {
+      if (!(*attachments)[i]->m_done) {
         next = (*attachments)[i];
         //
         // rhp: We need to get a little more understanding to failed URL
         // requests. So, at this point if most of next is NULL, then we
         // should just mark it fetched and move on! We probably ignored
         // this earlier on in the send process.
         //
-        if ( (!next->mURL) && (next->m_uri.IsEmpty()) )
-        {
+        if ((!next->mURL) && (next->m_uri.IsEmpty())) {
           (*attachments)[i]->m_done = true;
           (*attachments)[i]->SetMimeDeliveryState(nullptr);
-          m_mime_delivery_state->GetPendingAttachmentCount(&pendingAttachmentCount);
-          m_mime_delivery_state->SetPendingAttachmentCount(pendingAttachmentCount - 1);
+          m_mime_delivery_state->GetPendingAttachmentCount(
+              &pendingAttachmentCount);
+          m_mime_delivery_state->SetPendingAttachmentCount(
+              pendingAttachmentCount - 1);
           next->mPartUserOmissionOverride = true;
           next = nullptr;
           continue;
         }
 
         break;
       }
     }
 
-    if (next)
-    {
+    if (next) {
       nsresult status = next->SnarfAttachment(mCompFields);
-      if (NS_FAILED(status))
-      {
+      if (NS_FAILED(status)) {
         nsresult ignoreMe;
         m_mime_delivery_state->Fail(status, nullptr, &ignoreMe);
-        m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status, 0, nullptr);
+        m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status, 0,
+                                                           nullptr);
         SetMimeDeliveryState(nullptr);
         return NS_ERROR_UNEXPECTED;
       }
     }
   }
 
   m_mime_delivery_state->GetPendingAttachmentCount(&pendingAttachmentCount);
-  if (pendingAttachmentCount == 0)
-  {
+  if (pendingAttachmentCount == 0) {
     // If this is the last attachment, then either complete the
     // delivery (if successful) or report the error by calling
     // the exit routine and terminating the delivery.
-    if (NS_FAILED(status))
-    {
+    if (NS_FAILED(status)) {
       nsresult ignoreMe;
       m_mime_delivery_state->Fail(status, aMsg, &ignoreMe);
-      m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status, aMsg, nullptr);
+      m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status, aMsg,
+                                                         nullptr);
       SetMimeDeliveryState(nullptr);
       return NS_ERROR_UNEXPECTED;
-    }
-    else
-    {
-      status = m_mime_delivery_state->GatherMimeAttachments ();
-      if (NS_FAILED(status))
-      {
+    } else {
+      status = m_mime_delivery_state->GatherMimeAttachments();
+      if (NS_FAILED(status)) {
         nsresult ignoreMe;
         m_mime_delivery_state->Fail(status, aMsg, &ignoreMe);
-        m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status, aMsg, nullptr);
+        m_mime_delivery_state->NotifyListenerOnStopSending(nullptr, status,
+                                                           aMsg, nullptr);
         SetMimeDeliveryState(nullptr);
         return NS_ERROR_UNEXPECTED;
       }
     }
-  }
-  else
-  {
+  } else {
     // If this is not the last attachment, but it got an error,
     // then report that error and continue
-    if (NS_FAILED(status))
-    {
+    if (NS_FAILED(status)) {
       nsresult ignoreMe;
       m_mime_delivery_state->Fail(status, aMsg, &ignoreMe);
     }
   }
 
   SetMimeDeliveryState(nullptr);
   return NS_OK;
 }
 
-
-nsresult
-nsMsgAttachmentHandler::GetMimeDeliveryState(nsIMsgSend** _retval)
-{
+nsresult nsMsgAttachmentHandler::GetMimeDeliveryState(nsIMsgSend **_retval) {
   NS_ENSURE_ARG(_retval);
   NS_IF_ADDREF(*_retval = m_mime_delivery_state);
   return NS_OK;
 }
 
-nsresult
-nsMsgAttachmentHandler::SetMimeDeliveryState(nsIMsgSend* mime_delivery_state)
-{
+nsresult nsMsgAttachmentHandler::SetMimeDeliveryState(
+    nsIMsgSend *mime_delivery_state) {
   m_mime_delivery_state = mime_delivery_state;
   return NS_OK;
 }
--- a/mailnews/compose/src/nsMsgAttachmentHandler.h
+++ b/mailnews/compose/src/nsMsgAttachmentHandler.h
@@ -13,182 +13,186 @@
 #include "nsIMsgSend.h"
 #include "nsIFileStreams.h"
 #include "nsIStreamConverter.h"
 #include "nsAutoPtr.h"
 #include "nsIMsgAttachmentHandler.h"
 
 #ifdef XP_MACOSX
 
-#include "nsMsgAppleDouble.h"
-#include "nsILocalFileMac.h"
+#  include "nsMsgAppleDouble.h"
+#  include "nsILocalFileMac.h"
 
-class AppleDoubleEncodeObject
-{
-public:
-  appledouble_encode_object   ap_encode_obj;
-  char                        *buff;          // the working buff
-  int32_t                     s_buff;         // the working buff size
-  nsCOMPtr <nsIOutputStream>  fileStream;    // file to hold the encoding
+class AppleDoubleEncodeObject {
+ public:
+  appledouble_encode_object ap_encode_obj;
+  char *buff;                            // the working buff
+  int32_t s_buff;                        // the working buff size
+  nsCOMPtr<nsIOutputStream> fileStream;  // file to hold the encoding
 };
 
 class nsILocalFileMac;
 class nsIZipWriter;
 
 /* Simple utility class that will synchronously zip any file
    (or folder hierarchy) you give it. */
-class nsSimpleZipper
-{
-  public:
+class nsSimpleZipper {
+ public:
+  // Synchronously zips the input file/folder and writes all
+  // data to the output file.
+  static nsresult Zip(nsIFile *aInputFile, nsIFile *aOutputFile);
 
-    // Synchronously zips the input file/folder and writes all
-    // data to the output file.
-    static nsresult Zip(nsIFile *aInputFile, nsIFile *aOutputFile);
-
-  private:
-
-    // Recursively adds the file or folder to aZipWriter.
-    static nsresult AddToZip(nsIZipWriter *aZipWriter,
-                             nsIFile *aFile,
-                             const nsACString &aPath);
+ private:
+  // Recursively adds the file or folder to aZipWriter.
+  static nsresult AddToZip(nsIZipWriter *aZipWriter, nsIFile *aFile,
+                           const nsACString &aPath);
 };
 #endif  // XP_MACOSX
 
 namespace mozilla {
 namespace mailnews {
 class MimeEncoder;
 }
-}
+}  // namespace mozilla
 
 //
 // This is a class that deals with processing remote attachments. It implements
 // an nsIStreamListener interface to deal with incoming data
 //
-class nsMsgAttachmentHandler : public nsIMsgAttachmentHandler
-{
+class nsMsgAttachmentHandler : public nsIMsgAttachmentHandler {
+  typedef mozilla::mailnews::MimeEncoder MimeEncoder;
 
-  typedef mozilla::mailnews::MimeEncoder MimeEncoder;
-public:
+ public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIMSGATTACHMENTHANDLER
 
   nsMsgAttachmentHandler();
-public:
-  nsresult              SnarfAttachment(nsMsgCompFields *compFields);
-  nsresult              PickEncoding(const char *charset, nsIMsgSend* mime_delivery_state);
-  nsresult              PickCharset();
-  void                  AnalyzeSnarfedFile ();      // Analyze a previously-snarfed file.
-                                                    // (Currently only used for plaintext
-                                                    // converted from HTML.)
-  nsresult              Abort();
-  nsresult              UrlExit(nsresult status, const char16_t* aMsg);
 
-  // if there's an intermediate temp file left, takes care to remove it from disk.
+ public:
+  nsresult SnarfAttachment(nsMsgCompFields *compFields);
+  nsresult PickEncoding(const char *charset, nsIMsgSend *mime_delivery_state);
+  nsresult PickCharset();
+  void AnalyzeSnarfedFile();  // Analyze a previously-snarfed file.
+                              // (Currently only used for plaintext
+                              // converted from HTML.)
+  nsresult Abort();
+  nsresult UrlExit(nsresult status, const char16_t *aMsg);
+
+  // if there's an intermediate temp file left, takes care to remove it from
+  // disk.
   //
-  // NOTE: this takes care of the mEncodedWorkingFile temp file, but not mTmpFile which seems
-  // to be used by lots of other classes at the moment.
-  void                  CleanupTempFile();
+  // NOTE: this takes care of the mEncodedWorkingFile temp file, but not
+  // mTmpFile which seems to be used by lots of other classes at the moment.
+  void CleanupTempFile();
 
-private:
+ private:
   virtual ~nsMsgAttachmentHandler();
 
-  // use when a message (e.g. original message in a reply) is attached as a rfc822 attachment.
-  nsresult              SnarfMsgAttachment(nsMsgCompFields *compFields);
-  bool                  UseUUEncode_p(void);
-  void                  AnalyzeDataChunk (const char *chunk, int32_t chunkSize);
-  nsresult              LoadDataFromFile(nsIFile *file, nsString &sigData, bool charsetConversion); //A similar function already exist in nsMsgCompose!
+  // use when a message (e.g. original message in a reply) is attached as a
+  // rfc822 attachment.
+  nsresult SnarfMsgAttachment(nsMsgCompFields *compFields);
+  bool UseUUEncode_p(void);
+  void AnalyzeDataChunk(const char *chunk, int32_t chunkSize);
+  nsresult LoadDataFromFile(
+      nsIFile *file, nsString &sigData,
+      bool charsetConversion);  // A similar function already exist in
+                                // nsMsgCompose!
 #ifdef XP_MACOSX
-  nsresult              ConvertToAppleEncoding(const nsCString &aFileSpecURI,
-                                               const nsCString &aFilePath,
-                                               nsILocalFileMac *aSourceFile);
-  // zips this attachment and does the work to make this attachment handler handle it properly.
+  nsresult ConvertToAppleEncoding(const nsCString &aFileSpecURI,
+                                  const nsCString &aFilePath,
+                                  nsILocalFileMac *aSourceFile);
+  // zips this attachment and does the work to make this attachment handler
+  // handle it properly.
   nsresult ConvertToZipFile(nsILocalFileMac *aSourceFile);
   bool HasResourceFork(FSRef *fsRef);
 #endif
 
   //
-public:
+ public:
   nsCOMPtr<nsIURI> mURL;
-  nsCOMPtr<nsIFile>        mTmpFile;         // The temp file to which we save it
-  nsCOMPtr<nsIOutputStream>  mOutFile;
-  nsCOMPtr<nsIRequest> mRequest; // The live request used while fetching an attachment
-  nsMsgCompFields       *mCompFields;       // Message composition fields for the sender
-  bool                  m_bogus_attachment; // This is to catch problem children...
+  nsCOMPtr<nsIFile> mTmpFile;  // The temp file to which we save it
+  nsCOMPtr<nsIOutputStream> mOutFile;
+  nsCOMPtr<nsIRequest>
+      mRequest;  // The live request used while fetching an attachment
+  nsMsgCompFields *mCompFields;  // Message composition fields for the sender
+  bool m_bogus_attachment;       // This is to catch problem children...
 
 #ifdef XP_MACOSX
-  // if we need to encode this file into for example an appledouble, or zip file,
-  // this file is our working file. currently only needed on mac.
+  // if we need to encode this file into for example an appledouble, or zip
+  // file, this file is our working file. currently only needed on mac.
   nsCOMPtr<nsIFile> mEncodedWorkingFile;
 #endif
 
-  nsCString m_xMacType;      // Mac file type
-  nsCString m_xMacCreator;   // Mac file creator
+  nsCString m_xMacType;     // Mac file type
+  nsCString m_xMacCreator;  // Mac file creator
 
   bool m_done;
-  nsCString m_charset;         // charset name
-  nsCString m_contentId;      // This is for mutipart/related Content-ID's
-  nsCString m_type;            // The real type, once we know it.
-  nsCString m_typeParam;      // Any addition parameters to add to the content-type (other than charset, macType and maccreator)
-  nsCString m_overrideType;   // The type we should assume it to be
-                                            // or 0, if we should get it from the
-                                            // server)
-  nsCString m_overrideEncoding; // Goes along with override_type
+  nsCString m_charset;    // charset name
+  nsCString m_contentId;  // This is for mutipart/related Content-ID's
+  nsCString m_type;       // The real type, once we know it.
+  nsCString m_typeParam;  // Any addition parameters to add to the content-type
+                          // (other than charset, macType and maccreator)
+  nsCString m_overrideType;      // The type we should assume it to be
+                                 // or 0, if we should get it from the
+                                 // server)
+  nsCString m_overrideEncoding;  // Goes along with override_type
 
-  nsCString m_desiredType;    // The type it should be converted to.
-  nsCString m_description;     // For Content-Description header
-  nsCString m_realName;       // The name for the headers, if different
-                                            // from the URL.
-  nsCString m_encoding;        // The encoding, once we've decided. */
-  bool                  m_already_encoded_p; // If we attach a document that is already
-                                             // encoded, we just pass it through.
+  nsCString m_desiredType;   // The type it should be converted to.
+  nsCString m_description;   // For Content-Description header
+  nsCString m_realName;      // The name for the headers, if different
+                             // from the URL.
+  nsCString m_encoding;      // The encoding, once we've decided. */
+  bool m_already_encoded_p;  // If we attach a document that is already
+                             // encoded, we just pass it through.
 
-  bool                  m_decrypted_p;  /* S/MIME -- when attaching a message that was
-                                           encrypted, it's necessary to decrypt it first
-                                           (since nobody but the original recipient can
-                                           read it -- if you forward it to someone in the
-                                           raw, it will be useless to them.)  This flag
-                                           indicates whether decryption occurred, so that
-                                           libmsg can issue appropriate warnings about
-                                           doing a cleartext forward of a message that was
-                                           originally encrypted. */
+  bool m_decrypted_p; /* S/MIME -- when attaching a message that was
+                         encrypted, it's necessary to decrypt it first
+                         (since nobody but the original recipient can
+                         read it -- if you forward it to someone in the
+                         raw, it will be useless to them.)  This flag
+                         indicates whether decryption occurred, so that
+                         libmsg can issue appropriate warnings about
+                         doing a cleartext forward of a message that was
+                         originally encrypted. */
+
+  bool mDeleteFile;  // If this is true, Delete the file...its
+                     // NOT the original file!
 
-  bool                  mDeleteFile;      // If this is true, Delete the file...its
-                                          // NOT the original file!
-
-  bool                  mMHTMLPart;           // This is true if its an MHTML part, otherwise, false
-  bool                  mPartUserOmissionOverride;  // This is true if the user send send the email without this part
-  bool                  mMainBody;            // True if this is a main body.
-   // true if this should be sent as a link to a file.
-  bool                  mSendViaCloud;
-  nsString              mHtmlAnnotation;
-  nsCString             mCloudFileAccountKey;
-  nsCString             mCloudUrl;
-  int32_t mNodeIndex; //If this is an embedded image, this is the index of the
-                      // corresponding domNode in the editor's
-                      //GetEmbeddedObjects. Otherwise, it will be -1.
+  bool mMHTMLPart;  // This is true if its an MHTML part, otherwise, false
+  bool mPartUserOmissionOverride;  // This is true if the user send send the
+                                   // email without this part
+  bool mMainBody;                  // True if this is a main body.
+                   // true if this should be sent as a link to a file.
+  bool mSendViaCloud;
+  nsString mHtmlAnnotation;
+  nsCString mCloudFileAccountKey;
+  nsCString mCloudUrl;
+  int32_t mNodeIndex;  // If this is an embedded image, this is the index of the
+                       // corresponding domNode in the editor's
+                       // GetEmbeddedObjects. Otherwise, it will be -1.
   //
   // Vars for analyzing file data...
   //
-  uint32_t              m_size;         /* Some state used while filtering it */
-  uint32_t              m_unprintable_count;
-  uint32_t              m_highbit_count;
-  uint32_t              m_ctl_count;
-  uint32_t              m_null_count;
-  uint8_t               m_have_cr, m_have_lf, m_have_crlf;
-  bool                  m_prev_char_was_cr;
-  uint32_t              m_current_column;
-  uint32_t              m_max_column;
-  uint32_t              m_lines;
-  bool                  m_file_analyzed;
+  uint32_t m_size; /* Some state used while filtering it */
+  uint32_t m_unprintable_count;
+  uint32_t m_highbit_count;
+  uint32_t m_ctl_count;
+  uint32_t m_null_count;
+  uint8_t m_have_cr, m_have_lf, m_have_crlf;
+  bool m_prev_char_was_cr;
+  uint32_t m_current_column;
+  uint32_t m_max_column;
+  uint32_t m_lines;
+  bool m_file_analyzed;
 
   nsAutoPtr<MimeEncoder> m_encoder;
-  nsCString             m_uri; // original uri string
+  nsCString m_uri;  // original uri string
+
+  nsresult GetMimeDeliveryState(nsIMsgSend **_retval);
+  nsresult SetMimeDeliveryState(nsIMsgSend *mime_delivery_state);
 
-  nsresult              GetMimeDeliveryState(nsIMsgSend** _retval);
-  nsresult              SetMimeDeliveryState(nsIMsgSend* mime_delivery_state);
-private:
-  nsCOMPtr<nsIMsgSend>  m_mime_delivery_state;
+ private:
+  nsCOMPtr<nsIMsgSend> m_mime_delivery_state;
   nsCOMPtr<nsIStreamConverter> m_mime_parser;
-  nsCOMPtr<nsIChannel>  m_converter_channel;
+  nsCOMPtr<nsIChannel> m_converter_channel;
 };
 
-
 #endif /* _nsMsgAttachmentHandler_H_ */
--- a/mailnews/compose/src/nsMsgCompFields.cpp
+++ b/mailnews/compose/src/nsMsgCompFields.cpp
@@ -27,677 +27,585 @@ struct HeaderInfo {
   /// If true, nsMsgCompFields should reflect the raw header value instead of
   /// the unstructured header value.
   bool mStructured;
 };
 
 // This is a mapping of the m_headers local set to the actual header name we
 // store on the structured header object.
 static HeaderInfo kHeaders[] = {
-  { "From", true },
-  { "Reply-To", true },
-  { "To", true },
-  { "Cc", true },
-  { "Bcc", true },
-  { nullptr, false }, // FCC
-  { nullptr, false }, // FCC2
-  { "Newsgroups", true },
-  { "Followup-To", true },
-  { "Subject", false },
-  { "Organization", false },
-  { "References", true },
-  { "X-Mozilla-News-Host", false },
-  { "X-Priority", false },
-  { nullptr, false }, // CHARACTER_SET
-  { "Message-Id", true },
-  { "X-Template", true },
-  { nullptr, false }, // DRAFT_ID
-  { nullptr, false }, // TEMPLATE_ID
-  { "Content-Language", true },
-  { nullptr, false } // CREATOR IDENTITY KEY
+    {"From", true},
+    {"Reply-To", true},
+    {"To", true},
+    {"Cc", true},
+    {"Bcc", true},
+    {nullptr, false},  // FCC
+    {nullptr, false},  // FCC2
+    {"Newsgroups", true},
+    {"Followup-To", true},
+    {"Subject", false},
+    {"Organization", false},
+    {"References", true},
+    {"X-Mozilla-News-Host", false},
+    {"X-Priority", false},
+    {nullptr, false},  // CHARACTER_SET
+    {"Message-Id", true},
+    {"X-Template", true},
+    {nullptr, false},  // DRAFT_ID
+    {nullptr, false},  // TEMPLATE_ID
+    {"Content-Language", true},
+    {nullptr, false}  // CREATOR IDENTITY KEY
 };
 
-static_assert(MOZ_ARRAY_LENGTH(kHeaders) ==
-    nsMsgCompFields::MSG_MAX_HEADERS,
-  "These two arrays need to be kept in sync or bad things will happen!");
+static_assert(
+    MOZ_ARRAY_LENGTH(kHeaders) == nsMsgCompFields::MSG_MAX_HEADERS,
+    "These two arrays need to be kept in sync or bad things will happen!");
 
 NS_IMPL_ISUPPORTS(nsMsgCompFields, nsIMsgCompFields, msgIStructuredHeaders,
-  msgIWritableStructuredHeaders)
+                  msgIWritableStructuredHeaders)
 
 nsMsgCompFields::nsMsgCompFields()
-: mStructuredHeaders(do_CreateInstance(NS_ISTRUCTUREDHEADERS_CONTRACTID))
-{
+    : mStructuredHeaders(do_CreateInstance(NS_ISTRUCTUREDHEADERS_CONTRACTID)) {
   m_body.Truncate();
 
   m_attachVCard = false;
   m_forcePlainText = false;
   m_useMultipartAlternative = false;
   m_returnReceipt = false;
   m_receiptHeaderType = nsIMsgMdnGenerator::eDntType;
   m_DSN = false;
   m_bodyIsAsciiOnly = false;
   m_forceMsgEncoding = false;
   m_needToCheckCharset = true;
   m_attachmentReminder = false;
   m_deliveryFormat = nsIMsgCompSendFormat::AskUser;
 
   // Get the default charset from pref, use this as a mail charset.
   nsString charset;
-  NS_GetLocalizedUnicharPreferenceWithDefault(nullptr, "mailnews.send_default_charset",
-                                              NS_LITERAL_STRING("UTF-8"), charset);
+  NS_GetLocalizedUnicharPreferenceWithDefault(
+      nullptr, "mailnews.send_default_charset", NS_LITERAL_STRING("UTF-8"),
+      charset);
 
-  LossyCopyUTF16toASCII(charset, m_DefaultCharacterSet); // Charsets better be ASCII
+  LossyCopyUTF16toASCII(charset,
+                        m_DefaultCharacterSet);  // Charsets better be ASCII
   SetCharacterSet(m_DefaultCharacterSet.get());
 }
 
-nsMsgCompFields::~nsMsgCompFields()
-{
-}
+nsMsgCompFields::~nsMsgCompFields() {}
 
-nsresult nsMsgCompFields::SetAsciiHeader(MsgHeaderID header, const char *value)
-{
+nsresult nsMsgCompFields::SetAsciiHeader(MsgHeaderID header,
+                                         const char *value) {
   NS_ASSERTION(header >= 0 && header < MSG_MAX_HEADERS,
                "Invalid message header index!");
 
   // If we are storing this on the structured header object, we need to set the
   // value on that object as well. Note that the value may be null, which we'll
   // take as an attempt to delete the header.
   const char *headerName = kHeaders[header].mName;
-  if (headerName)
-  {
-    if (!value || !*value)
-      return mStructuredHeaders->DeleteHeader(headerName);
+  if (headerName) {
+    if (!value || !*value) return mStructuredHeaders->DeleteHeader(headerName);
 
     return mStructuredHeaders->SetRawHeader(headerName,
-      nsDependentCString(value), "UTF-8");
+                                            nsDependentCString(value), "UTF-8");
   }
 
   // Not on the structurd header object, so save it locally.
   m_headers[header] = value;
 
   return NS_OK;
 }
 
-const char* nsMsgCompFields::GetAsciiHeader(MsgHeaderID header)
-{
+const char *nsMsgCompFields::GetAsciiHeader(MsgHeaderID header) {
   NS_ASSERTION(header >= 0 && header < MSG_MAX_HEADERS,
                "Invalid message header index!");
 
   const char *headerName = kHeaders[header].mName;
-  if (headerName)
-  {
+  if (headerName) {
     // We may be out of sync with the structured header object. Retrieve the
     // header value.
-    if (kHeaders[header].mStructured)
-    {
+    if (kHeaders[header].mStructured) {
       mStructuredHeaders->GetRawHeader(headerName, m_headers[header]);
-    }
-    else
-    {
+    } else {
       nsString value;
       mStructuredHeaders->GetUnstructuredHeader(headerName, value);
       CopyUTF16toUTF8(value, m_headers[header]);
     }
   }
 
   return m_headers[header].get();
 }
 
-nsresult nsMsgCompFields::SetUnicodeHeader(MsgHeaderID header, const nsAString& value)
-{
+nsresult nsMsgCompFields::SetUnicodeHeader(MsgHeaderID header,
+                                           const nsAString &value) {
   return SetAsciiHeader(header, NS_ConvertUTF16toUTF8(value).get());
 }
 
-nsresult nsMsgCompFields::GetUnicodeHeader(MsgHeaderID header, nsAString& aResult)
-{
+nsresult nsMsgCompFields::GetUnicodeHeader(MsgHeaderID header,
+                                           nsAString &aResult) {
   CopyUTF8toUTF16(nsDependentCString(GetAsciiHeader(header)), aResult);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetFrom(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetFrom(const nsAString &value) {
   return SetUnicodeHeader(MSG_FROM_HEADER_ID, value);
 }
 
-
-NS_IMETHODIMP nsMsgCompFields::GetFrom(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetFrom(nsAString &_retval) {
   return GetUnicodeHeader(MSG_FROM_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetReplyTo(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetReplyTo(const nsAString &value) {
   return SetUnicodeHeader(MSG_REPLY_TO_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetReplyTo(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetReplyTo(nsAString &_retval) {
   return GetUnicodeHeader(MSG_REPLY_TO_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetTo(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetTo(const nsAString &value) {
   return SetUnicodeHeader(MSG_TO_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetTo(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetTo(nsAString &_retval) {
   return GetUnicodeHeader(MSG_TO_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetCc(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetCc(const nsAString &value) {
   return SetUnicodeHeader(MSG_CC_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetCc(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetCc(nsAString &_retval) {
   return GetUnicodeHeader(MSG_CC_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetBcc(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetBcc(const nsAString &value) {
   return SetUnicodeHeader(MSG_BCC_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetBcc(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetBcc(nsAString &_retval) {
   return GetUnicodeHeader(MSG_BCC_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetFcc(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetFcc(const nsAString &value) {
   return SetUnicodeHeader(MSG_FCC_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetFcc(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetFcc(nsAString &_retval) {
   return GetUnicodeHeader(MSG_FCC_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetFcc2(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetFcc2(const nsAString &value) {
   return SetUnicodeHeader(MSG_FCC2_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetFcc2(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetFcc2(nsAString &_retval) {
   return GetUnicodeHeader(MSG_FCC2_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetNewsgroups(const nsAString &aValue)
-{
+NS_IMETHODIMP nsMsgCompFields::SetNewsgroups(const nsAString &aValue) {
   return SetUnicodeHeader(MSG_NEWSGROUPS_HEADER_ID, aValue);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetNewsgroups(nsAString &aGroup)
-{
+NS_IMETHODIMP nsMsgCompFields::GetNewsgroups(nsAString &aGroup) {
   return GetUnicodeHeader(MSG_NEWSGROUPS_HEADER_ID, aGroup);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetFollowupTo(const nsAString &aValue)
-{
+NS_IMETHODIMP nsMsgCompFields::SetFollowupTo(const nsAString &aValue) {
   return SetUnicodeHeader(MSG_FOLLOWUP_TO_HEADER_ID, aValue);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetFollowupTo(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetFollowupTo(nsAString &_retval) {
   return GetUnicodeHeader(MSG_FOLLOWUP_TO_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetHasRecipients(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetHasRecipients(bool *_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
 
   *_retval = NS_SUCCEEDED(mime_sanity_check_fields_recipients(
-    GetTo(), GetCc(), GetBcc(), GetNewsgroups()));
+      GetTo(), GetCc(), GetBcc(), GetNewsgroups()));
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetCreatorIdentityKey(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetCreatorIdentityKey(const char *value) {
   return SetAsciiHeader(MSG_CREATOR_IDENTITY_KEY_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetCreatorIdentityKey(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetCreatorIdentityKey(char **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = strdup(GetAsciiHeader(MSG_CREATOR_IDENTITY_KEY_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetSubject(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetSubject(const nsAString &value) {
   return SetUnicodeHeader(MSG_SUBJECT_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetSubject(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetSubject(nsAString &_retval) {
   return GetUnicodeHeader(MSG_SUBJECT_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetOrganization(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetOrganization(const nsAString &value) {
   return SetUnicodeHeader(MSG_ORGANIZATION_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetOrganization(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetOrganization(nsAString &_retval) {
   return GetUnicodeHeader(MSG_ORGANIZATION_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetReferences(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetReferences(const char *value) {
   return SetAsciiHeader(MSG_REFERENCES_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetReferences(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetReferences(char **_retval) {
   *_retval = strdup(GetAsciiHeader(MSG_REFERENCES_HEADER_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetNewspostUrl(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetNewspostUrl(const char *value) {
   return SetAsciiHeader(MSG_NEWSPOSTURL_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetNewspostUrl(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetNewspostUrl(char **_retval) {
   *_retval = strdup(GetAsciiHeader(MSG_NEWSPOSTURL_HEADER_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetPriority(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetPriority(const char *value) {
   return SetAsciiHeader(MSG_PRIORITY_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetPriority(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetPriority(char **_retval) {
   *_retval = strdup(GetAsciiHeader(MSG_PRIORITY_HEADER_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetCharacterSet(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetCharacterSet(const char *value) {
   return SetAsciiHeader(MSG_CHARACTER_SET_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetCharacterSet(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetCharacterSet(char **_retval) {
   *_retval = strdup(GetAsciiHeader(MSG_CHARACTER_SET_HEADER_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetMessageId(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetMessageId(const char *value) {
   return SetAsciiHeader(MSG_MESSAGE_ID_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetMessageId(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetMessageId(char **_retval) {
   *_retval = strdup(GetAsciiHeader(MSG_MESSAGE_ID_HEADER_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetTemplateName(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetTemplateName(const nsAString &value) {
   return SetUnicodeHeader(MSG_X_TEMPLATE_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetTemplateName(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetTemplateName(nsAString &_retval) {
   return GetUnicodeHeader(MSG_X_TEMPLATE_HEADER_ID, _retval);
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetDraftId(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetDraftId(const char *value) {
   return SetAsciiHeader(MSG_DRAFT_ID_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetDraftId(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetDraftId(char **_retval) {
   *_retval = strdup(GetAsciiHeader(MSG_DRAFT_ID_HEADER_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetTemplateId(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetTemplateId(const char *value) {
   return SetAsciiHeader(MSG_TEMPLATE_ID_HEADER_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetTemplateId(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetTemplateId(char **_retval) {
   *_retval = strdup(GetAsciiHeader(MSG_TEMPLATE_ID_HEADER_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetReturnReceipt(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetReturnReceipt(bool value) {
   m_returnReceipt = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetReturnReceipt(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetReturnReceipt(bool *_retval) {
   *_retval = m_returnReceipt;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetReceiptHeaderType(int32_t value)
-{
-    m_receiptHeaderType = value;
-    return NS_OK;
+NS_IMETHODIMP nsMsgCompFields::SetReceiptHeaderType(int32_t value) {
+  m_receiptHeaderType = value;
+  return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetReceiptHeaderType(int32_t *_retval)
-{
-    *_retval = m_receiptHeaderType;
-    return NS_OK;
+NS_IMETHODIMP nsMsgCompFields::GetReceiptHeaderType(int32_t *_retval) {
+  *_retval = m_receiptHeaderType;
+  return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetDSN(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetDSN(bool value) {
   m_DSN = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetDSN(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetDSN(bool *_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = m_DSN;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetAttachVCard(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetAttachVCard(bool value) {
   m_attachVCard = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetAttachVCard(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetAttachVCard(bool *_retval) {
   *_retval = m_attachVCard;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetAttachmentReminder(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetAttachmentReminder(bool *_retval) {
   *_retval = m_attachmentReminder;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetAttachmentReminder(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetAttachmentReminder(bool value) {
   m_attachmentReminder = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetDeliveryFormat(int32_t value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetDeliveryFormat(int32_t value) {
   switch (value) {
     case nsIMsgCompSendFormat::AskUser:
     case nsIMsgCompSendFormat::PlainText:
     case nsIMsgCompSendFormat::HTML:
     case nsIMsgCompSendFormat::Both:
       m_deliveryFormat = value;
       break;
     default:
       m_deliveryFormat = nsIMsgCompSendFormat::AskUser;
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetDeliveryFormat(int32_t *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetDeliveryFormat(int32_t *_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = m_deliveryFormat;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetContentLanguage(const char *value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetContentLanguage(const char *value) {
   return SetAsciiHeader(MSG_CONTENT_LANGUAGE_ID, value);
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetContentLanguage(char **_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetContentLanguage(char **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = strdup(GetAsciiHeader(MSG_CONTENT_LANGUAGE_ID));
   return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetForcePlainText(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetForcePlainText(bool value) {
   m_forcePlainText = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetForcePlainText(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetForcePlainText(bool *_retval) {
   *_retval = m_forcePlainText;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetForceMsgEncoding(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetForceMsgEncoding(bool value) {
   m_forceMsgEncoding = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetForceMsgEncoding(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetForceMsgEncoding(bool *_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = m_forceMsgEncoding;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetUseMultipartAlternative(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetUseMultipartAlternative(bool value) {
   m_useMultipartAlternative = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetUseMultipartAlternative(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetUseMultipartAlternative(bool *_retval) {
   *_retval = m_useMultipartAlternative;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetBodyIsAsciiOnly(bool value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetBodyIsAsciiOnly(bool value) {
   m_bodyIsAsciiOnly = value;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetBodyIsAsciiOnly(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetBodyIsAsciiOnly(bool *_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
 
   *_retval = m_bodyIsAsciiOnly;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetBody(const nsAString &value)
-{
+NS_IMETHODIMP nsMsgCompFields::SetBody(const nsAString &value) {
   CopyUTF16toUTF8(value, m_body);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetBody(nsAString &_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetBody(nsAString &_retval) {
   CopyUTF8toUTF16(m_body, _retval);
   return NS_OK;
 }
 
-nsresult nsMsgCompFields::SetBody(const char *value)
-{
+nsresult nsMsgCompFields::SetBody(const char *value) {
   if (value)
     m_body = value;
   else
     m_body.Truncate();
   return NS_OK;
 }
 
-const char* nsMsgCompFields::GetBody()
-{
-    return m_body.get();
-}
+const char *nsMsgCompFields::GetBody() { return m_body.get(); }
 
 /* readonly attribute nsISimpleEnumerator attachmentsArray; */
-NS_IMETHODIMP nsMsgCompFields::GetAttachments(nsISimpleEnumerator * *aAttachmentsEnum)
-{
-  return aAttachmentsEnum ? NS_NewArrayEnumerator(aAttachmentsEnum, m_attachments, NS_GET_IID(nsIMsgAttachment)) : NS_ERROR_NULL_POINTER;
+NS_IMETHODIMP nsMsgCompFields::GetAttachments(
+    nsISimpleEnumerator **aAttachmentsEnum) {
+  return aAttachmentsEnum
+             ? NS_NewArrayEnumerator(aAttachmentsEnum, m_attachments,
+                                     NS_GET_IID(nsIMsgAttachment))
+             : NS_ERROR_NULL_POINTER;
 }
 
 /* void addAttachment (in nsIMsgAttachment attachment); */
-NS_IMETHODIMP nsMsgCompFields::AddAttachment(nsIMsgAttachment *attachment)
-{
+NS_IMETHODIMP nsMsgCompFields::AddAttachment(nsIMsgAttachment *attachment) {
   int32_t attachmentCount = m_attachments.Count();
 
-  //Don't add twice the same attachment.
+  // Don't add twice the same attachment.
   nsCOMPtr<nsIMsgAttachment> element;
   bool sameUrl;
-  for (int32_t i = 0; i < attachmentCount; i ++)
-  {
+  for (int32_t i = 0; i < attachmentCount; i++) {
     m_attachments[i]->EqualsUrl(attachment, &sameUrl);
-    if (sameUrl)
-      return NS_OK;
+    if (sameUrl) return NS_OK;
   }
   m_attachments.AppendObject(attachment);
 
   return NS_OK;
 }
 
 /* void removeAttachment (in nsIMsgAttachment attachment); */
-NS_IMETHODIMP nsMsgCompFields::RemoveAttachment(nsIMsgAttachment *attachment)
-{
+NS_IMETHODIMP nsMsgCompFields::RemoveAttachment(nsIMsgAttachment *attachment) {
   int32_t attachmentCount = m_attachments.Count();
 
   nsCOMPtr<nsIMsgAttachment> element;
   bool sameUrl;
-  for (int32_t i = 0; i < attachmentCount; i ++)
-  {
+  for (int32_t i = 0; i < attachmentCount; i++) {
     m_attachments[i]->EqualsUrl(attachment, &sameUrl);
-    if (sameUrl)
-    {
+    if (sameUrl) {
       m_attachments.RemoveObjectAt(i);
       break;
     }
   }
 
   return NS_OK;
 }
 
 /* void removeAttachments (); */
-NS_IMETHODIMP nsMsgCompFields::RemoveAttachments()
-{
+NS_IMETHODIMP nsMsgCompFields::RemoveAttachments() {
   m_attachments.Clear();
 
   return NS_OK;
 }
 
-
 // This method is called during the creation of a new window.
 NS_IMETHODIMP
 nsMsgCompFields::SplitRecipients(const nsAString &aRecipients,
-                                 bool aEmailAddressOnly,
-                                 uint32_t *aLength,
-                                 char16_t*** aResult)
-{
+                                 bool aEmailAddressOnly, uint32_t *aLength,
+                                 char16_t ***aResult) {
   NS_ENSURE_ARG_POINTER(aLength);
   NS_ENSURE_ARG_POINTER(aResult);
 
   *aLength = 0;
   *aResult = nullptr;
 
   nsCOMArray<msgIAddressObject> header(EncodedHeaderW(aRecipients));
   nsTArray<nsString> results;
   if (aEmailAddressOnly)
     ExtractEmails(header, results);
   else
     ExtractDisplayAddresses(header, results);
 
   uint32_t count = results.Length();
   char16_t **result = (char16_t **)moz_xmalloc(sizeof(char16_t *) * count);
-  for (uint32_t i = 0; i < count; ++i)
-    result[i] = ToNewUnicode(results[i]);
+  for (uint32_t i = 0; i < count; ++i) result[i] = ToNewUnicode(results[i]);
 
   *aResult = result;
   *aLength = count;
   return NS_OK;
 }
 
-
-// This method is called during the sending of message from nsMsgCompose::CheckAndPopulateRecipients()
+// This method is called during the sending of message from
+// nsMsgCompose::CheckAndPopulateRecipients()
 nsresult nsMsgCompFields::SplitRecipientsEx(const nsAString &recipients,
-                                            nsTArray<nsMsgRecipient> &aResult)
-{
+                                            nsTArray<nsMsgRecipient> &aResult) {
   nsTArray<nsString> names, addresses;
   ExtractAllAddresses(EncodedHeaderW(recipients), names, addresses);
 
   uint32_t numAddresses = names.Length();
-  for (uint32_t i = 0; i < numAddresses; ++i)
-  {
+  for (uint32_t i = 0; i < numAddresses; ++i) {
     nsMsgRecipient msgRecipient;
     msgRecipient.mEmail = addresses[i];
     msgRecipient.mName = names[i];
     aResult.AppendElement(msgRecipient);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::ConvertBodyToPlainText()
-{
+NS_IMETHODIMP nsMsgCompFields::ConvertBodyToPlainText() {
   nsresult rv = NS_OK;
 
-  if (!m_body.IsEmpty())
-  {
+  if (!m_body.IsEmpty()) {
     nsAutoString body;
     rv = GetBody(body);
-    if (NS_SUCCEEDED(rv))
-    {
+    if (NS_SUCCEEDED(rv)) {
       bool flowed, delsp, formatted, disallowBreaks;
-      GetSerialiserFlags(GetCharacterSet(), &flowed, &delsp, &formatted, &disallowBreaks);
-      rv = ConvertBufToPlainText(body, flowed, delsp, formatted, disallowBreaks);
-      if (NS_SUCCEEDED(rv))
-        rv = SetBody(body);
+      GetSerialiserFlags(GetCharacterSet(), &flowed, &delsp, &formatted,
+                         &disallowBreaks);
+      rv =
+          ConvertBufToPlainText(body, flowed, delsp, formatted, disallowBreaks);
+      if (NS_SUCCEEDED(rv)) rv = SetBody(body);
     }
   }
   return rv;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetComposeSecure(nsIMsgComposeSecure ** aComposeSecure)
-{
+NS_IMETHODIMP nsMsgCompFields::GetComposeSecure(
+    nsIMsgComposeSecure **aComposeSecure) {
   NS_ENSURE_ARG_POINTER(aComposeSecure);
   NS_IF_ADDREF(*aComposeSecure = mSecureCompFields);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetComposeSecure(nsIMsgComposeSecure * aComposeSecure)
-{
+NS_IMETHODIMP nsMsgCompFields::SetComposeSecure(
+    nsIMsgComposeSecure *aComposeSecure) {
   mSecureCompFields = aComposeSecure;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetDefaultCharacterSet(char * *aDefaultCharacterSet)
-{
+NS_IMETHODIMP nsMsgCompFields::GetDefaultCharacterSet(
+    char **aDefaultCharacterSet) {
   NS_ENSURE_ARG_POINTER(aDefaultCharacterSet);
   *aDefaultCharacterSet = ToNewCString(m_DefaultCharacterSet);
   return *aDefaultCharacterSet ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-NS_IMETHODIMP nsMsgCompFields::GetNeedToCheckCharset(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompFields::GetNeedToCheckCharset(bool *_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = m_needToCheckCharset;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompFields::SetNeedToCheckCharset(bool aCheck)
-{
+NS_IMETHODIMP nsMsgCompFields::SetNeedToCheckCharset(bool aCheck) {
   m_needToCheckCharset = aCheck;
   return NS_OK;
 }
--- a/mailnews/compose/src/nsMsgCompFields.h
+++ b/mailnews/compose/src/nsMsgCompFields.h
@@ -11,46 +11,44 @@
 #include "nsIAbCard.h"
 #include "nsIAbDirectory.h"
 #include "nsTArray.h"
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIMsgComposeSecure.h"
 
-struct nsMsgRecipient
-{
+struct nsMsgRecipient {
   nsString mName;
   nsString mEmail;
   nsCOMPtr<nsIAbCard> mCard;
   nsCOMPtr<nsIAbDirectory> mDirectory;
 };
 
 /* Note that all the "Get" methods never return NULL (except in case of serious
    error, like an illegal parameter); rather, they return "" if things were set
    to NULL.  This makes it real handy for the callers. */
 
 class nsMsgCompFields : public nsIMsgCompFields {
-public:
+ public:
   nsMsgCompFields();
 
   /* this macro defines QueryInterface, AddRef and Release for this class */
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_FORWARD_MSGISTRUCTUREDHEADERS(mStructuredHeaders->)
   NS_FORWARD_MSGIWRITABLESTRUCTUREDHEADERS(mStructuredHeaders->)
   NS_DECL_NSIMSGCOMPFIELDS
 
   // Allow the C++ utility methods for people who use a concrete class instead
   // of the interfaces.
   using msgIStructuredHeaders::GetAddressingHeader;
   using msgIWritableStructuredHeaders::SetAddressingHeader;
 
-  typedef enum MsgHeaderID
-  {
-    MSG_FROM_HEADER_ID        = 0,
+  typedef enum MsgHeaderID {
+    MSG_FROM_HEADER_ID = 0,
     MSG_REPLY_TO_HEADER_ID,
     MSG_TO_HEADER_ID,
     MSG_CC_HEADER_ID,
     MSG_BCC_HEADER_ID,
     MSG_FCC_HEADER_ID,
     MSG_FCC2_HEADER_ID,
     MSG_NEWSGROUPS_HEADER_ID,
     MSG_FOLLOWUP_TO_HEADER_ID,
@@ -62,114 +60,160 @@ public:
     MSG_CHARACTER_SET_HEADER_ID,
     MSG_MESSAGE_ID_HEADER_ID,
     MSG_X_TEMPLATE_HEADER_ID,
     MSG_DRAFT_ID_HEADER_ID,
     MSG_TEMPLATE_ID_HEADER_ID,
     MSG_CONTENT_LANGUAGE_ID,
     MSG_CREATOR_IDENTITY_KEY_ID,
 
-    MSG_MAX_HEADERS   //Must be the last one.
+    MSG_MAX_HEADERS  // Must be the last one.
   } MsgHeaderID;
 
-  nsresult SetAsciiHeader(MsgHeaderID header, const char *value);
-  const char* GetAsciiHeader(MsgHeaderID header); //just return the address of the internal header variable, don't dispose it
+  nsresult SetAsciiHeader(MsgHeaderID header, const char* value);
+  const char* GetAsciiHeader(
+      MsgHeaderID header);  // just return the address of the internal header
+                            // variable, don't dispose it
 
-  nsresult SetUnicodeHeader(MsgHeaderID header, const nsAString &value);
-  nsresult GetUnicodeHeader(MsgHeaderID header, nsAString &_retval);
+  nsresult SetUnicodeHeader(MsgHeaderID header, const nsAString& value);
+  nsresult GetUnicodeHeader(MsgHeaderID header, nsAString& _retval);
 
   /* Convenience routines to get and set header's value...
 
     IMPORTANT:
-    all routines const char* GetXxx(void) will return a pointer to the header, please don't free it.
+    all routines const char* GetXxx(void) will return a pointer to the header,
+    please don't free it.
   */
 
-  nsresult SetFrom(const char *value) {return SetAsciiHeader(MSG_FROM_HEADER_ID, value);}
-  const char* GetFrom(void) {return GetAsciiHeader(MSG_FROM_HEADER_ID);}
+  nsresult SetFrom(const char* value) {
+    return SetAsciiHeader(MSG_FROM_HEADER_ID, value);
+  }
+  const char* GetFrom(void) { return GetAsciiHeader(MSG_FROM_HEADER_ID); }
 
-  nsresult SetReplyTo(const char *value) {return SetAsciiHeader(MSG_REPLY_TO_HEADER_ID, value);}
-  const char* GetReplyTo() {return GetAsciiHeader(MSG_REPLY_TO_HEADER_ID);}
+  nsresult SetReplyTo(const char* value) {
+    return SetAsciiHeader(MSG_REPLY_TO_HEADER_ID, value);
+  }
+  const char* GetReplyTo() { return GetAsciiHeader(MSG_REPLY_TO_HEADER_ID); }
 
-  nsresult SetTo(const char *value) {return SetAsciiHeader(MSG_TO_HEADER_ID, value);}
-  const char* GetTo() {return GetAsciiHeader(MSG_TO_HEADER_ID);}
+  nsresult SetTo(const char* value) {
+    return SetAsciiHeader(MSG_TO_HEADER_ID, value);
+  }
+  const char* GetTo() { return GetAsciiHeader(MSG_TO_HEADER_ID); }
 
-  nsresult SetCc(const char *value) {return SetAsciiHeader(MSG_CC_HEADER_ID, value);}
-  const char* GetCc() {return GetAsciiHeader(MSG_CC_HEADER_ID);}
-
-  nsresult SetBcc(const char *value) {return SetAsciiHeader(MSG_BCC_HEADER_ID, value);}
-  const char* GetBcc() {return GetAsciiHeader(MSG_BCC_HEADER_ID);}
+  nsresult SetCc(const char* value) {
+    return SetAsciiHeader(MSG_CC_HEADER_ID, value);
+  }
+  const char* GetCc() { return GetAsciiHeader(MSG_CC_HEADER_ID); }
 
-  nsresult SetFcc(const char *value) {return SetAsciiHeader(MSG_FCC_HEADER_ID, value);}
-  const char* GetFcc() {return GetAsciiHeader(MSG_FCC_HEADER_ID);}
+  nsresult SetBcc(const char* value) {
+    return SetAsciiHeader(MSG_BCC_HEADER_ID, value);
+  }
+  const char* GetBcc() { return GetAsciiHeader(MSG_BCC_HEADER_ID); }
 
-  nsresult SetFcc2(const char *value) {return SetAsciiHeader(MSG_FCC2_HEADER_ID, value);}
-  const char* GetFcc2() {return GetAsciiHeader(MSG_FCC2_HEADER_ID);}
+  nsresult SetFcc(const char* value) {
+    return SetAsciiHeader(MSG_FCC_HEADER_ID, value);
+  }
+  const char* GetFcc() { return GetAsciiHeader(MSG_FCC_HEADER_ID); }
 
-  nsresult SetNewsgroups(const char *aValue) {return SetAsciiHeader(MSG_NEWSGROUPS_HEADER_ID, aValue);}
-  const char* GetNewsgroups() {return GetAsciiHeader(MSG_NEWSGROUPS_HEADER_ID);}
+  nsresult SetFcc2(const char* value) {
+    return SetAsciiHeader(MSG_FCC2_HEADER_ID, value);
+  }
+  const char* GetFcc2() { return GetAsciiHeader(MSG_FCC2_HEADER_ID); }
 
-  nsresult SetFollowupTo(const char *aValue) {return SetAsciiHeader(MSG_FOLLOWUP_TO_HEADER_ID, aValue);}
-  const char* GetFollowupTo() {return GetAsciiHeader(MSG_FOLLOWUP_TO_HEADER_ID);}
+  nsresult SetNewsgroups(const char* aValue) {
+    return SetAsciiHeader(MSG_NEWSGROUPS_HEADER_ID, aValue);
+  }
+  const char* GetNewsgroups() {
+    return GetAsciiHeader(MSG_NEWSGROUPS_HEADER_ID);
+  }
 
-  nsresult SetSubject(const char *value) {return SetAsciiHeader(MSG_SUBJECT_HEADER_ID, value);}
-  const char* GetSubject() {return GetAsciiHeader(MSG_SUBJECT_HEADER_ID);}
+  nsresult SetFollowupTo(const char* aValue) {
+    return SetAsciiHeader(MSG_FOLLOWUP_TO_HEADER_ID, aValue);
+  }
+  const char* GetFollowupTo() {
+    return GetAsciiHeader(MSG_FOLLOWUP_TO_HEADER_ID);
+  }
 
-  nsresult SetOrganization(const char *value) {return SetAsciiHeader(MSG_ORGANIZATION_HEADER_ID, value);}
-  const char* GetOrganization() {return GetAsciiHeader(MSG_ORGANIZATION_HEADER_ID);}
+  nsresult SetSubject(const char* value) {
+    return SetAsciiHeader(MSG_SUBJECT_HEADER_ID, value);
+  }
+  const char* GetSubject() { return GetAsciiHeader(MSG_SUBJECT_HEADER_ID); }
 
-  const char* GetReferences() {return GetAsciiHeader(MSG_REFERENCES_HEADER_ID);}
-
-  const char* GetNewspostUrl() {return GetAsciiHeader(MSG_NEWSPOSTURL_HEADER_ID);}
+  nsresult SetOrganization(const char* value) {
+    return SetAsciiHeader(MSG_ORGANIZATION_HEADER_ID, value);
+  }
+  const char* GetOrganization() {
+    return GetAsciiHeader(MSG_ORGANIZATION_HEADER_ID);
+  }
 
-  const char* GetPriority() {return GetAsciiHeader(MSG_PRIORITY_HEADER_ID);}
-
-  const char* GetCharacterSet() {return GetAsciiHeader(MSG_CHARACTER_SET_HEADER_ID);}
+  const char* GetReferences() {
+    return GetAsciiHeader(MSG_REFERENCES_HEADER_ID);
+  }
 
-  const char* GetMessageId() {return GetAsciiHeader(MSG_MESSAGE_ID_HEADER_ID);}
+  const char* GetNewspostUrl() {
+    return GetAsciiHeader(MSG_NEWSPOSTURL_HEADER_ID);
+  }
 
-  nsresult SetTemplateName(const char *value) {return SetAsciiHeader(MSG_X_TEMPLATE_HEADER_ID, value);}
-  const char* GetTemplateName() {return GetAsciiHeader(MSG_X_TEMPLATE_HEADER_ID);}
+  const char* GetPriority() { return GetAsciiHeader(MSG_PRIORITY_HEADER_ID); }
+
+  const char* GetCharacterSet() {
+    return GetAsciiHeader(MSG_CHARACTER_SET_HEADER_ID);
+  }
 
-  const char* GetDraftId() {return GetAsciiHeader(MSG_DRAFT_ID_HEADER_ID);}
-  const char* GetTemplateId() {return GetAsciiHeader(MSG_TEMPLATE_ID_HEADER_ID);}
+  const char* GetMessageId() {
+    return GetAsciiHeader(MSG_MESSAGE_ID_HEADER_ID);
+  }
 
-  const char* GetContentLanguage() {return GetAsciiHeader(MSG_CONTENT_LANGUAGE_ID);}
+  nsresult SetTemplateName(const char* value) {
+    return SetAsciiHeader(MSG_X_TEMPLATE_HEADER_ID, value);
+  }
+  const char* GetTemplateName() {
+    return GetAsciiHeader(MSG_X_TEMPLATE_HEADER_ID);
+  }
+
+  const char* GetDraftId() { return GetAsciiHeader(MSG_DRAFT_ID_HEADER_ID); }
+  const char* GetTemplateId() {
+    return GetAsciiHeader(MSG_TEMPLATE_ID_HEADER_ID);
+  }
 
-  bool GetReturnReceipt() {return m_returnReceipt;}
-  bool GetDSN() {return m_DSN;}
-  bool GetAttachVCard() {return m_attachVCard;}
-  bool GetAttachmentReminder() {return m_attachmentReminder;}
-  int32_t GetDeliveryFormat() {return m_deliveryFormat;}
-  bool GetForcePlainText() {return m_forcePlainText;}
-  bool GetUseMultipartAlternative() {return m_useMultipartAlternative;}
-  bool GetBodyIsAsciiOnly() {return m_bodyIsAsciiOnly;}
-  bool GetForceMsgEncoding() {return m_forceMsgEncoding;}
+  const char* GetContentLanguage() {
+    return GetAsciiHeader(MSG_CONTENT_LANGUAGE_ID);
+  }
 
-  nsresult SetBody(const char *value);
+  bool GetReturnReceipt() { return m_returnReceipt; }
+  bool GetDSN() { return m_DSN; }
+  bool GetAttachVCard() { return m_attachVCard; }
+  bool GetAttachmentReminder() { return m_attachmentReminder; }
+  int32_t GetDeliveryFormat() { return m_deliveryFormat; }
+  bool GetForcePlainText() { return m_forcePlainText; }
+  bool GetUseMultipartAlternative() { return m_useMultipartAlternative; }
+  bool GetBodyIsAsciiOnly() { return m_bodyIsAsciiOnly; }
+  bool GetForceMsgEncoding() { return m_forceMsgEncoding; }
+
+  nsresult SetBody(const char* value);
   const char* GetBody();
 
-  nsresult SplitRecipientsEx(const nsAString &recipients,
-                             nsTArray<nsMsgRecipient> &aResult);
+  nsresult SplitRecipientsEx(const nsAString& recipients,
+                             nsTArray<nsMsgRecipient>& aResult);
 
-protected:
+ protected:
   virtual ~nsMsgCompFields();
   nsCString m_headers[MSG_MAX_HEADERS];
-  nsCString   m_body;
+  nsCString m_body;
   nsCOMArray<nsIMsgAttachment> m_attachments;
-  bool        m_attachVCard;
-  bool        m_attachmentReminder;
-  int32_t     m_deliveryFormat;
-  bool        m_forcePlainText;
-  bool        m_useMultipartAlternative;
-  bool        m_returnReceipt;
-  bool        m_DSN;
-  bool        m_bodyIsAsciiOnly;
-  bool        m_forceMsgEncoding;
-  int32_t     m_receiptHeaderType;        /* receipt header type */
-  nsCString   m_DefaultCharacterSet;
-  bool        m_needToCheckCharset;
+  bool m_attachVCard;
+  bool m_attachmentReminder;
+  int32_t m_deliveryFormat;
+  bool m_forcePlainText;
+  bool m_useMultipartAlternative;
+  bool m_returnReceipt;
+  bool m_DSN;
+  bool m_bodyIsAsciiOnly;
+  bool m_forceMsgEncoding;
+  int32_t m_receiptHeaderType; /* receipt header type */
+  nsCString m_DefaultCharacterSet;
+  bool m_needToCheckCharset;
 
   nsCOMPtr<nsIMsgComposeSecure> mSecureCompFields;
   nsCOMPtr<msgIWritableStructuredHeaders> mStructuredHeaders;
 };
 
-
 #endif /* _MsgCompFields_H_ */
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -38,408 +38,364 @@
 #include "nsIMIMEInfo.h"
 #include "nsIMsgHeaderParser.h"
 #include "nsIMutableArray.h"
 #include "nsIRandomGenerator.h"
 #include "nsID.h"
 
 NS_IMPL_ISUPPORTS(nsMsgCompUtils, nsIMsgCompUtils)
 
-nsMsgCompUtils::nsMsgCompUtils()
-{
-}
+nsMsgCompUtils::nsMsgCompUtils() {}
 
-nsMsgCompUtils::~nsMsgCompUtils()
-{
-}
+nsMsgCompUtils::~nsMsgCompUtils() {}
 
 NS_IMETHODIMP nsMsgCompUtils::MimeMakeSeparator(const char *prefix,
-                                                char **_retval)
-{
+                                                char **_retval) {
   NS_ENSURE_ARG_POINTER(prefix);
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = mime_make_separator(prefix);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgCompUtils::MsgGenerateMessageId(nsIMsgIdentity *identity,
-                                                    char **_retval)
-{
+                                                   char **_retval) {
   NS_ENSURE_ARG_POINTER(identity);
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = msg_generate_message_id(identity);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompUtils::GetMsgMimeConformToStandard(bool *_retval)
-{
+NS_IMETHODIMP nsMsgCompUtils::GetMsgMimeConformToStandard(bool *_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nsMsgMIMEGetConformToStandard();
   return NS_OK;
 }
 
 //
 // Create a file for the a unique temp file
 // on the local machine. Caller must free memory
 //
-nsresult
-nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile)
-{
-  if ((!tFileName) || (!*tFileName))
-    tFileName = "nsmail.tmp";
+nsresult nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile) {
+  if ((!tFileName) || (!*tFileName)) tFileName = "nsmail.tmp";
 
-  nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR,
-                                                tFileName,
-                                                tFile);
+  nsresult rv =
+      GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, tFileName, tFile);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = (*tFile)->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
-  if (NS_FAILED(rv))
-    NS_RELEASE(*tFile);
+  if (NS_FAILED(rv)) NS_RELEASE(*tFile);
 
   return rv;
 }
 
 // This is the value a caller will Get if they don't Set first (like MDN
 // sending a return receipt), so init to the default value of the
 // mail.strictly_mime_headers preference.
 static bool mime_headers_use_quoted_printable_p = true;
 
-bool
-nsMsgMIMEGetConformToStandard (void)
-{
+bool nsMsgMIMEGetConformToStandard(void) {
   return mime_headers_use_quoted_printable_p;
 }
 
-void
-nsMsgMIMESetConformToStandard (bool conform_p)
-{
+void nsMsgMIMESetConformToStandard(bool conform_p) {
   /*
-  * If we are conforming to mime standard no matter what we set
-  * for the headers preference when generating mime headers we should
-  * also conform to the standard. Otherwise, depends the preference
-  * we set. For now, the headers preference is not accessible from UI.
-  */
+   * If we are conforming to mime standard no matter what we set
+   * for the headers preference when generating mime headers we should
+   * also conform to the standard. Otherwise, depends the preference
+   * we set. For now, the headers preference is not accessible from UI.
+   */
   if (conform_p)
     mime_headers_use_quoted_printable_p = true;
   else {
     nsresult rv;
-    nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+    nsCOMPtr<nsIPrefBranch> prefs(
+        do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
     if (NS_SUCCEEDED(rv)) {
-      prefs->GetBoolPref("mail.strictly_mime_headers", &mime_headers_use_quoted_printable_p);
+      prefs->GetBoolPref("mail.strictly_mime_headers",
+                         &mime_headers_use_quoted_printable_p);
     }
   }
 }
 
 /**
  * Checks if the recipient fields have sane values for message send.
  */
-nsresult mime_sanity_check_fields_recipients (
-          const char *to,
-          const char *cc,
-          const char *bcc,
-          const char *newsgroups)
-{
+nsresult mime_sanity_check_fields_recipients(const char *to, const char *cc,
+                                             const char *bcc,
+                                             const char *newsgroups) {
   if (to)
-    while (IS_SPACE(*to))
-      to++;
+    while (IS_SPACE(*to)) to++;
   if (cc)
-    while (IS_SPACE(*cc))
-      cc++;
+    while (IS_SPACE(*cc)) cc++;
   if (bcc)
-    while (IS_SPACE(*bcc))
-      bcc++;
+    while (IS_SPACE(*bcc)) bcc++;
   if (newsgroups)
-    while (IS_SPACE(*newsgroups))
-      newsgroups++;
+    while (IS_SPACE(*newsgroups)) newsgroups++;
 
-  if ((!to || !*to) && (!cc || !*cc) &&
-      (!bcc || !*bcc) && (!newsgroups || !*newsgroups))
+  if ((!to || !*to) && (!cc || !*cc) && (!bcc || !*bcc) &&
+      (!newsgroups || !*newsgroups))
     return NS_MSG_NO_RECIPIENTS;
 
   return NS_OK;
 }
 
 /**
  * Checks if the compose fields have sane values for message send.
  */
-nsresult mime_sanity_check_fields (
-          const char *from,
-          const char *reply_to,
-          const char *to,
-          const char *cc,
-          const char *bcc,
-          const char *fcc,
-          const char *newsgroups,
-          const char *followup_to,
-          const char * /*subject*/,
-          const char * /*references*/,
-          const char * /*organization*/,
-          const char * /*other_random_headers*/)
-{
+nsresult mime_sanity_check_fields(
+    const char *from, const char *reply_to, const char *to, const char *cc,
+    const char *bcc, const char *fcc, const char *newsgroups,
+    const char *followup_to, const char * /*subject*/,
+    const char * /*references*/, const char * /*organization*/,
+    const char * /*other_random_headers*/) {
   if (from)
-    while (IS_SPACE(*from))
-      from++;
+    while (IS_SPACE(*from)) from++;
   if (reply_to)
-    while (IS_SPACE(*reply_to))
-      reply_to++;
+    while (IS_SPACE(*reply_to)) reply_to++;
   if (fcc)
-    while (IS_SPACE(*fcc))
-      fcc++;
+    while (IS_SPACE(*fcc)) fcc++;
   if (followup_to)
-    while (IS_SPACE(*followup_to))
-      followup_to++;
+    while (IS_SPACE(*followup_to)) followup_to++;
 
   // TODO: sanity check other_random_headers for newline conventions
-  if (!from || !*from)
-    return NS_MSG_NO_SENDER;
+  if (!from || !*from) return NS_MSG_NO_SENDER;
 
   return mime_sanity_check_fields_recipients(to, cc, bcc, newsgroups);
 }
 
 //
 // Generate the message headers for the new RFC822 message
 //
 #define UA_PREF_PREFIX "general.useragent."
 
 // Helper macro for generating the X-Mozilla-Draft-Info header.
-#define APPEND_BOOL(method, param) \
-    do { \
-      bool val = false; \
-      fields->Get##method(&val); \
-      if (val) \
-        draftInfo.AppendLiteral(param "=1"); \
-      else \
-        draftInfo.AppendLiteral(param "=0"); \
-    } while (false)
+#define APPEND_BOOL(method, param)         \
+  do {                                     \
+    bool val = false;                      \
+    fields->Get##method(&val);             \
+    if (val)                               \
+      draftInfo.AppendLiteral(param "=1"); \
+    else                                   \
+      draftInfo.AppendLiteral(param "=0"); \
+  } while (false)
 
 nsresult mime_generate_headers(nsIMsgCompFields *fields,
                                nsMsgDeliverMode deliver_mode,
-                               msgIWritableStructuredHeaders *finalHeaders)
-{
+                               msgIWritableStructuredHeaders *finalHeaders) {
   nsresult rv = NS_OK;
 
   nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  bool isDraft =
-    deliver_mode == nsIMsgSend::nsMsgSaveAsDraft ||
-    deliver_mode == nsIMsgSend::nsMsgSaveAsTemplate ||
-    deliver_mode == nsIMsgSend::nsMsgQueueForLater ||
-    deliver_mode == nsIMsgSend::nsMsgDeliverBackground;
+  bool isDraft = deliver_mode == nsIMsgSend::nsMsgSaveAsDraft ||
+                 deliver_mode == nsIMsgSend::nsMsgSaveAsTemplate ||
+                 deliver_mode == nsIMsgSend::nsMsgQueueForLater ||
+                 deliver_mode == nsIMsgSend::nsMsgDeliverBackground;
 
   bool hasDisclosedRecipient = false;
 
   MOZ_ASSERT(fields, "null fields");
   NS_ENSURE_ARG_POINTER(fields);
 
   nsCOMArray<msgIAddressObject> from;
   fields->GetAddressingHeader("From", from, true);
 
   // Copy all headers from the original compose field.
   rv = finalHeaders->AddAllHeaders(fields);
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool hasMessageId = false;
   if (NS_SUCCEEDED(fields->HasHeader("Message-ID", &hasMessageId)) &&
-      hasMessageId)
-  {
+      hasMessageId) {
     /* MDN request header requires to have MessageID header presented
-    * in the message in order to
-    * coorelate the MDN reports to the original message. Here will be
-    * the right place
-    */
+     * in the message in order to
+     * coorelate the MDN reports to the original message. Here will be
+     * the right place
+     */
 
     bool returnReceipt = false;
     fields->GetReturnReceipt(&returnReceipt);
-    if (returnReceipt &&
-      (deliver_mode != nsIMsgSend::nsMsgSaveAsDraft &&
-      deliver_mode != nsIMsgSend::nsMsgSaveAsTemplate))
-    {
+    if (returnReceipt && (deliver_mode != nsIMsgSend::nsMsgSaveAsDraft &&
+                          deliver_mode != nsIMsgSend::nsMsgSaveAsTemplate)) {
       int32_t receipt_header_type = nsIMsgMdnGenerator::eDntType;
       fields->GetReceiptHeaderType(&receipt_header_type);
 
       // nsIMsgMdnGenerator::eDntType = MDN Disposition-Notification-To: ;
       // nsIMsgMdnGenerator::eRrtType = Return-Receipt-To: ;
       // nsIMsgMdnGenerator::eDntRrtType = both MDN DNT and RRT headers .
       if (receipt_header_type != nsIMsgMdnGenerator::eRrtType)
         finalHeaders->SetAddressingHeader("Disposition-Notification-To", from);
       if (receipt_header_type != nsIMsgMdnGenerator::eDntType)
         finalHeaders->SetAddressingHeader("Return-Receipt-To", from);
     }
   }
 
   PRExplodedTime now;
   PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &now);
-  int gmtoffset = (now.tm_params.tp_gmt_offset + now.tm_params.tp_dst_offset) / 60;
+  int gmtoffset =
+      (now.tm_params.tp_gmt_offset + now.tm_params.tp_dst_offset) / 60;
 
   /* 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 (superseding RFC 822.)
    */
   char dateString[130];
   PR_FormatTimeUSEnglish(dateString, sizeof(dateString),
-               "%a, %d %b %Y %H:%M:%S ",
-               &now);
+                         "%a, %d %b %Y %H:%M:%S ", &now);
 
   char *entryPoint = dateString + strlen(dateString);
   PR_snprintf(entryPoint, sizeof(dateString) - (entryPoint - dateString),
-        "%c%02d%02d" CRLF,
-        (gmtoffset >= 0 ? '+' : '-'),
-        ((gmtoffset >= 0 ? gmtoffset : -gmtoffset) / 60),
-        ((gmtoffset >= 0 ? gmtoffset : -gmtoffset) % 60));
+              "%c%02d%02d" CRLF, (gmtoffset >= 0 ? '+' : '-'),
+              ((gmtoffset >= 0 ? gmtoffset : -gmtoffset) / 60),
+              ((gmtoffset >= 0 ? gmtoffset : -gmtoffset) % 60));
   finalHeaders->SetRawHeader("Date", nsDependentCString(dateString), nullptr);
 
   // X-Mozilla-Draft-Info
-  if (isDraft)
-  {
+  if (isDraft) {
     nsAutoCString draftInfo;
     draftInfo.AppendLiteral("internal/draft; ");
     APPEND_BOOL(AttachVCard, "vcard");
     draftInfo.AppendLiteral("; ");
     bool hasReturnReceipt = false;
     fields->GetReturnReceipt(&hasReturnReceipt);
-    if (hasReturnReceipt)
-    {
+    if (hasReturnReceipt) {
       // slight change compared to 4.x; we used to use receipt= to tell
       // whether the draft/template has request for either MDN or DNS or both
       // return receipt; since the DNS is out of the picture we now use the
       // header type + 1 to tell whether user has requested the return receipt
       int32_t headerType = 0;
       fields->GetReceiptHeaderType(&headerType);
       draftInfo.AppendLiteral("receipt=");
       draftInfo.AppendInt(headerType + 1);
-    }
-    else
+    } else
       draftInfo.AppendLiteral("receipt=0");
     draftInfo.AppendLiteral("; ");
     APPEND_BOOL(DSN, "DSN");
     draftInfo.AppendLiteral("; ");
     draftInfo.AppendLiteral("uuencode=0");
     draftInfo.AppendLiteral("; ");
     APPEND_BOOL(AttachmentReminder, "attachmentreminder");
     draftInfo.AppendLiteral("; ");
     int32_t deliveryFormat;
     fields->GetDeliveryFormat(&deliveryFormat);
     draftInfo.AppendLiteral("deliveryformat=");
     draftInfo.AppendInt(deliveryFormat);
 
     finalHeaders->SetRawHeader(HEADER_X_MOZILLA_DRAFT_INFO, draftInfo, nullptr);
   }
 
-  nsCOMPtr<nsIHttpProtocolHandler> pHTTPHandler = do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv);
-  if (NS_SUCCEEDED(rv) && pHTTPHandler)
-  {
+  nsCOMPtr<nsIHttpProtocolHandler> pHTTPHandler =
+      do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv);
+  if (NS_SUCCEEDED(rv) && pHTTPHandler) {
     nsAutoCString userAgentString;
     // Ignore error since we're testing the return value.
     mozilla::Unused << pHTTPHandler->GetUserAgent(userAgentString);
 
     if (!userAgentString.IsEmpty())
-      finalHeaders->SetUnstructuredHeader("User-Agent",
-        NS_ConvertUTF8toUTF16(userAgentString));
+      finalHeaders->SetUnstructuredHeader(
+          "User-Agent", NS_ConvertUTF8toUTF16(userAgentString));
   }
 
   finalHeaders->SetUnstructuredHeader("MIME-Version", NS_LITERAL_STRING("1.0"));
 
   nsAutoCString newsgroups;
   finalHeaders->GetRawHeader("Newsgroups", newsgroups);
-  if (!newsgroups.IsEmpty())
-  {
+  if (!newsgroups.IsEmpty()) {
     // Since the newsgroup header can contain data in the form of:
     // "news://news.mozilla.org/netscape.test,news://news.mozilla.org/netscape.junk"
     // we need to turn that into: "netscape.test,netscape.junk"
     // (XXX: can it really?)
     nsCOMPtr<nsINntpService> nntpService =
-      do_GetService("@mozilla.org/messenger/nntpservice;1", &rv);
+        do_GetService("@mozilla.org/messenger/nntpservice;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCString newsgroupsHeaderVal;
     nsCString newshostHeaderVal;
-    rv = nntpService->GenerateNewsHeaderValsForPosting(newsgroups,
-      getter_Copies(newsgroupsHeaderVal), getter_Copies(newshostHeaderVal));
+    rv = nntpService->GenerateNewsHeaderValsForPosting(
+        newsgroups, getter_Copies(newsgroupsHeaderVal),
+        getter_Copies(newshostHeaderVal));
     NS_ENSURE_SUCCESS(rv, rv);
     finalHeaders->SetRawHeader("Newsgroups", newsgroupsHeaderVal, nullptr);
 
     // If we are here, we are NOT going to send this now. (i.e. it is a Draft,
     // Send Later file, etc...). Because of that, we need to store what the user
     // typed in on the original composition window for use later when rebuilding
     // the headers
     if (deliver_mode != nsIMsgSend::nsMsgDeliverNow &&
-        deliver_mode != nsIMsgSend::nsMsgSendUnsent)
-    {
+        deliver_mode != nsIMsgSend::nsMsgSendUnsent) {
       // This is going to be saved for later, that means we should just store
-      // what the user typed into the "Newsgroup" line in the HEADER_X_MOZILLA_NEWSHOST
-      // header for later use by "Send Unsent Messages", "Drafts" or "Templates"
+      // what the user typed into the "Newsgroup" line in the
+      // HEADER_X_MOZILLA_NEWSHOST header for later use by "Send Unsent
+      // Messages", "Drafts" or "Templates"
       finalHeaders->SetRawHeader(HEADER_X_MOZILLA_NEWSHOST, newshostHeaderVal,
-        nullptr);
+                                 nullptr);
     }
 
     // Newsgroups are a recipient...
     hasDisclosedRecipient = true;
   }
 
   nsCOMArray<msgIAddressObject> recipients;
   finalHeaders->GetAddressingHeader("To", recipients);
   hasDisclosedRecipient |= !recipients.IsEmpty();
   finalHeaders->GetAddressingHeader("Cc", recipients);
   hasDisclosedRecipient |= !recipients.IsEmpty();
 
   // If we don't have disclosed recipient (only Bcc), address the message to
   // undisclosed-recipients to prevent problem with some servers
 
-  // If we are saving the message as a draft, don't bother inserting the undisclosed recipients field. We'll take care of that when we
-  // really send the message.
-  if (!hasDisclosedRecipient && (!isDraft || deliver_mode == nsIMsgSend::nsMsgQueueForLater))
-  {
+  // If we are saving the message as a draft, don't bother inserting the
+  // undisclosed recipients field. We'll take care of that when we really send
+  // the message.
+  if (!hasDisclosedRecipient &&
+      (!isDraft || deliver_mode == nsIMsgSend::nsMsgQueueForLater)) {
     bool bAddUndisclosedRecipients = true;
-    prefs->GetBoolPref("mail.compose.add_undisclosed_recipients", &bAddUndisclosedRecipients);
-    if (bAddUndisclosedRecipients)
-    {
+    prefs->GetBoolPref("mail.compose.add_undisclosed_recipients",
+                       &bAddUndisclosedRecipients);
+    if (bAddUndisclosedRecipients) {
       bool hasBcc = false;
       fields->HasHeader("Bcc", &hasBcc);
-      if (hasBcc)
-      {
+      if (hasBcc) {
         nsCOMPtr<nsIStringBundleService> stringService =
-          mozilla::services::GetStringBundleService();
-        if (stringService)
-        {
+            mozilla::services::GetStringBundleService();
+        if (stringService) {
           nsCOMPtr<nsIStringBundle> composeStringBundle;
-          rv = stringService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(composeStringBundle));
-          if (NS_SUCCEEDED(rv))
-          {
+          rv = stringService->CreateBundle(
+              "chrome://messenger/locale/messengercompose/"
+              "composeMsgs.properties",
+              getter_AddRefs(composeStringBundle));
+          if (NS_SUCCEEDED(rv)) {
             nsString undisclosedRecipients;
             rv = composeStringBundle->GetStringFromName("undisclosedRecipients",
                                                         undisclosedRecipients);
-            if (NS_SUCCEEDED(rv) && !undisclosedRecipients.IsEmpty())
-            {
+            if (NS_SUCCEEDED(rv) && !undisclosedRecipients.IsEmpty()) {
               nsCOMPtr<nsIMsgHeaderParser> headerParser(
-                mozilla::services::GetHeaderParser());
+                  mozilla::services::GetHeaderParser());
               nsCOMPtr<msgIAddressObject> group;
-              headerParser->MakeGroupObject(undisclosedRecipients,
-                nullptr, 0, getter_AddRefs(group));
+              headerParser->MakeGroupObject(undisclosedRecipients, nullptr, 0,
+                                            getter_AddRefs(group));
               recipients.AppendElement(group);
               finalHeaders->SetAddressingHeader("To", recipients);
             }
           }
         }
       }
     }
   }
 
   // We don't want to emit a Bcc header to the output. If we are saving this to
   // Drafts/Sent, this is re-added later in nsMsgSend.cpp.
   finalHeaders->DeleteHeader("bcc");
 
   // Skip no or empty priority.
   nsAutoCString priority;
   rv = fields->GetRawHeader("X-Priority", priority);
-  if (NS_SUCCEEDED(rv) && !priority.IsEmpty())
-  {
+  if (NS_SUCCEEDED(rv) && !priority.IsEmpty()) {
     nsMsgPriorityValue priorityValue;
 
     NS_MsgGetPriorityFromString(priority.get(), priorityValue);
 
     // Skip default priority.
     if (priorityValue != nsMsgPriority::Default) {
       nsAutoCString priorityName;
       nsAutoCString priorityValueString;
@@ -452,209 +408,181 @@ nsresult mime_generate_headers(nsIMsgCom
       priorityValueString += priorityName;
       priorityValueString.Append(')');
       finalHeaders->SetRawHeader("X-Priority", priorityValueString, nullptr);
     }
   }
 
   nsAutoCString references;
   finalHeaders->GetRawHeader("References", references);
-  if (!references.IsEmpty())
-  {
+  if (!references.IsEmpty()) {
     // The References header should be kept under 998 characters: if it's too
     // long, trim out the earliest references to make it smaller.
-    if (references.Length() > 986)
-    {
+    if (references.Length() > 986) {
       int32_t firstRef = references.FindChar('<');
       int32_t secondRef = references.FindChar('<', firstRef + 1);
-      if (secondRef > 0)
-      {
+      if (secondRef > 0) {
         nsAutoCString newReferences(StringHead(references, secondRef));
-        int32_t bracket = references.FindChar('<',
-          references.Length() + newReferences.Length() - 986);
-        if (bracket > 0)
-        {
+        int32_t bracket = references.FindChar(
+            '<', references.Length() + newReferences.Length() - 986);
+        if (bracket > 0) {
           newReferences.Append(Substring(references, bracket));
           finalHeaders->SetRawHeader("References", newReferences, nullptr);
         }
       }
     }
     // The In-Reply-To header is the last entry in the references header...
     int32_t bracket = references.RFind("<");
     if (bracket >= 0)
       finalHeaders->SetRawHeader("In-Reply-To", Substring(references, bracket),
-        nullptr);
+                                 nullptr);
   }
 
   return NS_OK;
 }
 
-#undef APPEND_BOOL // X-Mozilla-Draft-Info helper macro
+#undef APPEND_BOOL  // X-Mozilla-Draft-Info helper macro
 
-static void
-GenerateGlobalRandomBytes(unsigned char *buf, int32_t len)
-{
+static void GenerateGlobalRandomBytes(unsigned char *buf, int32_t len) {
   // Attempt to generate bytes from system entropy-based RNG.
-  nsCOMPtr<nsIRandomGenerator> randomGenerator(do_GetService("@mozilla.org/security/random-generator;1"));
+  nsCOMPtr<nsIRandomGenerator> randomGenerator(
+      do_GetService("@mozilla.org/security/random-generator;1"));
   MOZ_ASSERT(randomGenerator, "nsIRandomGenerator service not retrievable");
   uint8_t *tempBuffer;
   nsresult rv = randomGenerator->GenerateRandomBytes(len, &tempBuffer);
-  if (NS_SUCCEEDED(rv))
-  {
+  if (NS_SUCCEEDED(rv)) {
     memcpy(buf, tempBuffer, len);
     free(tempBuffer);
     return;
   }
   // nsIRandomGenerator failed -- fall back to low entropy PRNG.
   static bool firstTime = true;
-  if (firstTime)
-  {
+  if (firstTime) {
     // Seed the random-number generator with current time so that
     // the numbers will be different every time we run.
-    srand( (unsigned)PR_Now() );
+    srand((unsigned)PR_Now());
     firstTime = false;
   }
 
-  for( int32_t i = 0; i < len; i++ )
-    buf[i] = rand() % 256;
+  for (int32_t i = 0; i < len; i++) buf[i] = rand() % 256;
 }
 
-char
-*mime_make_separator(const char *prefix)
-{
+char *mime_make_separator(const char *prefix) {
   unsigned char rand_buf[13];
   GenerateGlobalRandomBytes(rand_buf, 12);
 
-  return PR_smprintf("------------%s"
-           "%02X%02X%02X%02X"
-           "%02X%02X%02X%02X"
-           "%02X%02X%02X%02X",
-           prefix,
-           rand_buf[0], rand_buf[1], rand_buf[2], rand_buf[3],
-           rand_buf[4], rand_buf[5], rand_buf[6], rand_buf[7],
-           rand_buf[8], rand_buf[9], rand_buf[10], rand_buf[11]);
+  return PR_smprintf(
+      "------------%s"
+      "%02X%02X%02X%02X"
+      "%02X%02X%02X%02X"
+      "%02X%02X%02X%02X",
+      prefix, rand_buf[0], rand_buf[1], rand_buf[2], rand_buf[3], rand_buf[4],
+      rand_buf[5], rand_buf[6], rand_buf[7], rand_buf[8], rand_buf[9],
+      rand_buf[10], rand_buf[11]);
 }
 
-static char *
-RFC2231ParmFolding(const char *parmName, const char *parmValue);
+static char *RFC2231ParmFolding(const char *parmName, const char *parmValue);
 
-static char *
-LegacyParmFolding(const nsCString& aCharset,
-                  const nsCString& aFileName, int32_t aParmFolding);
+static char *LegacyParmFolding(const nsCString &aCharset,
+                               const nsCString &aFileName,
+                               int32_t aParmFolding);
 
-char *
-mime_generate_attachment_headers (const char *type,
-                  const char *type_param,
-                  const char *encoding,
-                  const char *description,
-                  const char *x_mac_type,
-                  const char *x_mac_creator,
-                  const char *real_name,
-                  const char *base_url,
-                  bool /*digest_p*/,
-                  nsMsgAttachmentHandler * /*ma*/,
-                  const char *attachmentCharset,
-                  const char *bodyCharset,
-                  bool bodyIsAsciiOnly,
-                  const char *content_id,
-                  bool        aBodyDocument)
-{
-  NS_ASSERTION (encoding, "null encoding");
+char *mime_generate_attachment_headers(
+    const char *type, const char *type_param, const char *encoding,
+    const char *description, const char *x_mac_type, const char *x_mac_creator,
+    const char *real_name, const char *base_url, bool /*digest_p*/,
+    nsMsgAttachmentHandler * /*ma*/, const char *attachmentCharset,
+    const char *bodyCharset, bool bodyIsAsciiOnly, const char *content_id,
+    bool aBodyDocument) {
+  NS_ASSERTION(encoding, "null encoding");
 
-  int32_t parmFolding = 2; // RFC 2231-compliant
+  int32_t parmFolding = 2;  // RFC 2231-compliant
   nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
-  if (prefs)
-    prefs->GetIntPref("mail.strictly_mime.parm_folding", &parmFolding);
+  if (prefs) prefs->GetIntPref("mail.strictly_mime.parm_folding", &parmFolding);
 
   /* Let's encode the real name */
   char *encodedRealName = nullptr;
   nsAutoString realName;
-  if (real_name)
-  {
+  if (real_name) {
     encodedRealName = RFC2231ParmFolding("filename", real_name);
     // somehow RFC2231ParamFolding failed. fall back to legacy method
     if (!encodedRealName || !*encodedRealName) {
       PR_FREEIF(encodedRealName);
       parmFolding = 0;
       // Not RFC 2231 style encoding (it's not standard-compliant)
-      encodedRealName = LegacyParmFolding(NS_LITERAL_CSTRING("UTF-8"),
-        nsDependentCString(real_name), parmFolding);
+      encodedRealName =
+          LegacyParmFolding(NS_LITERAL_CSTRING("UTF-8"),
+                            nsDependentCString(real_name), parmFolding);
     }
   }
 
   nsCString buf;  // very likely to be longer than 64 characters
   buf.AppendLiteral("Content-Type: ");
   buf.Append(type);
-  if (type_param && *type_param)
-  {
-    if (*type_param != ';')
-      buf.AppendLiteral("; ");
+  if (type_param && *type_param) {
+    if (*type_param != ';') buf.AppendLiteral("; ");
     buf.Append(type_param);
   }
 
-  if (mime_type_needs_charset (type))
-  {
-
-    char charset_label[65] = "";   // Content-Type: charset
-    if (attachmentCharset)
-    {
-      PL_strncpy(charset_label, attachmentCharset, sizeof(charset_label)-1);
-      charset_label[sizeof(charset_label)-1] = '\0';
+  if (mime_type_needs_charset(type)) {
+    char charset_label[65] = "";  // Content-Type: charset
+    if (attachmentCharset) {
+      PL_strncpy(charset_label, attachmentCharset, sizeof(charset_label) - 1);
+      charset_label[sizeof(charset_label) - 1] = '\0';
     }
 
     /* If the characters are all 7bit, arguably it's better to
     claim the charset to be US-ASCII. However, it causes
     a major 'interoperability problem' with MS OE, which makes it hard
     to sell Mozilla/TB to people most of whose correspondents use
     MS OE. MS OE turns all non-ASCII characters to question marks
     in replies to messages labeled as US-ASCII if users select 'send as is'
     with MIME turned on. (with MIME turned off, this happens without
     any warning.) To avoid this, we use the label 'US-ASCII' only when
     it's explicitly requested by setting the hidden pref.
     'mail.label_ascii_only_mail_as_us_ascii'. (bug 247958) */
     bool labelAsciiAsAscii = false;
     if (prefs)
       prefs->GetBoolPref("mail.label_ascii_only_mail_as_us_ascii",
                          &labelAsciiAsAscii);
-    if (labelAsciiAsAscii && encoding &&
-        !PL_strcasecmp (encoding, "7bit") && bodyIsAsciiOnly)
-      PL_strcpy (charset_label, "us-ascii");
+    if (labelAsciiAsAscii && encoding && !PL_strcasecmp(encoding, "7bit") &&
+        bodyIsAsciiOnly)
+      PL_strcpy(charset_label, "us-ascii");
 
-    // If charset is multibyte then no charset to be specified (apply base64 instead).
-    // The list of file types match with PickEncoding() where we put base64 label.
-    if ( ((attachmentCharset && !nsMsgI18Nmultibyte_charset(attachmentCharset)) ||
+    // If charset is multibyte then no charset to be specified (apply base64
+    // instead). The list of file types match with PickEncoding() where we put
+    // base64 label.
+    if (((attachmentCharset &&
+          !nsMsgI18Nmultibyte_charset(attachmentCharset)) ||
          ((PL_strcasecmp(type, TEXT_HTML) == 0) ||
-         (PL_strcasecmp(type, TEXT_MDL) == 0) ||
-         (PL_strcasecmp(type, TEXT_PLAIN) == 0) ||
-         (PL_strcasecmp(type, TEXT_RICHTEXT) == 0) ||
-         (PL_strcasecmp(type, TEXT_ENRICHED) == 0) ||
-         (PL_strcasecmp(type, TEXT_VCARD) == 0) ||
-         (PL_strcasecmp(type, APPLICATION_DIRECTORY) == 0) || /* text/x-vcard synonym */
-         (PL_strcasecmp(type, TEXT_CSS) == 0) ||
-         (PL_strcasecmp(type, TEXT_JSSS) == 0)) ||
+          (PL_strcasecmp(type, TEXT_MDL) == 0) ||
+          (PL_strcasecmp(type, TEXT_PLAIN) == 0) ||
+          (PL_strcasecmp(type, TEXT_RICHTEXT) == 0) ||
+          (PL_strcasecmp(type, TEXT_ENRICHED) == 0) ||
+          (PL_strcasecmp(type, TEXT_VCARD) == 0) ||
+          (PL_strcasecmp(type, APPLICATION_DIRECTORY) ==
+           0) || /* text/x-vcard synonym */
+          (PL_strcasecmp(type, TEXT_CSS) == 0) ||
+          (PL_strcasecmp(type, TEXT_JSSS) == 0)) ||
          (PL_strcasecmp(encoding, ENCODING_BASE64) != 0)) &&
-         (*charset_label))
-    {
+        (*charset_label)) {
       buf.AppendLiteral("; charset=");
       buf.Append(charset_label);
     }
   }
 
   // Only do this if we are in the body of a message
-  if (aBodyDocument)
-  {
+  if (aBodyDocument) {
     // Add format=flowed as in RFC 2646 if we are using that
-    if(type && !PL_strcasecmp(type, "text/plain"))
-    {
+    if (type && !PL_strcasecmp(type, "text/plain")) {
       bool flowed, delsp, formatted, disallowBreaks;
-      GetSerialiserFlags(bodyCharset, &flowed, &delsp, &formatted, &disallowBreaks);
-      if(flowed)
-        buf.AppendLiteral("; format=flowed");
-      if (delsp)
-        buf.AppendLiteral("; delsp=yes");
+      GetSerialiserFlags(bodyCharset, &flowed, &delsp, &formatted,
+                         &disallowBreaks);
+      if (flowed) buf.AppendLiteral("; format=flowed");
+      if (delsp) buf.AppendLiteral("; delsp=yes");
       // else
       // {
       // Don't add a markup. Could use
       //        PUSH_STRING ("; format=fixed");
       // but it is equivalent to nothing at all and we do want
       // to save bandwidth. Don't we?
       // }
     }
@@ -673,518 +601,453 @@ mime_generate_attachment_headers (const 
   }
 
 #ifdef EMIT_NAME_IN_CONTENT_TYPE
   if (encodedRealName && *encodedRealName) {
     // Note that we don't need to output the name field if the name encoding is
     // RFC 2231. If the MUA knows the RFC 2231, it should know the RFC 2183 too.
     if (parmFolding != 2) {
       // The underlying JS MIME code will only handle UTF-8 here.
-      char *nameValue = LegacyParmFolding(NS_LITERAL_CSTRING("UTF-8"),
-                                          nsDependentCString(real_name),
-                                          parmFolding);
+      char *nameValue =
+          LegacyParmFolding(NS_LITERAL_CSTRING("UTF-8"),
+                            nsDependentCString(real_name), parmFolding);
       if (!nameValue || !*nameValue) {
         PR_FREEIF(nameValue);
         nameValue = encodedRealName;
       }
       buf.AppendLiteral(";\r\n name=\"");
       buf.Append(nameValue);
       buf.Append('"');
-      if (nameValue != encodedRealName)
-        PR_FREEIF(nameValue);
+      if (nameValue != encodedRealName) PR_FREEIF(nameValue);
     }
   }
 #endif /* EMIT_NAME_IN_CONTENT_TYPE */
   buf.Append(CRLF);
 
   buf.AppendLiteral("Content-Transfer-Encoding: ");
   buf.Append(encoding);
   buf.Append(CRLF);
 
   if (description && *description) {
-    char *s = mime_fix_header (description);
+    char *s = mime_fix_header(description);
     if (s) {
       buf.AppendLiteral("Content-Description: ");
       buf.Append(s);
       buf.Append(CRLF);
       PR_Free(s);
     }
   }
 
-  if ( (content_id) && (*content_id) )
-  {
+  if ((content_id) && (*content_id)) {
     buf.AppendLiteral("Content-ID: <");
     buf.Append(content_id);
     buf.Append('>');
     buf.Append(CRLF);
   }
 
   if (encodedRealName && *encodedRealName) {
     char *period = PL_strrchr(encodedRealName, '.');
     int32_t pref_content_disposition = 0;
 
     if (prefs) {
-      mozilla::DebugOnly<nsresult> rv = prefs->GetIntPref("mail.content_disposition_type",
-                                                          &pref_content_disposition);
-      NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get mail.content_disposition_type");
+      mozilla::DebugOnly<nsresult> rv = prefs->GetIntPref(
+          "mail.content_disposition_type", &pref_content_disposition);
+      NS_ASSERTION(NS_SUCCEEDED(rv),
+                   "failed to get mail.content_disposition_type");
     }
 
     buf.AppendLiteral("Content-Disposition: ");
 
-    // If this is an attachment which is part of the message body and therefore has a
-    // Content-ID (e.g, image in HTML msg), then Content-Disposition has to be inline
+    // If this is an attachment which is part of the message body and therefore
+    // has a Content-ID (e.g, image in HTML msg), then Content-Disposition has
+    // to be inline
     if (content_id && *content_id)
       buf.AppendLiteral("inline");
     else if (pref_content_disposition == 1)
       buf.AppendLiteral("attachment");
-    else
-      if (pref_content_disposition == 2 &&
-          (!PL_strcasecmp(type, TEXT_PLAIN) ||
-          (period && !PL_strcasecmp(period, ".txt"))))
-        buf.AppendLiteral("attachment");
+    else if (pref_content_disposition == 2 &&
+             (!PL_strcasecmp(type, TEXT_PLAIN) ||
+              (period && !PL_strcasecmp(period, ".txt"))))
+      buf.AppendLiteral("attachment");
 
-      /* If this document is an anonymous binary file or a vcard,
-      then always show it as an attachment, never inline. */
-      else
-        if (!PL_strcasecmp(type, APPLICATION_OCTET_STREAM) ||
-            !PL_strcasecmp(type, TEXT_VCARD) ||
-            !PL_strcasecmp(type, APPLICATION_DIRECTORY)) /* text/x-vcard synonym */
-          buf.AppendLiteral("attachment");
-        else
-          buf.AppendLiteral("inline");
+    /* If this document is an anonymous binary file or a vcard,
+    then always show it as an attachment, never inline. */
+    else if (!PL_strcasecmp(type, APPLICATION_OCTET_STREAM) ||
+             !PL_strcasecmp(type, TEXT_VCARD) ||
+             !PL_strcasecmp(type,
+                            APPLICATION_DIRECTORY)) /* text/x-vcard synonym */
+      buf.AppendLiteral("attachment");
+    else
+      buf.AppendLiteral("inline");
 
     buf.AppendLiteral(";\r\n ");
     buf.Append(encodedRealName);
     buf.Append(CRLF);
-  }
-  else
-    if (type &&
-        (!PL_strcasecmp (type, MESSAGE_RFC822) ||
-        !PL_strcasecmp (type, MESSAGE_NEWS)))
-      buf.AppendLiteral("Content-Disposition: inline" CRLF);
+  } else if (type && (!PL_strcasecmp(type, MESSAGE_RFC822) ||
+                      !PL_strcasecmp(type, MESSAGE_NEWS)))
+    buf.AppendLiteral("Content-Disposition: inline" CRLF);
 
 #ifdef GENERATE_CONTENT_BASE
   /* If this is an HTML document, and we know the URL it originally
      came from, write out a Content-Base header. */
   if (type &&
-      (!PL_strcasecmp (type, TEXT_HTML) ||
-      !PL_strcasecmp (type, TEXT_MDL)) &&
-      base_url && *base_url)
-  {
+      (!PL_strcasecmp(type, TEXT_HTML) || !PL_strcasecmp(type, TEXT_MDL)) &&
+      base_url && *base_url) {
     int32_t col = 0;
     const char *s = base_url;
-    const char *colon = PL_strchr (s, ':');
-    bool useContentLocation = false;   /* rhp - add this  */
+    const char *colon = PL_strchr(s, ':');
+    bool useContentLocation = false; /* rhp - add this  */
 
-    if (!colon)
-      goto GIVE_UP_ON_CONTENT_BASE;  /* malformed URL? */
+    if (!colon) goto GIVE_UP_ON_CONTENT_BASE; /* malformed URL? */
 
     /* Don't emit a content-base that points to (or into) a news or
        mail message. */
-    if (!PL_strncasecmp (s, "news:", 5) ||
-        !PL_strncasecmp (s, "snews:", 6) ||
-        !PL_strncasecmp (s, "IMAP:", 5) ||
-        !PL_strncasecmp (s, "file:", 5) ||    /* rhp: fix targets from included HTML files */
-        !PL_strncasecmp (s, "mailbox:", 8))
+    if (!PL_strncasecmp(s, "news:", 5) || !PL_strncasecmp(s, "snews:", 6) ||
+        !PL_strncasecmp(s, "IMAP:", 5) ||
+        !PL_strncasecmp(
+            s, "file:", 5) || /* rhp: fix targets from included HTML files */
+        !PL_strncasecmp(s, "mailbox:", 8))
       goto GIVE_UP_ON_CONTENT_BASE;
 
     /* rhp - Put in a pref for using Content-Location instead of Content-Base.
            This will get tweaked to default to true in 5.0
     */
     if (prefs)
-      prefs->GetBoolPref("mail.use_content_location_on_send", &useContentLocation);
+      prefs->GetBoolPref("mail.use_content_location_on_send",
+                         &useContentLocation);
 
     if (useContentLocation)
       buf.AppendLiteral("Content-Location: \"");
     else
       buf.AppendLiteral("Content-Base: \"");
     /* rhp - Pref for Content-Location usage */
 
-/* rhp: this is to work with the Content-Location stuff */
-CONTENT_LOC_HACK:
+  /* rhp: this is to work with the Content-Location stuff */
+  CONTENT_LOC_HACK:
 
-    while (*s != 0 && *s != '#')
-    {
-      uint32_t ot=buf.Length();
-      char tmp[]="\x00\x00";
+    while (*s != 0 && *s != '#') {
+      uint32_t ot = buf.Length();
+      char tmp[] = "\x00\x00";
       /* URLs must be wrapped at 40 characters or less. */
       if (col >= 38) {
         buf.Append(CRLF "\t");
         col = 0;
       }
 
       if (*s == ' ')
         buf.AppendLiteral("%20");
       else if (*s == '\t')
         buf.AppendLiteral("%09");
       else if (*s == '\n')
         buf.AppendLiteral("%0A");
       else if (*s == '\r')
         buf.AppendLiteral("%0D");
       else {
-        tmp[0]=*s;
+        tmp[0] = *s;
         buf.Append(tmp);
       }
       s++;
       col += (buf.Length() - ot);
     }
     buf.AppendLiteral("\"" CRLF);
 
-    /* rhp: this is to try to get around this fun problem with Content-Location */
+    /* rhp: this is to try to get around this fun problem with Content-Location
+     */
     if (!useContentLocation) {
       buf.AppendLiteral("Content-Location: \"");
       s = base_url;
       col = 0;
       useContentLocation = true;
       goto CONTENT_LOC_HACK;
     }
-    /* rhp: this is to try to get around this fun problem with Content-Location */
+    /* rhp: this is to try to get around this fun problem with Content-Location
+     */
 
-GIVE_UP_ON_CONTENT_BASE:
-    ;
+  GIVE_UP_ON_CONTENT_BASE:;
   }
 #endif /* GENERATE_CONTENT_BASE */
 
   /* realloc it smaller... */
 
 #ifdef DEBUG_jungshik
-  printf ("header=%s\n", buf.get());
+  printf("header=%s\n", buf.get());
 #endif
   PR_Free(encodedRealName);
   return PL_strdup(buf.get());
 }
 
-static bool isValidHost( const char* host )
-{
-  if ( host )
+static bool isValidHost(const char *host) {
+  if (host)
     for (const char *s = host; *s; ++s)
-      if  (  !isalpha(*s)
-         && !isdigit(*s)
-         && *s != '-'
-         && *s != '_'
-         && *s != '.'
-         )
-      {
-       host = nullptr;
-       break;
+      if (!isalpha(*s) && !isdigit(*s) && *s != '-' && *s != '_' && *s != '.') {
+        host = nullptr;
+        break;
       }
 
   return nullptr != host;
 }
 
-char *
-msg_generate_message_id (nsIMsgIdentity *identity)
-{
+char *msg_generate_message_id(nsIMsgIdentity *identity) {
   const char *host = 0;
 
   nsCString forcedFQDN;
   nsCString from;
   nsresult rv = NS_OK;
 
   rv = identity->GetCharAttribute("FQDN", forcedFQDN);
 
-  if (NS_SUCCEEDED(rv) && !forcedFQDN.IsEmpty())
-    host = forcedFQDN.get();
+  if (NS_SUCCEEDED(rv) && !forcedFQDN.IsEmpty()) host = forcedFQDN.get();
 
-  if (!isValidHost(host))
-  {
+  if (!isValidHost(host)) {
     nsresult rv = identity->GetEmail(from);
-    if (NS_SUCCEEDED(rv) && !from.IsEmpty())
-      host = strchr(from.get(),'@');
+    if (NS_SUCCEEDED(rv) && !from.IsEmpty()) host = strchr(from.get(), '@');
 
     // No '@'? Munged address, anti-spam?
     // see bug #197203
-    if (host)
-      ++host;
+    if (host) ++host;
   }
 
   if (!isValidHost(host))
-  /* If we couldn't find a valid host name to use, we can't generate a
-     valid message ID, so bail, and let NNTP and SMTP generate them. */
+    /* If we couldn't find a valid host name to use, we can't generate a
+       valid message ID, so bail, and let NNTP and SMTP generate them. */
     return 0;
 
   // Generate 128-bit UUID for the local part. We use the high-entropy
   // GenerateGlobalRandomBytes to make tracking more difficult.
   nsID uuid;
-  GenerateGlobalRandomBytes((unsigned char*) &uuid, sizeof(nsID));
+  GenerateGlobalRandomBytes((unsigned char *)&uuid, sizeof(nsID));
   char uuidString[NSID_LENGTH];
   uuid.ToProvidedString(uuidString);
   // Drop first and last characters (curly braces).
   uuidString[NSID_LENGTH - 2] = 0;
   return PR_smprintf("<%s@%s>", uuidString + 1, host);
 }
 
-#define PR_MAX_FOLDING_LEN 75     // this is to guarantee the folded line will
-                                  // never be greater than 78 = 75 + CRLFLWSP
-/*static */ char *
-RFC2231ParmFolding(const char *parmName, const char *parmValue)
-{
+// this is to guarantee the folded line will never be greater
+// than 78 = 75 + CRLFLWSP
+#define PR_MAX_FOLDING_LEN 75
+
+/*static */ char *RFC2231ParmFolding(const char *parmName,
+                                     const char *parmValue) {
   NS_ENSURE_TRUE(parmName && *parmName && parmValue && *parmValue, nullptr);
 
   bool needEscape;
   nsCString dupParm;
   nsCString charset("UTF-8");
 
   if (!mozilla::IsAsciiNullTerminated(parmValue)) {
     needEscape = true;
     dupParm.Assign(parmValue);
     MsgEscapeString(dupParm, nsINetUtil::ESCAPE_ALL, dupParm);
-  }
-  else {
+  } else {
     needEscape = false;
     dupParm.Adopt(msg_make_filename_qtext(parmValue, true));
   }
 
   int32_t parmNameLen = PL_strlen(parmName);
   int32_t parmValueLen = dupParm.Length();
 
   parmNameLen += 5;  // *=__'__'___ or *[0]*=__'__'__ or *[1]*=___ or *[0]="___"
 
   char *foldedParm = nullptr;
 
-  if ((parmValueLen + parmNameLen + strlen("UTF-8")) < PR_MAX_FOLDING_LEN)
-  {
+  if ((parmValueLen + parmNameLen + strlen("UTF-8")) < PR_MAX_FOLDING_LEN) {
     foldedParm = PL_strdup(parmName);
-    if (needEscape)
-    {
+    if (needEscape) {
       NS_MsgSACat(&foldedParm, "*=");
       NS_MsgSACat(&foldedParm, "UTF-8");
-      NS_MsgSACat(&foldedParm, "''"); // We don't support language.
-    }
-    else
+      NS_MsgSACat(&foldedParm, "''");  // We don't support language.
+    } else
       NS_MsgSACat(&foldedParm, "=\"");
     NS_MsgSACat(&foldedParm, dupParm.get());
-    if (!needEscape)
-      NS_MsgSACat(&foldedParm, "\"");
-  }
-  else
-  {
+    if (!needEscape) NS_MsgSACat(&foldedParm, "\"");
+  } else {
     int curLineLen = 0;
     int counter = 0;
     char digits[32];
     char *start = dupParm.BeginWriting();
     char *end = NULL;
     char tmp = 0;
 
-    while (parmValueLen > 0)
-    {
+    while (parmValueLen > 0) {
       curLineLen = 0;
       if (counter == 0) {
         PR_FREEIF(foldedParm)
         foldedParm = PL_strdup(parmName);
-      }
-      else {
+      } else {
         NS_MsgSACat(&foldedParm, ";\r\n ");
         NS_MsgSACat(&foldedParm, parmName);
       }
       PR_snprintf(digits, sizeof(digits), "*%d", counter);
       NS_MsgSACat(&foldedParm, digits);
       curLineLen += PL_strlen(digits);
-      if (needEscape)
-      {
+      if (needEscape) {
         NS_MsgSACat(&foldedParm, "*=");
-        if (counter == 0)
-        {
+        if (counter == 0) {
           NS_MsgSACat(&foldedParm, "UTF-8");
-          NS_MsgSACat(&foldedParm, "''"); // We don't support language.
+          NS_MsgSACat(&foldedParm, "''");  // We don't support language.
           curLineLen += strlen("UTF-8");
         }
-      }
-      else
-      {
+      } else {
         NS_MsgSACat(&foldedParm, "=\"");
       }
       counter++;
       curLineLen += parmNameLen;
       if (parmValueLen <= PR_MAX_FOLDING_LEN - curLineLen)
         end = start + parmValueLen;
       else
         end = start + (PR_MAX_FOLDING_LEN - curLineLen);
 
       tmp = 0;
-      if (*end && needEscape)
-      {
+      if (*end && needEscape) {
         // Check to see if we are in the middle of escaped char.
         // We use ESCAPE_ALL, so every third character is a '%'.
         if (end - 1 > start && *(end - 1) == '%') {
           end -= 1;
         } else if (end - 2 > start && *(end - 2) == '%') {
           end -= 2;
         }
         // *end is now a '%'.
         // Check if the following UTF-8 octet is a continuation.
-        while (end - 3 > start &&
-               (*(end + 1) == '8' || *(end + 1) == '9' ||
-                *(end + 1) == 'A' || *(end + 1) == 'B')) {
+        while (end - 3 > start && (*(end + 1) == '8' || *(end + 1) == '9' ||
+                                   *(end + 1) == 'A' || *(end + 1) == 'B')) {
           end -= 3;
         }
-        tmp = *end; *end = 0;
-      }
-      else
-      {
-        tmp = *end; *end = 0;
+        tmp = *end;
+        *end = 0;
+      } else {
+        tmp = *end;
+        *end = 0;
       }
       NS_MsgSACat(&foldedParm, start);
-      if (!needEscape)
-        NS_MsgSACat(&foldedParm, "\"");
+      if (!needEscape) NS_MsgSACat(&foldedParm, "\"");
 
-      parmValueLen -= (end-start);
-      if (tmp)
-        *end = tmp;
+      parmValueLen -= (end - start);
+      if (tmp) *end = tmp;
       start = end;
     }
   }
 
   return foldedParm;
 }
 
-/*static */ char *
-LegacyParmFolding(const nsCString& aCharset,
-                  const nsCString& aFileName, int32_t aParmFolding)
-{
+/*static */ char *LegacyParmFolding(const nsCString &aCharset,
+                                    const nsCString &aFileName,
+                                    int32_t aParmFolding) {
   bool usemime = nsMsgMIMEGetConformToStandard();
-  char *encodedRealName =
-    nsMsgI18NEncodeMimePartIIStr(aFileName.get(), false, aCharset.get(),
-                                 0, usemime);
+  char *encodedRealName = nsMsgI18NEncodeMimePartIIStr(
+      aFileName.get(), false, aCharset.get(), 0, usemime);
 
   if (!encodedRealName || !*encodedRealName) {
     PR_FREEIF(encodedRealName);
-    encodedRealName = (char *) PR_Malloc(aFileName.Length() + 1);
-    if (encodedRealName)
-      PL_strcpy(encodedRealName, aFileName.get());
+    encodedRealName = (char *)PR_Malloc(aFileName.Length() + 1);
+    if (encodedRealName) PL_strcpy(encodedRealName, aFileName.get());
   }
 
   // Now put backslashes before special characters per RFC 822
-  char *qtextName =
-    msg_make_filename_qtext(encodedRealName, aParmFolding == 0);
+  char *qtextName = msg_make_filename_qtext(encodedRealName, aParmFolding == 0);
   if (qtextName) {
     PR_FREEIF(encodedRealName);
     encodedRealName = qtextName;
   }
   return encodedRealName;
 }
 
-bool
-mime_7bit_data_p (const char *string, uint32_t size)
-{
-  if ((!string) || (!*string))
-    return true;
+bool mime_7bit_data_p(const char *string, uint32_t size) {
+  if ((!string) || (!*string)) return true;
 
   char *ptr = (char *)string;
-  for (uint32_t i=0; i<size; i++)
-  {
-    if ((unsigned char) ptr[i] > 0x7F)
-      return false;
+  for (uint32_t i = 0; i < size; i++) {
+    if ((unsigned char)ptr[i] > 0x7F) return false;
   }
   return true;
 }
 
 /* Strips whitespace, and expands newlines into newline-tab for use in
    mail headers.  Returns a new string or 0 (if it would have been empty.)
    If addr_p is true, the addresses will be parsed and reemitted as
    rfc822 mailboxes.
  */
-char *
-mime_fix_header_1 (const char *string, bool addr_p, bool news_p)
-{
+char *mime_fix_header_1(const char *string, bool addr_p, bool news_p) {
   char *new_string;
   const char *in;
   char *out;
   int32_t i, old_size, new_size;
 
-  if (!string || !*string)
-    return 0;
+  if (!string || !*string) return 0;
 
   if (addr_p) {
     return strdup(string);
   }
 
-  old_size = PL_strlen (string);
+  old_size = PL_strlen(string);
   new_size = old_size;
   for (i = 0; i < old_size; i++)
-    if (string[i] == '\r' || string[i] == '\n')
-      new_size += 2;
+    if (string[i] == '\r' || string[i] == '\n') new_size += 2;
 
-  new_string = (char *) PR_Malloc (new_size + 1);
-  if (! new_string)
-    return 0;
+  new_string = (char *)PR_Malloc(new_size + 1);
+  if (!new_string) return 0;
 
-  in  = string;
+  in = string;
   out = new_string;
 
   /* strip leading whitespace. */
-  while (IS_SPACE (*in))
-    in++;
+  while (IS_SPACE(*in)) in++;
 
   /* replace CR, LF, or CRLF with CRLF-TAB. */
   while (*in) {
     if (*in == '\r' || *in == '\n') {
-      if (*in == '\r' && in[1] == '\n')
-        in++;
+      if (*in == '\r' && in[1] == '\n') in++;
       in++;
       *out++ = '\r';
       *out++ = '\n';
       *out++ = '\t';
-    }
-    else
-      if (news_p && *in == ',') {
-        *out++ = *in++;
-        /* skip over all whitespace after a comma. */
-        while (IS_SPACE (*in))
-          in++;
-      }
-      else
-        *out++ = *in++;
+    } else if (news_p && *in == ',') {
+      *out++ = *in++;
+      /* skip over all whitespace after a comma. */
+      while (IS_SPACE(*in)) in++;
+    } else
+      *out++ = *in++;
   }
   *out = 0;
 
   /* strip trailing whitespace. */
-  while (out > in && IS_SPACE (out[-1]))
-    *out-- = 0;
+  while (out > in && IS_SPACE(out[-1])) *out-- = 0;
 
   /* If we ended up throwing it all away, use 0 instead of "". */
   if (!*new_string) {
-    PR_Free (new_string);
+    PR_Free(new_string);
     new_string = 0;
   }
 
   return new_string;
 }
 
-char *
-mime_fix_header (const char *string)
-{
-  return mime_fix_header_1 (string, false, false);
+char *mime_fix_header(const char *string) {
+  return mime_fix_header_1(string, false, false);
 }
 
-char *
-mime_fix_addr_header (const char *string)
-{
-  return mime_fix_header_1 (string, true, false);
+char *mime_fix_addr_header(const char *string) {
+  return mime_fix_header_1(string, true, false);
 }
 
-char *
-mime_fix_news_header (const char *string)
-{
-  return mime_fix_header_1 (string, false, true);
+char *mime_fix_news_header(const char *string) {
+  return mime_fix_header_1(string, false, true);
 }
 
-bool
-mime_type_requires_b64_p (const char *type)
-{
-  if (!type || !PL_strcasecmp (type, UNKNOWN_CONTENT_TYPE))
-  /* Unknown types don't necessarily require encoding.  (Note that
-     "unknown" and "application/octet-stream" aren't the same.) */
-  return false;
+bool mime_type_requires_b64_p(const char *type) {
+  if (!type || !PL_strcasecmp(type, UNKNOWN_CONTENT_TYPE))
+    /* Unknown types don't necessarily require encoding.  (Note that
+       "unknown" and "application/octet-stream" aren't the same.) */
+    return false;
 
-  else if (!PL_strncasecmp (type, "image/", 6) ||
-       !PL_strncasecmp (type, "audio/", 6) ||
-       !PL_strncasecmp (type, "video/", 6) ||
-       !PL_strncasecmp (type, "application/", 12))
-  {
+  else if (!PL_strncasecmp(type, "image/", 6) ||
+           !PL_strncasecmp(type, "audio/", 6) ||
+           !PL_strncasecmp(type, "video/", 6) ||
+           !PL_strncasecmp(type, "application/", 12)) {
     /* The following types are application/ or image/ types that are actually
      known to contain textual data (meaning line-based, not binary, where
      CRLF conversion is desired rather than disastrous.)  So, if the type
      is any of these, it does not *require* base64, and if we do need to
      encode it for other reasons, we'll probably use quoted-printable.
      But, if it's not one of these types, then we assume that any subtypes
      of the non-"text/" types are binary data, where CRLF conversion would
      corrupt it, so we use base64 right off the bat.
@@ -1193,227 +1056,207 @@ mime_type_requires_b64_p (const char *ty
      base64 all the time is mainly to preserve the readability of them for
      non-MIME users: if I mail a /bin/sh script to someone, it might not
      need to be encoded at all, so we should leave it readable if we can.
 
      This list of types was derived from the comp.mail.mime FAQ, section
      10.2.2, "List of known unregistered MIME types" on 2-Feb-96.
      */
     static const char *app_and_image_types_which_are_really_text[] = {
-    "application/mac-binhex40",   /* APPLICATION_BINHEX */
-    "application/pgp",        /* APPLICATION_PGP */
-    "application/pgp-keys",
-    "application/x-pgp-message",  /* APPLICATION_PGP2 */
-    "application/postscript",   /* APPLICATION_POSTSCRIPT */
-    "application/x-uuencode",   /* APPLICATION_UUENCODE */
-    "application/x-uue",      /* APPLICATION_UUENCODE2 */
-    "application/uue",        /* APPLICATION_UUENCODE4 */
-    "application/uuencode",     /* APPLICATION_UUENCODE3 */
-    "application/sgml",
-    "application/x-csh",
-    "application/javascript",
-    "application/ecmascript",
-    "application/x-javascript",
-    "application/x-latex",
-    "application/x-macbinhex40",
-    "application/x-ns-proxy-autoconfig",
-    "application/x-www-form-urlencoded",
-    "application/x-perl",
-    "application/x-sh",
-    "application/x-shar",
-    "application/x-tcl",
-    "application/x-tex",
-    "application/x-texinfo",
-    "application/x-troff",
-    "application/x-troff-man",
-    "application/x-troff-me",
-    "application/x-troff-ms",
-    "application/x-troff-ms",
-    "application/x-wais-source",
-    "image/x-bitmap",
-    "image/x-pbm",
-    "image/x-pgm",
-    "image/x-portable-anymap",
-    "image/x-portable-bitmap",
-    "image/x-portable-graymap",
-    "image/x-portable-pixmap",    /* IMAGE_PPM */
-    "image/x-ppm",
-    "image/x-xbitmap",        /* IMAGE_XBM */
-    "image/x-xbm",          /* IMAGE_XBM2 */
-    "image/xbm",          /* IMAGE_XBM3 */
-    "image/x-xpixmap",
-    "image/x-xpm",
-    0 };
+        "application/mac-binhex40", /* APPLICATION_BINHEX */
+        "application/pgp",          /* APPLICATION_PGP */
+        "application/pgp-keys",
+        "application/x-pgp-message", /* APPLICATION_PGP2 */
+        "application/postscript",    /* APPLICATION_POSTSCRIPT */
+        "application/x-uuencode",    /* APPLICATION_UUENCODE */
+        "application/x-uue",         /* APPLICATION_UUENCODE2 */
+        "application/uue",           /* APPLICATION_UUENCODE4 */
+        "application/uuencode",      /* APPLICATION_UUENCODE3 */
+        "application/sgml",
+        "application/x-csh",
+        "application/javascript",
+        "application/ecmascript",
+        "application/x-javascript",
+        "application/x-latex",
+        "application/x-macbinhex40",
+        "application/x-ns-proxy-autoconfig",
+        "application/x-www-form-urlencoded",
+        "application/x-perl",
+        "application/x-sh",
+        "application/x-shar",
+        "application/x-tcl",
+        "application/x-tex",
+        "application/x-texinfo",
+        "application/x-troff",
+        "application/x-troff-man",
+        "application/x-troff-me",
+        "application/x-troff-ms",
+        "application/x-troff-ms",
+        "application/x-wais-source",
+        "image/x-bitmap",
+        "image/x-pbm",
+        "image/x-pgm",
+        "image/x-portable-anymap",
+        "image/x-portable-bitmap",
+        "image/x-portable-graymap",
+        "image/x-portable-pixmap", /* IMAGE_PPM */
+        "image/x-ppm",
+        "image/x-xbitmap", /* IMAGE_XBM */
+        "image/x-xbm",     /* IMAGE_XBM2 */
+        "image/xbm",       /* IMAGE_XBM3 */
+        "image/x-xpixmap",
+        "image/x-xpm",
+        0};
     const char **s;
     for (s = app_and_image_types_which_are_really_text; *s; s++)
-    if (!PL_strcasecmp (type, *s))
-      return false;
+      if (!PL_strcasecmp(type, *s)) return false;
 
     /* All others must be assumed to be binary formats, and need Base64. */
     return true;
   }
 
   else
-  return false;
+    return false;
 }
 
 //
 // Some types should have a "charset=" parameter, and some shouldn't.
 // This is what decides.
 //
-bool
-mime_type_needs_charset (const char *type)
-{
+bool mime_type_needs_charset(const char *type) {
   /* Only text types should have charset. */
   if (!type || !*type)
     return false;
+  else if (!PL_strncasecmp(type, "text", 4))
+    return true;
   else
-    if (!PL_strncasecmp (type, "text", 4))
-      return true;
-    else
-      return false;
+    return false;
 }
 
-/* Given a string, convert it to 'qtext' (quoted text) for RFC822 header purposes. */
-char *
-msg_make_filename_qtext(const char *srcText, bool stripCRLFs)
-{
+/* Given a string, convert it to 'qtext' (quoted text) for RFC822 header
+ * purposes. */
+char *msg_make_filename_qtext(const char *srcText, bool stripCRLFs) {
   /* newString can be at most twice the original string (every char quoted). */
-  char *newString = (char *) PR_Malloc(PL_strlen(srcText)*2 + 1);
+  char *newString = (char *)PR_Malloc(PL_strlen(srcText) * 2 + 1);
   if (!newString) return NULL;
 
   const char *s = srcText;
   const char *end = srcText + PL_strlen(srcText);
   char *d = newString;
 
-  while(*s)
-  {
+  while (*s) {
     /*  Put backslashes in front of existing backslashes, or double quote
       characters.
       If stripCRLFs is true, don't write out CRs or LFs. Otherwise,
       write out a backslash followed by the CR but not
       linear-white-space.
       We might already have quoted pair of "\ " or "\\t" skip it.
       */
     if (*s == '\\' || *s == '"' ||
-      (!stripCRLFs &&
-       (*s == '\r' && (s[1] != '\n' ||
-               (s[1] == '\n' && (s+2) < end && !IS_SPACE(s[2]))))))
+        (!stripCRLFs &&
+         (*s == '\r' && (s[1] != '\n' ||
+                         (s[1] == '\n' && (s + 2) < end && !IS_SPACE(s[2]))))))
       *d++ = '\\';
 
-    if (stripCRLFs && *s == '\r' && s[1] == '\n' && (s+2) < end && IS_SPACE(s[2]))
-    {
-        s += 3;     // skip CRLFLWSP
-    }
-    else
-    {
+    if (stripCRLFs && *s == '\r' && s[1] == '\n' && (s + 2) < end &&
+        IS_SPACE(s[2])) {
+      s += 3;  // skip CRLFLWSP
+    } else {
       *d++ = *s++;
     }
   }
   *d = 0;
 
   return newString;
 }
 
 /* Rip apart the URL and extract a reasonable value for the `real_name' slot.
  */
-void
-msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char16_t *proposedName, const char *charset)
-{
+void msg_pick_real_name(nsMsgAttachmentHandler *attachment,
+                        const char16_t *proposedName, const char *charset) {
   const char *s, *s2;
 
-  if (!attachment->m_realName.IsEmpty())
-    return;
+  if (!attachment->m_realName.IsEmpty()) return;
 
-  if (proposedName && *proposedName)
-  {
+  if (proposedName && *proposedName) {
     attachment->m_realName.Adopt(ToNewUTF8String(nsAutoString(proposedName)));
-  }
-  else //Let's extract the name from the URL
+  } else  // Let's extract the name from the URL
   {
     nsCString url;
     nsresult rv = attachment->mURL->GetSpec(url);
-    if (NS_FAILED(rv))
-      return;
+    if (NS_FAILED(rv)) return;
 
     s = url.get();
-    s2 = PL_strchr (s, ':');
-    if (s2)
-      s = s2 + 1;
+    s2 = PL_strchr(s, ':');
+    if (s2) s = s2 + 1;
     /* If we know the URL doesn't have a sensible file name in it,
      don't bother emitting a content-disposition. */
-    if (StringBeginsWith (url, NS_LITERAL_CSTRING("news:"), nsCaseInsensitiveCStringComparator()) ||
-        StringBeginsWith (url, NS_LITERAL_CSTRING("snews:"), nsCaseInsensitiveCStringComparator()) ||
-        StringBeginsWith (url, NS_LITERAL_CSTRING("IMAP:"), nsCaseInsensitiveCStringComparator()) ||
-        StringBeginsWith (url, NS_LITERAL_CSTRING("mailbox:"), nsCaseInsensitiveCStringComparator()))
+    if (StringBeginsWith(url, NS_LITERAL_CSTRING("news:"),
+                         nsCaseInsensitiveCStringComparator()) ||
+        StringBeginsWith(url, NS_LITERAL_CSTRING("snews:"),
+                         nsCaseInsensitiveCStringComparator()) ||
+        StringBeginsWith(url, NS_LITERAL_CSTRING("IMAP:"),
+                         nsCaseInsensitiveCStringComparator()) ||
+        StringBeginsWith(url, NS_LITERAL_CSTRING("mailbox:"),
+                         nsCaseInsensitiveCStringComparator()))
       return;
 
     if (StringBeginsWith(url, NS_LITERAL_CSTRING("data:"),
-                         nsCaseInsensitiveCStringComparator()))
-    {
+                         nsCaseInsensitiveCStringComparator())) {
       int32_t endNonData = url.FindChar(',');
-      if (endNonData == -1)
-        return;
+      if (endNonData == -1) return;
       nsCString nonDataPart(Substring(url, 5, endNonData - 5));
       int32_t filenamePos = nonDataPart.Find("filename=");
-      if (filenamePos != -1)
-      {
+      if (filenamePos != -1) {
         filenamePos += 9;
         int32_t endFilename = nonDataPart.FindChar(';', filenamePos);
-        if (endFilename == -1)
-          endFilename = endNonData;
-        attachment->m_realName = Substring(nonDataPart, filenamePos,
-                                           endFilename - filenamePos);
-      }
-      else
-      {
+        if (endFilename == -1) endFilename = endNonData;
+        attachment->m_realName =
+            Substring(nonDataPart, filenamePos, endFilename - filenamePos);
+      } else {
         // no filename; need to construct one based on the content type.
-        nsCOMPtr<nsIMIMEService> mimeService(do_GetService(NS_MIMESERVICE_CONTRACTID));
-        if (!mimeService)
-          return;
+        nsCOMPtr<nsIMIMEService> mimeService(
+            do_GetService(NS_MIMESERVICE_CONTRACTID));
+        if (!mimeService) return;
         nsCOMPtr<nsIMIMEInfo> mimeInfo;
-        nsCString mediaType(Substring(nonDataPart, 0, nonDataPart.FindChar(';')));
-        mimeService->GetFromTypeAndExtension(mediaType, EmptyCString(), getter_AddRefs(mimeInfo));
-        if (!mimeInfo)
-          return;
+        nsCString mediaType(
+            Substring(nonDataPart, 0, nonDataPart.FindChar(';')));
+        mimeService->GetFromTypeAndExtension(mediaType, EmptyCString(),
+                                             getter_AddRefs(mimeInfo));
+        if (!mimeInfo) return;
         nsCString filename;
         nsCString extension;
         mimeInfo->GetPrimaryExtension(extension);
         unsigned char filePrefixBytes[8];
         GenerateGlobalRandomBytes(filePrefixBytes, 8);
         // Create a filename prefix with 16 lowercase letters,
         // representing 8 bytes.
-        for (int32_t i = 0; i < 8; i++)
-        {
+        for (int32_t i = 0; i < 8; i++) {
           // A pair of letters, each any of (a-p).
           filename.Append((filePrefixBytes[i] & 0xF) + 'a');
           filename.Append((filePrefixBytes[i] >> 4) + 'a');
         }
         filename.Append('.');
         filename.Append(extension);
         attachment->m_realName = filename;
       }
-    }
-    else
-    {
+    } else {
       /* Take the part of the file name after the last / or \ */
-      s2 = PL_strrchr (s, '/');
-      if (s2) s = s2+1;
-      s2 = PL_strrchr (s, '\\');
+      s2 = PL_strrchr(s, '/');
+      if (s2) s = s2 + 1;
+      s2 = PL_strrchr(s, '\\');
 
-      if (s2) s = s2+1;
+      if (s2) s = s2 + 1;
       /* Copy it into the attachment struct. */
       attachment->m_realName = s;
       int32_t charPos = attachment->m_realName.FindChar('?');
-      if (charPos != -1)
-        attachment->m_realName.SetLength(charPos);
+      if (charPos != -1) attachment->m_realName.SetLength(charPos);
       /* Now trim off any named anchors or search data. */
       charPos = attachment->m_realName.FindChar('#');
-      if (charPos != -1)
-        attachment->m_realName.SetLength(charPos);
+      if (charPos != -1) attachment->m_realName.SetLength(charPos);
     }
     /* Now lose the %XX crap. */
     nsCString unescaped_real_name;
     MsgUnescapeString(attachment->m_realName, 0, unescaped_real_name);
     attachment->m_realName = unescaped_real_name;
   }
 
   /* Now a special case for attaching uuencoded files...
@@ -1426,185 +1269,153 @@ msg_pick_real_name (nsMsgAttachmentHandl
    will presumably make the file name in the Content-Disposition header be
    the same as the file name in the "begin" line of the uuencoded data.)
 
    However, since there are mailers out there (including earlier versions of
    Mozilla) that will use "foo.txt.uu" as the file name, we still need to
    cope with that; the code which copes with that is in the MIME parser, in
    libmime/mimei.c.
    */
-  if (attachment->m_already_encoded_p && !attachment->m_encoding.IsEmpty())
-  {
+  if (attachment->m_already_encoded_p && !attachment->m_encoding.IsEmpty()) {
     /* #### TOTAL KLUDGE.
      I'd like to ask the mime.types file, "what extensions correspond
      to obj->encoding (which happens to be "x-uuencode") but doing that
      in a non-sphagetti way would require brain surgery.  So, since
      currently uuencode is the only content-transfer-encoding which we
      understand which traditionally has an extension, we just special-
      case it here!
 
      Note that it's special-cased in a similar way in libmime/mimei.c.
      */
     if (attachment->m_encoding.LowerCaseEqualsLiteral(ENCODING_UUENCODE) ||
         attachment->m_encoding.LowerCaseEqualsLiteral(ENCODING_UUENCODE2) ||
         attachment->m_encoding.LowerCaseEqualsLiteral(ENCODING_UUENCODE3) ||
-        attachment->m_encoding.LowerCaseEqualsLiteral(ENCODING_UUENCODE4))
-    {
+        attachment->m_encoding.LowerCaseEqualsLiteral(ENCODING_UUENCODE4)) {
       if (StringEndsWith(attachment->m_realName, NS_LITERAL_CSTRING(".uu")))
         attachment->m_realName.Cut(attachment->m_realName.Length() - 3, 3);
-      else if (StringEndsWith(attachment->m_realName, NS_LITERAL_CSTRING(".uue")))
+      else if (StringEndsWith(attachment->m_realName,
+                              NS_LITERAL_CSTRING(".uue")))
         attachment->m_realName.Cut(attachment->m_realName.Length() - 4, 4);
     }
   }
 }
 
 // Utility to create a nsIURI object...
-nsresult
-nsMsgNewURL(nsIURI** aInstancePtrResult, const nsCString& aSpec)
-{
+nsresult nsMsgNewURL(nsIURI **aInstancePtrResult, const nsCString &aSpec) {
   nsresult rv = NS_OK;
-  if (nullptr == aInstancePtrResult)
-    return NS_ERROR_NULL_POINTER;
-  nsCOMPtr<nsIIOService> pNetService =
-    mozilla::services::GetIOService();
+  if (nullptr == aInstancePtrResult) return NS_ERROR_NULL_POINTER;
+  nsCOMPtr<nsIIOService> pNetService = mozilla::services::GetIOService();
   NS_ENSURE_TRUE(pNetService, NS_ERROR_UNEXPECTED);
-  if (aSpec.Find("://") == kNotFound && !StringBeginsWith(aSpec, NS_LITERAL_CSTRING("data:")))
-  {
-    //XXXjag Temporary fix for bug 139362 until the real problem(bug 70083) get fixed
+  if (aSpec.Find("://") == kNotFound &&
+      !StringBeginsWith(aSpec, NS_LITERAL_CSTRING("data:"))) {
+    // XXXjag Temporary fix for bug 139362 until the real problem(bug 70083) get
+    // fixed
     nsAutoCString uri(NS_LITERAL_CSTRING("http://"));
     uri.Append(aSpec);
     rv = pNetService->NewURI(uri, nullptr, nullptr, aInstancePtrResult);
-  }
-  else
+  } else
     rv = pNetService->NewURI(aSpec, nullptr, nullptr, aInstancePtrResult);
   return rv;
 }
 
-bool
-nsMsgIsLocalFile(const char *url)
-{
+bool nsMsgIsLocalFile(const char *url) {
   /*
     A url is considered as a local file if it's start with file://
     But on Window, we need to filter UNC file url because there
     are not really local file. Those start with file:////
   */
-  if (PL_strncasecmp(url, "file://", 7) == 0)
-  {
+  if (PL_strncasecmp(url, "file://", 7) == 0) {
 #ifdef XP_WIN
-    if (PL_strncasecmp(url, "file:////", 9) == 0)
-      return false;
+    if (PL_strncasecmp(url, "file:////", 9) == 0) return false;
 #endif
     return true;
-  }
-  else
+  } else
     return false;
 }
 
-char
-*nsMsgGetLocalFileFromURL(const char *url)
-{
-  char * finalPath;
+char *nsMsgGetLocalFileFromURL(const char *url) {
+  char *finalPath;
   NS_ASSERTION(PL_strncasecmp(url, "file://", 7) == 0, "invalid url");
-  finalPath = (char*)PR_Malloc(strlen(url));
-  if (finalPath == NULL)
-    return NULL;
-  strcpy(finalPath, url+6+1);
+  finalPath = (char *)PR_Malloc(strlen(url));
+  if (finalPath == NULL) return NULL;
+  strcpy(finalPath, url + 6 + 1);
   return finalPath;
 }
 
-char *
-nsMsgParseURLHost(const char *url)
-{
-  nsIURI        *workURI = nullptr;
-  nsresult      rv;
+char *nsMsgParseURLHost(const char *url) {
+  nsIURI *workURI = nullptr;
+  nsresult rv;
 
   rv = nsMsgNewURL(&workURI, nsDependentCString(url));
-  if (NS_FAILED(rv) || !workURI)
-    return nullptr;
+  if (NS_FAILED(rv) || !workURI) return nullptr;
 
   nsAutoCString host;
   rv = workURI->GetHost(host);
   NS_IF_RELEASE(workURI);
-  if (NS_FAILED(rv))
-    return nullptr;
+  if (NS_FAILED(rv)) return nullptr;
 
   return ToNewCString(host);
 }
 
-char *
-GenerateFileNameFromURI(nsIURI *aURL)
-{
-  nsresult    rv;
+char *GenerateFileNameFromURI(nsIURI *aURL) {
+  nsresult rv;
   nsCString file;
   nsCString spec;
-  char        *returnString;
-  char        *cp = nullptr;
-  char        *cp1 = nullptr;
+  char *returnString;
+  char *cp = nullptr;
+  char *cp1 = nullptr;
 
   rv = aURL->GetPathQueryRef(file);
-  if ( NS_SUCCEEDED(rv) && !file.IsEmpty())
-  {
+  if (NS_SUCCEEDED(rv) && !file.IsEmpty()) {
     char *newFile = ToNewCString(file);
-    if (!newFile)
-      return nullptr;
+    if (!newFile) return nullptr;
 
     // strip '/'
     cp = PL_strrchr(newFile, '/');
     if (cp)
       ++cp;
     else
       cp = newFile;
 
-    if (*cp)
-    {
+    if (*cp) {
       if ((cp1 = PL_strchr(cp, '/'))) *cp1 = 0;
       if ((cp1 = PL_strchr(cp, '?'))) *cp1 = 0;
       if ((cp1 = PL_strchr(cp, '>'))) *cp1 = 0;
-      if (*cp != '\0')
-      {
+      if (*cp != '\0') {
         returnString = PL_strdup(cp);
         PR_FREEIF(newFile);
         return returnString;
       }
-    }
-    else
+    } else
       return nullptr;
   }
 
   cp = nullptr;
   cp1 = nullptr;
 
-
   rv = aURL->GetSpec(spec);
-  if ( NS_SUCCEEDED(rv) && !spec.IsEmpty())
-  {
+  if (NS_SUCCEEDED(rv) && !spec.IsEmpty()) {
     char *newSpec = ToNewCString(spec);
-    if (!newSpec)
-      return nullptr;
+    if (!newSpec) return nullptr;
 
-    char *cp2 = NULL, *cp3=NULL ;
+    char *cp2 = NULL, *cp3 = NULL;
 
     // strip '"'
     cp2 = newSpec;
-    while (*cp2 == '"')
-      cp2++;
-    if ((cp3 = PL_strchr(cp2, '"')))
-      *cp3 = 0;
+    while (*cp2 == '"') cp2++;
+    if ((cp3 = PL_strchr(cp2, '"'))) *cp3 = 0;
 
     char *hostStr = nsMsgParseURLHost(cp2);
-    if (!hostStr)
-      hostStr = PL_strdup(cp2);
+    if (!hostStr) hostStr = PL_strdup(cp2);
 
     bool isHTTP = false;
-    if (NS_SUCCEEDED(aURL->SchemeIs("http", &isHTTP)) && isHTTP)
-    {
-        returnString = PR_smprintf("%s.html", hostStr);
-        PR_FREEIF(hostStr);
-    }
-    else
+    if (NS_SUCCEEDED(aURL->SchemeIs("http", &isHTTP)) && isHTTP) {
+      returnString = PR_smprintf("%s.html", hostStr);
+      PR_FREEIF(hostStr);
+    } else
       returnString = hostStr;
 
     PR_FREEIF(newSpec);
     return returnString;
   }
 
   return nullptr;
 }
@@ -1613,104 +1424,94 @@ GenerateFileNameFromURI(nsIURI *aURL)
 // This routine will generate a content id for use in a mail part.
 // It will take the part number passed in as well as the email
 // address. If the email address is null or invalid, we will simply
 // use netscape.com for the interesting part. The content ID's will
 // look like the following:
 //
 //      Content-ID: <part1.36DF1DCE.73B5A330@netscape.com>
 //
-char *
-mime_gen_content_id(uint32_t aPartNum, const char *aEmailAddress)
-{
-  int32_t           randLen = 5;
-  unsigned char     rand_buf1[5];
-  unsigned char     rand_buf2[5];
-  const char        *domain = nullptr;
-  const char        *defaultDomain = "@netscape.com";
+char *mime_gen_content_id(uint32_t aPartNum, const char *aEmailAddress) {
+  int32_t randLen = 5;
+  unsigned char rand_buf1[5];
+  unsigned char rand_buf2[5];
+  const char *domain = nullptr;
+  const char *defaultDomain = "@netscape.com";
 
-  memset(rand_buf1, 0, randLen-1);
-  memset(rand_buf2, 0, randLen-1);
+  memset(rand_buf1, 0, randLen - 1);
+  memset(rand_buf2, 0, randLen - 1);
 
   GenerateGlobalRandomBytes(rand_buf1, randLen);
   GenerateGlobalRandomBytes(rand_buf2, randLen);
 
   // Find the @domain.com string...
   if (aEmailAddress && *aEmailAddress)
-    domain = const_cast<const char*>(PL_strchr(aEmailAddress, '@'));
+    domain = const_cast<const char *>(PL_strchr(aEmailAddress, '@'));
 
-  if (!domain)
-    domain = defaultDomain;
+  if (!domain) domain = defaultDomain;
 
-  char *retVal = PR_smprintf("part%d."
-                              "%02X%02X%02X%02X"
-                              "."
-                              "%02X%02X%02X%02X"
-                              "%s",
-                              aPartNum,
-                              rand_buf1[0], rand_buf1[1], rand_buf1[2], rand_buf1[3],
-                              rand_buf2[0], rand_buf2[1], rand_buf2[2], rand_buf2[3],
-                              domain);
+  char *retVal = PR_smprintf(
+      "part%d."
+      "%02X%02X%02X%02X"
+      "."
+      "%02X%02X%02X%02X"
+      "%s",
+      aPartNum, rand_buf1[0], rand_buf1[1], rand_buf1[2], rand_buf1[3],
+      rand_buf2[0], rand_buf2[1], rand_buf2[2], rand_buf2[3], domain);
 
   return retVal;
 }
 
-void
-GetFolderURIFromUserPrefs(nsMsgDeliverMode aMode, nsIMsgIdentity* identity, nsCString& uri)
-{
+void GetFolderURIFromUserPrefs(nsMsgDeliverMode aMode, nsIMsgIdentity *identity,
+                               nsCString &uri) {
   nsresult rv;
   uri.Truncate();
 
   // QueueForLater (Outbox)
   if (aMode == nsIMsgSend::nsMsgQueueForLater ||
-      aMode == nsIMsgSend::nsMsgDeliverBackground)
-  {
-    nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-    if (NS_FAILED(rv))
-      return;
+      aMode == nsIMsgSend::nsMsgDeliverBackground) {
+    nsCOMPtr<nsIPrefBranch> prefs(
+        do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+    if (NS_FAILED(rv)) return;
     rv = prefs->GetCharPref("mail.default_sendlater_uri", uri);
     if (NS_FAILED(rv) || uri.IsEmpty())
       uri.AssignLiteral(ANY_SERVER);
-    else
-    {
+    else {
       // check if uri is unescaped, and if so, escape it and reset the pef.
-      if (uri.FindChar(' ') != kNotFound)
-      {
+      if (uri.FindChar(' ') != kNotFound) {
         MsgReplaceSubstring(uri, " ", "%20");
         prefs->SetCharPref("mail.default_sendlater_uri", uri);
       }
     }
     return;
   }
 
-  if (!identity)
-    return;
+  if (!identity) return;
 
-  if (aMode == nsIMsgSend::nsMsgSaveAsDraft)    // SaveAsDraft (Drafts)
+  if (aMode == nsIMsgSend::nsMsgSaveAsDraft)  // SaveAsDraft (Drafts)
     rv = identity->GetDraftFolder(uri);
-  else if (aMode == nsIMsgSend::nsMsgSaveAsTemplate) // SaveAsTemplate (Templates)
+  else if (aMode ==
+           nsIMsgSend::nsMsgSaveAsTemplate)  // SaveAsTemplate (Templates)
     rv = identity->GetStationeryFolder(uri);
-  else
-  {
+  else {
     bool doFcc = false;
     rv = identity->GetDoFcc(&doFcc);
-    if (doFcc)
-      rv = identity->GetFccFolder(uri);
+    if (doFcc) rv = identity->GetFccFolder(uri);
   }
   return;
 }
 
 /**
  * Check if we should use format=flowed (RFC 2646) for a mail.
  * We will use format=flowed unless the preference tells us not to do so.
  * In this function we set all the serialiser flags.
  * 'formatted' is always 'true'.
  */
-void GetSerialiserFlags(const char* charset, bool* flowed, bool* delsp, bool* formatted, bool* disallowBreaks)
-{
+void GetSerialiserFlags(const char *charset, bool *flowed, bool *delsp,
+                        bool *formatted, bool *disallowBreaks) {
   *flowed = false;
   *delsp = false;
   *formatted = true;
   *disallowBreaks = true;
 
   // Set format=flowed as in RFC 2646 according to the preference.
   nsresult rv;
   nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
@@ -1719,40 +1520,38 @@ void GetSerialiserFlags(const char* char
   }
 
   // We could test statefulCharset(charset) here, but since ISO-2022-JP is the
   // only one left we support, we might as well check for it directly.
   if (PL_strcasecmp(charset, "ISO-2022-JP") == 0) {
     // Make sure we honour RFC 1468. For encoding in ISO-2022-JP we need to
     // send short lines to allow 7bit transfer encoding.
     *disallowBreaks = false;
-    if (*flowed)
-      *delsp = true;
+    if (*flowed) *delsp = true;
   }
 }
 
-already_AddRefed<nsIArray>
-GetEmbeddedObjects(mozilla::dom::Document* aDocument)
-{
+already_AddRefed<nsIArray> GetEmbeddedObjects(
+    mozilla::dom::Document *aDocument) {
   nsCOMPtr<nsIMutableArray> nodes = do_CreateInstance(NS_ARRAY_CONTRACTID);
   if (NS_WARN_IF(!nodes)) {
     return nullptr;
   }
 
   mozilla::PostContentIterator iter;
   nsresult rv = iter.Init(aDocument->GetRootElement());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return nullptr;
   }
 
   // Loop through the content iterator for each content node.
   while (!iter.IsDone()) {
-    nsINode* node = iter.GetCurrentNode();
+    nsINode *node = iter.GetCurrentNode();
     if (node->IsElement()) {
-      mozilla::dom::Element* element = node->AsElement();
+      mozilla::dom::Element *element = node->AsElement();
 
       // See if it's an image or also include all links.
       // Let mail decide which link to send or not
       if (element->IsAnyOfHTMLElements(nsGkAtoms::img, nsGkAtoms::a) ||
           (element->IsHTMLElement(nsGkAtoms::body) &&
            element->HasAttr(kNameSpaceID_None, nsGkAtoms::background))) {
         nodes->AppendElement(node);
       }
--- a/mailnews/compose/src/nsMsgCompUtils.h
+++ b/mailnews/compose/src/nsMsgCompUtils.h
@@ -19,128 +19,111 @@ class nsIPrompt;
 #define ANY_SERVER "anyfolder://"
 
 // these are msg hdr property names for storing the original
 // msg uri's and disposition(replied/forwarded) when queuing
 // messages to send later.
 #define ORIG_URI_PROPERTY "origURIs"
 #define QUEUED_DISPOSITION_PROPERTY "queuedDisposition"
 
-class nsMsgCompUtils : public nsIMsgCompUtils
-{
-public:
+class nsMsgCompUtils : public nsIMsgCompUtils {
+ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMSGCOMPUTILS
 
   nsMsgCompUtils();
 
-private:
+ private:
   virtual ~nsMsgCompUtils();
 };
 
-already_AddRefed<nsIArray> GetEmbeddedObjects(mozilla::dom::Document* aDocument);
+already_AddRefed<nsIArray> GetEmbeddedObjects(
+    mozilla::dom::Document *aDocument);
 
 PR_BEGIN_EXTERN_C
 
 //
 // Create a file spec or file name using the name passed
 // in as a template
 //
-nsresult    nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile);
-char        *nsMsgCreateTempFileName(const char *tFileName);
-
+nsresult nsMsgCreateTempFile(const char *tFileName, nsIFile **tFile);
+char *nsMsgCreateTempFileName(const char *tFileName);
 
 //
 // Various utilities for building parts of MIME encoded
 // messages during message composition
 //
 
-nsresult    mime_sanity_check_fields_recipients (
-                            const char *to,
-                            const char *cc,
-                            const char *bcc,
-                            const char *newsgroups);
+nsresult mime_sanity_check_fields_recipients(const char *to, const char *cc,
+                                             const char *bcc,
+                                             const char *newsgroups);
 
-nsresult    mime_sanity_check_fields (
-                            const char *from,
-                            const char *reply_to,
-                            const char *to,
-                            const char *cc,
-                            const char *bcc,
-                            const char *fcc,
-                            const char *newsgroups,
-                            const char *followup_to,
-                            const char * /*subject*/,
-                            const char * /*references*/,
-                            const char * /*organization*/,
-                            const char * /*other_random_headers*/);
+nsresult mime_sanity_check_fields(
+    const char *from, const char *reply_to, const char *to, const char *cc,
+    const char *bcc, const char *fcc, const char *newsgroups,
+    const char *followup_to, const char * /*subject*/,
+    const char * /*references*/, const char * /*organization*/,
+    const char * /*other_random_headers*/);
 
 nsresult mime_generate_headers(nsIMsgCompFields *fields,
                                nsMsgDeliverMode deliver_mode,
                                msgIWritableStructuredHeaders *headers);
 
-char        *mime_make_separator(const char *prefix);
-char        *mime_gen_content_id(uint32_t aPartNum, const char *aEmailAddress);
+char *mime_make_separator(const char *prefix);
+char *mime_gen_content_id(uint32_t aPartNum, const char *aEmailAddress);
+
+char *mime_generate_attachment_headers(
+    const char *type, const char *type_param, const char *encoding,
+    const char *description, const char *x_mac_type, const char *x_mac_creator,
+    const char *real_name, const char *base_url, bool digest_p,
+    nsMsgAttachmentHandler *ma,
+    const char *attachmentCharset,  // charset of the attachment (can be null)
+    const char *bodyCharset,        // charset of the main body
+    bool bodyIsAsciiOnly, const char *content_id, bool aBodyDocument);
 
-char        *mime_generate_attachment_headers (
-                           const char *type,
-                           const char *type_param,
-                           const char *encoding,
-                           const char *description,
-                           const char *x_mac_type,
-                           const char *x_mac_creator,
-                           const char *real_name,
-                           const char *base_url,
-                           bool digest_p,
-                           nsMsgAttachmentHandler *ma,
-                           const char *attachmentCharset, // charset of the attachment (can be null)
-                           const char *bodyCharset,       // charset of the main body
-                           bool bodyIsAsciiOnly,
-                           const char *content_id,
-                           bool       aBodyDocument);
+char *msg_generate_message_id(nsIMsgIdentity *);
+
+bool mime_7bit_data_p(const char *string, uint32_t size);
 
-char        *msg_generate_message_id (nsIMsgIdentity*);
-
-bool        mime_7bit_data_p (const char *string, uint32_t size);
+char *mime_fix_header_1(const char *string, bool addr_p, bool news_p);
+char *mime_fix_header(const char *string);
+char *mime_fix_addr_header(const char *string);
+char *mime_fix_news_header(const char *string);
 
-char        *mime_fix_header_1 (const char *string, bool addr_p, bool news_p);
-char        *mime_fix_header (const char *string);
-char        *mime_fix_addr_header (const char *string);
-char        *mime_fix_news_header (const char *string);
+bool mime_type_requires_b64_p(const char *type);
+bool mime_type_needs_charset(const char *type);
 
-bool        mime_type_requires_b64_p (const char *type);
-bool        mime_type_needs_charset (const char *type);
-
-char        *msg_make_filename_qtext(const char *srcText, bool stripCRLFs);
+char *msg_make_filename_qtext(const char *srcText, bool stripCRLFs);
 
 // Rip apart the URL and extract a reasonable value for the `real_name' slot.
-void        msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char16_t *proposedName, const char *charset);
+void msg_pick_real_name(nsMsgAttachmentHandler *attachment,
+                        const char16_t *proposedName, const char *charset);
 
 //
 // Informational calls...
 //
-void        nsMsgMIMESetConformToStandard (bool conform_p);
-bool        nsMsgMIMEGetConformToStandard (void);
+void nsMsgMIMESetConformToStandard(bool conform_p);
+bool nsMsgMIMEGetConformToStandard(void);
 
 //
 // network service type calls...
 //
-nsresult    nsMsgNewURL(nsIURI** aInstancePtrResult, const nsCString& aSpec);
-bool        nsMsgIsLocalFile(const char *url);
-char        *nsMsgGetLocalFileFromURL(const char *url);
+nsresult nsMsgNewURL(nsIURI **aInstancePtrResult, const nsCString &aSpec);
+bool nsMsgIsLocalFile(const char *url);
+char *nsMsgGetLocalFileFromURL(const char *url);
 
-char        *nsMsgParseURLHost(const char *url);
+char *nsMsgParseURLHost(const char *url);
 
-char        *GenerateFileNameFromURI(nsIURI *aURL);
+char *GenerateFileNameFromURI(nsIURI *aURL);
 
 //
 // Folder calls...
 //
-void GetFolderURIFromUserPrefs(nsMsgDeliverMode   aMode, nsIMsgIdentity *identity, nsCString& uri);
+void GetFolderURIFromUserPrefs(nsMsgDeliverMode aMode, nsIMsgIdentity *identity,
+                               nsCString &uri);
 
 // Check if we should use format=flowed
-void GetSerialiserFlags(const char *charset, bool *flowed, bool *delsp, bool *formatted, bool *disallowBreaks);
+void GetSerialiserFlags(const char *charset, bool *flowed, bool *delsp,
+                        bool *formatted, bool *disallowBreaks);
 
 PR_END_EXTERN_C
 
-
 #endif /* _nsMsgCompUtils_H_ */
-
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -8,17 +8,17 @@
 #include "nsPIDOMWindow.h"
 #include "mozIDOMWindow.h"
 #include "nsISelectionController.h"
 #include "nsMsgI18N.h"
 #include "nsMsgCompCID.h"
 #include "nsMsgQuote.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
-#include "nsIDocumentEncoder.h"    // for editor output flags
+#include "nsIDocumentEncoder.h"  // for editor output flags
 #include "nsMsgCompUtils.h"
 #include "nsComposeStrings.h"
 #include "nsIMsgSend.h"
 #include "nsMailHeaders.h"
 #include "nsMsgPrompts.h"
 #include "nsMimeTypes.h"
 #include "nsICharsetConverterManager.h"
 #include "nsTextFormatter.h"
@@ -71,345 +71,326 @@
 #include "mozilla/dom/HTMLAnchorElement.h"
 #include "mozilla/dom/HTMLImageElement.h"
 #include "mozilla/dom/Selection.h"
 #include "nsStreamConverter.h"
 #include "nsIObserverService.h"
 #include "nsIProtocolHandler.h"
 #include "nsContentUtils.h"
 #include "nsIFileURL.h"
-#include "nsTextNode.h" // from dom/base
+#include "nsTextNode.h"  // from dom/base
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::mailnews;
 
-static nsresult GetReplyHeaderInfo(int32_t* reply_header_type,
-                                   nsString& reply_header_authorwrote,
-                                   nsString& reply_header_ondateauthorwrote,
-                                   nsString& reply_header_authorwroteondate,
-                                   nsString& reply_header_originalmessage)
-{
+static nsresult GetReplyHeaderInfo(int32_t *reply_header_type,
+                                   nsString &reply_header_authorwrote,
+                                   nsString &reply_header_ondateauthorwrote,
+                                   nsString &reply_header_authorwroteondate,
+                                   nsString &reply_header_originalmessage) {
   nsresult rv;
   *reply_header_type = 0;
-  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If fetching any of the preferences fails,
   // we return early with header_type = 0 meaning "no header".
-  rv = NS_GetLocalizedUnicharPreference(prefBranch, "mailnews.reply_header_authorwrotesingle",
-                                        reply_header_authorwrote);
+  rv = NS_GetLocalizedUnicharPreference(
+      prefBranch, "mailnews.reply_header_authorwrotesingle",
+      reply_header_authorwrote);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = NS_GetLocalizedUnicharPreference(prefBranch, "mailnews.reply_header_ondateauthorwrote",
-                                        reply_header_ondateauthorwrote);
+  rv = NS_GetLocalizedUnicharPreference(
+      prefBranch, "mailnews.reply_header_ondateauthorwrote",
+      reply_header_ondateauthorwrote);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = NS_GetLocalizedUnicharPreference(prefBranch, "mailnews.reply_header_authorwroteondate",
-                                        reply_header_authorwroteondate);
+  rv = NS_GetLocalizedUnicharPreference(
+      prefBranch, "mailnews.reply_header_authorwroteondate",
+      reply_header_authorwroteondate);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = NS_GetLocalizedUnicharPreference(prefBranch, "mailnews.reply_header_originalmessage",
+  rv = NS_GetLocalizedUnicharPreference(prefBranch,
+                                        "mailnews.reply_header_originalmessage",
                                         reply_header_originalmessage);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return prefBranch->GetIntPref("mailnews.reply_header_type", reply_header_type);
+  return prefBranch->GetIntPref("mailnews.reply_header_type",
+                                reply_header_type);
 }
 
-static void TranslateLineEnding(nsString& data)
-{
-  char16_t* rPtr;   //Read pointer
-  char16_t* wPtr;   //Write pointer
-  char16_t* sPtr;   //Start data pointer
-  char16_t* ePtr;   //End data pointer
+static void TranslateLineEnding(nsString &data) {
+  char16_t *rPtr;  // Read pointer
+  char16_t *wPtr;  // Write pointer
+  char16_t *sPtr;  // Start data pointer
+  char16_t *ePtr;  // End data pointer
 
   rPtr = wPtr = sPtr = data.BeginWriting();
   ePtr = rPtr + data.Length();
 
-  while (rPtr < ePtr)
-  {
+  while (rPtr < ePtr) {
     if (*rPtr == nsCRT::CR) {
       *wPtr = nsCRT::LF;
-      if (rPtr + 1 < ePtr && *(rPtr + 1) == nsCRT::LF)
-        rPtr ++;
-    }
-    else
+      if (rPtr + 1 < ePtr && *(rPtr + 1) == nsCRT::LF) rPtr++;
+    } else
       *wPtr = *rPtr;
 
-    rPtr ++;
-    wPtr ++;
+    rPtr++;
+    wPtr++;
   }
 
   data.SetLength(wPtr - sPtr);
 }
 
-static void GetTopmostMsgWindowCharacterSet(nsCString& charset, bool* charsetOverride)
-{
-  // HACK: if we are replying to a message and that message used a charset over ride
-  // (as specified in the top most window (assuming the reply originated from that window)
-  // then use that over ride charset instead of the charset specified in the message
-  nsCOMPtr <nsIMsgMailSession> mailSession (do_GetService(NS_MSGMAILSESSION_CONTRACTID));
-  if (mailSession)
-  {
-    nsCOMPtr<nsIMsgWindow>    msgWindow;
+static void GetTopmostMsgWindowCharacterSet(nsCString &charset,
+                                            bool *charsetOverride) {
+  // HACK: if we are replying to a message and that message used a charset over
+  // ride (as specified in the top most window (assuming the reply originated
+  // from that window) then use that over ride charset instead of the charset
+  // specified in the message
+  nsCOMPtr<nsIMsgMailSession> mailSession(
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID));
+  if (mailSession) {
+    nsCOMPtr<nsIMsgWindow> msgWindow;
     mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow));
-    if (msgWindow)
-    {
+    if (msgWindow) {
       msgWindow->GetMailCharacterSet(charset);
       msgWindow->GetCharsetOverride(charsetOverride);
     }
   }
 }
 
-nsMsgCompose::nsMsgCompose()
-{
-
+nsMsgCompose::nsMsgCompose() {
   mQuotingToFollow = false;
   mInsertingQuotedContent = false;
   mWhatHolder = 1;
   m_window = nullptr;
   m_editor = nullptr;
-  mQuoteStreamListener=nullptr;
+  mQuoteStreamListener = nullptr;
   mCharsetOverride = false;
   mAnswerDefaultCharset = false;
   mDeleteDraft = false;
-  m_compFields = nullptr;    //m_compFields will be set during nsMsgCompose::Initialize
+  m_compFields =
+      nullptr;  // m_compFields will be set during nsMsgCompose::Initialize
   mType = nsIMsgCompType::New;
 
   // For TagConvertible
   // Read and cache pref
   mConvertStructs = false;
-  nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID));
+  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (prefBranch)
     prefBranch->GetBoolPref("converter.html2txt.structs", &mConvertStructs);
 
   m_composeHTML = false;
 }
 
-
-nsMsgCompose::~nsMsgCompose()
-{
-}
-
-/* the following macro actually implement addref, release and query interface for our component. */
+nsMsgCompose::~nsMsgCompose() {}
+
+/* the following macro actually implement addref, release and query interface
+ * for our component. */
 NS_IMPL_ISUPPORTS(nsMsgCompose, nsIMsgCompose, nsIMsgSendListener,
-  nsISupportsWeakReference)
+                  nsISupportsWeakReference)
 
 //
 // Once we are here, convert the data which we know to be UTF-8 to UTF-16
 // for insertion into the editor
 //
-nsresult
-GetChildOffset(nsINode *aChild, nsINode *aParent, int32_t &aOffset)
-{
+nsresult GetChildOffset(nsINode *aChild, nsINode *aParent, int32_t &aOffset) {
   NS_ASSERTION((aChild && aParent), "bad args");
 
-  if (!aChild || !aParent)
-    return NS_ERROR_NULL_POINTER;
-
-  nsINodeList* childNodes = aParent->ChildNodes();
-  for (uint32_t i = 0; i < childNodes->Length(); i++)
-  {
-    nsINode* childNode = childNodes->Item(i);
-    if (childNode == aChild)
-    {
+  if (!aChild || !aParent) return NS_ERROR_NULL_POINTER;
+
+  nsINodeList *childNodes = aParent->ChildNodes();
+  for (uint32_t i = 0; i < childNodes->Length(); i++) {
+    nsINode *childNode = childNodes->Item(i);
+    if (childNode == aChild) {
       aOffset = i;
       return NS_OK;
     }
   }
 
   return NS_ERROR_NULL_POINTER;
 }
 
-nsresult
-GetNodeLocation(nsINode *inChild, nsCOMPtr<nsINode> *outParent, int32_t *outOffset)
-{
+nsresult GetNodeLocation(nsINode *inChild, nsCOMPtr<nsINode> *outParent,
+                         int32_t *outOffset) {
   NS_ASSERTION((outParent && outOffset), "bad args");
   nsresult result = NS_ERROR_NULL_POINTER;
-  if (inChild && outParent && outOffset)
-  {
+  if (inChild && outParent && outOffset) {
     nsCOMPtr<nsINode> inChild2 = inChild;
     *outParent = inChild2->GetParentNode();
-    if (*outParent)
-    {
+    if (*outParent) {
       result = GetChildOffset(inChild2, *outParent, *outOffset);
     }
   }
 
   return result;
 }
 
-bool nsMsgCompose::IsEmbeddedObjectSafe(const char * originalScheme,
-                                        const char * originalHost,
-                                        const char * originalPath,
-                                        Element * element)
-{
+bool nsMsgCompose::IsEmbeddedObjectSafe(const char *originalScheme,
+                                        const char *originalHost,
+                                        const char *originalPath,
+                                        Element *element) {
   nsresult rv;
 
   nsAutoString objURL;
 
-  if (!originalScheme || !originalPath) // Having a null host is OK.
+  if (!originalScheme || !originalPath)  // Having a null host is OK.
     return false;
 
-  RefPtr<HTMLImageElement>  image  = HTMLImageElement::FromNode(element);
+  RefPtr<HTMLImageElement> image = HTMLImageElement::FromNode(element);
   RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::FromNode(element);
 
   if (image)
     image->GetSrc(objURL);
   else if (anchor)
     anchor->GetHref(objURL);
   else
     return false;
 
-  if (!objURL.IsEmpty())
-  {
+  if (!objURL.IsEmpty()) {
     nsCOMPtr<nsIURI> uri;
     rv = NS_NewURI(getter_AddRefs(uri), objURL);
-    if (NS_SUCCEEDED(rv) && uri)
-    {
+    if (NS_SUCCEEDED(rv) && uri) {
       nsAutoCString scheme;
       rv = uri->GetScheme(scheme);
-      if (NS_SUCCEEDED(rv) && scheme.Equals(originalScheme, nsCaseInsensitiveCStringComparator()))
-      {
+      if (NS_SUCCEEDED(rv) &&
+          scheme.Equals(originalScheme, nsCaseInsensitiveCStringComparator())) {
         nsAutoCString host;
         rv = uri->GetAsciiHost(host);
         // mailbox url don't have a host therefore don't be too strict.
-        if (NS_SUCCEEDED(rv) && (host.IsEmpty() || originalHost || host.Equals(originalHost, nsCaseInsensitiveCStringComparator())))
-        {
+        if (NS_SUCCEEDED(rv) &&
+            (host.IsEmpty() || originalHost ||
+             host.Equals(originalHost, nsCaseInsensitiveCStringComparator()))) {
           nsAutoCString path;
           rv = uri->GetPathQueryRef(path);
-          if (NS_SUCCEEDED(rv))
-          {
-            const char * query = strrchr(path.get(), '?');
-            if (query && PL_strncasecmp(path.get(), originalPath, query - path.get()) == 0)
-              return true; // This object is a part of the original message, we can send it safely.
+          if (NS_SUCCEEDED(rv)) {
+            const char *query = strrchr(path.get(), '?');
+            if (query && PL_strncasecmp(path.get(), originalPath,
+                                        query - path.get()) == 0)
+              return true;  // This object is a part of the original message, we
+                            // can send it safely.
           }
         }
       }
     }
   }
 
   return false;
 }
 
-/* Reset the uri's of embedded objects because we've saved the draft message, and the
-   original message doesn't exist anymore.
+/* Reset the uri's of embedded objects because we've saved the draft message,
+   and the original message doesn't exist anymore.
  */
-nsresult nsMsgCompose::ResetUrisForEmbeddedObjects()
-{
+nsresult nsMsgCompose::ResetUrisForEmbeddedObjects() {
   uint32_t numNodes;
   uint32_t i;
 
-  if (!m_editor)
-    return NS_ERROR_FAILURE;
+  if (!m_editor) return NS_ERROR_FAILURE;
 
   nsCOMPtr<Document> document;
   m_editor->GetDocument(getter_AddRefs(document));
-  if (!document)
-    return NS_ERROR_FAILURE;
+  if (!document) return NS_ERROR_FAILURE;
   nsCOMPtr<nsIArray> aNodeList = GetEmbeddedObjects(document);
-  if (!aNodeList)
-    return NS_ERROR_FAILURE;
-
-  if (NS_FAILED(aNodeList->GetLength(&numNodes)))
-    return NS_ERROR_FAILURE;
+  if (!aNodeList) return NS_ERROR_FAILURE;
+
+  if (NS_FAILED(aNodeList->GetLength(&numNodes))) return NS_ERROR_FAILURE;
 
   nsCString curDraftIdURL;
 
   nsresult rv = m_compFields->GetDraftId(getter_Copies(curDraftIdURL));
 
   // Skip if no draft id (probably a new draft msg).
-  if (NS_SUCCEEDED(rv) && mMsgSend && !curDraftIdURL.IsEmpty())
-  {
-    nsCOMPtr <nsIMsgDBHdr> msgDBHdr;
+  if (NS_SUCCEEDED(rv) && mMsgSend && !curDraftIdURL.IsEmpty()) {
+    nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
     rv = GetMsgDBHdrFromURI(curDraftIdURL.get(), getter_AddRefs(msgDBHdr));
-    NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't get msg header DB interface pointer.");
-    if (NS_SUCCEEDED(rv) && msgDBHdr)
-    {
+    NS_ASSERTION(
+        NS_SUCCEEDED(rv),
+        "RemoveCurrentDraftMessage can't get msg header DB interface pointer.");
+    if (NS_SUCCEEDED(rv) && msgDBHdr) {
       // build up the old and new ?number= parts. This code assumes it is
       // called *before* RemoveCurrentDraftMessage, so that curDraftIdURL
       // is the previous draft.
       // This code works for both imap and local messages.
       nsMsgKey newMsgKey;
       nsCString folderUri;
       nsCString baseMsgUri;
       mMsgSend->GetMessageKey(&newMsgKey);
       mMsgSend->GetFolderUri(folderUri);
       nsCOMPtr<nsIMsgFolder> folder;
       rv = GetExistingFolder(folderUri, getter_AddRefs(folder));
       NS_ENSURE_SUCCESS(rv, rv);
       folder->GetBaseMessageURI(baseMsgUri);
       NS_ENSURE_SUCCESS(rv, rv);
 
       RefPtr<Element> domElement;
-      for (i = 0; i < numNodes; i ++)
-      {
+      for (i = 0; i < numNodes; i++) {
         domElement = do_QueryElementAt(aNodeList, i);
-        if (!domElement)
-          continue;
+        if (!domElement) continue;
 
         RefPtr<HTMLImageElement> image = HTMLImageElement::FromNode(domElement);
-        if (!image)
-          continue;
+        if (!image) continue;
         nsCString partNum;
         mMsgSend->GetPartForDomIndex(i, partNum);
         // do we care about anything besides images?
         nsAutoString objURL;
         image->GetSrc(objURL);
 
         // First we need to make sure that the URL is associated with a message
         // protocol so we don't accidentally manipulate a URL like:
         // http://www.site.com/retrieve.html?C=image.jpg.
-        nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
+        nsCOMPtr<nsIIOService> ioService =
+            do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
         NS_ENSURE_SUCCESS(rv, rv);
         nsAutoCString scheme;
         ioService->ExtractScheme(NS_ConvertUTF16toUTF8(objURL), scheme);
 
         // Detect message protocols where attachments can occur.
         nsCOMPtr<nsIProtocolHandler> handler;
         ioService->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
-        if (!handler)
-          continue;
-        nsCOMPtr<nsIMsgMessageFetchPartService> mailHandler = do_QueryInterface(handler);
-        if (!mailHandler)
-          continue;
+        if (!handler) continue;
+        nsCOMPtr<nsIMsgMessageFetchPartService> mailHandler =
+            do_QueryInterface(handler);
+        if (!mailHandler) continue;
 
         // the objURL is the full path to the embedded content. We need
         // to update it with uri for the folder we just saved to, and the new
         // msg key.
         int32_t restOfUrlIndex = objURL.Find("?number=");
         if (restOfUrlIndex == kNotFound)
           restOfUrlIndex = objURL.FindChar('?');
         else
           restOfUrlIndex = objURL.FindChar('&', restOfUrlIndex);
 
-        if (restOfUrlIndex == kNotFound)
-          continue;
+        if (restOfUrlIndex == kNotFound) continue;
 
         nsCString newURI(baseMsgUri);
         newURI.Append('#');
         newURI.AppendInt(newMsgKey);
-        nsString restOfUrl(Substring(objURL, restOfUrlIndex, objURL.Length() - restOfUrlIndex));
+        nsString restOfUrl(Substring(objURL, restOfUrlIndex,
+                                     objURL.Length() - restOfUrlIndex));
         int32_t partIndex = restOfUrl.Find("part=");
-        if (partIndex != kNotFound)
-        {
+        if (partIndex != kNotFound) {
           partIndex += 5;
           int32_t endPart = restOfUrl.FindChar('&', partIndex);
-          int32_t existingPartLen = (endPart == kNotFound) ? -1 : endPart - partIndex;
-          restOfUrl.Replace(partIndex, existingPartLen, NS_ConvertASCIItoUTF16(partNum));
+          int32_t existingPartLen =
+              (endPart == kNotFound) ? -1 : endPart - partIndex;
+          restOfUrl.Replace(partIndex, existingPartLen,
+                            NS_ConvertASCIItoUTF16(partNum));
         }
 
         nsCOMPtr<nsIMsgMessageService> msgService;
         rv = GetMessageServiceFromURI(newURI, getter_AddRefs(msgService));
-        if (NS_FAILED(rv))
-          continue;
+        if (NS_FAILED(rv)) continue;
         nsCOMPtr<nsIURI> newUrl;
-        rv = msgService->GetUrlForUri(newURI.get(), getter_AddRefs(newUrl), nullptr);
-        if (!newUrl)
-          continue;
+        rv = msgService->GetUrlForUri(newURI.get(), getter_AddRefs(newUrl),
+                                      nullptr);
+        if (!newUrl) continue;
         nsCString spec;
         rv = newUrl->GetSpec(spec);
         NS_ENSURE_SUCCESS(rv, rv);
         nsString newSrc;
         // mailbox urls will have ?number=xxx; imap urls won't. We need to
         // handle both cases because we may be going from a mailbox url to
         // and imap url, or vice versa, depending on the original folder,
         // and the destination drafts folder.
@@ -424,105 +405,92 @@ nsresult nsMsgCompose::ResetUrisForEmbed
         image->SetSrc(newSrc, rv2);
       }
     }
   }
 
   return NS_OK;
 }
 
-
-/* The purpose of this function is to mark any embedded object that wasn't a RFC822 part
-   of the original message as moz-do-not-send.
-   That will prevent us to attach data not specified by the user or not present in the
-   original message.
+/* The purpose of this function is to mark any embedded object that wasn't a
+   RFC822 part of the original message as moz-do-not-send. That will prevent us
+   to attach data not specified by the user or not present in the original
+   message.
 */
-nsresult nsMsgCompose::TagEmbeddedObjects(nsIEditor *aEditor)
-{
+nsresult nsMsgCompose::TagEmbeddedObjects(nsIEditor *aEditor) {
   nsresult rv = NS_OK;
   uint32_t count;
   uint32_t i;
 
-  if (!aEditor)
-    return NS_ERROR_FAILURE;
+  if (!aEditor) return NS_ERROR_FAILURE;
 
   nsCOMPtr<Document> document;
   aEditor->GetDocument(getter_AddRefs(document));
-  if (!document)
-    return NS_ERROR_FAILURE;
+  if (!document) return NS_ERROR_FAILURE;
   nsCOMPtr<nsIArray> aNodeList = GetEmbeddedObjects(document);
-  if (!aNodeList)
-    return NS_ERROR_FAILURE;
-
-  if (NS_FAILED(aNodeList->GetLength(&count)))
-    return NS_ERROR_FAILURE;
+  if (!aNodeList) return NS_ERROR_FAILURE;
+
+  if (NS_FAILED(aNodeList->GetLength(&count))) return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIURI> originalUrl;
   nsCString originalScheme;
   nsCString originalHost;
   nsCString originalPath;
 
-  // first, convert the rdf original msg uri into a url that represents the message...
-  nsCOMPtr <nsIMsgMessageService> msgService;
+  // first, convert the rdf original msg uri into a url that represents the
+  // message...
+  nsCOMPtr<nsIMsgMessageService> msgService;
   rv = GetMessageServiceFromURI(mOriginalMsgURI, getter_AddRefs(msgService));
-  if (NS_SUCCEEDED(rv))
-  {
-    rv = msgService->GetUrlForUri(mOriginalMsgURI.get(), getter_AddRefs(originalUrl), nullptr);
-    if (NS_SUCCEEDED(rv) && originalUrl)
-    {
+  if (NS_SUCCEEDED(rv)) {
+    rv = msgService->GetUrlForUri(mOriginalMsgURI.get(),
+                                  getter_AddRefs(originalUrl), nullptr);
+    if (NS_SUCCEEDED(rv) && originalUrl) {
       originalUrl->GetScheme(originalScheme);
       originalUrl->GetAsciiHost(originalHost);
       originalUrl->GetPathQueryRef(originalPath);
     }
   }
 
   // Then compare the url of each embedded objects with the original message.
   // If they a not coming from the original message, they should not be sent
   // with the message.
-  for (i = 0; i < count; i ++)
-  {
+  for (i = 0; i < count; i++) {
     nsCOMPtr<Element> domElement = do_QueryElementAt(aNodeList, i);
-    if (!domElement)
-      continue;
+    if (!domElement) continue;
     if (IsEmbeddedObjectSafe(originalScheme.get(), originalHost.get(),
                              originalPath.get(), domElement))
-      continue; // Don't need to tag this object, it's safe to send it.
+      continue;  // Don't need to tag this object, it's safe to send it.
 
     // The source of this object should not be sent with the message.
     IgnoredErrorResult rv2;
     domElement->SetAttribute(NS_LITERAL_STRING("moz-do-not-send"),
-                             NS_LITERAL_STRING("true"),
-                             rv2);
+                             NS_LITERAL_STRING("true"), rv2);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::GetInsertingQuotedContent(bool * aInsertingQuotedText)
-{
+nsMsgCompose::GetInsertingQuotedContent(bool *aInsertingQuotedText) {
   NS_ENSURE_ARG_POINTER(aInsertingQuotedText);
   *aInsertingQuotedText = mInsertingQuotedContent;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::SetInsertingQuotedContent(bool aInsertingQuotedText)
-{
+nsMsgCompose::SetInsertingQuotedContent(bool aInsertingQuotedText) {
   mInsertingQuotedContent = aInsertingQuotedText;
   return NS_OK;
 }
 
-MOZ_CAN_RUN_SCRIPT void
-nsMsgCompose::InsertDivWrappedTextAtSelection(const nsAString &aText,
-                                              const nsAString &classStr)
-{
-  NS_ASSERTION(m_editor, "InsertDivWrappedTextAtSelection called, but no editor exists");
-  if (!m_editor)
-    return;
+MOZ_CAN_RUN_SCRIPT void nsMsgCompose::InsertDivWrappedTextAtSelection(
+    const nsAString &aText, const nsAString &classStr) {
+  NS_ASSERTION(m_editor,
+               "InsertDivWrappedTextAtSelection called, but no editor exists");
+  if (!m_editor) return;
 
   RefPtr<Element> divElem;
   nsCOMPtr<nsIHTMLEditor> htmlEditor(do_QueryInterface(m_editor));
 
   nsresult rv = htmlEditor->CreateElementWithDefaults(NS_LITERAL_STRING("div"),
                                                       getter_AddRefs(divElem));
 
   NS_ENSURE_SUCCESS_VOID(rv);
@@ -532,24 +500,22 @@ nsMsgCompose::InsertDivWrappedTextAtSele
   rv = m_editor->GetDocument(getter_AddRefs(doc));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   // Break up the text by newlines, and then insert text nodes followed
   // by <br> nodes.
   int32_t start = 0;
   int32_t end = aText.Length();
 
-  for (;;)
-  {
+  for (;;) {
     int32_t delimiter = aText.FindChar('\n', start);
-    if (delimiter == kNotFound)
-      delimiter = end;
+    if (delimiter == kNotFound) delimiter = end;
 
     RefPtr<nsTextNode> textNode =
-      doc->CreateTextNode(Substring(aText, start, delimiter - start));
+        doc->CreateTextNode(Substring(aText, start, delimiter - start));
 
     IgnoredErrorResult rv2;
     divElem->AppendChild(*textNode, rv2);
     if (rv2.Failed()) {
       return;
     }
 
     // Now create and insert a BR
@@ -557,123 +523,112 @@ nsMsgCompose::InsertDivWrappedTextAtSele
     rv = htmlEditor->CreateElementWithDefaults(NS_LITERAL_STRING("br"),
                                                getter_AddRefs(brElem));
     NS_ENSURE_SUCCESS_VOID(rv);
     divElem->AppendChild(*brElem, rv2);
     if (rv2.Failed()) {
       return;
     }
 
-    if (delimiter == end)
-      break;
+    if (delimiter == end) break;
     start = ++delimiter;
-    if (start == end)
-      break;
+    if (start == end) break;
   }
 
   htmlEditor->InsertElementAtSelection(divElem, true);
   nsCOMPtr<nsINode> parent;
   int32_t offset;
 
   rv = GetNodeLocation(divElem, address_of(parent), &offset);
-  if (NS_SUCCEEDED(rv))
-  {
+  if (NS_SUCCEEDED(rv)) {
     RefPtr<Selection> selection;
     m_editor->GetSelection(getter_AddRefs(selection));
 
-    if (selection)
-      selection->Collapse(parent, offset + 1);
+    if (selection) selection->Collapse(parent, offset + 1);
   }
   if (divElem) {
     RefPtr<Element> divElem2 = divElem;
     IgnoredErrorResult rv2;
     divElem2->SetAttribute(NS_LITERAL_STRING("class"), classStr, rv2);
   }
 }
 
 /*
  * The following function replaces <plaintext> tags with <x-plaintext>.
  * <plaintext> is a funny beast: It leads to everything following it
  * being displayed verbatim, even a </plaintext> tag is ignored.
  */
-static void
-remove_plaintext_tag(nsString &body)
-{
+static void remove_plaintext_tag(nsString &body) {
   // Replace all <plaintext> and </plaintext> tags.
   int32_t index = 0;
   bool replaced = false;
-  while ((index = body.Find("<plaintext", /* ignoreCase = */ true, index)) != kNotFound) {
-    body.Insert(u"x-", index+1);
+  while ((index = body.Find("<plaintext", /* ignoreCase = */ true, index)) !=
+         kNotFound) {
+    body.Insert(u"x-", index + 1);
     index += 12;
     replaced = true;
   }
   if (replaced) {
     index = 0;
-    while ((index = body.Find("</plaintext", /* ignoreCase = */ true, index)) != kNotFound) {
-      body.Insert(u"x-", index+2);
+    while ((index = body.Find("</plaintext", /* ignoreCase = */ true, index)) !=
+           kNotFound) {
+      body.Insert(u"x-", index + 2);
       index += 13;
     }
   }
 }
 
 MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP
-nsMsgCompose::ConvertAndLoadComposeWindow(nsString& aPrefix,
-                                          nsString& aBuf,
-                                          nsString& aSignature,
-                                          bool aQuoted,
-                                          bool aHTMLEditor)
-{
+nsMsgCompose::ConvertAndLoadComposeWindow(nsString &aPrefix, nsString &aBuf,
+                                          nsString &aSignature, bool aQuoted,
+                                          bool aHTMLEditor) {
   NS_ASSERTION(m_editor, "ConvertAndLoadComposeWindow but no editor");
   NS_ENSURE_TRUE(m_editor && m_identity, NS_ERROR_NOT_INITIALIZED);
 
   // First, get the nsIEditor interface for future use
   nsCOMPtr<nsINode> nodeInserted;
 
   TranslateLineEnding(aPrefix);
   TranslateLineEnding(aBuf);
   TranslateLineEnding(aSignature);
 
   m_editor->EnableUndo(false);
 
   // Ok - now we need to figure out the charset of the aBuf we are going to send
-  // into the editor shell. There are I18N calls to sniff the data and then we need
-  // to call the new routine in the editor that will allow us to send in the charset
+  // into the editor shell. There are I18N calls to sniff the data and then we
+  // need to call the new routine in the editor that will allow us to send in
+  // the charset
   //
 
   // Now, insert it into the editor...
   RefPtr<HTMLEditor> htmlEditor = m_editor->AsHTMLEditor();
-  nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(m_editor));
+  nsCOMPtr<nsIPlaintextEditor> textEditor(do_QueryInterface(m_editor));
   int32_t reply_on_top = 0;
   bool sig_bottom = true;
   m_identity->GetReplyOnTop(&reply_on_top);
   m_identity->GetSigBottom(&sig_bottom);
   bool sigOnTop = (reply_on_top == 1 && !sig_bottom);
   bool isForwarded = (mType == nsIMsgCompType::ForwardInline);
 
   // When in paragraph mode, don't call InsertLineBreak() since that inserts
   // a full paragraph instead of just a line break since we switched
   // the default paragraph separator to "p".
   bool paragraphMode =
-    mozilla::Preferences::GetBool("mail.compose.default_to_paragraph", false);
-
-  if (aQuoted)
-  {
+      mozilla::Preferences::GetBool("mail.compose.default_to_paragraph", false);
+
+  if (aQuoted) {
     mInsertingQuotedContent = true;
-    if (!aPrefix.IsEmpty())
-    {
-      if (!aHTMLEditor)
-        aPrefix.AppendLiteral("\n");
+    if (!aPrefix.IsEmpty()) {
+      if (!aHTMLEditor) aPrefix.AppendLiteral("\n");
 
       int32_t reply_on_top = 0;
       m_identity->GetReplyOnTop(&reply_on_top);
-      if (reply_on_top == 1)
-      {
+      if (reply_on_top == 1) {
         // HTML editor eats one line break but not a whole paragraph.
-        if (aHTMLEditor && !paragraphMode)
-          textEditor->InsertLineBreak();
+        if (aHTMLEditor && !paragraphMode) textEditor->InsertLineBreak();
 
         // add one newline if a signature comes before the quote, two otherwise
         bool includeSignature = true;
         bool sig_bottom = true;
         bool attachFile = false;
         nsString prefSigText;
 
         m_identity->GetSigOnReply(&includeSignature);
@@ -690,118 +645,103 @@ nsMsgCompose::ConvertAndLoadComposeWindo
           }
         }
       }
 
       InsertDivWrappedTextAtSelection(aPrefix,
                                       NS_LITERAL_STRING("moz-cite-prefix"));
     }
 
-    if (!aBuf.IsEmpty())
-    {
+    if (!aBuf.IsEmpty()) {
       // This leaves the caret at the right place to insert a bottom signature.
       if (aHTMLEditor) {
         nsAutoString body(aBuf);
         remove_plaintext_tag(body);
-        htmlEditor->InsertAsCitedQuotation(body,
-                                           mCiteReference,
-                                           true,
+        htmlEditor->InsertAsCitedQuotation(body, mCiteReference, true,
                                            getter_AddRefs(nodeInserted));
       } else {
-        htmlEditor->InsertAsQuotation(aBuf,
-                                      getter_AddRefs(nodeInserted));
+        htmlEditor->InsertAsQuotation(aBuf, getter_AddRefs(nodeInserted));
       }
     }
 
     mInsertingQuotedContent = false;
 
     (void)TagEmbeddedObjects(m_editor);
 
-    if (!aSignature.IsEmpty())
-    {
-      //we cannot add it on top earlier, because TagEmbeddedObjects will mark all images in the signature as "moz-do-not-send"
-      if( sigOnTop )
-        MoveToBeginningOfDocument();
+    if (!aSignature.IsEmpty()) {
+      // we cannot add it on top earlier, because TagEmbeddedObjects will mark
+      // all images in the signature as "moz-do-not-send"
+      if (sigOnTop) MoveToBeginningOfDocument();
 
       if (aHTMLEditor)
         htmlEditor->InsertHTML(aSignature);
-      else
-      {
+      else {
         textEditor->InsertLineBreak();
         InsertDivWrappedTextAtSelection(aSignature,
                                         NS_LITERAL_STRING("moz-signature"));
       }
 
-      if( sigOnTop )
-        m_editor->EndOfDocument();
+      if (sigOnTop) m_editor->EndOfDocument();
     }
-  }
-  else
-  {
-    if (aHTMLEditor)
-    {
+  } else {
+    if (aHTMLEditor) {
       mInsertingQuotedContent = true;
-      if (isForwarded && Substring(aBuf, 0, sizeof(MIME_FORWARD_HTML_PREFIX)-1)
-                         .EqualsLiteral(MIME_FORWARD_HTML_PREFIX)) {
+      if (isForwarded &&
+          Substring(aBuf, 0, sizeof(MIME_FORWARD_HTML_PREFIX) - 1)
+              .EqualsLiteral(MIME_FORWARD_HTML_PREFIX)) {
         // We assign the opening tag inside "<HTML><BODY><BR><BR>" before the
         // two <br> elements.
         // This is a bit hacky but we know that the MIME code prepares the
         // forwarded content like this:
         // <HTML><BODY><BR><BR> + forwarded header + header table.
         // Note: We only do this when we prepare the message to be forwarded,
         // a re-opened saved draft of a forwarded message does not repeat this.
         nsString newBody(aBuf);
         nsString divTag;
         divTag.AssignLiteral("<div class=\"moz-forward-container\">");
-        newBody.Insert(divTag, sizeof(MIME_FORWARD_HTML_PREFIX)-1-8);
+        newBody.Insert(divTag, sizeof(MIME_FORWARD_HTML_PREFIX) - 1 - 8);
         remove_plaintext_tag(newBody);
         htmlEditor->RebuildDocumentFromSource(newBody);
       } else {
         htmlEditor->RebuildDocumentFromSource(aBuf);
       }
       mInsertingQuotedContent = false;
 
       // When forwarding a message as inline, or editing as new (which could
       // contain unsanitized remote content), tag any embedded objects
       // with moz-do-not-send=true so they don't get attached upon send.
       if (isForwarded || mType == nsIMsgCompType::EditAsNew)
         (void)TagEmbeddedObjects(m_editor);
 
-      if (!aSignature.IsEmpty())
-      {
+      if (!aSignature.IsEmpty()) {
         if (isForwarded && sigOnTop) {
-          // Use our own function, nsEditor::BeginningOfDocument() would position
-          // into the <div class="moz-forward-container"> we've just created.
+          // Use our own function, nsEditor::BeginningOfDocument() would
+          // position into the <div class="moz-forward-container"> we've just
+          // created.
           MoveToBeginningOfDocument();
         } else {
           // Use our own function, nsEditor::EndOfDocument() would position
           // into the <div class="moz-forward-container"> we've just created.
           MoveToEndOfDocument();
         }
         htmlEditor->InsertHTML(aSignature);
-        if (isForwarded && sigOnTop)
-          m_editor->EndOfDocument();
-      }
-      else
+        if (isForwarded && sigOnTop) m_editor->EndOfDocument();
+      } else
         m_editor->EndOfDocument();
-    }
-    else
-    {
+    } else {
       bool sigOnTopInserted = false;
-      if (isForwarded && sigOnTop && !aSignature.IsEmpty())
-      {
+      if (isForwarded && sigOnTop && !aSignature.IsEmpty()) {
         textEditor->InsertLineBreak();
         InsertDivWrappedTextAtSelection(aSignature,
                                         NS_LITERAL_STRING("moz-signature"));
         m_editor->EndOfDocument();
         sigOnTopInserted = true;
       }
 
-      if (!aBuf.IsEmpty())
-      {
+      if (!aBuf.IsEmpty()) {
         nsresult rv;
         RefPtr<Element> divElem;
         RefPtr<Element> extraBr;
 
         if (isForwarded) {
           // Special treatment for forwarded messages: Part 1.
           // Create a <div> of the required class.
           rv = htmlEditor->CreateElementWithDefaults(NS_LITERAL_STRING("div"),
@@ -839,18 +779,18 @@ nsMsgCompose::ConvertAndLoadComposeWindo
 
         rv = htmlEditor->InsertTextWithQuotations(aBuf);
         NS_ENSURE_SUCCESS(rv, rv);
 
         if (isForwarded) {
           nsCOMPtr<nsIEditor> editor(m_editor);  // Strong reference.
           // Special treatment for forwarded messages: Part 2.
           if (sigOnTopInserted) {
-            // Sadly the M-C editor inserts a <br> between the <div> for the signature
-            // and this <div>, so remove the <br> we don't want.
+            // Sadly the M-C editor inserts a <br> between the <div> for the
+            // signature and this <div>, so remove the <br> we don't want.
             nsCOMPtr<nsINode> brBeforeDiv;
             nsAutoString tagLocalName;
             brBeforeDiv = divElem->GetPreviousSibling();
             if (brBeforeDiv) {
               tagLocalName = brBeforeDiv->LocalName();
               if (tagLocalName.EqualsLiteral("br")) {
                 rv = editor->DeleteNode(brBeforeDiv);
                 NS_ENSURE_SUCCESS(rv, rv);
@@ -876,147 +816,135 @@ nsMsgCompose::ConvertAndLoadComposeWindo
         InsertDivWrappedTextAtSelection(aSignature,
                                         NS_LITERAL_STRING("moz-signature"));
       }
     }
   }
 
   if (aBuf.IsEmpty())
     m_editor->BeginningOfDocument();
-  else
-  {
-    switch (reply_on_top)
-    {
+  else {
+    switch (reply_on_top) {
       // This should set the cursor after the body but before the sig
-      case 0:
-      {
-        if (!textEditor)
-        {
+      case 0: {
+        if (!textEditor) {
           m_editor->BeginningOfDocument();
           break;
         }
 
         RefPtr<Selection> selection;
         nsCOMPtr<nsINode> parent;
         int32_t offset;
         nsresult rv;
 
         // get parent and offset of mailcite
         rv = GetNodeLocation(nodeInserted, address_of(parent), &offset);
-        if (NS_FAILED(rv) || (!parent))
-        {
+        if (NS_FAILED(rv) || (!parent)) {
           m_editor->BeginningOfDocument();
           break;
         }
 
         // get selection
         m_editor->GetSelection(getter_AddRefs(selection));
-        if (!selection)
-        {
+        if (!selection) {
           m_editor->BeginningOfDocument();
           break;
         }
 
         // place selection after mailcite
-        selection->Collapse(parent, offset+1);
+        selection->Collapse(parent, offset + 1);
 
         // insert a break at current selection
-        if (!paragraphMode || !aHTMLEditor)
-          textEditor->InsertLineBreak();
+        if (!paragraphMode || !aHTMLEditor) textEditor->InsertLineBreak();
 
         // i'm not sure if you need to move the selection back to before the
         // break. expirement.
-        selection->Collapse(parent, offset+1);
+        selection->Collapse(parent, offset + 1);
 
         break;
       }
 
-      case 2:
-      {
+      case 2: {
         nsCOMPtr<nsIEditor> editor(m_editor);  // Strong reference.
         editor->SelectAll();
         break;
       }
 
       // This should set the cursor to the top!
-      default:
-      {
+      default: {
         MoveToBeginningOfDocument();
         break;
       }
     }
   }
 
   nsCOMPtr<nsISelectionController> selCon;
   m_editor->GetSelectionController(getter_AddRefs(selCon));
 
   if (selCon)
-    selCon->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, nsISelectionController::SELECTION_ANCHOR_REGION, true);
+    selCon->ScrollSelectionIntoView(
+        nsISelectionController::SELECTION_NORMAL,
+        nsISelectionController::SELECTION_ANCHOR_REGION, true);
 
   m_editor->EnableUndo(true);
   SetBodyModified(false);
 
 #ifdef MSGCOMP_TRACE_PERFORMANCE
-  nsCOMPtr<nsIMsgComposeService> composeService (do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID));
-  composeService->TimeStamp("Finished inserting data into the editor. The window is finally ready!", false);
+  nsCOMPtr<nsIMsgComposeService> composeService(
+      do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID));
+  composeService->TimeStamp(
+      "Finished inserting data into the editor. The window is finally ready!",
+      false);
 #endif
   return NS_OK;
 }
 
 /**
  * Check the identity pref to include signature on replies and forwards.
  */
-bool nsMsgCompose::CheckIncludeSignaturePrefs(nsIMsgIdentity *identity)
-{
+bool nsMsgCompose::CheckIncludeSignaturePrefs(nsIMsgIdentity *identity) {
   bool includeSignature = true;
-  switch (mType)
-  {
+  switch (mType) {
     case nsIMsgCompType::ForwardInline:
     case nsIMsgCompType::ForwardAsAttachment:
       identity->GetSigOnForward(&includeSignature);
       break;
     case nsIMsgCompType::Reply:
     case nsIMsgCompType::ReplyAll:
     case nsIMsgCompType::ReplyToList:
     case nsIMsgCompType::ReplyToGroup:
     case nsIMsgCompType::ReplyToSender:
     case nsIMsgCompType::ReplyToSenderAndGroup:
       identity->GetSigOnReply(&includeSignature);
       break;
   }
   return includeSignature;
 }
 
-nsresult
-nsMsgCompose::SetQuotingToFollow(bool aVal)
-{
+nsresult nsMsgCompose::SetQuotingToFollow(bool aVal) {
   mQuotingToFollow = aVal;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::GetQuotingToFollow(bool* quotingToFollow)
-{
+nsMsgCompose::GetQuotingToFollow(bool *quotingToFollow) {
   NS_ENSURE_ARG(quotingToFollow);
   *quotingToFollow = mQuotingToFollow;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgCompose::Initialize(nsIMsgComposeParams *aParams,
-                         mozIDOMWindowProxy *aWindow,
-                         nsIDocShell *aDocShell)
-{
+                         mozIDOMWindowProxy *aWindow, nsIDocShell *aDocShell) {
   NS_ENSURE_ARG_POINTER(aParams);
   nsresult rv;
 
   aParams->GetIdentity(getter_AddRefs(m_identity));
 
-  if (aWindow)
-  {
+  if (aWindow) {
     m_window = aWindow;
     nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);
     NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIDocShellTreeItem> treeItem = window->GetDocShell();
     nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
     rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
     if (NS_FAILED(rv)) return rv;
@@ -1032,35 +960,34 @@ nsMsgCompose::Initialize(nsIMsgComposePa
 
   nsCString originalMsgURI;
   aParams->GetOriginalMsgURI(getter_Copies(originalMsgURI));
   aParams->GetOrigMsgHdr(getter_AddRefs(mOrigMsgHdr));
 
   nsCOMPtr<nsIMsgCompFields> composeFields;
   aParams->GetComposeFields(getter_AddRefs(composeFields));
 
-  nsCOMPtr<nsIMsgComposeService> composeService = do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgComposeService> composeService =
+      do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   rv = composeService->DetermineComposeHTML(m_identity, format, &m_composeHTML);
-  NS_ENSURE_SUCCESS(rv,rv);
-
-  if (composeFields)
-  {
-    nsAutoCString draftId; // will get set for drafts and templates
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  if (composeFields) {
+    nsAutoCString draftId;  // will get set for drafts and templates
     rv = composeFields->GetDraftId(getter_Copies(draftId));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     // Set return receipt flag and type, and if we should attach a vCard
     // by checking the identity prefs - but don't clobber the values for
     // drafts and templates as they were set up already by mime when
     // initializing the message.
-    if (m_identity && draftId.IsEmpty() && type != nsIMsgCompType::Template
-        && type != nsIMsgCompType::EditAsNew)
-    {
+    if (m_identity && draftId.IsEmpty() && type != nsIMsgCompType::Template &&
+        type != nsIMsgCompType::EditAsNew) {
       bool requestReturnReceipt = false;
       rv = m_identity->GetRequestReturnReceipt(&requestReturnReceipt);
       NS_ENSURE_SUCCESS(rv, rv);
       rv = composeFields->SetReturnReceipt(requestReturnReceipt);
       NS_ENSURE_SUCCESS(rv, rv);
 
       int32_t receiptType = nsIMsgMdnGenerator::eDntType;
       rv = m_identity->GetReceiptHeaderType(&receiptType);
@@ -1079,125 +1006,123 @@ nsMsgCompose::Initialize(nsIMsgComposePa
       NS_ENSURE_SUCCESS(rv, rv);
       rv = composeFields->SetAttachVCard(attachVCard);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   nsCOMPtr<nsIMsgSendListener> externalSendListener;
   aParams->GetSendListener(getter_AddRefs(externalSendListener));
-  if(externalSendListener)
-    AddMsgSendListener( externalSendListener );
+  if (externalSendListener) AddMsgSendListener(externalSendListener);
 
   nsString smtpPassword;
   aParams->GetSmtpPassword(smtpPassword);
   mSmtpPassword = smtpPassword;
 
   aParams->GetHtmlToQuote(mHtmlToQuote);
 
-  if (aDocShell)
-  {
+  if (aDocShell) {
     mDocShell = aDocShell;
     // register the compose object with the compose service
     rv = composeService->RegisterComposeDocShell(aDocShell, this);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return CreateMessage(originalMsgURI.get(), type, composeFields);
 }
 
 MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
-nsMsgCompose::SetDocumentCharset(const char *aCharset)
-{
+nsMsgCompose::SetDocumentCharset(const char *aCharset) {
   NS_ENSURE_TRUE(m_compFields && m_editor, NS_ERROR_NOT_INITIALIZED);
 
   // Set charset, this will be used for the MIME charset labeling.
   m_compFields->SetCharacterSet(aCharset);
 
   // notify the change to editor
   nsCString charset;
-  if (aCharset)
-    charset = nsDependentCString(aCharset);
+  if (aCharset) charset = nsDependentCString(aCharset);
   if (m_editor) {
     nsCOMPtr<nsIEditor> editor(m_editor);  // Strong reference.
     editor->SetDocumentCharacterSet(charset);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::RegisterStateListener(nsIMsgComposeStateListener *aStateListener)
-{
+nsMsgCompose::RegisterStateListener(
+    nsIMsgComposeStateListener *aStateListener) {
   NS_ENSURE_ARG_POINTER(aStateListener);
   mStateListeners.AppendElement(aStateListener);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::UnregisterStateListener(nsIMsgComposeStateListener *aStateListener)
-{
+nsMsgCompose::UnregisterStateListener(
+    nsIMsgComposeStateListener *aStateListener) {
   NS_ENSURE_ARG_POINTER(aStateListener);
-  return mStateListeners.RemoveElement(aStateListener) ? NS_OK : NS_ERROR_FAILURE;
+  return mStateListeners.RemoveElement(aStateListener) ? NS_OK
+                                                       : NS_ERROR_FAILURE;
 }
 
 // Added to allow easier use of the nsIMsgSendListener
-NS_IMETHODIMP nsMsgCompose::AddMsgSendListener( nsIMsgSendListener *aMsgSendListener )
-{
+NS_IMETHODIMP nsMsgCompose::AddMsgSendListener(
+    nsIMsgSendListener *aMsgSendListener) {
   NS_ENSURE_ARG_POINTER(aMsgSendListener);
   mExternalSendListeners.AppendElement(aMsgSendListener);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompose::RemoveMsgSendListener( nsIMsgSendListener *aMsgSendListener )
-{
+NS_IMETHODIMP nsMsgCompose::RemoveMsgSendListener(
+    nsIMsgSendListener *aMsgSendListener) {
   NS_ENSURE_ARG_POINTER(aMsgSendListener);
-  return mExternalSendListeners.RemoveElement(aMsgSendListener) ? NS_OK : NS_ERROR_FAILURE;
+  return mExternalSendListeners.RemoveElement(aMsgSendListener)
+             ? NS_OK
+             : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::SendMsgToServer(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity,
-                              const char *accountKey)
-{
+nsMsgCompose::SendMsgToServer(MSG_DeliverMode deliverMode,
+                              nsIMsgIdentity *identity,
+                              const char *accountKey) {
   nsresult rv = NS_OK;
 
-  // clear saved message id if sending, so we don't send out the same message-id.
+  // clear saved message id if sending, so we don't send out the same
+  // message-id.
   if (deliverMode == nsIMsgCompDeliverMode::Now ||
       deliverMode == nsIMsgCompDeliverMode::Later ||
       deliverMode == nsIMsgCompDeliverMode::Background)
     m_compFields->SetMessageId("");
 
-  if (m_compFields && identity)
-  {
+  if (m_compFields && identity) {
     // Pref values are supposed to be stored as UTF-8, so no conversion
     nsCString email;
     nsString fullName;
     nsString organization;
 
     identity->GetEmail(email);
     identity->GetFullName(fullName);
     identity->GetOrganization(organization);
 
-    const char* pFrom = m_compFields->GetFrom();
-    if (!pFrom || !*pFrom)
-    {
+    const char *pFrom = m_compFields->GetFrom();
+    if (!pFrom || !*pFrom) {
       nsCString sender;
       MakeMimeAddress(NS_ConvertUTF16toUTF8(fullName), email, sender);
       m_compFields->SetFrom(sender.IsEmpty() ? email.get() : sender.get());
     }
 
     m_compFields->SetOrganization(organization);
 
     // We need an nsIMsgSend instance to send the message. Allow extensions
     // to override the default SMTP sender by observing mail-set-sender.
     mMsgSend = nullptr;
     mDeliverMode = deliverMode;  // save for possible access by observer.
 
     // Allow extensions to specify an outgoing server.
     nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
+        mozilla::services::GetObserverService();
     NS_ENSURE_STATE(observerService);
 
     // Assemble a string with sending parameters.
     nsAutoString sendParms;
 
     // First parameter: account key. This may be null.
     sendParms.AppendASCII(accountKey && *accountKey ? accountKey : "");
     sendParms.Append(',');
@@ -1206,292 +1131,256 @@ nsMsgCompose::SendMsgToServer(MSG_Delive
     sendParms.AppendInt(deliverMode);
     sendParms.Append(',');
 
     // Third parameter: identity (as identity key).
     nsAutoCString identityKey;
     identity->GetKey(identityKey);
     sendParms.AppendASCII(identityKey.get());
 
-    observerService->NotifyObservers(
-      NS_ISUPPORTS_CAST(nsIMsgCompose*, this),
-      "mail-set-sender",
-      sendParms.get());
-
-    if (!mMsgSend)
-      mMsgSend = do_CreateInstance(NS_MSGSEND_CONTRACTID);
-
-    if (mMsgSend)
-    {
+    observerService->NotifyObservers(NS_ISUPPORTS_CAST(nsIMsgCompose *, this),
+                                     "mail-set-sender", sendParms.get());
+
+    if (!mMsgSend) mMsgSend = do_CreateInstance(NS_MSGSEND_CONTRACTID);
+
+    if (mMsgSend) {
       nsCString bodyString(m_compFields->GetBody());
 
       // Create the listener for the send operation...
-      nsCOMPtr<nsIMsgComposeSendListener> composeSendListener = do_CreateInstance(NS_MSGCOMPOSESENDLISTENER_CONTRACTID);
-      if (!composeSendListener)
-        return NS_ERROR_OUT_OF_MEMORY;
+      nsCOMPtr<nsIMsgComposeSendListener> composeSendListener =
+          do_CreateInstance(NS_MSGCOMPOSESENDLISTENER_CONTRACTID);
+      if (!composeSendListener) return NS_ERROR_OUT_OF_MEMORY;
 
       // right now, AutoSaveAsDraft is identical to SaveAsDraft as
       // far as the msg send code is concerned. This way, we don't have
       // to add an nsMsgDeliverMode for autosaveasdraft, and add cases for
       // it in the msg send code.
       if (deliverMode == nsIMsgCompDeliverMode::AutoSaveAsDraft)
         deliverMode = nsIMsgCompDeliverMode::SaveAsDraft;
 
       RefPtr<nsIMsgCompose> msgCompose(this);
       composeSendListener->SetMsgCompose(msgCompose);
       composeSendListener->SetDeliverMode(deliverMode);
 
-      if (mProgress)
-      {
-        nsCOMPtr<nsIWebProgressListener> progressListener = do_QueryInterface(composeSendListener);
+      if (mProgress) {
+        nsCOMPtr<nsIWebProgressListener> progressListener =
+            do_QueryInterface(composeSendListener);
         mProgress->RegisterListener(progressListener);
       }
 
       // If we are composing HTML, then this should be sent as
       // multipart/related which means we pass the editor into the
       // backend...if not, just pass nullptr
       //
-      nsCOMPtr<nsIMsgSendListener> sendListener = do_QueryInterface(composeSendListener);
+      nsCOMPtr<nsIMsgSendListener> sendListener =
+          do_QueryInterface(composeSendListener);
       rv = mMsgSend->CreateAndSendMessage(
-                    m_composeHTML ? m_editor.get() : nullptr,
-                    identity,
-                    accountKey,
-                    m_compFields,
-                    false,
-                    false,
-                    (nsMsgDeliverMode)deliverMode,
-                    nullptr,
-                    m_composeHTML ? TEXT_HTML : TEXT_PLAIN,
-                    bodyString,
-                    nullptr,
-                    nullptr,
-                    m_window,
-                    mProgress,
-                    sendListener,
-                    mSmtpPassword,
-                    mOriginalMsgURI,
-                    mType);
-    }
-    else
-        rv = NS_ERROR_FAILURE;
-  }
-  else
+          m_composeHTML ? m_editor.get() : nullptr, identity, accountKey,
+          m_compFields, false, false, (nsMsgDeliverMode)deliverMode, nullptr,
+          m_composeHTML ? TEXT_HTML : TEXT_PLAIN, bodyString, nullptr, nullptr,
+          m_window, mProgress, sendListener, mSmtpPassword, mOriginalMsgURI,
+          mType);
+    } else
+      rv = NS_ERROR_FAILURE;
+  } else
     rv = NS_ERROR_NOT_INITIALIZED;
 
   if (NS_FAILED(rv))
     NotifyStateListeners(nsIMsgComposeNotificationType::ComposeProcessDone, rv);
 
   return rv;
 }
 
-NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const char *accountKey, nsIMsgWindow *aMsgWindow, nsIMsgProgress *progress)
-{
+NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
+                                    nsIMsgIdentity *identity,
+                                    const char *accountKey,
+                                    nsIMsgWindow *aMsgWindow,
+                                    nsIMsgProgress *progress) {
   NS_ENSURE_TRUE(m_compFields, NS_ERROR_NOT_INITIALIZED);
   nsresult rv = NS_OK;
   nsCOMPtr<nsIPrompt> prompt;
 
   // i'm assuming the compose window is still up at this point...
   if (m_window) {
     nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(m_window);
     window->GetPrompter(getter_AddRefs(prompt));
   }
 
   // Set content type based on which type of compose window we had.
-  nsString contentType = (m_composeHTML) ? NS_LITERAL_STRING("text/html"):
-                                           NS_LITERAL_STRING("text/plain");
+  nsString contentType = (m_composeHTML) ? NS_LITERAL_STRING("text/html")
+                                         : NS_LITERAL_STRING("text/plain");
   nsString msgBody;
   const char *charset = m_compFields->GetCharacterSet();
-  if (m_editor)
-  {
+  if (m_editor) {
     // Reset message body previously stored in the compose fields
-    // There is 2 nsIMsgCompFields::SetBody() functions using a pointer as argument,
-    // therefore a casting is required.
+    // There is 2 nsIMsgCompFields::SetBody() functions using a pointer as
+    // argument, therefore a casting is required.
     m_compFields->SetBody((const char *)nullptr);
 
     uint32_t flags = nsIDocumentEncoder::OutputCRLineBreak |
                      nsIDocumentEncoder::OutputLFLineBreak;
 
     if (m_composeHTML) {
       flags |= nsIDocumentEncoder::OutputFormatted |
                nsIDocumentEncoder::OutputDisallowLineBreaking;
     } else {
       bool flowed, delsp, formatted, disallowBreaks;
       GetSerialiserFlags(charset, &flowed, &delsp, &formatted, &disallowBreaks);
-      if (flowed)
-        flags |= nsIDocumentEncoder::OutputFormatFlowed;
-      if (delsp)
-        flags |= nsIDocumentEncoder::OutputFormatDelSp;
-      if (formatted)
-        flags |= nsIDocumentEncoder::OutputFormatted;
+      if (flowed) flags |= nsIDocumentEncoder::OutputFormatFlowed;
+      if (delsp) flags |= nsIDocumentEncoder::OutputFormatDelSp;
+      if (formatted) flags |= nsIDocumentEncoder::OutputFormatted;
       if (disallowBreaks)
         flags |= nsIDocumentEncoder::OutputDisallowLineBreaking;
       // Don't lose NBSP in the plain text encoder.
       flags |= nsIDocumentEncoder::OutputPersistNBSP;
     }
     rv = m_editor->OutputToString(contentType, flags, msgBody);
     NS_ENSURE_SUCCESS(rv, rv);
-  }
-  else
-  {
+  } else {
     m_compFields->GetBody(msgBody);
   }
-  if (!msgBody.IsEmpty())
-  {
-    bool isAsciiOnly = mozilla::IsAsciiNullTerminated(static_cast<const char16_t*>(msgBody.get()));
+  if (!msgBody.IsEmpty()) {
+    bool isAsciiOnly = mozilla::IsAsciiNullTerminated(
+        static_cast<const char16_t *>(msgBody.get()));
     // Convert body to mail charset
     nsCString outCString;
-    rv = nsMsgI18NConvertFromUnicode(charset ? nsDependentCString(charset) : EmptyCString(),
-                                     msgBody, outCString, true);
-    if (m_compFields->GetForceMsgEncoding())
-      isAsciiOnly = false;
-    if (NS_SUCCEEDED(rv) && !outCString.IsEmpty())
-    {
+    rv = nsMsgI18NConvertFromUnicode(
+        charset ? nsDependentCString(charset) : EmptyCString(), msgBody,
+        outCString, true);
+    if (m_compFields->GetForceMsgEncoding()) isAsciiOnly = false;
+    if (NS_SUCCEEDED(rv) && !outCString.IsEmpty()) {
       // If the body contains characters outside the repertoire of the current
       // charset, just convert to UTF-8 and be done with it
       // unless disable_fallback_to_utf8 is set for this charset.
-      if (NS_ERROR_UENC_NOMAPPING == rv)
-      {
+      if (NS_ERROR_UENC_NOMAPPING == rv) {
         bool needToCheckCharset;
         m_compFields->GetNeedToCheckCharset(&needToCheckCharset);
-        if (needToCheckCharset)
-        {
+        if (needToCheckCharset) {
           bool disableFallback = false;
-          nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-          if (prefBranch && charset)
-          {
+          nsCOMPtr<nsIPrefBranch> prefBranch(
+              do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+          if (prefBranch && charset) {
             nsCString prefName("mailnews.disable_fallback_to_utf8.");
             prefName.Append(charset);
             prefBranch->GetBoolPref(prefName.get(), &disableFallback);
           }
-          if (!disableFallback)
-          {
+          if (!disableFallback) {
             CopyUTF16toUTF8(msgBody, outCString);
             m_compFields->SetCharacterSet("UTF-8");
             SetDocumentCharset("UTF-8");
           }
         }
       }
       m_compFields->SetBodyIsAsciiOnly(isAsciiOnly);
       m_compFields->SetBody(outCString.get());
-    }
-    else
-    {
+    } else {
       m_compFields->SetBody(NS_ConvertUTF16toUTF8(msgBody).get());
       m_compFields->SetCharacterSet("UTF-8");
       SetDocumentCharset("UTF-8");
     }
   }
 
   // Let's open the progress dialog
-  if (progress)
-  {
+  if (progress) {
     mProgress = progress;
 
-    if (deliverMode != nsIMsgCompDeliverMode::AutoSaveAsDraft)
-    {
+    if (deliverMode != nsIMsgCompDeliverMode::AutoSaveAsDraft) {
       nsAutoString msgSubject;
       m_compFields->GetSubject(msgSubject);
 
       bool showProgress = false;
-      nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID));
-      if (prefBranch)
-      {
+      nsCOMPtr<nsIPrefBranch> prefBranch(
+          do_GetService(NS_PREFSERVICE_CONTRACTID));
+      if (prefBranch) {
         prefBranch->GetBoolPref("mailnews.show_send_progress", &showProgress);
-        if (showProgress)
-        {
-          nsCOMPtr<nsIMsgComposeProgressParams> params = do_CreateInstance(NS_MSGCOMPOSEPROGRESSPARAMS_CONTRACTID, &rv);
-          if (NS_FAILED(rv) || !params)
-            return NS_ERROR_FAILURE;
+        if (showProgress) {
+          nsCOMPtr<nsIMsgComposeProgressParams> params =
+              do_CreateInstance(NS_MSGCOMPOSEPROGRESSPARAMS_CONTRACTID, &rv);
+          if (NS_FAILED(rv) || !params) return NS_ERROR_FAILURE;
 
           params->SetSubject(msgSubject.get());
           params->SetDeliveryMode(deliverMode);
 
-          mProgress->OpenProgressDialog(m_window, aMsgWindow,
-                                        "chrome://messenger/content/messengercompose/sendProgress.xul",
-                                        false, params);
+          mProgress->OpenProgressDialog(
+              m_window, aMsgWindow,
+              "chrome://messenger/content/messengercompose/sendProgress.xul",
+              false, params);
         }
       }
     }
 
-    mProgress->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_START, NS_OK);
+    mProgress->OnStateChange(nullptr, nullptr,
+                             nsIWebProgressListener::STATE_START, NS_OK);
   }
 
   bool attachVCard = false;
   m_compFields->GetAttachVCard(&attachVCard);
 
   if (attachVCard && identity &&
       (deliverMode == nsIMsgCompDeliverMode::Now ||
        deliverMode == nsIMsgCompDeliverMode::Later ||
-       deliverMode == nsIMsgCompDeliverMode::Background))
-  {
-      nsCString escapedVCard;
-      // make sure, if there is no card, this returns an empty string, or NS_ERROR_FAILURE
-      rv = identity->GetEscapedVCard(escapedVCard);
-
-      if (NS_SUCCEEDED(rv) && !escapedVCard.IsEmpty())
-      {
-          nsCString vCardUrl;
-          vCardUrl = "data:text/x-vcard;charset=utf-8;base64,";
-          nsCString unescapedData;
-          MsgUnescapeString(escapedVCard, 0, unescapedData);
-          char *result = PL_Base64Encode(unescapedData.get(), 0, nullptr);
-          vCardUrl += result;
-          PR_Free(result);
-
-          nsCOMPtr<nsIMsgAttachment> attachment = do_CreateInstance(NS_MSGATTACHMENT_CONTRACTID, &rv);
-          if (NS_SUCCEEDED(rv) && attachment)
-          {
-              // [comment from 4.x]
-              // Send the vCard out with a filename which distinguishes this user. e.g. jsmith.vcf
-              // The main reason to do this is for interop with Eudora, which saves off
-              // the attachments separately from the message body
-              nsCString userid;
-              (void)identity->GetEmail(userid);
-              int32_t index = userid.FindChar('@');
-              if (index != kNotFound)
-                  userid.SetLength(index);
-
-              if (userid.IsEmpty())
-                  attachment->SetName(NS_LITERAL_STRING("vcard.vcf"));
-              else
-              {
-                  // Replace any dot with underscore to stop vCards
-                  // generating false positives with some heuristic scanners
-                  MsgReplaceChar(userid, '.', '_');
-                  userid.AppendLiteral(".vcf");
-                  attachment->SetName(NS_ConvertASCIItoUTF16(userid));
-              }
-
-              attachment->SetUrl(vCardUrl);
-              m_compFields->AddAttachment(attachment);
-          }
+       deliverMode == nsIMsgCompDeliverMode::Background)) {
+    nsCString escapedVCard;
+    // make sure, if there is no card, this returns an empty string, or
+    // NS_ERROR_FAILURE
+    rv = identity->GetEscapedVCard(escapedVCard);
+
+    if (NS_SUCCEEDED(rv) && !escapedVCard.IsEmpty()) {
+      nsCString vCardUrl;
+      vCardUrl = "data:text/x-vcard;charset=utf-8;base64,";
+      nsCString unescapedData;
+      MsgUnescapeString(escapedVCard, 0, unescapedData);
+      char *result = PL_Base64Encode(unescapedData.get(), 0, nullptr);
+      vCardUrl += result;
+      PR_Free(result);
+
+      nsCOMPtr<nsIMsgAttachment> attachment =
+          do_CreateInstance(NS_MSGATTACHMENT_CONTRACTID, &rv);
+      if (NS_SUCCEEDED(rv) && attachment) {
+        // [comment from 4.x]
+        // Send the vCard out with a filename which distinguishes this user.
+        // e.g. jsmith.vcf The main reason to do this is for interop with
+        // Eudora, which saves off the attachments separately from the message
+        // body
+        nsCString userid;
+        (void)identity->GetEmail(userid);
+        int32_t index = userid.FindChar('@');
+        if (index != kNotFound) userid.SetLength(index);
+
+        if (userid.IsEmpty())
+          attachment->SetName(NS_LITERAL_STRING("vcard.vcf"));
+        else {
+          // Replace any dot with underscore to stop vCards
+          // generating false positives with some heuristic scanners
+          MsgReplaceChar(userid, '.', '_');
+          userid.AppendLiteral(".vcf");
+          attachment->SetName(NS_ConvertASCIItoUTF16(userid));
+        }
+
+        attachment->SetUrl(vCardUrl);
+        m_compFields->AddAttachment(attachment);
       }
+    }
   }
 
   // Save the identity being sent for later use.
   m_identity = identity;
 
   rv = SendMsgToServer(deliverMode, identity, accountKey);
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     nsCOMPtr<nsIMsgSendReport> sendReport;
-    if (mMsgSend)
-      mMsgSend->GetSendReport(getter_AddRefs(sendReport));
-    if (sendReport)
-    {
+    if (mMsgSend) mMsgSend->GetSendReport(getter_AddRefs(sendReport));
+    if (sendReport) {
       nsresult theError;
       sendReport->DisplayReport(prompt, true, true, &theError);
-    }
-    else
-    {
-      /* If we come here it's because we got an error before we could initialize a
-         send report! Let's try our best...
+    } else {
+      /* If we come here it's because we got an error before we could initialize
+         a send report! Let's try our best...
       */
-      switch (deliverMode)
-      {
+      switch (deliverMode) {
         case nsIMsgCompDeliverMode::Later:
           nsMsgDisplayMessageByName(prompt, "unableToSendLater");
           break;
         case nsIMsgCompDeliverMode::AutoSaveAsDraft:
         case nsIMsgCompDeliverMode::SaveAsDraft:
           nsMsgDisplayMessageByName(prompt, "unableToSaveDraft");
           break;
         case nsIMsgCompDeliverMode::SaveAsTemplate:
@@ -1499,135 +1388,123 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_
           break;
 
         default:
           nsMsgDisplayMessageByName(prompt, "sendFailed");
           break;
       }
     }
 
-    if (progress)
-      progress->CloseProgressDialog(true);
+    if (progress) progress->CloseProgressDialog(true);
   }
 
   return rv;
 }
 
 /* attribute boolean deleteDraft */
-NS_IMETHODIMP nsMsgCompose::GetDeleteDraft(bool *aDeleteDraft)
-{
+NS_IMETHODIMP nsMsgCompose::GetDeleteDraft(bool *aDeleteDraft) {
   NS_ENSURE_ARG_POINTER(aDeleteDraft);
   *aDeleteDraft = mDeleteDraft;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompose::SetDeleteDraft(bool aDeleteDraft)
-{
+NS_IMETHODIMP nsMsgCompose::SetDeleteDraft(bool aDeleteDraft) {
   mDeleteDraft = aDeleteDraft;
   return NS_OK;
 }
 
-bool nsMsgCompose::IsLastWindow()
-{
+bool nsMsgCompose::IsLastWindow() {
   nsresult rv;
   bool more;
   nsCOMPtr<nsIWindowMediator> windowMediator =
-              do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv))
-  {
+      do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
     rv = windowMediator->GetEnumerator(nullptr,
-               getter_AddRefs(windowEnumerator));
-    if (NS_SUCCEEDED(rv))
-    {
+                                       getter_AddRefs(windowEnumerator));
+    if (NS_SUCCEEDED(rv)) {
       nsCOMPtr<nsISupports> isupports;
 
       if (NS_SUCCEEDED(windowEnumerator->GetNext(getter_AddRefs(isupports))))
         if (NS_SUCCEEDED(windowEnumerator->HasMoreElements(&more)))
           return !more;
     }
   }
   return true;
 }
 
-NS_IMETHODIMP nsMsgCompose::CloseWindow(void)
-{
+NS_IMETHODIMP nsMsgCompose::CloseWindow(void) {
   nsresult rv;
 
-  nsCOMPtr<nsIMsgComposeService> composeService = do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgComposeService> composeService =
+      do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // unregister the compose object with the compose service
   rv = composeService->UnregisterComposeDocShell(mDocShell);
   NS_ENSURE_SUCCESS(rv, rv);
   mDocShell = nullptr;
 
   // ensure that the destructor of nsMsgSend is invoked to remove
   // temporary files.
   mMsgSend = nullptr;
 
-  //We are going away for real, we need to do some clean up first
-  if (m_baseWindow)
-  {
-    if (m_editor)
-    {
+  // We are going away for real, we need to do some clean up first
+  if (m_baseWindow) {
+    if (m_editor) {
       // The editor will be destroyed during the close window.
       // Set it to null to be sure we won't use it anymore.
       m_editor = nullptr;
     }
-    nsIBaseWindow * window = m_baseWindow;
+    nsIBaseWindow *window = m_baseWindow;
     m_baseWindow = nullptr;
     rv = window->Destroy();
   }
 
   m_window = nullptr;
   return rv;
 }
 
-nsresult nsMsgCompose::Abort()
-{
-  if (mMsgSend)
-    mMsgSend->Abort();
-
-  if (mProgress)
-    mProgress->CloseProgressDialog(true);
+nsresult nsMsgCompose::Abort() {
+  if (mMsgSend) mMsgSend->Abort();
+
+  if (mProgress) mProgress->CloseProgressDialog(true);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompose::GetEditor(nsIEditor * *aEditor)
-{
+NS_IMETHODIMP nsMsgCompose::GetEditor(nsIEditor **aEditor) {
   NS_IF_ADDREF(*aEditor = m_editor);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompose::SetEditor(nsIEditor *aEditor)
-{
+NS_IMETHODIMP nsMsgCompose::SetEditor(nsIEditor *aEditor) {
   m_editor = aEditor;
   return NS_OK;
 }
 
-static nsresult fixCharset(nsCString &aCharset)
-{
+static nsresult fixCharset(nsCString &aCharset) {
   // Convert to a canonical charset name.
   nsresult rv;
   nsCOMPtr<nsICharsetConverterManager> ccm =
-    do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
+      do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString charset(aCharset);
   rv = ccm->GetCharsetAlias(charset.get(), aCharset);
 
   // Replace an unrecognized charset with the default.
   if (NS_FAILED(rv)) {
-    nsCOMPtr<nsIPrefBranch> prefs (do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+    nsCOMPtr<nsIPrefBranch> prefs(
+        do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     nsString defaultCharset;
-    NS_GetLocalizedUnicharPreferenceWithDefault(prefs, "mailnews.send_default_charset",
-                                                NS_LITERAL_STRING("UTF-8"), defaultCharset);
+    NS_GetLocalizedUnicharPreferenceWithDefault(
+        prefs, "mailnews.send_default_charset", NS_LITERAL_STRING("UTF-8"),
+        defaultCharset);
     LossyCopyUTF16toASCII(defaultCharset, aCharset);
     return NS_OK;
   }
 
   // Don't accept UTF-16 ever. UTF-16 should never be selected as an
   // outgoing encoding for e-mail. MIME can't handle those messages
   // encoded in ASCII-incompatible encodings.
   if (StringBeginsWith(aCharset, NS_LITERAL_CSTRING("UTF-16"))) {
@@ -1635,328 +1512,294 @@ static nsresult fixCharset(nsCString &aC
   }
   return NS_OK;
 }
 
 // This used to be called BEFORE editor was created
 //  (it did the loadURI that triggered editor creation)
 // It is called from JS after editor creation
 //  (loadURI is done in JS)
-MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP
-nsMsgCompose::InitEditor(nsIEditor* aEditor, mozIDOMWindowProxy* aContentWindow)
-{
+MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsMsgCompose::InitEditor(
+    nsIEditor *aEditor, mozIDOMWindowProxy *aContentWindow) {
   NS_ENSURE_ARG_POINTER(aEditor);
   NS_ENSURE_ARG_POINTER(aContentWindow);
   nsresult rv;
 
   m_editor = aEditor;
 
   nsAutoCString msgCharSet(m_compFields->GetCharacterSet());
   rv = fixCharset(msgCharSet);
   NS_ENSURE_SUCCESS(rv, rv);
   m_compFields->SetCharacterSet(msgCharSet.get());
   aEditor->SetDocumentCharacterSet(msgCharSet);
 
-  nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aContentWindow);
+  nsCOMPtr<nsPIDOMWindowOuter> window =
+      nsPIDOMWindowOuter::From(aContentWindow);
 
   nsIDocShell *docShell = window->GetDocShell();
   NS_ENSURE_TRUE(docShell, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIContentViewer> childCV;
-  NS_ENSURE_SUCCESS(docShell->GetContentViewer(getter_AddRefs(childCV)), NS_ERROR_FAILURE);
-  if (childCV)
-  {
+  NS_ENSURE_SUCCESS(docShell->GetContentViewer(getter_AddRefs(childCV)),
+                    NS_ERROR_FAILURE);
+  if (childCV) {
     // SetForceCharacterSet will complain about "UTF-7" or "x-mac-croatian"
     // (see test-charset-edit.js), but we deal with this elsewhere.
     rv = childCV->SetForceCharacterSet(msgCharSet);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetForceCharacterSet() failed");
   }
 
   // This is what used to be done in mDocumentListener,
   //   nsMsgDocumentStateListener::NotifyDocumentCreated()
   bool quotingToFollow = false;
   GetQuotingToFollow(&quotingToFollow);
   if (quotingToFollow)
     return BuildQuotedMessageAndSignature();
-  else
-  {
-    NotifyStateListeners(nsIMsgComposeNotificationType::ComposeFieldsReady, NS_OK);
+  else {
+    NotifyStateListeners(nsIMsgComposeNotificationType::ComposeFieldsReady,
+                         NS_OK);
     rv = BuildBodyMessageAndSignature();
-    NotifyStateListeners(nsIMsgComposeNotificationType::ComposeBodyReady, NS_OK);
+    NotifyStateListeners(nsIMsgComposeNotificationType::ComposeBodyReady,
+                         NS_OK);
     return rv;
   }
 }
 
-NS_IMETHODIMP nsMsgCompose::GetBodyRaw(nsACString& aBodyRaw)
-{
+NS_IMETHODIMP nsMsgCompose::GetBodyRaw(nsACString &aBodyRaw) {
   aBodyRaw.Assign((char *)m_compFields->GetBody());
   return NS_OK;
 }
 
-nsresult nsMsgCompose::GetBodyModified(bool * modified)
-{
+nsresult nsMsgCompose::GetBodyModified(bool *modified) {
   nsresult rv;
 
-  if (! modified)
-    return NS_ERROR_NULL_POINTER;
+  if (!modified) return NS_ERROR_NULL_POINTER;
 
   *modified = true;
 
-  if (m_editor)
-  {
+  if (m_editor) {
     rv = m_editor->GetDocumentModified(modified);
-    if (NS_FAILED(rv))
-      *modified = true;
+    if (NS_FAILED(rv)) *modified = true;
   }
 
   return NS_OK;
 }
 
 MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult
-nsMsgCompose::SetBodyModified(bool modified)
-{
-  nsresult  rv = NS_OK;
-
-  if (m_editor)
-  {
+nsMsgCompose::SetBodyModified(bool modified) {
+  nsresult rv = NS_OK;
+
+  if (m_editor) {
     nsCOMPtr<nsIEditor> editor(m_editor);  // Strong reference.
-    if (modified)
-    {
+    if (modified) {
       int32_t modCount = 0;
       editor->GetModificationCount(&modCount);
-      if (modCount == 0)
-        editor->IncrementModificationCount(1);
-    }
-    else
+      if (modCount == 0) editor->IncrementModificationCount(1);
+    } else
       editor->ResetModificationCount();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::GetDomWindow(mozIDOMWindowProxy * *aDomWindow)
-{
+nsMsgCompose::GetDomWindow(mozIDOMWindowProxy **aDomWindow) {
   NS_IF_ADDREF(*aDomWindow = m_window);
   return NS_OK;
 }
 
-nsresult nsMsgCompose::GetCompFields(nsIMsgCompFields * *aCompFields)
-{
-  NS_IF_ADDREF(*aCompFields = (nsIMsgCompFields*)m_compFields);
+nsresult nsMsgCompose::GetCompFields(nsIMsgCompFields **aCompFields) {
+  NS_IF_ADDREF(*aCompFields = (nsIMsgCompFields *)m_compFields);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgCompose::GetComposeHTML(bool *aComposeHTML)
-{
+NS_IMETHODIMP nsMsgCompose::GetComposeHTML(bool *aComposeHTML) {
   *aComposeHTML = m_composeHTML;
   return NS_OK;
 }
 
-nsresult nsMsgCompose::GetWrapLength(int32_t *aWrapLength)
-{
+nsresult nsMsgCompose::GetWrapLength(int32_t *aWrapLength) {
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   if (NS_FAILED(rv)) return rv;
 
   return prefBranch->GetIntPref("mailnews.wraplength", aWrapLength);
 }
 
-nsresult nsMsgCompose::CreateMessage(const char * originalMsgURI,
+nsresult nsMsgCompose::CreateMessage(const char *originalMsgURI,
                                      MSG_ComposeType type,
-                                     nsIMsgCompFields * compFields)
-{
+                                     nsIMsgCompFields *compFields) {
   nsresult rv = NS_OK;
   mType = type;
   mDraftDisposition = nsIMsgFolder::nsMsgDispositionState_None;
 
   mDeleteDraft = (type == nsIMsgCompType::Draft);
   nsAutoCString msgUri(originalMsgURI);
   bool fileUrl = StringBeginsWith(msgUri, NS_LITERAL_CSTRING("file:"));
   int32_t typeIndex = msgUri.Find("type=application/x-message-display");
-  if (typeIndex != kNotFound && typeIndex > 0)
-  {
+  if (typeIndex != kNotFound && typeIndex > 0) {
     // Strip out type=application/x-message-display because it confuses libmime.
     msgUri.Cut(typeIndex, sizeof("type=application/x-message-display"));
-    if (fileUrl) // we're dealing with an .eml file msg
+    if (fileUrl)  // we're dealing with an .eml file msg
     {
       // We have now removed the type from the uri. Make sure we don't have
       // an uri with "&&" now. If we do, remove the second '&'.
-      if (msgUri.CharAt(typeIndex) == '&')
-        msgUri.Cut(typeIndex, 1);
+      if (msgUri.CharAt(typeIndex) == '&') msgUri.Cut(typeIndex, 1);
       // Remove possible trailing '?'.
       if (msgUri.CharAt(msgUri.Length() - 1) == '?')
         msgUri.Cut(msgUri.Length() - 1, 1);
-    }
-    else // we're dealing with a message/rfc822 attachment
+    } else  // we're dealing with a message/rfc822 attachment
     {
       // nsURLFetcher will check for "realtype=message/rfc822" and will set the
       // content type to message/rfc822 in the forwarded message.
       msgUri.AppendLiteral("&realtype=message/rfc822");
     }
     originalMsgURI = msgUri.get();
   }
 
-  if (compFields)
-  {
-    m_compFields = reinterpret_cast<nsMsgCompFields*>(compFields);
-  }
-  else
-  {
+  if (compFields) {
+    m_compFields = reinterpret_cast<nsMsgCompFields *>(compFields);
+  } else {
     m_compFields = new nsMsgCompFields();
   }
 
-  if (m_identity && mType != nsIMsgCompType::Draft)
-  {
+  if (m_identity && mType != nsIMsgCompType::Draft) {
     // Setup reply-to field.
     nsCString replyTo;
     m_identity->GetReplyTo(replyTo);
-    if (!replyTo.IsEmpty())
-    {
+    if (!replyTo.IsEmpty()) {
       nsCString resultStr;
       RemoveDuplicateAddresses(nsDependentCString(m_compFields->GetReplyTo()),
                                replyTo, resultStr);
-      if (!resultStr.IsEmpty())
-      {
+      if (!resultStr.IsEmpty()) {
         replyTo.Append(',');
         replyTo.Append(resultStr);
       }
       m_compFields->SetReplyTo(replyTo.get());
     }
 
     // Setup auto-Cc field.
     bool doCc;
     m_identity->GetDoCc(&doCc);
-    if (doCc)
-    {
+    if (doCc) {
       nsCString ccList;
       m_identity->GetDoCcList(ccList);
 
       nsCString resultStr;
       RemoveDuplicateAddresses(nsDependentCString(m_compFields->GetCc()),
                                ccList, resultStr);
-      if (!resultStr.IsEmpty())
-      {
+      if (!resultStr.IsEmpty()) {
         ccList.Append(',');
         ccList.Append(resultStr);
       }
       m_compFields->SetCc(ccList.get());
     }
 
     // Setup auto-Bcc field.
     bool doBcc;
     m_identity->GetDoBcc(&doBcc);
-    if (doBcc)
-    {
+    if (doBcc) {
       nsCString bccList;
       m_identity->GetDoBccList(bccList);
 
       nsCString resultStr;
       RemoveDuplicateAddresses(nsDependentCString(m_compFields->GetBcc()),
                                bccList, resultStr);
-      if (!resultStr.IsEmpty())
-      {
+      if (!resultStr.IsEmpty()) {
         bccList.Append(',');
         bccList.Append(resultStr);
       }
       m_compFields->SetBcc(bccList.get());
     }
   }
 
-  if (mType == nsIMsgCompType::Draft)
-  {
+  if (mType == nsIMsgCompType::Draft) {
     nsCString curDraftIdURL;
     rv = m_compFields->GetDraftId(getter_Copies(curDraftIdURL));
-    NS_ASSERTION(NS_SUCCEEDED(rv) && !curDraftIdURL.IsEmpty(), "CreateMessage can't get draft id");
+    NS_ASSERTION(NS_SUCCEEDED(rv) && !curDraftIdURL.IsEmpty(),
+                 "CreateMessage can't get draft id");
 
     // Skip if no draft id (probably a new draft msg).
-    if (NS_SUCCEEDED(rv) && !curDraftIdURL.IsEmpty())
-    {
-      nsCOMPtr <nsIMsgDBHdr> msgDBHdr;
+    if (NS_SUCCEEDED(rv) && !curDraftIdURL.IsEmpty()) {
+      nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
       rv = GetMsgDBHdrFromURI(curDraftIdURL.get(), getter_AddRefs(msgDBHdr));
-      NS_ASSERTION(NS_SUCCEEDED(rv), "CreateMessage can't get msg header DB interface pointer.");
-      if (msgDBHdr)
-      {
+      NS_ASSERTION(NS_SUCCEEDED(rv),
+                   "CreateMessage can't get msg header DB interface pointer.");
+      if (msgDBHdr) {
         nsCString queuedDisposition;
-        msgDBHdr->GetStringProperty(QUEUED_DISPOSITION_PROPERTY, getter_Copies(queuedDisposition));
+        msgDBHdr->GetStringProperty(QUEUED_DISPOSITION_PROPERTY,
+                                    getter_Copies(queuedDisposition));
         // We need to retrieve the original URI from the database so we can
-        // set the disposition flags correctly if the draft is a reply or forwarded message.
+        // set the disposition flags correctly if the draft is a reply or
+        // forwarded message.
         nsCString originalMsgURIfromDB;
-        msgDBHdr->GetStringProperty(ORIG_URI_PROPERTY, getter_Copies(originalMsgURIfromDB));
+        msgDBHdr->GetStringProperty(ORIG_URI_PROPERTY,
+                                    getter_Copies(originalMsgURIfromDB));
         mOriginalMsgURI = originalMsgURIfromDB;
-        if (!queuedDisposition.IsEmpty())
-        {
+        if (!queuedDisposition.IsEmpty()) {
           if (queuedDisposition.EqualsLiteral("replied"))
-             mDraftDisposition = nsIMsgFolder::nsMsgDispositionState_Replied;
+            mDraftDisposition = nsIMsgFolder::nsMsgDispositionState_Replied;
           else if (queuedDisposition.EqualsLiteral("forward"))
-             mDraftDisposition = nsIMsgFolder::nsMsgDispositionState_Forwarded;
+            mDraftDisposition = nsIMsgFolder::nsMsgDispositionState_Forwarded;
         }
       }
     }
   }
 
   // If we don't have an original message URI, nothing else to do...
-  if (!originalMsgURI || *originalMsgURI == 0)
-    return NS_OK;
-
-  // store the original message URI so we can extract it after we send the message to properly
-  // mark any disposition flags like replied or forwarded on the message.
-  if (mOriginalMsgURI.IsEmpty())
-    mOriginalMsgURI = originalMsgURI;
-
-  nsCOMPtr<nsIPrefBranch> prefs (do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  if (!originalMsgURI || *ori