Bug 1546364 - Reformat to Google coding style in mailnews/base/src (part 1). rs=reformat
authorJorg K <jorgk@jorgk.com>
Thu, 16 May 2019 13:01:43 +0200
changeset 26625 9ec6e58a9d52e87a0dc3eb8bf5ad247d40efb744
parent 26624 7d081913dbc716feb58c7c1bce6b492745955690
child 26626 d05d70ad9d05bde2e19cab53929c98c1d3058fe9
push id15926
push usermozilla@jorgk.com
push dateThu, 16 May 2019 22:32:11 +0000
treeherdercomm-central@d05d70ad9d05 [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/base/src (part 1). rs=reformat # ignore-this-changeset
mailnews/base/src/MailNewsDLF.cpp
mailnews/base/src/MailNewsDLF.h
mailnews/base/src/MailnewsLoadContextInfo.cpp
mailnews/base/src/MailnewsLoadContextInfo.h
mailnews/base/src/nsCidProtocolHandler.cpp
mailnews/base/src/nsCidProtocolHandler.h
mailnews/base/src/nsCopyMessageStreamListener.cpp
mailnews/base/src/nsCopyMessageStreamListener.h
mailnews/base/src/nsMailDirProvider.cpp
mailnews/base/src/nsMailDirProvider.h
mailnews/base/src/nsMailDirServiceDefs.h
mailnews/base/src/nsMessenger.cpp
mailnews/base/src/nsMessenger.h
mailnews/base/src/nsMessengerBootstrap.cpp
mailnews/base/src/nsMessengerBootstrap.h
mailnews/base/src/nsMessengerContentHandler.cpp
mailnews/base/src/nsMessengerContentHandler.h
mailnews/base/src/nsMessengerOSXIntegration.h
mailnews/base/src/nsMessengerOSXIntegration.mm
mailnews/base/src/nsMessengerUnixIntegration.cpp
mailnews/base/src/nsMessengerUnixIntegration.h
mailnews/base/src/nsMessengerWinIntegration.cpp
mailnews/base/src/nsMessengerWinIntegration.h
--- a/mailnews/base/src/MailNewsDLF.cpp
+++ b/mailnews/base/src/MailNewsDLF.cpp
@@ -14,80 +14,71 @@
 #include "nsIStreamListener.h"
 #include "nsNetCID.h"
 #include "nsMsgUtils.h"
 
 namespace mozilla {
 namespace mailnews {
 NS_IMPL_ISUPPORTS(MailNewsDLF, nsIDocumentLoaderFactory)
 
-MailNewsDLF::MailNewsDLF()
-{
-}
+MailNewsDLF::MailNewsDLF() {}
 
-MailNewsDLF::~MailNewsDLF()
-{
-}
+MailNewsDLF::~MailNewsDLF() {}
 
 NS_IMETHODIMP
-MailNewsDLF::CreateInstance(const char* aCommand,
-                            nsIChannel* aChannel,
+MailNewsDLF::CreateInstance(const char* aCommand, nsIChannel* aChannel,
                             nsILoadGroup* aLoadGroup,
                             const nsACString& aContentType,
-                            nsIDocShell* aContainer,
-                            nsISupports* aExtraInfo,
+                            nsIDocShell* aContainer, nsISupports* aExtraInfo,
                             nsIStreamListener** aDocListener,
-                            nsIContentViewer** aDocViewer)
-{
+                            nsIContentViewer** aDocViewer) {
   nsresult rv;
 
-  bool viewSource = (PL_strstr(PromiseFlatCString(aContentType).get(),
-                               "view-source") != 0);
+  bool viewSource =
+      (PL_strstr(PromiseFlatCString(aContentType).get(), "view-source") != 0);
 
   aChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_HTML));
 
   // Get the HTML category
   nsCOMPtr<nsICategoryManager> catMan(
-    do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
+      do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString contractID;
-  rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", TEXT_HTML,
-                                contractID);
+  rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", TEXT_HTML, contractID);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIDocumentLoaderFactory> factory(do_GetService(contractID.get(),
-                                             &rv));
+  nsCOMPtr<nsIDocumentLoaderFactory> factory(
+      do_GetService(contractID.get(), &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStreamListener> listener;
 
   if (viewSource) {
-    rv = factory->CreateInstance("view-source", aChannel, aLoadGroup,
-                                 NS_LITERAL_CSTRING(TEXT_HTML "; x-view-type=view-source"),
-                                 aContainer, aExtraInfo, getter_AddRefs(listener),
-                                 aDocViewer);
+    rv = factory->CreateInstance(
+        "view-source", aChannel, aLoadGroup,
+        NS_LITERAL_CSTRING(TEXT_HTML "; x-view-type=view-source"), aContainer,
+        aExtraInfo, getter_AddRefs(listener), aDocViewer);
   } else {
-    rv = factory->CreateInstance("view", aChannel, aLoadGroup, NS_LITERAL_CSTRING(TEXT_HTML),
-                                 aContainer, aExtraInfo, getter_AddRefs(listener),
-                                 aDocViewer);
+    rv = factory->CreateInstance(
+        "view", aChannel, aLoadGroup, NS_LITERAL_CSTRING(TEXT_HTML), aContainer,
+        aExtraInfo, getter_AddRefs(listener), aDocViewer);
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStreamConverterService> scs(
-    do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv));
+      do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return scs->AsyncConvertData(MESSAGE_RFC822, TEXT_HTML, listener, aChannel,
                                aDocListener);
 }
 
 NS_IMETHODIMP
 MailNewsDLF::CreateInstanceForDocument(nsISupports* aContainer,
                                        mozilla::dom::Document* aDocument,
                                        const char* aCommand,
-                                       nsIContentViewer** aDocViewer)
-{
+                                       nsIContentViewer** aDocViewer) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-}
-}
+}  // namespace mailnews
+}  // namespace mozilla
--- a/mailnews/base/src/MailNewsDLF.h
+++ b/mailnews/base/src/MailNewsDLF.h
@@ -13,26 +13,25 @@
 namespace mozilla {
 namespace mailnews {
 
 /*
  * This factory is a thin wrapper around the text/html loader factory. All it
  * does is convert message/rfc822 to text/html and delegate the rest of the
  * work to the text/html factory.
  */
-class MailNewsDLF : public nsIDocumentLoaderFactory
-{
-public:
+class MailNewsDLF : public nsIDocumentLoaderFactory {
+ public:
   MailNewsDLF();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOCUMENTLOADERFACTORY
 
-private:
+ private:
   virtual ~MailNewsDLF();
 };
-}
-}
+}  // namespace mailnews
+}  // namespace mozilla
 
 #define MAILNEWSDLF_CATEGORIES \
-  { "Gecko-Content-Viewers", MESSAGE_RFC822, NS_MAILNEWSDLF_CONTRACTID }, \
+  {"Gecko-Content-Viewers", MESSAGE_RFC822, NS_MAILNEWSDLF_CONTRACTID},
 
 #endif
--- a/mailnews/base/src/MailnewsLoadContextInfo.cpp
+++ b/mailnews/base/src/MailnewsLoadContextInfo.cpp
@@ -11,45 +11,41 @@
 #include "nsILoadContext.h"
 #include "nsIWebNavigation.h"
 #include "nsNetUtil.h"
 
 // MailnewsLoadContextInfo
 
 NS_IMPL_ISUPPORTS(MailnewsLoadContextInfo, nsILoadContextInfo)
 
-MailnewsLoadContextInfo::MailnewsLoadContextInfo(bool aIsPrivate, bool aIsAnonymous, mozilla::OriginAttributes aOriginAttributes)
-  : mIsPrivate(aIsPrivate)
-  , mIsAnonymous(aIsAnonymous)
-  , mOriginAttributes(aOriginAttributes)
-{
+MailnewsLoadContextInfo::MailnewsLoadContextInfo(
+    bool aIsPrivate, bool aIsAnonymous,
+    mozilla::OriginAttributes aOriginAttributes)
+    : mIsPrivate(aIsPrivate),
+      mIsAnonymous(aIsAnonymous),
+      mOriginAttributes(aOriginAttributes) {
   mOriginAttributes.SyncAttributesWithPrivateBrowsing(mIsPrivate);
 }
 
-MailnewsLoadContextInfo::~MailnewsLoadContextInfo()
-{
-}
+MailnewsLoadContextInfo::~MailnewsLoadContextInfo() {}
 
-NS_IMETHODIMP MailnewsLoadContextInfo::GetIsPrivate(bool *aIsPrivate)
-{
+NS_IMETHODIMP MailnewsLoadContextInfo::GetIsPrivate(bool *aIsPrivate) {
   *aIsPrivate = mIsPrivate;
   return NS_OK;
 }
 
-NS_IMETHODIMP MailnewsLoadContextInfo::GetIsAnonymous(bool *aIsAnonymous)
-{
+NS_IMETHODIMP MailnewsLoadContextInfo::GetIsAnonymous(bool *aIsAnonymous) {
   *aIsAnonymous = mIsAnonymous;
   return NS_OK;
 }
 
-mozilla::OriginAttributes const* MailnewsLoadContextInfo::OriginAttributesPtr()
-{
+mozilla::OriginAttributes const *
+MailnewsLoadContextInfo::OriginAttributesPtr() {
   return &mOriginAttributes;
 }
 
-NS_IMETHODIMP MailnewsLoadContextInfo::GetOriginAttributes(JSContext *aCx,
-                                                   JS::MutableHandle<JS::Value> aVal)
-{
+NS_IMETHODIMP MailnewsLoadContextInfo::GetOriginAttributes(
+    JSContext *aCx, JS::MutableHandle<JS::Value> aVal) {
   if (NS_WARN_IF(!ToJSValue(aCx, mOriginAttributes, aVal))) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
--- a/mailnews/base/src/MailnewsLoadContextInfo.h
+++ b/mailnews/base/src/MailnewsLoadContextInfo.h
@@ -7,26 +7,26 @@
 #ifndef MailnewsLoadContextInfo_h__
 #define MailnewsLoadContextInfo_h__
 
 #include "nsILoadContextInfo.h"
 
 class nsIChannel;
 class nsILoadContext;
 
-class MailnewsLoadContextInfo : public nsILoadContextInfo
-{
-public:
+class MailnewsLoadContextInfo : public nsILoadContextInfo {
+ public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSILOADCONTEXTINFO
 
-  MailnewsLoadContextInfo(bool aIsPrivate, bool aIsAnonymous, mozilla::OriginAttributes aOriginAttributes);
+  MailnewsLoadContextInfo(bool aIsPrivate, bool aIsAnonymous,
+                          mozilla::OriginAttributes aOriginAttributes);
 
-private:
+ private:
   virtual ~MailnewsLoadContextInfo();
 
-protected:
+ protected:
   bool mIsPrivate : 1;
   bool mIsAnonymous : 1;
   mozilla::OriginAttributes mOriginAttributes;
 };
 
 #endif
--- a/mailnews/base/src/nsCidProtocolHandler.cpp
+++ b/mailnews/base/src/nsCidProtocolHandler.cpp
@@ -5,62 +5,54 @@
 
 #include "nsCidProtocolHandler.h"
 #include "nsString.h"
 #include "nsIURI.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsComponentManagerUtils.h"
 
-nsCidProtocolHandler::nsCidProtocolHandler()
-{
-}
+nsCidProtocolHandler::nsCidProtocolHandler() {}
 
-nsCidProtocolHandler::~nsCidProtocolHandler()
-{
-}
+nsCidProtocolHandler::~nsCidProtocolHandler() {}
 
 NS_IMPL_ISUPPORTS(nsCidProtocolHandler, nsIProtocolHandler)
 
-NS_IMETHODIMP nsCidProtocolHandler::GetScheme(nsACString & aScheme)
-{
+NS_IMETHODIMP nsCidProtocolHandler::GetScheme(nsACString &aScheme) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-NS_IMETHODIMP nsCidProtocolHandler::GetDefaultPort(int32_t *aDefaultPort)
-{
+NS_IMETHODIMP nsCidProtocolHandler::GetDefaultPort(int32_t *aDefaultPort) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-NS_IMETHODIMP nsCidProtocolHandler::GetProtocolFlags(uint32_t *aProtocolFlags)
-{
+NS_IMETHODIMP nsCidProtocolHandler::GetProtocolFlags(uint32_t *aProtocolFlags) {
   // XXXbz so why does this protocol handler exist, exactly?
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-NS_IMETHODIMP nsCidProtocolHandler::NewURI(const nsACString & aSpec, const char *aOriginCharset, nsIURI *aBaseURI, nsIURI **_retval)
-{
+NS_IMETHODIMP nsCidProtocolHandler::NewURI(const nsACString &aSpec,
+                                           const char *aOriginCharset,
+                                           nsIURI *aBaseURI, nsIURI **_retval) {
   // the right fix is to use the baseSpec (or aBaseUri)
   // and specify the cid, and then fix mime
   // to handle that, like it does with "...&part=1.2"
   // for now, do about blank to prevent spam
   // from popping up annoying alerts about not implementing the cid
   // protocol
   nsCOMPtr<nsIURI> url;
   nsresult rv = NS_NewURI(getter_AddRefs(url), "about:blank");
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   url.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsCidProtocolHandler::NewChannel(nsIURI *aURI,
-                                               nsILoadInfo* aLoadInfo,
-                                               nsIChannel **_retval)
-{
+                                               nsILoadInfo *aLoadInfo,
+                                               nsIChannel **_retval) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-NS_IMETHODIMP nsCidProtocolHandler::AllowPort(int32_t port, const char *scheme, bool *_retval)
-{
+NS_IMETHODIMP nsCidProtocolHandler::AllowPort(int32_t port, const char *scheme,
+                                              bool *_retval) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
-
--- a/mailnews/base/src/nsCidProtocolHandler.h
+++ b/mailnews/base/src/nsCidProtocolHandler.h
@@ -4,21 +4,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsCidProtocolHandler_h__
 #define nsCidProtocolHandler_h__
 
 #include "nsCOMPtr.h"
 #include "nsIProtocolHandler.h"
 
-class nsCidProtocolHandler : public nsIProtocolHandler
-{
-public:
+class nsCidProtocolHandler : public nsIProtocolHandler {
+ public:
   nsCidProtocolHandler();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPROTOCOLHANDLER
 
-private:
+ private:
   virtual ~nsCidProtocolHandler();
 };
 
 #endif /* nsCidProtocolHandler_h__ */
--- a/mailnews/base/src/nsCopyMessageStreamListener.cpp
+++ b/mailnews/base/src/nsCopyMessageStreamListener.cpp
@@ -9,151 +9,138 @@
 #include "nsIMsgHdr.h"
 #include "nsIMsgImapMailFolder.h"
 #include "nsIMsgMessageService.h"
 #include "nsMsgUtils.h"
 #include "nsIChannel.h"
 #include "netCore.h"
 
 NS_IMPL_ISUPPORTS(nsCopyMessageStreamListener, nsIStreamListener,
-  nsIRequestObserver, nsICopyMessageStreamListener)
+                  nsIRequestObserver, nsICopyMessageStreamListener)
 
-static nsresult GetMessage(nsIURI *aURL, nsIMsgDBHdr **message)
-{
+static nsresult GetMessage(nsIURI *aURL, nsIMsgDBHdr **message) {
   NS_ENSURE_ARG_POINTER(message);
 
   nsCOMPtr<nsIMsgMessageUrl> uriURL;
   nsresult rv;
 
-  //Need to get message we are about to copy
+  // Need to get message we are about to copy
   uriURL = do_QueryInterface(aURL, &rv);
-  if(NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
   // get the uri.  first try and use the original message spec
   // if that fails, use the spec of nsIURI that we're called with
   nsCString uri;
   rv = uriURL->GetOriginalSpec(getter_Copies(uri));
   if (NS_FAILED(rv) || uri.IsEmpty()) {
     rv = uriURL->GetUri(getter_Copies(uri));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  nsCOMPtr <nsIMsgMessageService> msgMessageService;
+  nsCOMPtr<nsIMsgMessageService> msgMessageService;
   rv = GetMessageServiceFromURI(uri, getter_AddRefs(msgMessageService));
-  NS_ENSURE_SUCCESS(rv,rv);
-  if (!msgMessageService)
-    return NS_ERROR_FAILURE;
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (!msgMessageService) return NS_ERROR_FAILURE;
 
   rv = msgMessageService->MessageURIToMsgHdr(uri.get(), message);
   return rv;
 }
 
-nsCopyMessageStreamListener::nsCopyMessageStreamListener()
-{
+nsCopyMessageStreamListener::nsCopyMessageStreamListener() {}
+
+nsCopyMessageStreamListener::~nsCopyMessageStreamListener() {
+  // All member variables are nsCOMPtr's.
 }
 
-nsCopyMessageStreamListener::~nsCopyMessageStreamListener()
-{
-  //All member variables are nsCOMPtr's.
-}
-
-NS_IMETHODIMP nsCopyMessageStreamListener::Init(nsIMsgFolder *srcFolder, nsICopyMessageListener *destination, nsISupports *listenerData)
-{
+NS_IMETHODIMP nsCopyMessageStreamListener::Init(
+    nsIMsgFolder *srcFolder, nsICopyMessageListener *destination,
+    nsISupports *listenerData) {
   mSrcFolder = srcFolder;
   mDestination = destination;
   mListenerData = listenerData;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCopyMessageStreamListener::StartMessage()
-{
-  if (mDestination)
-    mDestination->StartMessage();
+NS_IMETHODIMP nsCopyMessageStreamListener::StartMessage() {
+  if (mDestination) mDestination->StartMessage();
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCopyMessageStreamListener::EndMessage(nsMsgKey key)
-{
-  if (mDestination)
-    mDestination->EndMessage(key);
+NS_IMETHODIMP nsCopyMessageStreamListener::EndMessage(nsMsgKey key) {
+  if (mDestination) mDestination->EndMessage(key);
 
   return NS_OK;
 }
 
-
-NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(nsIRequest * /* request */, nsIInputStream *aIStream, uint64_t sourceOffset, uint32_t aLength)
-{
+NS_IMETHODIMP nsCopyMessageStreamListener::OnDataAvailable(
+    nsIRequest * /* request */, nsIInputStream *aIStream, uint64_t sourceOffset,
+    uint32_t aLength) {
   nsresult rv;
   rv = mDestination->CopyData(aIStream, aLength);
   return rv;
 }
 
-NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIRequest * request)
-{
+NS_IMETHODIMP nsCopyMessageStreamListener::OnStartRequest(nsIRequest *request) {
   nsCOMPtr<nsIMsgDBHdr> message;
   nsresult rv = NS_OK;
   nsCOMPtr<nsIURI> uri;
 
   // We know the request is an nsIChannel we can get a URI from, but this is
   // probably bad form. See Bug 1528662.
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(request, &rv);
-  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "error QI nsIRequest to nsIChannel failed");
-  if (NS_SUCCEEDED(rv))
-    rv = channel->GetURI(getter_AddRefs(uri));
-  if (NS_SUCCEEDED(rv))
-    rv = GetMessage(uri, getter_AddRefs(message));
-  if(NS_SUCCEEDED(rv))
-    rv = mDestination->BeginCopy(message);
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                       "error QI nsIRequest to nsIChannel failed");
+  if (NS_SUCCEEDED(rv)) rv = channel->GetURI(getter_AddRefs(uri));
+  if (NS_SUCCEEDED(rv)) rv = GetMessage(uri, getter_AddRefs(message));
+  if (NS_SUCCEEDED(rv)) rv = mDestination->BeginCopy(message);
 
   NS_ENSURE_SUCCESS(rv, rv);
   return rv;
 }
 
-NS_IMETHODIMP nsCopyMessageStreamListener::EndCopy(nsISupports *url, nsresult aStatus)
-{
+NS_IMETHODIMP nsCopyMessageStreamListener::EndCopy(nsISupports *url,
+                                                   nsresult aStatus) {
   nsresult rv;
   nsCOMPtr<nsIURI> uri = do_QueryInterface(url, &rv);
 
   NS_ENSURE_SUCCESS(rv, rv);
   bool copySucceeded = (aStatus == NS_BINDING_SUCCEEDED);
   rv = mDestination->EndCopy(copySucceeded);
-  //If this is a move and we finished the copy, delete the old message.
+  // If this is a move and we finished the copy, delete the old message.
   bool moveMessage = false;
 
   nsCOMPtr<nsIMsgMailNewsUrl> mailURL(do_QueryInterface(uri));
-  if (mailURL)
-    rv = mailURL->IsUrlType(nsIMsgMailNewsUrl::eMove, &moveMessage);
+  if (mailURL) rv = mailURL->IsUrlType(nsIMsgMailNewsUrl::eMove, &moveMessage);
 
-  if (NS_FAILED(rv))
-    moveMessage = false;
+  if (NS_FAILED(rv)) moveMessage = false;
 
-  // OK, this is wrong if we're moving to an imap folder, for example. This really says that
-  // we were able to pull the message from the source, NOT that we were able to
-  // put it in the destination!
-  if (moveMessage)
-  {
-    // don't do this if we're moving to an imap folder - that's handled elsewhere.
+  // OK, this is wrong if we're moving to an imap folder, for example. This
+  // really says that we were able to pull the message from the source, NOT that
+  // we were able to put it in the destination!
+  if (moveMessage) {
+    // don't do this if we're moving to an imap folder - that's handled
+    // elsewhere.
     nsCOMPtr<nsIMsgImapMailFolder> destImap = do_QueryInterface(mDestination);
-      // if the destination is a local folder, it will handle the delete from the source in EndMove
-    if (!destImap)
-      rv = mDestination->EndMove(copySucceeded);
+    // if the destination is a local folder, it will handle the delete from the
+    // source in EndMove
+    if (!destImap) rv = mDestination->EndMove(copySucceeded);
   }
   // Even if the above actions failed we probably still want to return NS_OK.
-  // There should probably be some error dialog if either the copy or delete failed.
+  // There should probably be some error dialog if either the copy or delete
+  // failed.
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIRequest* request, nsresult aStatus)
-{
+NS_IMETHODIMP nsCopyMessageStreamListener::OnStopRequest(nsIRequest *request,
+                                                         nsresult aStatus) {
   nsresult rv;
   // We know the request is an nsIChannel we can get a URI from, but this is
   // probably bad form. See Bug 1528662.
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(request, &rv);
-  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "error QI nsIRequest to nsIChannel failed");
+  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                       "error QI nsIRequest to nsIChannel failed");
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIURI> uri;
   rv = channel->GetURI(getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
   return EndCopy(uri, aStatus);
 }
-
--- a/mailnews/base/src/nsCopyMessageStreamListener.h
+++ b/mailnews/base/src/nsCopyMessageStreamListener.h
@@ -8,28 +8,27 @@
 
 #include "nsICopyMsgStreamListener.h"
 #include "nsIStreamListener.h"
 #include "nsIMsgFolder.h"
 #include "nsICopyMessageListener.h"
 #include "nsCOMPtr.h"
 #include "nsIURI.h"
 
-class nsCopyMessageStreamListener : public nsIStreamListener, public nsICopyMessageStreamListener {
-
-public:
+class nsCopyMessageStreamListener : public nsIStreamListener,
+                                    public nsICopyMessageStreamListener {
+ public:
   nsCopyMessageStreamListener();
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSICOPYMESSAGESTREAMLISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
 
-protected:
+ protected:
   virtual ~nsCopyMessageStreamListener();
 
   nsCOMPtr<nsICopyMessageListener> mDestination;
   nsCOMPtr<nsISupports> mListenerData;
   nsCOMPtr<nsIMsgFolder> mSrcFolder;
-
 };
 
 #endif
--- a/mailnews/base/src/nsMailDirProvider.cpp
+++ b/mailnews/base/src/nsMailDirProvider.cpp
@@ -13,191 +13,174 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIChromeRegistry.h"
 #include "nsICategoryManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "mozilla/Services.h"
 
-#define MAIL_DIR_50_NAME             "Mail"
-#define IMAP_MAIL_DIR_50_NAME        "ImapMail"
-#define NEWS_DIR_50_NAME             "News"
+#define MAIL_DIR_50_NAME "Mail"
+#define IMAP_MAIL_DIR_50_NAME "ImapMail"
+#define NEWS_DIR_50_NAME "News"
 #define MSG_FOLDER_CACHE_DIR_50_NAME "panacea.dat"
 
-nsresult
-nsMailDirProvider::EnsureDirectory(nsIFile *aDirectory)
-{
+nsresult nsMailDirProvider::EnsureDirectory(nsIFile *aDirectory) {
   bool exists;
   nsresult rv = aDirectory->Exists(&exists);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!exists)
-    rv = aDirectory->Create(nsIFile::DIRECTORY_TYPE, 0700);
+  if (!exists) rv = aDirectory->Create(nsIFile::DIRECTORY_TYPE, 0700);
 
   return rv;
 }
 
-NS_IMPL_ISUPPORTS(nsMailDirProvider,
-                   nsIDirectoryServiceProvider,
-                   nsIDirectoryServiceProvider2)
+NS_IMPL_ISUPPORTS(nsMailDirProvider, nsIDirectoryServiceProvider,
+                  nsIDirectoryServiceProvider2)
 
 NS_IMETHODIMP
 nsMailDirProvider::GetFile(const char *aKey, bool *aPersist,
-                           nsIFile **aResult)
-{
+                           nsIFile **aResult) {
   // NOTE: This function can be reentrant through the NS_GetSpecialDirectory
   // call, so be careful not to cause infinite recursion.
   // i.e. the check for supported files must come first.
-  const char* leafName = nullptr;
+  const char *leafName = nullptr;
   bool isDirectory = true;
 
   if (!strcmp(aKey, NS_APP_MAIL_50_DIR))
     leafName = MAIL_DIR_50_NAME;
   else if (!strcmp(aKey, NS_APP_IMAP_MAIL_50_DIR))
     leafName = IMAP_MAIL_DIR_50_NAME;
   else if (!strcmp(aKey, NS_APP_NEWS_50_DIR))
     leafName = NEWS_DIR_50_NAME;
   else if (!strcmp(aKey, NS_APP_MESSENGER_FOLDER_CACHE_50_FILE)) {
     isDirectory = false;
     leafName = MSG_FOLDER_CACHE_DIR_50_NAME;
-  }
-  else
+  } else
     return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIFile> parentDir;
   nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
                                        getter_AddRefs(parentDir));
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
   nsCOMPtr<nsIFile> file;
   rv = parentDir->Clone(getter_AddRefs(file));
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
   nsDependentCString leafStr(leafName);
   rv = file->AppendNative(leafStr);
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
   bool exists;
   if (isDirectory && NS_SUCCEEDED(file->Exists(&exists)) && !exists)
     rv = EnsureDirectory(file);
 
   *aPersist = true;
   file.forget(aResult);
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsMailDirProvider::GetFiles(const char *aKey,
-                            nsISimpleEnumerator **aResult)
-{
-  if (strcmp(aKey, ISP_DIRECTORY_LIST) != 0)
-    return NS_ERROR_FAILURE;
+nsMailDirProvider::GetFiles(const char *aKey, nsISimpleEnumerator **aResult) {
+  if (strcmp(aKey, ISP_DIRECTORY_LIST) != 0) return NS_ERROR_FAILURE;
 
   // The list of isp directories includes the isp directory
   // in the current process dir (i.e. <path to thunderbird.exe>\isp and
   // <path to thunderbird.exe>\isp\locale
   // and isp and isp\locale for each active extension
 
   nsCOMPtr<nsIProperties> dirSvc =
-    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
-  if (!dirSvc)
-    return NS_ERROR_FAILURE;
+      do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
+  if (!dirSvc) return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIFile> currentProcessDir;
-  nsresult rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
-                   NS_GET_IID(nsIFile), getter_AddRefs(currentProcessDir));
+  nsresult rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile),
+                            getter_AddRefs(currentProcessDir));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
-  rv = NS_NewSingletonEnumerator(getter_AddRefs(directoryEnumerator), currentProcessDir);
+  rv = NS_NewSingletonEnumerator(getter_AddRefs(directoryEnumerator),
+                                 currentProcessDir);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsISimpleEnumerator> combinedEnumerator;
   nsCOMPtr<nsISimpleEnumerator> extensionsEnum;
 
-  // xpcshell-tests don't have XRE_EXTENSIONS_DIR_LIST, so accept a null return here.
-  dirSvc->Get(XRE_EXTENSIONS_DIR_LIST,
-              NS_GET_IID(nsISimpleEnumerator),
+  // xpcshell-tests don't have XRE_EXTENSIONS_DIR_LIST, so accept a null return
+  // here.
+  dirSvc->Get(XRE_EXTENSIONS_DIR_LIST, NS_GET_IID(nsISimpleEnumerator),
               getter_AddRefs(extensionsEnum));
 
-  rv = NS_NewUnionEnumerator(getter_AddRefs(combinedEnumerator), directoryEnumerator, extensionsEnum);
+  rv = NS_NewUnionEnumerator(getter_AddRefs(combinedEnumerator),
+                             directoryEnumerator, extensionsEnum);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ADDREF(*aResult = new AppendingEnumerator(combinedEnumerator));
   return NS_SUCCESS_AGGREGATE_RESULT;
 }
 
 NS_IMETHODIMP
-nsMailDirProvider::AppendingEnumerator::HasMoreElements(bool *aResult)
-{
+nsMailDirProvider::AppendingEnumerator::HasMoreElements(bool *aResult) {
   *aResult = mNext || mNextWithLocale ? true : false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMailDirProvider::AppendingEnumerator::GetNext(nsISupports* *aResult)
-{
+nsMailDirProvider::AppendingEnumerator::GetNext(nsISupports **aResult) {
   // Set the return value to the next directory we want to enumerate over
-  if (aResult)
-    NS_ADDREF(*aResult = mNext);
+  if (aResult) NS_ADDREF(*aResult = mNext);
 
-  if (mNextWithLocale)
-  {
+  if (mNextWithLocale) {
     mNext = mNextWithLocale;
     mNextWithLocale = nullptr;
     return NS_OK;
   }
 
   mNext = nullptr;
 
   // Ignore all errors
 
   bool more;
   while (NS_SUCCEEDED(mBase->HasMoreElements(&more)) && more) {
     nsCOMPtr<nsISupports> nextbasesupp;
     mBase->GetNext(getter_AddRefs(nextbasesupp));
 
     nsCOMPtr<nsIFile> nextbase(do_QueryInterface(nextbasesupp));
-    if (!nextbase)
-      continue;
+    if (!nextbase) continue;
 
     nextbase->Clone(getter_AddRefs(mNext));
-    if (!mNext)
-      continue;
+    if (!mNext) continue;
 
     mNext->AppendNative(NS_LITERAL_CSTRING("isp"));
     bool exists;
     nsresult rv = mNext->Exists(&exists);
-    if (NS_SUCCEEDED(rv) && exists)
-    {
-      if (!mLocale.IsEmpty())
-      {
+    if (NS_SUCCEEDED(rv) && exists) {
+      if (!mLocale.IsEmpty()) {
         mNext->Clone(getter_AddRefs(mNextWithLocale));
         mNextWithLocale->AppendNative(mLocale);
         rv = mNextWithLocale->Exists(&exists);
-        if (NS_FAILED(rv) || !exists)
-          mNextWithLocale = nullptr; // clear out mNextWithLocale, so we don't try to iterate over it
+        if (NS_FAILED(rv) || !exists) {
+          // Clear out mNextWithLocale, so we don't try to iterate over it.
+          mNextWithLocale = nullptr;
+        }
       }
       break;
     }
 
     mNext = nullptr;
   }
 
   return NS_OK;
 }
 
-nsMailDirProvider::AppendingEnumerator::AppendingEnumerator
-    (nsISimpleEnumerator* aBase) :
-  mBase(aBase)
-{
+nsMailDirProvider::AppendingEnumerator::AppendingEnumerator(
+    nsISimpleEnumerator *aBase)
+    : mBase(aBase) {
   nsCOMPtr<nsIXULChromeRegistry> packageRegistry =
-    mozilla::services::GetXULChromeRegistryService();
+      mozilla::services::GetXULChromeRegistryService();
   if (packageRegistry)
-    packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"), false, mLocale);
+    packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"), false,
+                                       mLocale);
   // Initialize mNext to begin
   GetNext(nullptr);
 }
--- a/mailnews/base/src/nsMailDirProvider.h
+++ b/mailnews/base/src/nsMailDirProvider.h
@@ -7,43 +7,37 @@
 #define nsMailDirProvider_h__
 
 #include "nsIDirectoryService.h"
 #include "nsSimpleEnumerator.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsIFile.h"
 
-class nsMailDirProvider final : public nsIDirectoryServiceProvider2
-{
-public:
+class nsMailDirProvider final : public nsIDirectoryServiceProvider2 {
+ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
 
-private:
+ private:
   ~nsMailDirProvider() {}
 
-  nsresult EnsureDirectory(nsIFile *aDirectory);
-
+  nsresult EnsureDirectory(nsIFile* aDirectory);
 
-  class AppendingEnumerator final : public nsSimpleEnumerator
-  {
-  public:
-    const nsID& DefaultInterface() override
-    {
-      return NS_GET_IID(nsIFile);
-    }
+  class AppendingEnumerator final : public nsSimpleEnumerator {
+   public:
+    const nsID& DefaultInterface() override { return NS_GET_IID(nsIFile); }
 
     NS_DECL_NSISIMPLEENUMERATOR
 
     explicit AppendingEnumerator(nsISimpleEnumerator* aBase);
 
-  private:
+   private:
     ~AppendingEnumerator() override = default;
     nsCOMPtr<nsISimpleEnumerator> mBase;
-    nsCOMPtr<nsIFile>             mNext;
-    nsCOMPtr<nsIFile>             mNextWithLocale;
-    nsCString                     mLocale;
+    nsCOMPtr<nsIFile> mNext;
+    nsCOMPtr<nsIFile> mNextWithLocale;
+    nsCString mLocale;
   };
 };
 
-#endif // nsMailDirProvider_h__
+#endif  // nsMailDirProvider_h__
--- a/mailnews/base/src/nsMailDirServiceDefs.h
+++ b/mailnews/base/src/nsMailDirServiceDefs.h
@@ -1,13 +1,12 @@
 /* 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/. */
 
-
 #ifndef nsMailDirectoryServiceDefs_h___
 #define nsMailDirectoryServiceDefs_h___
 
 //=============================================================================
 //
 // Defines property names for directories available from the mail-specific
 // nsMailDirProvider.
 //
@@ -15,17 +14,17 @@
 // General application properties are defined in nsAppDirectoryServiceDefs.h.
 //
 //=============================================================================
 
 // ----------------------------------------------------------------------------
 // Files and directories that exist on a per-profile basis.
 // ----------------------------------------------------------------------------
 
-#define NS_APP_MAIL_50_DIR                      "MailD"
-#define NS_APP_IMAP_MAIL_50_DIR                 "IMapMD"
-#define NS_APP_NEWS_50_DIR                      "NewsD"
+#define NS_APP_MAIL_50_DIR "MailD"
+#define NS_APP_IMAP_MAIL_50_DIR "IMapMD"
+#define NS_APP_NEWS_50_DIR "NewsD"
 
-#define NS_APP_MESSENGER_FOLDER_CACHE_50_FILE   "MFCaF"
+#define NS_APP_MESSENGER_FOLDER_CACHE_50_FILE "MFCaF"
 
-#define ISP_DIRECTORY_LIST                 "ISPDL"
+#define ISP_DIRECTORY_LIST "ISPDL"
 
 #endif
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -31,18 +31,18 @@
 #include "nsIMIMEInfo.h"
 
 // gecko
 #include "nsLayoutCID.h"
 #include "nsIContentViewer.h"
 
 // embedding
 #ifdef NS_PRINTING
-#include "nsIWebBrowserPrint.h"
-#include "nsMsgPrintEngine.h"
+#  include "nsIWebBrowserPrint.h"
+#  include "nsMsgPrintEngine.h"
 #endif
 
 /* for access to docshell */
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebNavigation.h"
 #include "nsContentUtils.h"
@@ -86,154 +86,148 @@
 #include "nsCExternalHandlerService.h"
 #include "nsIExternalProtocolService.h"
 #include "nsIMIMEService.h"
 #include "nsITransfer.h"
 
 #include "nsILinkHandler.h"
 
 #define MESSENGER_SAVE_DIR_PREF_NAME "messenger.save.dir"
-#define MIMETYPE_DELETED    "text/x-moz-deleted"
+#define MIMETYPE_DELETED "text/x-moz-deleted"
 #define ATTACHMENT_PERMISSION 00664
 
 //
 // Convert an nsString buffer to plain text...
 //
 #include "nsMsgUtils.h"
 #include "nsCharsetSource.h"
 #include "nsIChannel.h"
 #include "nsIOutputStream.h"
 #include "nsIPrincipal.h"
 
-static void ConvertAndSanitizeFileName(const char * displayName, nsString& aResult)
-{
+static void ConvertAndSanitizeFileName(const char *displayName,
+                                       nsString &aResult) {
   nsCString unescapedName;
 
   /* we need to convert the UTF-8 fileName to platform specific character set.
      The display name is in UTF-8 because it has been escaped from JS
   */
   MsgUnescapeString(nsDependentCString(displayName), 0, unescapedName);
   CopyUTF8toUTF16(unescapedName, aResult);
 
-  // replace platform specific path separator and illegale characters to avoid any confusion
+  // replace platform specific path separator and illegale characters to avoid
+  // any confusion
   MsgReplaceChar(aResult, FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '-');
 }
 
 // ***************************************************
 // jefft - this is a rather obscured class serves for Save Message As File,
 // Save Message As Template, and Save Attachment to a file
 //
 class nsSaveAllAttachmentsState;
 
 class nsSaveMsgListener : public nsIUrlListener,
                           public nsIMsgCopyServiceListener,
                           public nsIStreamListener,
-                          public nsICancelable
-{
+                          public nsICancelable {
   using PathChar = mozilla::filesystem::Path::value_type;
-public:
-  nsSaveMsgListener(nsIFile *file, nsMessenger *aMessenger, nsIUrlListener *aListener);
+
+ public:
+  nsSaveMsgListener(nsIFile *file, nsMessenger *aMessenger,
+                    nsIUrlListener *aListener);
 
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSIURLLISTENER
   NS_DECL_NSIMSGCOPYSERVICELISTENER
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSICANCELABLE
 
   nsCOMPtr<nsIFile> m_file;
   nsCOMPtr<nsIOutputStream> m_outputStream;
   char m_dataBuffer[FILE_IO_BUFFER_SIZE];
   nsCOMPtr<nsIChannel> m_channel;
   nsCString m_templateUri;
-  nsMessenger *m_messenger; // not ref counted
+  nsMessenger *m_messenger;  // not ref counted
   nsSaveAllAttachmentsState *m_saveAllAttachmentsState;
 
   // rhp: For character set handling
-  bool          m_doCharsetConversion;
-  nsString      m_charset;
-  enum {
-    eUnknown,
-    ePlainText,
-    eHTML
-  }             m_outputFormat;
-  nsCString     m_msgBuffer;
-
-  nsCString     m_contentType;    // used only when saving attachment
+  bool m_doCharsetConversion;
+  nsString m_charset;
+  enum { eUnknown, ePlainText, eHTML } m_outputFormat;
+  nsCString m_msgBuffer;
+
+  nsCString m_contentType;  // used only when saving attachment
 
   nsCOMPtr<nsITransfer> mTransfer;
   nsCOMPtr<nsIUrlListener> mListener;
   nsCOMPtr<nsIURI> mListenerUri;
   int64_t mProgress;
   int64_t mMaxProgress;
-  bool    mCanceled;
-  bool    mInitialized;
-  bool    mUrlHasStopped;
-  bool    mRequestHasStopped;
-  nsresult InitializeDownload(nsIRequest * aRequest);
-
-private:
+  bool mCanceled;
+  bool mInitialized;
+  bool mUrlHasStopped;
+  bool mRequestHasStopped;
+  nsresult InitializeDownload(nsIRequest *aRequest);
+
+ private:
   virtual ~nsSaveMsgListener();
 };
 
-class nsSaveAllAttachmentsState
-{
+class nsSaveAllAttachmentsState {
   using PathChar = mozilla::filesystem::Path::value_type;
-public:
-  nsSaveAllAttachmentsState(uint32_t count,
-                            const char **contentTypeArray,
+
+ public:
+  nsSaveAllAttachmentsState(uint32_t count, const char **contentTypeArray,
                             const char **urlArray,
                             const char **displayNameArray,
                             const char **messageUriArray,
                             const PathChar *directoryName,
                             bool detachingAttachments);
   virtual ~nsSaveAllAttachmentsState();
 
   uint32_t m_count;
   uint32_t m_curIndex;
-  PathChar* m_directoryName;
-  char** m_contentTypeArray;
-  char** m_urlArray;
-  char** m_displayNameArray;
-  char** m_messageUriArray;
+  PathChar *m_directoryName;
+  char **m_contentTypeArray;
+  char **m_urlArray;
+  char **m_displayNameArray;
+  char **m_messageUriArray;
   bool m_detachingAttachments;
 
   // if detaching, do without warning? Will create unique files instead of
-  //  prompting if duplicate files exist.
+  // prompting if duplicate files exist.
   bool m_withoutWarning;
-  nsTArray<nsCString> m_savedFiles; // if detaching first, remember where we saved to.
+  // if detaching first, remember where we saved to.
+  nsTArray<nsCString> m_savedFiles;
 };
 
 //
 // nsMessenger
 //
-nsMessenger::nsMessenger()
-{
-  mCurHistoryPos = -2; // first message selected goes at position 0.
+nsMessenger::nsMessenger() {
+  mCurHistoryPos = -2;  // first message selected goes at position 0.
   //  InitializeFolderRoot();
 }
 
-nsMessenger::~nsMessenger()
-{
-}
-
-
-NS_IMPL_ISUPPORTS(nsMessenger, nsIMessenger, nsISupportsWeakReference, nsIFolderListener)
-
-NS_IMETHODIMP nsMessenger::SetWindow(mozIDOMWindowProxy *aWin, nsIMsgWindow *aMsgWindow)
-{
+nsMessenger::~nsMessenger() {}
+
+NS_IMPL_ISUPPORTS(nsMessenger, nsIMessenger, nsISupportsWeakReference,
+                  nsIFolderListener)
+
+NS_IMETHODIMP nsMessenger::SetWindow(mozIDOMWindowProxy *aWin,
+                                     nsIMsgWindow *aMsgWindow) {
   nsresult rv;
 
   nsCOMPtr<nsIMsgMailSession> mailSession =
-    do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (aWin)
-  {
+  if (aWin) {
     mMsgWindow = aMsgWindow;
     mWindow = aWin;
 
     rv = mailSession->AddFolderListener(this, nsIFolderListener::removed);
     NS_ENSURE_SUCCESS(rv, rv);
 
     NS_ENSURE_TRUE(aWin, NS_ERROR_FAILURE);
     nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(aWin);
@@ -241,161 +235,148 @@ NS_IMETHODIMP nsMessenger::SetWindow(moz
     nsIDocShell *docShell = win->GetDocShell();
     nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(docShell);
     NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIDocShellTreeItem> rootDocShellAsItem;
     docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootDocShellAsItem));
 
     nsCOMPtr<nsIDocShellTreeItem> childAsItem;
-    rv = rootDocShellAsItem->FindChildWithName(NS_LITERAL_STRING("messagepane"), true, false,
-                                               nullptr, nullptr, getter_AddRefs(childAsItem));
+    rv = rootDocShellAsItem->FindChildWithName(NS_LITERAL_STRING("messagepane"),
+                                               true, false, nullptr, nullptr,
+                                               getter_AddRefs(childAsItem));
 
     mDocShell = do_QueryInterface(childAsItem);
     if (NS_SUCCEEDED(rv) && mDocShell) {
-      mCurrentDisplayCharset = ""; // Important! Clear out mCurrentDisplayCharset so we reset a default charset on mDocshell the next time we try to load something into it.
+      // Important! Clear out mCurrentDisplayCharset so we reset a default
+      // charset on mDocshell the next time we try to load something into it.
+      mCurrentDisplayCharset = "";
 
       if (aMsgWindow)
         aMsgWindow->GetTransactionManager(getter_AddRefs(mTxnMgr));
     }
 
     // we don't always have a message pane, like in the addressbook
     // so if we don't have a docshell, use the one for the xul window.
     // we do this so OpenURL() will work.
-    if (!mDocShell)
-      mDocShell = docShell;
-  } // if aWin
-  else
-  {
+    if (!mDocShell) mDocShell = docShell;
+  }  // if aWin
+  else {
     // Remove the folder listener if we added it, i.e. if mWindow is non-null
-    if (mWindow)
-    {
+    if (mWindow) {
       rv = mailSession->RemoveFolderListener(this);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     mWindow = nullptr;
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMessenger::SetDisplayCharset(const nsACString& aCharset)
-{
+NS_IMETHODIMP nsMessenger::SetDisplayCharset(const nsACString &aCharset) {
   // libmime always converts to UTF-8 (both HTML and XML)
-  if (mDocShell)
-  {
+  if (mDocShell) {
     nsCOMPtr<nsIContentViewer> cv;
     mDocShell->GetContentViewer(getter_AddRefs(cv));
-    if (cv)
-    {
+    if (cv) {
       cv->SetHintCharacterSet(aCharset);
       cv->SetHintCharacterSetSource(kCharsetFromChannel);
 
       mCurrentDisplayCharset = aCharset;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(nsMessenger::nsFilePickerShownCallback,
                   nsIFilePickerShownCallback)
-nsMessenger::nsFilePickerShownCallback::nsFilePickerShownCallback()
-{
+nsMessenger::nsFilePickerShownCallback::nsFilePickerShownCallback() {
   mPickerDone = false;
 }
 
 NS_IMETHODIMP
-nsMessenger::nsFilePickerShownCallback::Done(int16_t aResult)
-{
+nsMessenger::nsFilePickerShownCallback::Done(int16_t aResult) {
   mResult = aResult;
   mPickerDone = true;
   return NS_OK;
 }
 
-nsresult nsMessenger::ShowPicker(nsIFilePicker *aPicker, int16_t *aResult)
-{
+nsresult nsMessenger::ShowPicker(nsIFilePicker *aPicker, int16_t *aResult) {
   nsCOMPtr<nsIFilePickerShownCallback> callback =
-    new nsMessenger::nsFilePickerShownCallback();
+      new nsMessenger::nsFilePickerShownCallback();
   nsFilePickerShownCallback *cb =
-    static_cast<nsFilePickerShownCallback*>(callback.get());
+      static_cast<nsFilePickerShownCallback *>(callback.get());
 
   nsresult rv;
   rv = aPicker->Open(callback);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Spin the event loop until the callback was called.
   nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
   while (!cb->mPickerDone) {
     NS_ProcessPendingEvents(thread);
   }
 
   *aResult = cb->mResult;
   return NS_OK;
 }
 
-nsresult
-nsMessenger::PromptIfFileExists(nsIFile *file)
-{
+nsresult nsMessenger::PromptIfFileExists(nsIFile *file) {
   nsresult rv = NS_ERROR_FAILURE;
   bool exists;
   file->Exists(&exists);
-  if (!exists)
-    return NS_OK;
+  if (!exists) return NS_OK;
 
   nsCOMPtr<nsIPrompt> dialog(do_GetInterface(mDocShell));
   if (!dialog) return rv;
   nsAutoString path;
   bool dialogResult = false;
   nsString errorMessage;
 
   file->GetPath(path);
-  const char16_t *pathFormatStrings[] = { path.get() };
-
-  if (!mStringBundle)
-  {
+  const char16_t *pathFormatStrings[] = {path.get()};
+
+  if (!mStringBundle) {
     rv = InitStringBundle();
     NS_ENSURE_SUCCESS(rv, rv);
   }
-  rv = mStringBundle->FormatStringFromName("fileExists",
-                                           pathFormatStrings, 1,
+  rv = mStringBundle->FormatStringFromName("fileExists", pathFormatStrings, 1,
                                            errorMessage);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = dialog->Confirm(nullptr, errorMessage.get(), &dialogResult);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (dialogResult)
-    return NS_OK; // user says okay to replace
+  if (dialogResult) return NS_OK;  // user says okay to replace
 
   // if we don't re-init the path for redisplay the picker will
   // show the full path, not just the file name
-  nsCOMPtr<nsIFile> currentFile = do_CreateInstance("@mozilla.org/file/local;1");
+  nsCOMPtr<nsIFile> currentFile =
+      do_CreateInstance("@mozilla.org/file/local;1");
   if (!currentFile) return NS_ERROR_FAILURE;
 
   rv = currentFile->InitWithPath(path);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoString leafName;
   currentFile->GetLeafName(leafName);
   if (!leafName.IsEmpty())
-    path.Assign(leafName); // path should be a copy of leafName
+    path.Assign(leafName);  // path should be a copy of leafName
 
   nsCOMPtr<nsIFilePicker> filePicker =
-    do_CreateInstance("@mozilla.org/filepicker;1", &rv);
+      do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsString saveAttachmentStr;
   GetString(NS_LITERAL_STRING("SaveAttachment"), saveAttachmentStr);
-  filePicker->Init(mWindow,
-                   saveAttachmentStr,
-                   nsIFilePicker::modeSave);
+  filePicker->Init(mWindow, saveAttachmentStr, nsIFilePicker::modeSave);
   filePicker->SetDefaultString(path);
   filePicker->AppendFilters(nsIFilePicker::filterAll);
 
-  nsCOMPtr <nsIFile> lastSaveDir;
+  nsCOMPtr<nsIFile> lastSaveDir;
   rv = GetLastSaveDirectory(getter_AddRefs(lastSaveDir));
   if (NS_SUCCEEDED(rv) && lastSaveDir) {
     filePicker->SetDisplayDirectory(lastSaveDir);
   }
 
   int16_t dialogReturn;
   rv = ShowPicker(filePicker, &dialogReturn);
   if (NS_FAILED(rv) || dialogReturn == nsIFilePicker::returnCancel) {
@@ -407,637 +388,587 @@ nsMessenger::PromptIfFileExists(nsIFile 
   }
 
   nsCOMPtr<nsIFile> localFile;
 
   rv = filePicker->GetFile(getter_AddRefs(localFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = SetLastSaveDirectory(localFile);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // reset the file to point to the new path
   return file->InitWithFile(localFile);
 }
 
 NS_IMETHODIMP
-nsMessenger::AddMsgUrlToNavigateHistory(const nsACString& aURL)
-{
+nsMessenger::AddMsgUrlToNavigateHistory(const nsACString &aURL) {
   // mNavigatingToUri is set to a url if we're already doing a back/forward,
   // in which case we don't want to add the url to the history list.
-  // Or if the entry at the cur history pos is the same as what we're loading, don't
-  // add it to the list.
-  if (!mNavigatingToUri.Equals(aURL) && (mCurHistoryPos < 0 || !mLoadedMsgHistory[mCurHistoryPos].Equals(aURL)))
-  {
+  // Or if the entry at the cur history pos is the same as what we're loading,
+  // don't add it to the list.
+  if (!mNavigatingToUri.Equals(aURL) &&
+      (mCurHistoryPos < 0 || !mLoadedMsgHistory[mCurHistoryPos].Equals(aURL))) {
     mNavigatingToUri = aURL;
     nsCString curLoadedFolderUri;
-    nsCOMPtr <nsIMsgFolder> curLoadedFolder;
+    nsCOMPtr<nsIMsgFolder> curLoadedFolder;
 
     mMsgWindow->GetOpenFolder(getter_AddRefs(curLoadedFolder));
     // for virtual folders, we want to select the right folder,
     // which isn't the same as the folder specified in the msg uri.
     // So add the uri for the currently loaded folder to the history list.
-    if (curLoadedFolder)
-      curLoadedFolder->GetURI(curLoadedFolderUri);
+    if (curLoadedFolder) curLoadedFolder->GetURI(curLoadedFolderUri);
 
     mLoadedMsgHistory.InsertElementAt(mCurHistoryPos++ + 2, mNavigatingToUri);
     mLoadedMsgHistory.InsertElementAt(mCurHistoryPos++ + 2, curLoadedFolderUri);
     // we may want to prune this history if it gets large, but I think it's
     // more interesting to prune the back and forward menu.
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessenger::OpenURL(const nsACString& aURL)
-{
+nsMessenger::OpenURL(const nsACString &aURL) {
   // This is to setup the display DocShell as UTF-8 capable...
   SetDisplayCharset(NS_LITERAL_CSTRING("UTF-8"));
 
-  nsCOMPtr <nsIMsgMessageService> messageService;
+  nsCOMPtr<nsIMsgMessageService> messageService;
   nsresult rv = GetMessageServiceFromURI(aURL, getter_AddRefs(messageService));
 
-  if (NS_SUCCEEDED(rv) && messageService)
-  {
+  if (NS_SUCCEEDED(rv) && messageService) {
     nsCOMPtr<nsIURI> dummyNull;
     messageService->DisplayMessage(PromiseFlatCString(aURL).get(), mDocShell,
-        mMsgWindow, nullptr, nullptr, getter_AddRefs(dummyNull));
+                                   mMsgWindow, nullptr, nullptr,
+                                   getter_AddRefs(dummyNull));
     AddMsgUrlToNavigateHistory(aURL);
-    mLastDisplayURI = aURL; // remember the last uri we displayed....
+    mLastDisplayURI = aURL;  // remember the last uri we displayed....
     return NS_OK;
   }
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
-  if(!webNav)
-    return NS_ERROR_FAILURE;
+  if (!webNav) return NS_ERROR_FAILURE;
   mozilla::dom::LoadURIOptions loadURIOptions;
   loadURIOptions.mLoadFlags = nsIWebNavigation::LOAD_FLAGS_IS_LINK;
   loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
   rv = webNav->LoadURI(NS_ConvertASCIItoUTF16(aURL), loadURIOptions);
   return rv;
 }
 
-NS_IMETHODIMP nsMessenger::LaunchExternalURL(const nsACString& aURL)
-{
+NS_IMETHODIMP nsMessenger::LaunchExternalURL(const nsACString &aURL) {
   nsresult rv;
 
   nsCOMPtr<nsIURI> uri;
   rv = NS_NewURI(getter_AddRefs(uri), PromiseFlatCString(aURL).get());
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIExternalProtocolService> extProtService = do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIExternalProtocolService> extProtService =
+      do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   return extProtService->LoadURI(uri, nullptr);
 }
 
 NS_IMETHODIMP
-nsMessenger::LoadURL(mozIDOMWindowProxy *aWin, const nsACString& aURL)
-{
+nsMessenger::LoadURL(mozIDOMWindowProxy *aWin, const nsACString &aURL) {
   nsresult rv;
 
   SetDisplayCharset(NS_LITERAL_CSTRING("UTF-8"));
 
   NS_ConvertASCIItoUTF16 uriString(aURL);
   // Cleanup the empty spaces that might be on each end.
   uriString.Trim(" ");
   // Eliminate embedded newlines, which single-line text fields now allow:
   uriString.StripChars("\r\n");
   NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE);
 
   bool loadingFromFile = false;
   bool getDummyMsgHdr = false;
   int64_t fileSize;
 
-  if (StringBeginsWith(uriString, NS_LITERAL_STRING("file:")))
-  {
+  if (StringBeginsWith(uriString, NS_LITERAL_STRING("file:"))) {
     nsCOMPtr<nsIURI> fileUri;
     rv = NS_NewURI(getter_AddRefs(fileUri), uriString);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr <nsIFileURL> fileUrl = do_QueryInterface(fileUri, &rv);
+    nsCOMPtr<nsIFileURL> fileUrl = do_QueryInterface(fileUri, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr <nsIFile> file;
+    nsCOMPtr<nsIFile> file;
     rv = fileUrl->GetFile(getter_AddRefs(file));
     NS_ENSURE_SUCCESS(rv, rv);
     file->GetFileSize(&fileSize);
     uriString.Replace(0, 5, NS_LITERAL_STRING("mailbox:"));
     uriString.AppendLiteral(u"&number=0");
     loadingFromFile = true;
     getDummyMsgHdr = true;
-  }
-  else if (StringBeginsWith(uriString, NS_LITERAL_STRING("mailbox:")) &&
-           (CaseInsensitiveFindInReadable(NS_LITERAL_STRING(".eml?"), uriString)))
-  {
+  } else if (StringBeginsWith(uriString, NS_LITERAL_STRING("mailbox:")) &&
+             (CaseInsensitiveFindInReadable(NS_LITERAL_STRING(".eml?"),
+                                            uriString))) {
     // if we have a mailbox:// url that points to an .eml file, we have to read
     // the file size as well
     uriString.Replace(0, 8, NS_LITERAL_STRING("file:"));
     nsCOMPtr<nsIURI> fileUri;
     rv = NS_NewURI(getter_AddRefs(fileUri), uriString);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr <nsIFileURL> fileUrl = do_QueryInterface(fileUri, &rv);
+    nsCOMPtr<nsIFileURL> fileUrl = do_QueryInterface(fileUri, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr <nsIFile> file;
+    nsCOMPtr<nsIFile> file;
     rv = fileUrl->GetFile(getter_AddRefs(file));
     NS_ENSURE_SUCCESS(rv, rv);
     file->GetFileSize(&fileSize);
     uriString.Replace(0, 5, NS_LITERAL_STRING("mailbox:"));
     loadingFromFile = true;
     getDummyMsgHdr = true;
-  }
-  else if (uriString.Find("type=application/x-message-display") >= 0)
+  } else if (uriString.Find("type=application/x-message-display") >= 0)
     getDummyMsgHdr = true;
 
   nsCOMPtr<nsIURI> uri;
   rv = NS_NewURI(getter_AddRefs(uri), uriString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
   nsCOMPtr<nsIMsgMailNewsUrl> msgurl = do_QueryInterface(uri);
-  if (msgurl)
-  {
+  if (msgurl) {
     msgurl->SetMsgWindow(mMsgWindow);
-    if (loadingFromFile || getDummyMsgHdr)
-    {
-      if (loadingFromFile)
-      {
-        nsCOMPtr <nsIMailboxUrl> mailboxUrl = do_QueryInterface(msgurl, &rv);
-        mailboxUrl->SetMessageSize((uint32_t) fileSize);
+    if (loadingFromFile || getDummyMsgHdr) {
+      if (loadingFromFile) {
+        nsCOMPtr<nsIMailboxUrl> mailboxUrl = do_QueryInterface(msgurl, &rv);
+        mailboxUrl->SetMessageSize((uint32_t)fileSize);
       }
-      if (getDummyMsgHdr)
-      {
-        nsCOMPtr <nsIMsgHeaderSink> headerSink;
-         // need to tell the header sink to capture some headers to create a fake db header
-         // so we can do reply to a .eml file or a rfc822 msg attachment.
+      if (getDummyMsgHdr) {
+        nsCOMPtr<nsIMsgHeaderSink> headerSink;
+        // need to tell the header sink to capture some headers to create a fake
+        // db header so we can do reply to a .eml file or a rfc822 msg
+        // attachment.
         mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));
-        if (headerSink)
-        {
-          nsCOMPtr <nsIMsgDBHdr> dummyHeader;
+        if (headerSink) {
+          nsCOMPtr<nsIMsgDBHdr> dummyHeader;
           headerSink->GetDummyMsgHeader(getter_AddRefs(dummyHeader));
           if (dummyHeader && loadingFromFile)
-            dummyHeader->SetMessageSize((uint32_t) fileSize);
+            dummyHeader->SetMessageSize((uint32_t)fileSize);
         }
       }
     }
   }
 
   AddMsgUrlToNavigateHistory(aURL);
   mNavigatingToUri.Truncate();
-  mLastDisplayURI = aURL; // Remember the last uri we displayed.
+  mLastDisplayURI = aURL;  // Remember the last uri we displayed.
   RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(uri);
   loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
   loadState->SetFirstParty(true);
   loadState->SetTriggeringPrincipal(nsContentUtils::GetSystemPrincipal());
   return mDocShell->LoadURI(loadState);
 }
 
 NS_IMETHODIMP nsMessenger::SaveAttachmentToFile(nsIFile *aFile,
                                                 const nsACString &aURL,
                                                 const nsACString &aMessageUri,
                                                 const nsACString &aContentType,
-                                                nsIUrlListener *aListener)
-{
-  return SaveAttachment(aFile, aURL, aMessageUri, aContentType, nullptr, aListener);
+                                                nsIUrlListener *aListener) {
+  return SaveAttachment(aFile, aURL, aMessageUri, aContentType, nullptr,
+                        aListener);
 }
 
 NS_IMETHODIMP
-nsMessenger::DetachAttachmentsWOPrompts(nsIFile* aDestFolder,
-                                        uint32_t aCount,
+nsMessenger::DetachAttachmentsWOPrompts(nsIFile *aDestFolder, uint32_t aCount,
                                         const char **aContentTypeArray,
                                         const char **aUrlArray,
                                         const char **aDisplayNameArray,
                                         const char **aMessageUriArray,
-                                        nsIUrlListener *aListener)
-{
+                                        nsIUrlListener *aListener) {
   NS_ENSURE_ARG_POINTER(aDestFolder);
   NS_ENSURE_ARG_POINTER(aContentTypeArray);
   NS_ENSURE_ARG_POINTER(aUrlArray);
   NS_ENSURE_ARG_POINTER(aMessageUriArray);
   NS_ENSURE_ARG_POINTER(aDisplayNameArray);
-  if (!aCount)
-    return NS_OK;
+  if (!aCount) return NS_OK;
   nsSaveAllAttachmentsState *saveState;
   nsCOMPtr<nsIFile> attachmentDestination;
   nsresult rv = aDestFolder->Clone(getter_AddRefs(attachmentDestination));
   NS_ENSURE_SUCCESS(rv, rv);
 
   PathString path = attachmentDestination->NativePath();
 
   nsAutoString unescapedFileName;
   ConvertAndSanitizeFileName(aDisplayNameArray[0], unescapedFileName);
   rv = attachmentDestination->Append(unescapedFileName);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE, ATTACHMENT_PERMISSION);
+  rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE,
+                                           ATTACHMENT_PERMISSION);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  saveState = new nsSaveAllAttachmentsState(aCount,
-                                            aContentTypeArray,
-                                            aUrlArray,
-                                            aDisplayNameArray,
-                                            aMessageUriArray,
-                                            path.get(),
-                                            true);
+  saveState = new nsSaveAllAttachmentsState(aCount, aContentTypeArray,
+                                            aUrlArray, aDisplayNameArray,
+                                            aMessageUriArray, path.get(), true);
 
   // This method is used in filters, where we don't want to warn
   saveState->m_withoutWarning = true;
-  rv = SaveAttachment(attachmentDestination,
-                      nsDependentCString(aUrlArray[0]),
+  rv = SaveAttachment(attachmentDestination, nsDependentCString(aUrlArray[0]),
                       nsDependentCString(aMessageUriArray[0]),
                       nsDependentCString(aContentTypeArray[0]),
-                      (void *)saveState,
-                      aListener);
+                      (void *)saveState, aListener);
   return rv;
 }
 
-nsresult nsMessenger::SaveAttachment(nsIFile *aFile,
-                                     const nsACString &aURL,
+nsresult nsMessenger::SaveAttachment(nsIFile *aFile, const nsACString &aURL,
                                      const nsACString &aMessageUri,
                                      const nsACString &aContentType,
-                                     void *closure,
-                                     nsIUrlListener *aListener)
-{
+                                     void *closure, nsIUrlListener *aListener) {
   nsCOMPtr<nsIMsgMessageService> messageService;
-  nsSaveAllAttachmentsState *saveState= (nsSaveAllAttachmentsState*) closure;
+  nsSaveAllAttachmentsState *saveState = (nsSaveAllAttachmentsState *)closure;
   nsCOMPtr<nsIMsgMessageFetchPartService> fetchService;
   nsAutoCString urlString;
   nsAutoCString fullMessageUri(aMessageUri);
 
   // This instance will be held onto by the listeners, and will be released once
   // the transfer has been completed.
-  RefPtr<nsSaveMsgListener> saveListener(new nsSaveMsgListener(aFile, this, aListener));
+  RefPtr<nsSaveMsgListener> saveListener(
+      new nsSaveMsgListener(aFile, this, aListener));
 
   saveListener->m_contentType = aContentType;
-  if (saveState)
-  {
+  if (saveState) {
     saveListener->m_saveAllAttachmentsState = saveState;
-    if (saveState->m_detachingAttachments)
-    {
+    if (saveState->m_detachingAttachments) {
       nsCOMPtr<nsIURI> outputURI;
       nsresult rv = NS_NewFileURI(getter_AddRefs(outputURI), aFile);
       NS_ENSURE_SUCCESS(rv, rv);
       nsAutoCString fileUriSpec;
       rv = outputURI->GetSpec(fileUriSpec);
       NS_ENSURE_SUCCESS(rv, rv);
       saveState->m_savedFiles.AppendElement(fileUriSpec);
     }
   }
 
   urlString = aURL;
   // strip out ?type=application/x-message-display because it confuses libmime
 
   int32_t typeIndex = urlString.Find("?type=application/x-message-display");
-  if (typeIndex != kNotFound)
-  {
+  if (typeIndex != kNotFound) {
     urlString.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1);
     // we also need to replace the next '&' with '?'
     int32_t firstPartIndex = urlString.FindChar('&');
-    if (firstPartIndex != kNotFound)
-      urlString.SetCharAt('?', firstPartIndex);
+    if (firstPartIndex != kNotFound) urlString.SetCharAt('?', firstPartIndex);
   }
 
   MsgReplaceSubstring(urlString, "/;section", "?section");
   nsCOMPtr<nsIURI> URL;
   nsresult rv = NS_NewURI(getter_AddRefs(URL), urlString);
 
-  if (NS_SUCCEEDED(rv))
-  {
+  if (NS_SUCCEEDED(rv)) {
     rv = GetMessageServiceFromURI(aMessageUri, getter_AddRefs(messageService));
-    if (NS_SUCCEEDED(rv))
-    {
+    if (NS_SUCCEEDED(rv)) {
       fetchService = do_QueryInterface(messageService);
-      // if the message service has a fetch part service then we know we can fetch mime parts...
-      if (fetchService)
-      {
+      // if the message service has a fetch part service then we know we can
+      // fetch mime parts...
+      if (fetchService) {
         int32_t partPos = urlString.FindChar('?');
-        if (partPos == kNotFound)
-          return NS_ERROR_FAILURE;
+        if (partPos == kNotFound) return NS_ERROR_FAILURE;
         fullMessageUri.Append(Substring(urlString, partPos));
       }
 
       nsCOMPtr<nsIStreamListener> convertedListener;
       saveListener->QueryInterface(NS_GET_IID(nsIStreamListener),
-                                 getter_AddRefs(convertedListener));
+                                   getter_AddRefs(convertedListener));
 
       nsCOMPtr<nsIURI> dummyNull;
       if (fetchService)
-        rv = fetchService->FetchMimePart(URL, fullMessageUri.get(),
-                                         convertedListener, mMsgWindow,
-                                         saveListener, getter_AddRefs(dummyNull));
+        rv = fetchService->FetchMimePart(
+            URL, fullMessageUri.get(), convertedListener, mMsgWindow,
+            saveListener, getter_AddRefs(dummyNull));
       else
-        rv = messageService->DisplayMessage(fullMessageUri.get(),
-                                            convertedListener, mMsgWindow,
-                                            nullptr, nullptr,
-                                            getter_AddRefs(dummyNull));
-    } // if we got a message service
-  } // if we created a url
-
-  if (NS_FAILED(rv))
-    Alert("saveAttachmentFailed");
+        rv = messageService->DisplayMessage(
+            fullMessageUri.get(), convertedListener, mMsgWindow, nullptr,
+            nullptr, getter_AddRefs(dummyNull));
+    }  // if we got a message service
+  }    // if we created a url
+
+  if (NS_FAILED(rv)) Alert("saveAttachmentFailed");
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::OpenAttachment(const nsACString& aContentType, const nsACString& aURL,
-                            const nsACString& aDisplayName, const nsACString& aMessageUri, bool aIsExternalAttachment)
-{
+nsMessenger::OpenAttachment(const nsACString &aContentType,
+                            const nsACString &aURL,
+                            const nsACString &aDisplayName,
+                            const nsACString &aMessageUri,
+                            bool aIsExternalAttachment) {
   nsresult rv = NS_OK;
 
-  // open external attachments inside our message pane which in turn should trigger the
-  // helper app dialog...
+  // open external attachments inside our message pane which in turn should
+  // trigger the helper app dialog...
   if (aIsExternalAttachment)
     rv = OpenURL(aURL);
-  else
-  {
-    nsCOMPtr <nsIMsgMessageService> messageService;
+  else {
+    nsCOMPtr<nsIMsgMessageService> messageService;
     rv = GetMessageServiceFromURI(aMessageUri, getter_AddRefs(messageService));
     if (messageService)
-      rv = messageService->OpenAttachment(PromiseFlatCString(aContentType).get(), PromiseFlatCString(aDisplayName).get(),
-                                          PromiseFlatCString(aURL).get(), PromiseFlatCString(aMessageUri).get(),
-                                          mDocShell, mMsgWindow, nullptr);
+      rv = messageService->OpenAttachment(
+          PromiseFlatCString(aContentType).get(),
+          PromiseFlatCString(aDisplayName).get(),
+          PromiseFlatCString(aURL).get(), PromiseFlatCString(aMessageUri).get(),
+          mDocShell, mMsgWindow, nullptr);
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::SaveAttachmentToFolder(const nsACString& contentType, const nsACString& url, const nsACString& displayName,
-                                    const nsACString& messageUri, nsIFile * aDestFolder, nsIFile ** aOutFile)
-{
+nsMessenger::SaveAttachmentToFolder(const nsACString &contentType,
+                                    const nsACString &url,
+                                    const nsACString &displayName,
+                                    const nsACString &messageUri,
+                                    nsIFile *aDestFolder, nsIFile **aOutFile) {
   NS_ENSURE_ARG_POINTER(aDestFolder);
   nsresult rv;
 
   nsCOMPtr<nsIFile> attachmentDestination;
   rv = aDestFolder->Clone(getter_AddRefs(attachmentDestination));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString unescapedFileName;
-  ConvertAndSanitizeFileName(PromiseFlatCString(displayName).get(), unescapedFileName);
+  ConvertAndSanitizeFileName(PromiseFlatCString(displayName).get(),
+                             unescapedFileName);
   rv = attachmentDestination->Append(unescapedFileName);
   NS_ENSURE_SUCCESS(rv, rv);
 #ifdef XP_MACOSX
-  rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE, ATTACHMENT_PERMISSION);
+  rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE,
+                                           ATTACHMENT_PERMISSION);
   NS_ENSURE_SUCCESS(rv, rv);
 #endif
 
-  rv = SaveAttachment(attachmentDestination, url, messageUri, contentType, nullptr, nullptr);
+  rv = SaveAttachment(attachmentDestination, url, messageUri, contentType,
+                      nullptr, nullptr);
   attachmentDestination.forget(aOutFile);
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::SaveAttachment(const nsACString& aContentType, const nsACString& aURL,
-                            const nsACString& aDisplayName, const nsACString& aMessageUri, bool aIsExternalAttachment)
-{
-  // open external attachments inside our message pane which in turn should trigger the
-  // helper app dialog...
-  if (aIsExternalAttachment)
-    return OpenURL(aURL);
+nsMessenger::SaveAttachment(const nsACString &aContentType,
+                            const nsACString &aURL,
+                            const nsACString &aDisplayName,
+                            const nsACString &aMessageUri,
+                            bool aIsExternalAttachment) {
+  // open external attachments inside our message pane which in turn should
+  // trigger the helper app dialog...
+  if (aIsExternalAttachment) return OpenURL(aURL);
   return SaveOneAttachment(PromiseFlatCString(aContentType).get(),
                            PromiseFlatCString(aURL).get(),
                            PromiseFlatCString(aDisplayName).get(),
-                           PromiseFlatCString(aMessageUri).get(),
-                           false);
+                           PromiseFlatCString(aMessageUri).get(), false);
 }
 
-nsresult
-nsMessenger::SaveOneAttachment(const char * aContentType, const char * aURL,
-                               const char * aDisplayName, const char * aMessageUri,
-                               bool detaching)
-{
+nsresult nsMessenger::SaveOneAttachment(const char *aContentType,
+                                        const char *aURL,
+                                        const char *aDisplayName,
+                                        const char *aMessageUri,
+                                        bool detaching) {
   nsresult rv = NS_ERROR_OUT_OF_MEMORY;
   nsCOMPtr<nsIFilePicker> filePicker =
       do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   int16_t dialogResult;
   nsCOMPtr<nsIFile> localFile;
   nsCOMPtr<nsIFile> lastSaveDir;
   nsCString filePath;
   nsString saveAttachmentStr;
   nsString defaultDisplayString;
   ConvertAndSanitizeFileName(aDisplayName, defaultDisplayString);
 
   if (detaching) {
     GetString(NS_LITERAL_STRING("DetachAttachment"), saveAttachmentStr);
-  }
-  else {
+  } else {
     GetString(NS_LITERAL_STRING("SaveAttachment"), saveAttachmentStr);
   }
-  filePicker->Init(mWindow, saveAttachmentStr,
-                   nsIFilePicker::modeSave);
+  filePicker->Init(mWindow, saveAttachmentStr, nsIFilePicker::modeSave);
   filePicker->SetDefaultString(defaultDisplayString);
 
   // Check if the attachment file name has an extension (which must not
   // contain spaces) and set it as the default extension for the attachment.
   int32_t extensionIndex = defaultDisplayString.RFindChar('.');
   if (extensionIndex > 0 &&
-      defaultDisplayString.FindChar(' ', extensionIndex) == kNotFound)
-  {
+      defaultDisplayString.FindChar(' ', extensionIndex) == kNotFound) {
     nsString extension;
     extension = Substring(defaultDisplayString, extensionIndex + 1);
     filePicker->SetDefaultExtension(extension);
-    if (!mStringBundle)
-    {
+    if (!mStringBundle) {
       rv = InitStringBundle();
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     nsString filterName;
-    const char16_t *extensionParam[] = { extension.get() };
-    rv = mStringBundle->FormatStringFromName(
-      "saveAsType", extensionParam, 1, filterName);
+    const char16_t *extensionParam[] = {extension.get()};
+    rv = mStringBundle->FormatStringFromName("saveAsType", extensionParam, 1,
+                                             filterName);
     NS_ENSURE_SUCCESS(rv, rv);
 
     extension.InsertLiteral(u"*.", 0);
     filePicker->AppendFilter(filterName, extension);
   }
 
   filePicker->AppendFilters(nsIFilePicker::filterAll);
 
   rv = GetLastSaveDirectory(getter_AddRefs(lastSaveDir));
   if (NS_SUCCEEDED(rv) && lastSaveDir)
     filePicker->SetDisplayDirectory(lastSaveDir);
 
   rv = ShowPicker(filePicker, &dialogResult);
-  if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel)
-    return rv;
+  if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel) return rv;
 
   rv = filePicker->GetFile(getter_AddRefs(localFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   SetLastSaveDirectory(localFile);
 
   PathString dirName = localFile->NativePath();
 
   nsSaveAllAttachmentsState *saveState =
-    new nsSaveAllAttachmentsState(1,
-                                  &aContentType,
-                                  &aURL,
-                                  &aDisplayName,
-                                  &aMessageUri,
-                                  dirName.get(),
-                                  detaching);
-
-  return SaveAttachment(localFile, nsDependentCString(aURL), nsDependentCString(aMessageUri),
-                        nsDependentCString(aContentType), (void *)saveState, nullptr);
+      new nsSaveAllAttachmentsState(1, &aContentType, &aURL, &aDisplayName,
+                                    &aMessageUri, dirName.get(), detaching);
+
+  return SaveAttachment(
+      localFile, nsDependentCString(aURL), nsDependentCString(aMessageUri),
+      nsDependentCString(aContentType), (void *)saveState, nullptr);
 }
 
-
 NS_IMETHODIMP
-nsMessenger::SaveAllAttachments(uint32_t count,
-                                const char **contentTypeArray,
+nsMessenger::SaveAllAttachments(uint32_t count, const char **contentTypeArray,
                                 const char **urlArray,
                                 const char **displayNameArray,
-                                const char **messageUriArray)
-{
-  if (!count)
-    return NS_ERROR_INVALID_ARG;
-  return SaveAllAttachments(count, contentTypeArray, urlArray, displayNameArray, messageUriArray, false);
+                                const char **messageUriArray) {
+  if (!count) return NS_ERROR_INVALID_ARG;
+  return SaveAllAttachments(count, contentTypeArray, urlArray, displayNameArray,
+                            messageUriArray, false);
 }
 
-nsresult
-nsMessenger::SaveAllAttachments(uint32_t count,
-                                const char **contentTypeArray,
-                                const char **urlArray,
-                                const char **displayNameArray,
-                                const char **messageUriArray,
-                                bool detaching)
-{
+nsresult nsMessenger::SaveAllAttachments(uint32_t count,
+                                         const char **contentTypeArray,
+                                         const char **urlArray,
+                                         const char **displayNameArray,
+                                         const char **messageUriArray,
+                                         bool detaching) {
   nsresult rv = NS_ERROR_OUT_OF_MEMORY;
   nsCOMPtr<nsIFilePicker> filePicker =
-    do_CreateInstance("@mozilla.org/filepicker;1", &rv);
+      do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   nsCOMPtr<nsIFile> localFile;
   nsCOMPtr<nsIFile> lastSaveDir;
   int16_t dialogResult;
   nsString saveAttachmentStr;
 
   NS_ENSURE_SUCCESS(rv, rv);
   if (detaching) {
     GetString(NS_LITERAL_STRING("DetachAllAttachments"), saveAttachmentStr);
-  }
-  else {
+  } else {
     GetString(NS_LITERAL_STRING("SaveAllAttachments"), saveAttachmentStr);
   }
-  filePicker->Init(mWindow,
-                   saveAttachmentStr,
-                   nsIFilePicker::modeGetFolder);
+  filePicker->Init(mWindow, saveAttachmentStr, nsIFilePicker::modeGetFolder);
 
   rv = GetLastSaveDirectory(getter_AddRefs(lastSaveDir));
   if (NS_SUCCEEDED(rv) && lastSaveDir)
     filePicker->SetDisplayDirectory(lastSaveDir);
 
   rv = ShowPicker(filePicker, &dialogResult);
-  if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel)
-    return rv;
+  if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel) return rv;
 
   rv = filePicker->GetFile(getter_AddRefs(localFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = SetLastSaveDirectory(localFile);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsSaveAllAttachmentsState *saveState = nullptr;
   PathString dirName = localFile->NativePath();
 
-  saveState = new nsSaveAllAttachmentsState(count,
-                                            contentTypeArray,
-                                            urlArray,
-                                            displayNameArray,
-                                            messageUriArray,
-                                            dirName.get(),
-                                            detaching);
+  saveState = new nsSaveAllAttachmentsState(count, contentTypeArray, urlArray,
+                                            displayNameArray, messageUriArray,
+                                            dirName.get(), detaching);
   nsString unescapedName;
   ConvertAndSanitizeFileName(displayNameArray[0], unescapedName);
   rv = localFile->Append(unescapedName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = PromptIfFileExists(localFile);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = SaveAttachment(localFile, nsDependentCString(urlArray[0]), nsDependentCString(messageUriArray[0]),
-                      nsDependentCString(contentTypeArray[0]), (void *)saveState, nullptr);
+  rv = SaveAttachment(localFile, nsDependentCString(urlArray[0]),
+                      nsDependentCString(messageUriArray[0]),
+                      nsDependentCString(contentTypeArray[0]),
+                      (void *)saveState, nullptr);
   return rv;
 }
 
-enum MESSENGER_SAVEAS_FILE_TYPE
-{
- EML_FILE_TYPE =  0,
- HTML_FILE_TYPE = 1,
- TEXT_FILE_TYPE = 2,
- ANY_FILE_TYPE = 3
+enum MESSENGER_SAVEAS_FILE_TYPE {
+  EML_FILE_TYPE = 0,
+  HTML_FILE_TYPE = 1,
+  TEXT_FILE_TYPE = 2,
+  ANY_FILE_TYPE = 3
 };
 #define HTML_FILE_EXTENSION ".htm"
 #define HTML_FILE_EXTENSION2 ".html"
 #define TEXT_FILE_EXTENSION ".txt"
 
 /**
  * Adjust the file name, removing characters from the middle of the name if
  * the name would otherwise be too long - too long for what file systems
  * usually support.
  */
-nsresult nsMessenger::AdjustFileIfNameTooLong(nsIFile* aFile)
-{
+nsresult nsMessenger::AdjustFileIfNameTooLong(nsIFile *aFile) {
   NS_ENSURE_ARG_POINTER(aFile);
   nsAutoString path;
   nsresult rv = aFile->GetPath(path);
   NS_ENSURE_SUCCESS(rv, rv);
   // Most common file systems have a max filename length of 255. On windows, the
   // total path length is (at least for all practical purposees) limited to 255.
   // Let's just don't allow paths longer than that elsewhere either for
   // simplicity.
   uint32_t MAX = 255;
   if (path.Length() > MAX) {
     nsAutoString leafName;
     rv = aFile->GetLeafName(leafName);
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t pathLengthUpToLeaf = path.Length() - leafName.Length();
-    if (pathLengthUpToLeaf >= MAX - 8) { // want at least 8 chars for name
+    if (pathLengthUpToLeaf >= MAX - 8) {  // want at least 8 chars for name
       return NS_ERROR_FILE_NAME_TOO_LONG;
     }
-    uint32_t x = MAX - pathLengthUpToLeaf; // x = max leaf size
+    uint32_t x = MAX - pathLengthUpToLeaf;  // x = max leaf size
     nsAutoString truncatedLeaf;
-    truncatedLeaf.Append(Substring(leafName, 0, x/2));
+    truncatedLeaf.Append(Substring(leafName, 0, x / 2));
     truncatedLeaf.AppendLiteral("...");
-    truncatedLeaf.Append(Substring(leafName, leafName.Length() - x/2 + 3,
-                                   leafName.Length()));
+    truncatedLeaf.Append(
+        Substring(leafName, leafName.Length() - x / 2 + 3, leafName.Length()));
     rv = aFile->SetLeafName(truncatedLeaf);
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::SaveAs(const nsACString& aURI, bool aAsFile,
-                    nsIMsgIdentity *aIdentity, const nsAString& aMsgFilename,
-                    bool aBypassFilePicker)
-{
+nsMessenger::SaveAs(const nsACString &aURI, bool aAsFile,
+                    nsIMsgIdentity *aIdentity, const nsAString &aMsgFilename,
+                    bool aBypassFilePicker) {
   nsCOMPtr<nsIMsgMessageService> messageService;
   nsCOMPtr<nsIUrlListener> urlListener;
   RefPtr<nsSaveMsgListener> saveListener;
   nsCOMPtr<nsIStreamListener> convertedListener;
   int32_t saveAsFileType = EML_FILE_TYPE;
 
   nsresult rv = GetMessageServiceFromURI(aURI, getter_AddRefs(messageService));
-  if (NS_FAILED(rv))
-    goto done;
-
-  if (aAsFile)
-  {
+  if (NS_FAILED(rv)) goto done;
+
+  if (aAsFile) {
     nsCOMPtr<nsIFile> saveAsFile;
     // show the file picker if BypassFilePicker is not specified (null) or false
     if (!aBypassFilePicker) {
-      rv = GetSaveAsFile(aMsgFilename, &saveAsFileType, getter_AddRefs(saveAsFile));
+      rv = GetSaveAsFile(aMsgFilename, &saveAsFileType,
+                         getter_AddRefs(saveAsFile));
       // A null saveAsFile means that the user canceled the save as
-      if (NS_FAILED(rv) || !saveAsFile)
-        goto done;
-    }
-    else {
+      if (NS_FAILED(rv) || !saveAsFile) goto done;
+    } else {
       saveAsFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
       rv = saveAsFile->InitWithPath(aMsgFilename);
-      if (NS_FAILED(rv))
-        goto done;
+      if (NS_FAILED(rv)) goto done;
       if (StringEndsWith(aMsgFilename, NS_LITERAL_STRING(TEXT_FILE_EXTENSION),
                          nsCaseInsensitiveStringComparator()))
         saveAsFileType = TEXT_FILE_TYPE;
       else if ((StringEndsWith(aMsgFilename,
                                NS_LITERAL_STRING(HTML_FILE_EXTENSION),
                                nsCaseInsensitiveStringComparator())) ||
                (StringEndsWith(aMsgFilename,
                                NS_LITERAL_STRING(HTML_FILE_EXTENSION2),
@@ -1053,284 +984,254 @@ nsMessenger::SaveAs(const nsACString& aU
     rv = PromptIfFileExists(saveAsFile);
     if (NS_FAILED(rv)) {
       goto done;
     }
 
     // After saveListener goes out of scope, the listener will be owned by
     // whoever the listener is registered with, usually a URL.
     saveListener = new nsSaveMsgListener(saveAsFile, this, nullptr);
-    rv = saveListener->QueryInterface(NS_GET_IID(nsIUrlListener), getter_AddRefs(urlListener));
-    if (NS_FAILED(rv))
-      goto done;
-
-    if (saveAsFileType == EML_FILE_TYPE)
-    {
+    rv = saveListener->QueryInterface(NS_GET_IID(nsIUrlListener),
+                                      getter_AddRefs(urlListener));
+    if (NS_FAILED(rv)) goto done;
+
+    if (saveAsFileType == EML_FILE_TYPE) {
       nsCOMPtr<nsIURI> dummyNull;
-      rv = messageService->SaveMessageToDisk(PromiseFlatCString(aURI).get(), saveAsFile, false,
-        urlListener, getter_AddRefs(dummyNull),
-        true, mMsgWindow);
-    }
-    else
-    {
+      rv = messageService->SaveMessageToDisk(
+          PromiseFlatCString(aURI).get(), saveAsFile, false, urlListener,
+          getter_AddRefs(dummyNull), true, mMsgWindow);
+    } else {
       nsAutoCString urlString(aURI);
 
       // we can't go RFC822 to TXT until bug #1775 is fixed
       // so until then, do the HTML to TXT conversion in
       // nsSaveMsgListener::OnStopRequest(), see ConvertBufToPlainText()
       //
       // Setup the URL for a "Save As..." Operation...
       // For now, if this is a save as TEXT operation, then do
       // a "printing" operation
-      if (saveAsFileType == TEXT_FILE_TYPE)
-      {
+      if (saveAsFileType == TEXT_FILE_TYPE) {
         saveListener->m_outputFormat = nsSaveMsgListener::ePlainText;
         saveListener->m_doCharsetConversion = true;
         urlString.AppendLiteral("?header=print");
-      }
-      else
-      {
+      } else {
         saveListener->m_outputFormat = nsSaveMsgListener::eHTML;
         saveListener->m_doCharsetConversion = false;
         urlString.AppendLiteral("?header=saveas");
       }
 
       nsCOMPtr<nsIURI> url;
       rv = NS_NewURI(getter_AddRefs(url), urlString);
       NS_ASSERTION(NS_SUCCEEDED(rv), "NS_NewURI failed");
-      if (NS_FAILED(rv))
-        goto done;
+      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;
 
       saveListener->m_channel = nullptr;
-      rv = NS_NewInputStreamChannel(getter_AddRefs(saveListener->m_channel),
-                                    url,
-                                    nullptr,
-                                    nullPrincipal,
-                                    nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                                    nsIContentPolicy::TYPE_OTHER);
+      rv = NS_NewInputStreamChannel(
+          getter_AddRefs(saveListener->m_channel), url, nullptr, nullPrincipal,
+          nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+          nsIContentPolicy::TYPE_OTHER);
       NS_ASSERTION(NS_SUCCEEDED(rv), "NS_NewChannel failed");
-      if (NS_FAILED(rv))
-        goto done;
-
-      nsCOMPtr<nsIStreamConverterService> streamConverterService = do_GetService("@mozilla.org/streamConverters;1");
-      nsCOMPtr<nsISupports> channelSupport = do_QueryInterface(saveListener->m_channel);
+      if (NS_FAILED(rv)) goto done;
+
+      nsCOMPtr<nsIStreamConverterService> streamConverterService =
+          do_GetService("@mozilla.org/streamConverters;1");
+      nsCOMPtr<nsISupports> channelSupport =
+          do_QueryInterface(saveListener->m_channel);
 
       // we can't go RFC822 to TXT until bug #1775 is fixed
       // so until then, do the HTML to TXT conversion in
       // nsSaveMsgListener::OnStopRequest(), see ConvertBufToPlainText()
-      rv = streamConverterService->AsyncConvertData(MESSAGE_RFC822,
-        TEXT_HTML,
-        saveListener,
-        channelSupport,
-        getter_AddRefs(convertedListener));
+      rv = streamConverterService->AsyncConvertData(
+          MESSAGE_RFC822, TEXT_HTML, saveListener, channelSupport,
+          getter_AddRefs(convertedListener));
       NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncConvertData failed");
-      if (NS_FAILED(rv))
-        goto done;
+      if (NS_FAILED(rv)) goto done;
 
       nsCOMPtr<nsIURI> dummyNull;
-      rv = messageService->DisplayMessage(urlString.get(), convertedListener, mMsgWindow,
-        nullptr, nullptr, getter_AddRefs(dummyNull));
+      rv = messageService->DisplayMessage(urlString.get(), convertedListener,
+                                          mMsgWindow, nullptr, nullptr,
+                                          getter_AddRefs(dummyNull));
     }
-  }
-  else
-  {
+  } else {
     // ** save as Template
-    nsCOMPtr <nsIFile> tmpFile;
-    nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR,
-                                                  "nsmail.tmp",
+    nsCOMPtr<nsIFile> tmpFile;
+    nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, "nsmail.tmp",
                                                   getter_AddRefs(tmpFile));
 
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // For temp file, we should use restrictive 00600 instead of ATTACHMENT_PERMISSION
+    // For temp file, we should use restrictive 00600 instead of
+    // ATTACHMENT_PERMISSION
     rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
     if (NS_FAILED(rv)) goto done;
 
     // The saveListener is owned by whoever we ultimately register the
     // listener with, generally a URL.
     saveListener = new nsSaveMsgListener(tmpFile, this, nullptr);
 
     if (aIdentity)
       rv = aIdentity->GetStationeryFolder(saveListener->m_templateUri);
-    if (NS_FAILED(rv))
-      goto done;
-
-    bool needDummyHeader = StringBeginsWith(saveListener->m_templateUri, NS_LITERAL_CSTRING("mailbox://"));
-    bool canonicalLineEnding = StringBeginsWith(saveListener->m_templateUri, NS_LITERAL_CSTRING("imap://"));
-
-    rv = saveListener->QueryInterface(
-      NS_GET_IID(nsIUrlListener),
-      getter_AddRefs(urlListener));
-    if (NS_FAILED(rv))
-      goto done;
+    if (NS_FAILED(rv)) goto done;
+
+    bool needDummyHeader = StringBeginsWith(saveListener->m_templateUri,
+                                            NS_LITERAL_CSTRING("mailbox://"));
+    bool canonicalLineEnding = StringBeginsWith(saveListener->m_templateUri,
+                                                NS_LITERAL_CSTRING("imap://"));
+
+    rv = saveListener->QueryInterface(NS_GET_IID(nsIUrlListener),
+                                      getter_AddRefs(urlListener));
+    if (NS_FAILED(rv)) goto done;
 
     nsCOMPtr<nsIURI> dummyNull;
-    rv = messageService->SaveMessageToDisk(PromiseFlatCString(aURI).get(), tmpFile,
-      needDummyHeader,
-      urlListener, getter_AddRefs(dummyNull),
-      canonicalLineEnding, mMsgWindow);
+    rv = messageService->SaveMessageToDisk(
+        PromiseFlatCString(aURI).get(), tmpFile, needDummyHeader, urlListener,
+        getter_AddRefs(dummyNull), canonicalLineEnding, mMsgWindow);
   }
 
 done:
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     Alert("saveMessageFailed");
   }
   return rv;
 }
 
-nsresult
-nsMessenger::GetSaveAsFile(const nsAString& aMsgFilename, int32_t *aSaveAsFileType,
-                           nsIFile **aSaveAsFile)
-{
+nsresult nsMessenger::GetSaveAsFile(const nsAString &aMsgFilename,
+                                    int32_t *aSaveAsFileType,
+                                    nsIFile **aSaveAsFile) {
   nsresult rv;
-  nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
+  nsCOMPtr<nsIFilePicker> filePicker =
+      do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsString saveMailAsStr;
   GetString(NS_LITERAL_STRING("SaveMailAs"), saveMailAsStr);
   filePicker->Init(mWindow, saveMailAsStr, nsIFilePicker::modeSave);
 
-  // if we have a non-null filename use it, otherwise use default save message one
-  if (aMsgFilename.IsEmpty())
-  {
+  // if we have a non-null filename use it, otherwise use default save message
+  // one
+  if (aMsgFilename.IsEmpty()) {
     nsString saveMsgStr;
     GetString(NS_LITERAL_STRING("defaultSaveMessageAsFileName"), saveMsgStr);
     filePicker->SetDefaultString(saveMsgStr);
-  }
-  else
-  {
+  } else {
     filePicker->SetDefaultString(aMsgFilename);
   }
 
   // because we will be using GetFilterIndex()
   // we must call AppendFilters() one at a time,
   // in MESSENGER_SAVEAS_FILE_TYPE order
   nsString emlFilesStr;
   GetString(NS_LITERAL_STRING("EMLFiles"), emlFilesStr);
-  filePicker->AppendFilter(emlFilesStr,
-                           NS_LITERAL_STRING("*.eml"));
+  filePicker->AppendFilter(emlFilesStr, NS_LITERAL_STRING("*.eml"));
   filePicker->AppendFilters(nsIFilePicker::filterHTML);
   filePicker->AppendFilters(nsIFilePicker::filterText);
   filePicker->AppendFilters(nsIFilePicker::filterAll);
 
   // Save as the "All Files" file type by default. We want to save as .eml by
   // default, but the filepickers on some platforms don't switch extensions
   // based on the file type selected (bug 508597).
   filePicker->SetFilterIndex(ANY_FILE_TYPE);
   // Yes, this is fine even if we ultimately save as HTML or text. On Windows,
   // this actually is a boolean telling the file picker to automatically add
   // the correct extension depending on the filter. On Mac or Linux this is a
   // no-op.
   filePicker->SetDefaultExtension(NS_LITERAL_STRING("eml"));
 
   int16_t dialogResult;
 
-  nsCOMPtr <nsIFile> lastSaveDir;
+  nsCOMPtr<nsIFile> lastSaveDir;
   rv = GetLastSaveDirectory(getter_AddRefs(lastSaveDir));
   if (NS_SUCCEEDED(rv) && lastSaveDir)
     filePicker->SetDisplayDirectory(lastSaveDir);
 
   nsCOMPtr<nsIFile> localFile;
   rv = ShowPicker(filePicker, &dialogResult);
   NS_ENSURE_SUCCESS(rv, rv);
-  if (dialogResult == nsIFilePicker::returnCancel)
-  {
+  if (dialogResult == nsIFilePicker::returnCancel) {
     // We'll indicate this by setting the outparam to null.
     *aSaveAsFile = nullptr;
     return NS_OK;
   }
 
   rv = filePicker->GetFile(getter_AddRefs(localFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = SetLastSaveDirectory(localFile);
   NS_ENSURE_SUCCESS(rv, rv);
 
   int32_t selectedSaveAsFileType;
   rv = filePicker->GetFilterIndex(&selectedSaveAsFileType);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If All Files was selected, look at the extension
-  if (selectedSaveAsFileType == ANY_FILE_TYPE)
-  {
+  if (selectedSaveAsFileType == ANY_FILE_TYPE) {
     nsAutoString fileName;
     rv = localFile->GetLeafName(fileName);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (StringEndsWith(fileName, NS_LITERAL_STRING(HTML_FILE_EXTENSION),
                        nsCaseInsensitiveStringComparator()) ||
         StringEndsWith(fileName, NS_LITERAL_STRING(HTML_FILE_EXTENSION2),
                        nsCaseInsensitiveStringComparator()))
       *aSaveAsFileType = HTML_FILE_TYPE;
     else if (StringEndsWith(fileName, NS_LITERAL_STRING(TEXT_FILE_EXTENSION),
                             nsCaseInsensitiveStringComparator()))
       *aSaveAsFileType = TEXT_FILE_TYPE;
     else
       // The default is .eml
       *aSaveAsFileType = EML_FILE_TYPE;
-  }
-  else
-  {
+  } else {
     *aSaveAsFileType = selectedSaveAsFileType;
   }
 
-  if (dialogResult == nsIFilePicker::returnReplace)
-  {
+  if (dialogResult == nsIFilePicker::returnReplace) {
     // be extra safe and only delete when the file is really a file
     bool isFile;
     rv = localFile->IsFile(&isFile);
-    if (NS_SUCCEEDED(rv) && isFile)
-    {
+    if (NS_SUCCEEDED(rv) && isFile) {
       rv = localFile->Remove(false /* recursive delete */);
       NS_ENSURE_SUCCESS(rv, rv);
-    }
-    else
-    {
+    } else {
       // We failed, or this isn't a file. We can't do anything about it.
       return NS_ERROR_FAILURE;
     }
   }
 
   *aSaveAsFile = nullptr;
   localFile.forget(aSaveAsFile);
   return NS_OK;
 }
 
 /**
  * Show a Save All dialog allowing the user to pick which folder to save
  * messages to.
  * @param [out] aSaveDir directory to save to. Will be null on cancel.
  */
-nsresult
-nsMessenger::GetSaveToDir(nsIFile **aSaveDir)
-{
+nsresult nsMessenger::GetSaveToDir(nsIFile **aSaveDir) {
   nsresult rv;
   nsCOMPtr<nsIFilePicker> filePicker =
-    do_CreateInstance("@mozilla.org/filepicker;1", &rv);
+      do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString chooseFolderStr;
   GetString(NS_LITERAL_STRING("ChooseFolder"), chooseFolderStr);
   filePicker->Init(mWindow, chooseFolderStr, nsIFilePicker::modeGetFolder);
 
   nsCOMPtr<nsIFile> lastSaveDir;
   rv = GetLastSaveDirectory(getter_AddRefs(lastSaveDir));
   if (NS_SUCCEEDED(rv) && lastSaveDir)
     filePicker->SetDisplayDirectory(lastSaveDir);
 
   int16_t dialogResult;
   rv = ShowPicker(filePicker, &dialogResult);
-  if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel)
-  {
+  if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel) {
     // We'll indicate this by setting the outparam to null.
     *aSaveDir = nullptr;
     return NS_OK;
   }
 
   nsCOMPtr<nsIFile> dir;
   rv = filePicker->GetFile(getter_AddRefs(dir));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1339,1703 +1240,1546 @@ nsMessenger::GetSaveToDir(nsIFile **aSav
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aSaveDir = nullptr;
   dir.forget(aSaveDir);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessenger::SaveMessages(uint32_t aCount,
-                          const char16_t **aFilenameArray,
-                          const char **aMessageUriArray)
-{
+nsMessenger::SaveMessages(uint32_t aCount, const char16_t **aFilenameArray,
+                          const char **aMessageUriArray) {
   NS_ENSURE_ARG_MIN(aCount, 1);
   NS_ENSURE_ARG_POINTER(aFilenameArray);
   NS_ENSURE_ARG_POINTER(aMessageUriArray);
 
   nsresult rv;
 
   nsCOMPtr<nsIFile> saveDir;
   rv = GetSaveToDir(getter_AddRefs(saveDir));
   NS_ENSURE_SUCCESS(rv, rv);
-  if (!saveDir) // A null saveDir means that the user canceled the save.
+  if (!saveDir)  // A null saveDir means that the user canceled the save.
     return NS_OK;
 
   for (uint32_t i = 0; i < aCount; i++) {
-    if (!aFilenameArray[i]) // just to be sure
+    if (!aFilenameArray[i])  // just to be sure
       return NS_ERROR_FAILURE;
 
-    nsCOMPtr<nsIFile> saveToFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
+    nsCOMPtr<nsIFile> saveToFile =
+        do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = saveToFile->InitWithFile(saveDir);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = saveToFile->Append(nsDependentString(aFilenameArray[i]));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = AdjustFileIfNameTooLong(saveToFile);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = PromptIfFileExists(saveToFile);
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     nsCOMPtr<nsIMsgMessageService> messageService;
     nsCOMPtr<nsIUrlListener> urlListener;
 
     rv = GetMessageServiceFromURI(nsDependentCString(aMessageUriArray[i]),
                                   getter_AddRefs(messageService));
     if (NS_FAILED(rv)) {
       Alert("saveMessageFailed");
       return rv;
     }
 
-    RefPtr<nsSaveMsgListener> saveListener = new nsSaveMsgListener(saveToFile, this, nullptr);
+    RefPtr<nsSaveMsgListener> saveListener =
+        new nsSaveMsgListener(saveToFile, this, nullptr);
 
     rv = saveListener->QueryInterface(NS_GET_IID(nsIUrlListener),
                                       getter_AddRefs(urlListener));
     if (NS_FAILED(rv)) {
       Alert("saveMessageFailed");
       return rv;
     }
 
     // Ok, now save the message.
     nsCOMPtr<nsIURI> dummyNull;
-    rv = messageService->SaveMessageToDisk(aMessageUriArray[i],
-                                           saveToFile, false,
-                                           urlListener, getter_AddRefs(dummyNull),
-                                           true, mMsgWindow);
+    rv = messageService->SaveMessageToDisk(
+        aMessageUriArray[i], saveToFile, false, urlListener,
+        getter_AddRefs(dummyNull), true, mMsgWindow);
     if (NS_FAILED(rv)) {
       Alert("saveMessageFailed");
       return rv;
     }
   }
   return rv;
 }
 
-nsresult
-nsMessenger::Alert(const char *stringName)
-{
+nsresult nsMessenger::Alert(const char *stringName) {
   nsresult rv = NS_OK;
 
-  if (mDocShell)
-  {
+  if (mDocShell) {
     nsCOMPtr<nsIPrompt> dialog(do_GetInterface(mDocShell));
 
-    if (dialog)
-    {
+    if (dialog) {
       nsString alertStr;
       GetString(NS_ConvertASCIItoUTF16(stringName), alertStr);
       rv = dialog->Alert(nullptr, alertStr.get());
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::MessageServiceFromURI(const nsACString& aUri, nsIMsgMessageService **aMsgService)
-{
+nsMessenger::MessageServiceFromURI(const nsACString &aUri,
+                                   nsIMsgMessageService **aMsgService) {
   NS_ENSURE_ARG_POINTER(aMsgService);
   return GetMessageServiceFromURI(aUri, aMsgService);
 }
 
 NS_IMETHODIMP
-nsMessenger::MsgHdrFromURI(const nsACString& aUri, nsIMsgDBHdr **aMsgHdr)
-{
+nsMessenger::MsgHdrFromURI(const nsACString &aUri, nsIMsgDBHdr **aMsgHdr) {
   NS_ENSURE_ARG_POINTER(aMsgHdr);
-  nsCOMPtr <nsIMsgMessageService> msgService;
+  nsCOMPtr<nsIMsgMessageService> msgService;
   nsresult rv;
 
-
-  if (mMsgWindow &&
-      (StringBeginsWith(aUri, NS_LITERAL_CSTRING("file:")) ||
-       PromiseFlatCString(aUri).Find("type=application/x-message-display") >= 0))
-  {
-    nsCOMPtr <nsIMsgHeaderSink> headerSink;
+  if (mMsgWindow && (StringBeginsWith(aUri, NS_LITERAL_CSTRING("file:")) ||
+                     PromiseFlatCString(aUri).Find(
+                         "type=application/x-message-display") >= 0)) {
+    nsCOMPtr<nsIMsgHeaderSink> headerSink;
     mMsgWindow->GetMsgHeaderSink(getter_AddRefs(headerSink));
-    if (headerSink)
-    {
+    if (headerSink) {
       rv = headerSink->GetDummyMsgHeader(aMsgHdr);
       // Is there a way to check if they're asking for the hdr currently
       // displayed in a stand-alone msg window from a .eml file?
       // (pretty likely if this is a file: uri)
       return rv;
     }
   }
 
   rv = GetMessageServiceFromURI(aUri, getter_AddRefs(msgService));
   NS_ENSURE_SUCCESS(rv, rv);
-  return msgService->MessageURIToMsgHdr(PromiseFlatCString(aUri).get(), aMsgHdr);
+  return msgService->MessageURIToMsgHdr(PromiseFlatCString(aUri).get(),
+                                        aMsgHdr);
 }
 
-NS_IMETHODIMP nsMessenger::GetUndoTransactionType(uint32_t *txnType)
-{
+NS_IMETHODIMP nsMessenger::GetUndoTransactionType(uint32_t *txnType) {
   NS_ENSURE_TRUE(txnType && mTxnMgr, NS_ERROR_NULL_POINTER);
 
   nsresult rv;
   *txnType = nsMessenger::eUnknown;
   nsCOMPtr<nsITransaction> txn;
   rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
-  if (NS_SUCCEEDED(rv) && txn)
-  {
-    nsCOMPtr <nsIPropertyBag2> propertyBag = do_QueryInterface(txn, &rv);
+  if (NS_SUCCEEDED(rv) && txn) {
+    nsCOMPtr<nsIPropertyBag2> propertyBag = do_QueryInterface(txn, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     return propertyBag->GetPropertyAsUint32(NS_LITERAL_STRING("type"), txnType);
   }
   return rv;
 }
 
-NS_IMETHODIMP nsMessenger::CanUndo(bool *bValue)
-{
+NS_IMETHODIMP nsMessenger::CanUndo(bool *bValue) {
   NS_ENSURE_TRUE(bValue && mTxnMgr, NS_ERROR_NULL_POINTER);
 
   nsresult rv;
   *bValue = false;
   int32_t count = 0;
   rv = mTxnMgr->GetNumberOfUndoItems(&count);
-  if (NS_SUCCEEDED(rv) && count > 0)
-    *bValue = true;
+  if (NS_SUCCEEDED(rv) && count > 0) *bValue = true;
   return rv;
 }
 
-NS_IMETHODIMP nsMessenger::GetRedoTransactionType(uint32_t *txnType)
-{
+NS_IMETHODIMP nsMessenger::GetRedoTransactionType(uint32_t *txnType) {
   NS_ENSURE_TRUE(txnType && mTxnMgr, NS_ERROR_NULL_POINTER);
 
   nsresult rv;
   *txnType = nsMessenger::eUnknown;
   nsCOMPtr<nsITransaction> txn;
   rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn));
-  if (NS_SUCCEEDED(rv) && txn)
-  {
-    nsCOMPtr <nsIPropertyBag2> propertyBag = do_QueryInterface(txn, &rv);
+  if (NS_SUCCEEDED(rv) && txn) {
+    nsCOMPtr<nsIPropertyBag2> propertyBag = do_QueryInterface(txn, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     return propertyBag->GetPropertyAsUint32(NS_LITERAL_STRING("type"), txnType);
   }
   return rv;
 }
 
-NS_IMETHODIMP nsMessenger::CanRedo(bool *bValue)
-{
+NS_IMETHODIMP nsMessenger::CanRedo(bool *bValue) {
   NS_ENSURE_TRUE(bValue && mTxnMgr, NS_ERROR_NULL_POINTER);
 
   nsresult rv;
   *bValue = false;
   int32_t count = 0;
   rv = mTxnMgr->GetNumberOfRedoItems(&count);
-  if (NS_SUCCEEDED(rv) && count > 0)
-    *bValue = true;
+  if (NS_SUCCEEDED(rv) && count > 0) *bValue = true;
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::Undo(nsIMsgWindow *msgWindow)
-{
+nsMessenger::Undo(nsIMsgWindow *msgWindow) {
   nsresult rv = NS_OK;
-  if (mTxnMgr)
-  {
+  if (mTxnMgr) {
     int32_t numTxn = 0;
     rv = mTxnMgr->GetNumberOfUndoItems(&numTxn);
-    if (NS_SUCCEEDED(rv) && numTxn > 0)
-    {
-        nsCOMPtr<nsITransaction> txn;
-        rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
-        if (NS_SUCCEEDED(rv) && txn)
-        {
-            static_cast<nsMsgTxn*>(static_cast<nsITransaction*>(txn.get()))->SetMsgWindow(msgWindow);
-        }
-        mTxnMgr->UndoTransaction();
+    if (NS_SUCCEEDED(rv) && numTxn > 0) {
+      nsCOMPtr<nsITransaction> txn;
+      rv = mTxnMgr->PeekUndoStack(getter_AddRefs(txn));
+      if (NS_SUCCEEDED(rv) && txn) {
+        static_cast<nsMsgTxn *>(static_cast<nsITransaction *>(txn.get()))
+            ->SetMsgWindow(msgWindow);
+      }
+      mTxnMgr->UndoTransaction();
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::Redo(nsIMsgWindow *msgWindow)
-{
+nsMessenger::Redo(nsIMsgWindow *msgWindow) {
   nsresult rv = NS_OK;
-  if (mTxnMgr)
-  {
+  if (mTxnMgr) {
     int32_t numTxn = 0;
     rv = mTxnMgr->GetNumberOfRedoItems(&numTxn);
-    if (NS_SUCCEEDED(rv) && numTxn > 0)
-    {
-        nsCOMPtr<nsITransaction> txn;
-        rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn));
-        if (NS_SUCCEEDED(rv) && txn)
-        {
-            static_cast<nsMsgTxn*>(static_cast<nsITransaction*>(txn.get()))->SetMsgWindow(msgWindow);
-        }
-        mTxnMgr->RedoTransaction();
+    if (NS_SUCCEEDED(rv) && numTxn > 0) {
+      nsCOMPtr<nsITransaction> txn;
+      rv = mTxnMgr->PeekRedoStack(getter_AddRefs(txn));
+      if (NS_SUCCEEDED(rv) && txn) {
+        static_cast<nsMsgTxn *>(static_cast<nsITransaction *>(txn.get()))
+            ->SetMsgWindow(msgWindow);
+      }
+      mTxnMgr->RedoTransaction();
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsMessenger::GetTransactionManager(nsITransactionManager* *aTxnMgr)
-{
+nsMessenger::GetTransactionManager(nsITransactionManager **aTxnMgr) {
   NS_ENSURE_TRUE(mTxnMgr && aTxnMgr, NS_ERROR_NULL_POINTER);
   NS_ADDREF(*aTxnMgr = mTxnMgr);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMessenger::SetDocumentCharset(const nsACString& aCharacterSet)
-{
-  // We want to redisplay the currently selected message (if any) but forcing the
-  // redisplay to use characterSet
-  if (!mLastDisplayURI.IsEmpty())
-  {
+NS_IMETHODIMP nsMessenger::SetDocumentCharset(const nsACString &aCharacterSet) {
+  // We want to redisplay the currently selected message (if any) but forcing
+  // the redisplay to use characterSet
+  if (!mLastDisplayURI.IsEmpty()) {
     SetDisplayCharset(NS_LITERAL_CSTRING("UTF-8"));
 
-    nsCOMPtr <nsIMsgMessageService> messageService;
-    nsresult rv = GetMessageServiceFromURI(mLastDisplayURI, getter_AddRefs(messageService));
-
-    if (NS_SUCCEEDED(rv) && messageService)
-    {
+    nsCOMPtr<nsIMsgMessageService> messageService;
+    nsresult rv = GetMessageServiceFromURI(mLastDisplayURI,
+                                           getter_AddRefs(messageService));
+
+    if (NS_SUCCEEDED(rv) && messageService) {
       nsCOMPtr<nsIURI> dummyNull;
-      messageService->DisplayMessage(mLastDisplayURI.get(), mDocShell, mMsgWindow, nullptr,
-                                     PromiseFlatCString(aCharacterSet).get(), getter_AddRefs(dummyNull));
+      messageService->DisplayMessage(
+          mLastDisplayURI.get(), mDocShell, mMsgWindow, nullptr,
+          PromiseFlatCString(aCharacterSet).get(), getter_AddRefs(dummyNull));
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessenger::GetLastDisplayedMessageUri(nsACString& aLastDisplayedMessageUri)
-{
+nsMessenger::GetLastDisplayedMessageUri(nsACString &aLastDisplayedMessageUri) {
   aLastDisplayedMessageUri = mLastDisplayURI;
   return NS_OK;
 }
 
-nsSaveMsgListener::nsSaveMsgListener(nsIFile* aFile, nsMessenger *aMessenger, nsIUrlListener *aListener)
-{
+nsSaveMsgListener::nsSaveMsgListener(nsIFile *aFile, nsMessenger *aMessenger,
+                                     nsIUrlListener *aListener) {
   m_file = aFile;
   m_messenger = aMessenger;
   mListener = aListener;
   mUrlHasStopped = false;
   mRequestHasStopped = false;
 
-    // rhp: for charset handling
+  // rhp: for charset handling
   m_doCharsetConversion = false;
   m_saveAllAttachmentsState = nullptr;
   mProgress = 0;
   mMaxProgress = -1;
   mCanceled = false;
   m_outputFormat = eUnknown;
   mInitialized = false;
 }
 
-nsSaveMsgListener::~nsSaveMsgListener()
-{
-}
+nsSaveMsgListener::~nsSaveMsgListener() {}
 
 //
 // nsISupports
 //
-NS_IMPL_ISUPPORTS(nsSaveMsgListener,
-                   nsIUrlListener,
-                   nsIMsgCopyServiceListener,
-                   nsIStreamListener,
-                   nsIRequestObserver,
-                   nsICancelable)
+NS_IMPL_ISUPPORTS(nsSaveMsgListener, nsIUrlListener, nsIMsgCopyServiceListener,
+                  nsIStreamListener, nsIRequestObserver, nsICancelable)
 
 NS_IMETHODIMP
-nsSaveMsgListener::Cancel(nsresult status)
-{
+nsSaveMsgListener::Cancel(nsresult status) {
   mCanceled = true;
   return NS_OK;
 }
 
 //
 // nsIUrlListener
 //
 NS_IMETHODIMP
-nsSaveMsgListener::OnStartRunningUrl(nsIURI* url)
-{
-  if (mListener)
-    mListener->OnStartRunningUrl(url);
+nsSaveMsgListener::OnStartRunningUrl(nsIURI *url) {
+  if (mListener) mListener->OnStartRunningUrl(url);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::OnStopRunningUrl(nsIURI *url, nsresult exitCode)
-{
+nsSaveMsgListener::OnStopRunningUrl(nsIURI *url, nsresult exitCode) {
   nsresult rv = exitCode;
   mUrlHasStopped = true;
 
   // ** save as template goes here
-  if (!m_templateUri.IsEmpty())
-  {
+  if (!m_templateUri.IsEmpty()) {
     nsCOMPtr<nsIMsgFolder> templateFolder;
     rv = GetOrCreateFolder(m_templateUri, getter_AddRefs(templateFolder));
     if (NS_FAILED(rv)) goto done;
-    nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID);
-    if (copyService)
-    {
+    nsCOMPtr<nsIMsgCopyService> copyService =
+        do_GetService(NS_MSGCOPYSERVICE_CONTRACTID);
+    if (copyService) {
       nsCOMPtr<nsIFile> clone;
       m_file->Clone(getter_AddRefs(clone));
-      rv = copyService->CopyFileMessage(clone, templateFolder, nullptr,
-                                        true, nsMsgMessageFlags::Read,
-                                        EmptyCString(), this, nullptr);
+      rv = copyService->CopyFileMessage(clone, templateFolder, nullptr, true,
+                                        nsMsgMessageFlags::Read, EmptyCString(),
+                                        this, nullptr);
       // Clear this so we don't end up in a loop if OnStopRunningUrl gets
       // called again.
       m_templateUri.Truncate();
     }
-  }
-  else if (m_outputStream && mRequestHasStopped)
-  {
+  } else if (m_outputStream && mRequestHasStopped) {
     m_outputStream->Close();
     m_outputStream = nullptr;
   }
 
 done:
-  if (NS_FAILED(rv))
-  {
-    if (m_file)
-      m_file->Remove(false);
-    if (m_messenger)
-        m_messenger->Alert("saveMessageFailed");
+  if (NS_FAILED(rv)) {
+    if (m_file) m_file->Remove(false);
+    if (m_messenger) m_messenger->Alert("saveMessageFailed");
   }
 
   if (mRequestHasStopped && mListener)
     mListener->OnStopRunningUrl(url, exitCode);
   else
     mListenerUri = url;
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::OnStartCopy(void)
-{
-  return NS_OK;
-}
+nsSaveMsgListener::OnStartCopy(void) { return NS_OK; }
 
 NS_IMETHODIMP
-nsSaveMsgListener::OnProgress(uint32_t aProgress, uint32_t aProgressMax)
-{
+nsSaveMsgListener::OnProgress(uint32_t aProgress, uint32_t aProgressMax) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::SetMessageKey(nsMsgKey aKey)
-{
+nsSaveMsgListener::SetMessageKey(nsMsgKey aKey) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::GetMessageId(nsACString& aMessageId)
-{
+nsSaveMsgListener::GetMessageId(nsACString &aMessageId) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::OnStopCopy(nsresult aStatus)
-{
-  if (m_file)
-    m_file->Remove(false);
+nsSaveMsgListener::OnStopCopy(nsresult aStatus) {
+  if (m_file) m_file->Remove(false);
   return aStatus;
 }
 
 // initializes the progress window if we are going to show one
 // and for OSX, sets creator flags on the output file
-nsresult nsSaveMsgListener::InitializeDownload(nsIRequest * aRequest)
-{
+nsresult nsSaveMsgListener::InitializeDownload(nsIRequest *aRequest) {
   nsresult rv = NS_OK;
 
   mInitialized = true;
-  nsCOMPtr<nsIChannel> channel (do_QueryInterface(aRequest));
-
-  if (!channel)
-    return rv;
+  nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
+
+  if (!channel) return rv;
 
   // Get the max progress from the URL if we haven't already got it.
-  if (mMaxProgress == -1)
-  {
+  if (mMaxProgress == -1) {
     nsCOMPtr<nsIURI> uri;
     channel->GetURI(getter_AddRefs(uri));
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(do_QueryInterface(uri));
-    if (mailnewsUrl)
-      mailnewsUrl->GetMaxProgress(&mMaxProgress);
+    if (mailnewsUrl) mailnewsUrl->GetMaxProgress(&mMaxProgress);
   }
 
-  if (!m_contentType.IsEmpty())
-  {
-    nsCOMPtr<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID));
+  if (!m_contentType.IsEmpty()) {
+    nsCOMPtr<nsIMIMEService> mimeService(
+        do_GetService(NS_MIMESERVICE_CONTRACTID));
     nsCOMPtr<nsIMIMEInfo> mimeinfo;
 
-    mimeService->GetFromTypeAndExtension(m_contentType, EmptyCString(), getter_AddRefs(mimeinfo));
+    mimeService->GetFromTypeAndExtension(m_contentType, EmptyCString(),
+                                         getter_AddRefs(mimeinfo));
 
     // create a download progress window
 
     // Set saveToDisk explicitly to avoid launching the saved file.
-    // See https://hg.mozilla.org/mozilla-central/file/814a6f071472/toolkit/components/jsdownloads/src/DownloadLegacy.js#l164
+    // See
+    // https://hg.mozilla.org/mozilla-central/file/814a6f071472/toolkit/components/jsdownloads/src/DownloadLegacy.js#l164
     mimeinfo->SetPreferredAction(nsIHandlerInfo::saveToDisk);
 
     // When we don't allow warnings, also don't show progress, as this
     //  is an environment (typically filters) where we don't want
     //  interruption.
     bool allowProgress = true;
     if (m_saveAllAttachmentsState)
       allowProgress = !m_saveAllAttachmentsState->m_withoutWarning;
-    if (allowProgress)
-    {
+    if (allowProgress) {
       nsCOMPtr<nsITransfer> tr = do_CreateInstance(NS_TRANSFER_CONTRACTID, &rv);
-      if (tr && m_file)
-      {
+      if (tr && m_file) {
         PRTime timeDownloadStarted = PR_Now();
 
         nsCOMPtr<nsIURI> outputURI;
         NS_NewFileURI(getter_AddRefs(outputURI), m_file);
 
         nsCOMPtr<nsIURI> url;
         channel->GetURI(getter_AddRefs(url));
         rv = tr->Init(url, outputURI, EmptyString(), mimeinfo,
                       timeDownloadStarted, nullptr, this, false);
 
-          // now store the web progresslistener
+        // now store the web progresslistener
         mTransfer = tr;
       }
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::OnStartRequest(nsIRequest* request)
-{
+nsSaveMsgListener::OnStartRequest(nsIRequest *request) {
   if (m_file)
-    MsgNewBufferedFileOutputStream(getter_AddRefs(m_outputStream), m_file, -1, ATTACHMENT_PERMISSION);
-  if (!m_outputStream)
-  {
+    MsgNewBufferedFileOutputStream(getter_AddRefs(m_outputStream), m_file, -1,
+                                   ATTACHMENT_PERMISSION);
+  if (!m_outputStream) {
     mCanceled = true;
-    if (m_messenger)
-      m_messenger->Alert("saveAttachmentFailed");
+    if (m_messenger) m_messenger->Alert("saveAttachmentFailed");
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsresult status)
-{
+nsSaveMsgListener::OnStopRequest(nsIRequest *request, nsresult status) {
   nsresult rv = NS_OK;
   mRequestHasStopped = true;
 
   // rhp: If we are doing the charset conversion magic, this is different
   // processing, otherwise, its just business as usual.
   // If we need text/plain, then we need to convert the HTML and then convert
   // to the systems charset.
-  if (m_doCharsetConversion && m_outputStream)
-  {
+  if (m_doCharsetConversion && m_outputStream) {
     // For HTML, code is emitted immediately in OnDataAvailable.
     MOZ_ASSERT(m_outputFormat == ePlainText,
-      "For HTML, m_doCharsetConversion shouldn't be set");
+               "For HTML, m_doCharsetConversion shouldn't be set");
     NS_ConvertUTF8toUTF16 utf16Buffer(m_msgBuffer);
     ConvertBufToPlainText(utf16Buffer, false, false, false, false);
 
     nsCString outCString;
-    // NS_CopyUnicodeToNative() doesn't return an error, so we have no choice but to
-    // always use UTF-8.
+    // NS_CopyUnicodeToNative() doesn't return an error, so we have no choice
+    // but to always use UTF-8.
     CopyUTF16toUTF8(utf16Buffer, outCString);
     uint32_t writeCount;
-    rv = m_outputStream->Write(outCString.get(), outCString.Length(), &writeCount);
-    if (outCString.Length() != writeCount)
-      rv = NS_ERROR_FAILURE;
+    rv = m_outputStream->Write(outCString.get(), outCString.Length(),
+                               &writeCount);
+    if (outCString.Length() != writeCount) rv = NS_ERROR_FAILURE;
   }
 
-  if (m_outputStream)
-  {
+  if (m_outputStream) {
     m_outputStream->Close();
     m_outputStream = nullptr;
   }
 
-  if (m_saveAllAttachmentsState)
-  {
+  if (m_saveAllAttachmentsState) {
     m_saveAllAttachmentsState->m_curIndex++;
-    if (!mCanceled && m_saveAllAttachmentsState->m_curIndex < m_saveAllAttachmentsState->m_count)
-    {
+    if (!mCanceled && m_saveAllAttachmentsState->m_curIndex <
+                          m_saveAllAttachmentsState->m_count) {
       nsSaveAllAttachmentsState *state = m_saveAllAttachmentsState;
       uint32_t i = state->m_curIndex;
       nsString unescapedName;
       RefPtr<nsLocalFile> localFile =
-        new nsLocalFile(nsTDependentString<PathChar>(state->m_directoryName));
+          new nsLocalFile(nsTDependentString<PathChar>(state->m_directoryName));
       if (localFile->NativePath().IsEmpty()) {
         rv = NS_ERROR_FAILURE;
         goto done;
       }
 
       ConvertAndSanitizeFileName(state->m_displayNameArray[i], unescapedName);
       rv = localFile->Append(unescapedName);
-      if (NS_FAILED(rv))
-        goto done;
-
-      // When we are running with no warnings (typically filters and other automatic
-      //  uses), then don't prompt for duplicates, but create a unique file
-      //  instead.
-      if (!m_saveAllAttachmentsState->m_withoutWarning)
-      {
+      if (NS_FAILED(rv)) goto done;
+
+      // When we are running with no warnings (typically filters and other
+      // automatic uses), then don't prompt for duplicates, but create a unique
+      // file instead.
+      if (!m_saveAllAttachmentsState->m_withoutWarning) {
         rv = m_messenger->PromptIfFileExists(localFile);
         if (NS_FAILED(rv)) goto done;
-      }
-      else
-      {
-        rv = localFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, ATTACHMENT_PERMISSION);
+      } else {
+        rv = localFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE,
+                                     ATTACHMENT_PERMISSION);
         if (NS_FAILED(rv)) goto done;
       }
-      rv = m_messenger->SaveAttachment(localFile,
-                                       nsDependentCString(state->m_urlArray[i]),
-                                       nsDependentCString(state->m_messageUriArray[i]),
-                                       nsDependentCString(state->m_contentTypeArray[i]),
-                                       (void *)state, nullptr);
-      done:
-        if (NS_FAILED(rv))
-        {
-          delete state;
-          m_saveAllAttachmentsState = nullptr;
-        }
-    }
-    else
-    {
-          // check if we're saving attachments prior to detaching them.
-      if (m_saveAllAttachmentsState->m_detachingAttachments && !mCanceled)
-      {
+      rv = m_messenger->SaveAttachment(
+          localFile, nsDependentCString(state->m_urlArray[i]),
+          nsDependentCString(state->m_messageUriArray[i]),
+          nsDependentCString(state->m_contentTypeArray[i]), (void *)state,
+          nullptr);
+    done:
+      if (NS_FAILED(rv)) {
+        delete state;
+        m_saveAllAttachmentsState = nullptr;
+      }
+    } else {
+      // check if we're saving attachments prior to detaching them.
+      if (m_saveAllAttachmentsState->m_detachingAttachments && !mCanceled) {
         nsSaveAllAttachmentsState *state = m_saveAllAttachmentsState;
-        m_messenger->DetachAttachments(state->m_count,
-                                       (const char **) state->m_contentTypeArray,
-                                       (const char **) state->m_urlArray,
-                                       (const char **) state->m_displayNameArray,
-                                       (const char **) state->m_messageUriArray,
-                                       &state->m_savedFiles,
-                                       state->m_withoutWarning);
+        m_messenger->DetachAttachments(
+            state->m_count, (const char **)state->m_contentTypeArray,
+            (const char **)state->m_urlArray,
+            (const char **)state->m_displayNameArray,
+            (const char **)state->m_messageUriArray, &state->m_savedFiles,
+            state->m_withoutWarning);
       }
 
       delete m_saveAllAttachmentsState;
       m_saveAllAttachmentsState = nullptr;
     }
   }
 
-  if(mTransfer)
-  {
-    mTransfer->OnProgressChange64(nullptr, nullptr, mMaxProgress, mMaxProgress, mMaxProgress, mMaxProgress);
-    mTransfer->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP |
-      nsIWebProgressListener::STATE_IS_NETWORK, NS_OK);
-    mTransfer = nullptr; // break any circular dependencies between the progress dialog and use
+  if (mTransfer) {
+    mTransfer->OnProgressChange64(nullptr, nullptr, mMaxProgress, mMaxProgress,
+                                  mMaxProgress, mMaxProgress);
+    mTransfer->OnStateChange(nullptr, nullptr,
+                             nsIWebProgressListener::STATE_STOP |
+                                 nsIWebProgressListener::STATE_IS_NETWORK,
+                             NS_OK);
+    mTransfer = nullptr;  // break any circular dependencies between the
+                          // progress dialog and use
   }
 
   if (mUrlHasStopped && mListener)
     mListener->OnStopRunningUrl(mListenerUri, rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSaveMsgListener::OnDataAvailable(nsIRequest* request,
-                                  nsIInputStream* inStream,
-                                  uint64_t srcOffset,
-                                  uint32_t count)
-{
+nsSaveMsgListener::OnDataAvailable(nsIRequest *request,
+                                   nsIInputStream *inStream, uint64_t srcOffset,
+                                   uint32_t count) {
   nsresult rv = NS_ERROR_FAILURE;
   // first, check to see if we've been canceled....
-  if (mCanceled) // then go cancel our underlying channel too
+  if (mCanceled)  // then go cancel our underlying channel too
     return request->Cancel(NS_BINDING_ABORTED);
 
-  if (!mInitialized)
-    InitializeDownload(request);
-
-  if (m_outputStream)
-  {
+  if (!mInitialized) InitializeDownload(request);
+
+  if (m_outputStream) {
     mProgress += count;
     uint64_t available;
     uint32_t readCount, maxReadCount = sizeof(m_dataBuffer);
     uint32_t writeCount;
     rv = inStream->Available(&available);
-    while (NS_SUCCEEDED(rv) && available)
-    {
-      if (maxReadCount > available)
-        maxReadCount = (uint32_t)available;
+    while (NS_SUCCEEDED(rv) && available) {
+      if (maxReadCount > available) maxReadCount = (uint32_t)available;
       rv = inStream->Read(m_dataBuffer, maxReadCount, &readCount);
 
       // rhp:
       // Ok, now we do one of two things. If we are sending out HTML, then
       // just write it to the HTML stream as it comes along...but if this is
       // a save as TEXT operation, we need to buffer this up for conversion
-      // when we are done. When the stream converter for HTML-TEXT gets in place,
-      // this magic can go away.
+      // when we are done. When the stream converter for HTML-TEXT gets in
+      // place, this magic can go away.
       //
-      if (NS_SUCCEEDED(rv))
-      {
-        if ( (m_doCharsetConversion) && (m_outputFormat == ePlainText) )
+      if (NS_SUCCEEDED(rv)) {
+        if ((m_doCharsetConversion) && (m_outputFormat == ePlainText))
           m_msgBuffer.Append(Substring(m_dataBuffer, m_dataBuffer + readCount));
         else
           rv = m_outputStream->Write(m_dataBuffer, readCount, &writeCount);
 
         available -= readCount;
       }
     }
 
-    if (NS_SUCCEEDED(rv) && mTransfer) // Send progress notification.
-      mTransfer->OnProgressChange64(nullptr, request, mProgress, mMaxProgress, mProgress, mMaxProgress);
+    if (NS_SUCCEEDED(rv) && mTransfer)  // Send progress notification.
+      mTransfer->OnProgressChange64(nullptr, request, mProgress, mMaxProgress,
+                                    mProgress, mMaxProgress);
   }
   return rv;
 }
 
-#define MESSENGER_STRING_URL       "chrome://messenger/locale/messenger.properties"
-
-nsresult
-nsMessenger::InitStringBundle()
-{
-  if (mStringBundle)
-    return NS_OK;
+#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties"
+
+nsresult nsMessenger::InitStringBundle() {
+  if (mStringBundle) return NS_OK;
 
   const char propertyURL[] = MESSENGER_STRING_URL;
   nsCOMPtr<nsIStringBundleService> sBundleService =
-    mozilla::services::GetStringBundleService();
+      mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
   return sBundleService->CreateBundle(propertyURL,
                                       getter_AddRefs(mStringBundle));
 }
 
-void
-nsMessenger::GetString(const nsString& aStringName, nsString& aValue)
-{
+void nsMessenger::GetString(const nsString &aStringName, nsString &aValue) {
   nsresult rv;
   aValue.Truncate();
 
-  if (!mStringBundle)
-    rv = InitStringBundle();
+  if (!mStringBundle) rv = InitStringBundle();
 
   if (mStringBundle)
-    rv = mStringBundle->GetStringFromName(NS_ConvertUTF16toUTF8(aStringName).get(), aValue);
+    rv = mStringBundle->GetStringFromName(
+        NS_ConvertUTF16toUTF8(aStringName).get(), aValue);
   else
     rv = NS_ERROR_FAILURE;
 
-  if (NS_FAILED(rv) || aValue.IsEmpty())
-    aValue = aStringName;
+  if (NS_FAILED(rv) || aValue.IsEmpty()) aValue = aStringName;
   return;
 }
 
-nsSaveAllAttachmentsState::nsSaveAllAttachmentsState(uint32_t count,
-                                                     const char **contentTypeArray,
-                                                     const char **urlArray,
-                                                     const char **nameArray,
-                                                     const char **uriArray,
-                                                     const PathChar *dirName,
-                                                     bool detachingAttachments)
-    : m_withoutWarning(false)
-{
-    uint32_t i;
-    NS_ASSERTION(count && urlArray && nameArray && uriArray && dirName,
-                 "fatal - invalid parameters\n");
-
-    m_count = count;
-    m_curIndex = 0;
-    m_contentTypeArray = new char*[count];
-    m_urlArray = new char*[count];
-    m_displayNameArray = new char*[count];
-    m_messageUriArray = new char*[count];
-    for (i = 0; i < count; i++)
-    {
-        m_contentTypeArray[i] = strdup(contentTypeArray[i]);
-        m_urlArray[i] = strdup(urlArray[i]);
-        m_displayNameArray[i] = strdup(nameArray[i]);
-        m_messageUriArray[i] = strdup(uriArray[i]);
-    }
-    m_directoryName = NS_xstrdup(dirName);
-    m_detachingAttachments = detachingAttachments;
+nsSaveAllAttachmentsState::nsSaveAllAttachmentsState(
+    uint32_t count, const char **contentTypeArray, const char **urlArray,
+    const char **nameArray, const char **uriArray, const PathChar *dirName,
+    bool detachingAttachments)
+    : m_withoutWarning(false) {
+  uint32_t i;
+  NS_ASSERTION(count && urlArray && nameArray && uriArray && dirName,
+               "fatal - invalid parameters\n");
+
+  m_count = count;
+  m_curIndex = 0;
+  m_contentTypeArray = new char *[count];
+  m_urlArray = new char *[count];
+  m_displayNameArray = new char *[count];
+  m_messageUriArray = new char *[count];
+  for (i = 0; i < count; i++) {
+    m_contentTypeArray[i] = strdup(contentTypeArray[i]);
+    m_urlArray[i] = strdup(urlArray[i]);
+    m_displayNameArray[i] = strdup(nameArray[i]);
+    m_messageUriArray[i] = strdup(uriArray[i]);
+  }
+  m_directoryName = NS_xstrdup(dirName);
+  m_detachingAttachments = detachingAttachments;
 }
 
-nsSaveAllAttachmentsState::~nsSaveAllAttachmentsState()
-{
-    uint32_t i;
-    for (i = 0; i < m_count; i++)
-    {
-      free(m_contentTypeArray[i]);
-      free(m_urlArray[i]);
-      free(m_displayNameArray[i]);
-      free(m_messageUriArray[i]);
-    }
-    delete[] m_contentTypeArray;
-    delete[] m_urlArray;
-    delete[] m_displayNameArray;
-    delete[] m_messageUriArray;
-    free(m_directoryName);
+nsSaveAllAttachmentsState::~nsSaveAllAttachmentsState() {
+  uint32_t i;
+  for (i = 0; i < m_count; i++) {
+    free(m_contentTypeArray[i]);
+    free(m_urlArray[i]);
+    free(m_displayNameArray[i]);
+    free(m_messageUriArray[i]);
+  }
+  delete[] m_contentTypeArray;
+  delete[] m_urlArray;
+  delete[] m_displayNameArray;
+  delete[] m_messageUriArray;
+  free(m_directoryName);
 }
 
-nsresult
-nsMessenger::GetLastSaveDirectory(nsIFile **aLastSaveDir)
-{
+nsresult nsMessenger::GetLastSaveDirectory(nsIFile **aLastSaveDir) {
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
-
-  // this can fail, and it will, on the first time we call it, as there is no default for this pref.
-  nsCOMPtr <nsIFile> localFile;
-  rv = prefBranch->GetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME, NS_GET_IID(nsIFile), getter_AddRefs(localFile));
-  if (NS_SUCCEEDED(rv))
-    localFile.forget(aLastSaveDir);
+  nsCOMPtr<nsIPrefBranch> prefBranch =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  // this can fail, and it will, on the first time we call it, as there is no
+  // default for this pref.
+  nsCOMPtr<nsIFile> localFile;
+  rv = prefBranch->GetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME,
+                                   NS_GET_IID(nsIFile),
+                                   getter_AddRefs(localFile));
+  if (NS_SUCCEEDED(rv)) localFile.forget(aLastSaveDir);
   return rv;
 }
 
-nsresult
-nsMessenger::SetLastSaveDirectory(nsIFile *aLocalFile)
-{
+nsresult nsMessenger::SetLastSaveDirectory(nsIFile *aLocalFile) {
   NS_ENSURE_ARG_POINTER(aLocalFile);
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIPrefBranch> prefBranch =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // if the file is a directory, just use it for the last dir chosen
   // otherwise, use the parent of the file as the last dir chosen.
   // IsDirectory() will return error on saving a file, as the
   // file doesn't exist yet.
   bool isDirectory;
   rv = aLocalFile->IsDirectory(&isDirectory);
   if (NS_SUCCEEDED(rv) && isDirectory) {
-    rv = prefBranch->SetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME, NS_GET_IID(nsIFile), aLocalFile);
-    NS_ENSURE_SUCCESS(rv,rv);
-  }
-  else {
-    nsCOMPtr <nsIFile> parent;
+    rv = prefBranch->SetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME,
+                                     NS_GET_IID(nsIFile), aLocalFile);
+    NS_ENSURE_SUCCESS(rv, rv);
+  } else {
+    nsCOMPtr<nsIFile> parent;
     rv = aLocalFile->GetParent(getter_AddRefs(parent));
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    rv = prefBranch->SetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME, NS_GET_IID(nsIFile), parent);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    rv = prefBranch->SetComplexValue(MESSENGER_SAVE_DIR_PREF_NAME,
+                                     NS_GET_IID(nsIFile), parent);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
-/* void getUrisAtNavigatePos (in long aPos, out ACString aFolderUri, out ACString aMsgUri); */
+/* void getUrisAtNavigatePos (in long aPos, out ACString aFolderUri, out
+ * ACString aMsgUri); */
 // aPos is relative to the current history cursor - 1 is forward, -1 is back.
-NS_IMETHODIMP nsMessenger::GetMsgUriAtNavigatePos(int32_t aPos, nsACString& aMsgUri)
-{
+NS_IMETHODIMP nsMessenger::GetMsgUriAtNavigatePos(int32_t aPos,
+                                                  nsACString &aMsgUri) {
   int32_t desiredArrayIndex = (mCurHistoryPos + (aPos << 1));
-  if (desiredArrayIndex >= 0 && desiredArrayIndex < (int32_t)mLoadedMsgHistory.Length())
-  {
+  if (desiredArrayIndex >= 0 &&
+      desiredArrayIndex < (int32_t)mLoadedMsgHistory.Length()) {
     mNavigatingToUri = mLoadedMsgHistory[desiredArrayIndex];
     aMsgUri = mNavigatingToUri;
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsMessenger::SetNavigatePos(int32_t aPos)
-{
-  if ((aPos << 1) < (int32_t)mLoadedMsgHistory.Length())
-  {
+NS_IMETHODIMP nsMessenger::SetNavigatePos(int32_t aPos) {
+  if ((aPos << 1) < (int32_t)mLoadedMsgHistory.Length()) {
     mCurHistoryPos = aPos << 1;
     return NS_OK;
-  }
-  else
+  } else
     return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP nsMessenger::GetNavigatePos(int32_t *aPos)
-{
+NS_IMETHODIMP nsMessenger::GetNavigatePos(int32_t *aPos) {
   NS_ENSURE_ARG_POINTER(aPos);
   *aPos = mCurHistoryPos >> 1;
   return NS_OK;
 }
 
 // aPos is relative to the current history cursor - 1 is forward, -1 is back.
-NS_IMETHODIMP nsMessenger::GetFolderUriAtNavigatePos(int32_t aPos, nsACString& aFolderUri)
-{
+NS_IMETHODIMP nsMessenger::GetFolderUriAtNavigatePos(int32_t aPos,
+                                                     nsACString &aFolderUri) {
   int32_t desiredArrayIndex = (mCurHistoryPos + (aPos << 1));
-  if (desiredArrayIndex >= 0 && desiredArrayIndex < (int32_t)mLoadedMsgHistory.Length())
-  {
+  if (desiredArrayIndex >= 0 &&
+      desiredArrayIndex < (int32_t)mLoadedMsgHistory.Length()) {
     mNavigatingToUri = mLoadedMsgHistory[desiredArrayIndex + 1];
     aFolderUri = mNavigatingToUri;
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsMessenger::GetNavigateHistory(uint32_t *aCurPos, uint32_t *aCount, char *** aHistoryUris)
-{
+NS_IMETHODIMP nsMessenger::GetNavigateHistory(uint32_t *aCurPos,
+                                              uint32_t *aCount,
+                                              char ***aHistoryUris) {
   NS_ENSURE_ARG_POINTER(aCount);
   NS_ENSURE_ARG_POINTER(aCurPos);
 
   *aCurPos = mCurHistoryPos >> 1;
   *aCount = mLoadedMsgHistory.Length();
   // for just enabling commands, we don't need the history uris.
-  if (!aHistoryUris)
-    return NS_OK;
+  if (!aHistoryUris) return NS_OK;
 
   char **outArray, **next;
   next = outArray = (char **)moz_xmalloc(*aCount * sizeof(char *));
   if (!outArray) return NS_ERROR_OUT_OF_MEMORY;
-  for (uint32_t i = 0; i < *aCount; i++)
-  {
+  for (uint32_t i = 0; i < *aCount; i++) {
     *next = ToNewCString(mLoadedMsgHistory[i]);
-    if (!*next)
-      return NS_ERROR_OUT_OF_MEMORY;
+    if (!*next) return NS_ERROR_OUT_OF_MEMORY;
     next++;
   }
   *aHistoryUris = outArray;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessenger::FormatFileSize(uint64_t aSize, bool aUseKB, nsAString& aFormattedSize)
-{
+nsMessenger::FormatFileSize(uint64_t aSize, bool aUseKB,
+                            nsAString &aFormattedSize) {
   return ::FormatFileSize(aSize, aUseKB, aFormattedSize);
 }
 
-
-/* void OnItemAdded (in nsIMsgFolder parentItem, in nsISupports item); */
-NS_IMETHODIMP nsMessenger::OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item)
-{
+NS_IMETHODIMP nsMessenger::OnItemAdded(nsIMsgFolder *parentItem,
+                                       nsISupports *item) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-/* void OnItemRemoved (in nsIMsgFolder parentItem, in nsISupports item); */
-NS_IMETHODIMP nsMessenger::OnItemRemoved(nsIMsgFolder *parentItem, nsISupports *item)
-{
+NS_IMETHODIMP nsMessenger::OnItemRemoved(nsIMsgFolder *parentItem,
+                                         nsISupports *item) {
   // check if this item is a message header that's in our history list. If so,
   // remove it from the history list.
-  nsCOMPtr <nsIMsgDBHdr> msgHdr = do_QueryInterface(item);
-  if (msgHdr)
-  {
-    nsCOMPtr <nsIMsgFolder> folder;
+  nsCOMPtr<nsIMsgDBHdr> msgHdr = do_QueryInterface(item);
+  if (msgHdr) {
+    nsCOMPtr<nsIMsgFolder> folder;
     msgHdr->GetFolder(getter_AddRefs(folder));
-    if (folder)
-    {
+    if (folder) {
       nsCString msgUri;
       nsMsgKey msgKey;
       msgHdr->GetMessageKey(&msgKey);
       folder->GenerateMessageURI(msgKey, msgUri);
       // need to remove the correspnding folder entry, and
       // adjust the current history pos.
       size_t uriPos = mLoadedMsgHistory.IndexOf(msgUri);
-      if (uriPos != mLoadedMsgHistory.NoIndex)
-      {
+      if (uriPos != mLoadedMsgHistory.NoIndex) {
         mLoadedMsgHistory.RemoveElementAt(uriPos);
-        mLoadedMsgHistory.RemoveElementAt(uriPos); // and the folder uri entry
-        if (mCurHistoryPos >= (int32_t)uriPos)
-          mCurHistoryPos -= 2;
+        mLoadedMsgHistory.RemoveElementAt(uriPos);  // and the folder uri entry
+        if (mCurHistoryPos >= (int32_t)uriPos) mCurHistoryPos -= 2;
       }
     }
   }
   return NS_OK;
 }
 
-/* void OnItemPropertyChanged (in nsIMsgFolder item, in ACString property, in string oldValue, in string newValue); */
-NS_IMETHODIMP nsMessenger::OnItemPropertyChanged(nsIMsgFolder *item, const nsACString &property, const char *oldValue, const char *newValue)
-{
+NS_IMETHODIMP nsMessenger::OnItemPropertyChanged(nsIMsgFolder *item,
+                                                 const nsACString &property,
+                                                 const char *oldValue,
+                                                 const char *newValue) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-/* void OnItemIntPropertyChanged (in nsIMsgFolder item, in ACString property, in long long oldValue, in long long newValue); */
-NS_IMETHODIMP nsMessenger::OnItemIntPropertyChanged(nsIMsgFolder *item, const nsACString &property, int64_t oldValue, int64_t newValue)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/* void OnItemBoolPropertyChanged (in nsIMsgFolder item, in ACString property, in boolean oldValue, in boolean newValue); */
-NS_IMETHODIMP nsMessenger::OnItemBoolPropertyChanged(nsIMsgFolder *item, const nsACString &property, bool oldValue, bool newValue)
-{
+NS_IMETHODIMP nsMessenger::OnItemIntPropertyChanged(nsIMsgFolder *item,
+                                                    const nsACString &property,
+                                                    int64_t oldValue,
+                                                    int64_t newValue) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-/* void OnItemUnicharPropertyChanged (in nsIMsgFolder item, in ACString property, in wstring oldValue, in wstring newValue); */
-NS_IMETHODIMP nsMessenger::OnItemUnicharPropertyChanged(nsIMsgFolder *item, const nsACString &property, const char16_t *oldValue, const char16_t *newValue)
-{
+NS_IMETHODIMP nsMessenger::OnItemBoolPropertyChanged(nsIMsgFolder *item,
+                                                     const nsACString &property,
+                                                     bool oldValue,
+                                                     bool newValue) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-/* void OnItemPropertyFlagChanged (in nsIMsgDBHdr item, in ACString property, in unsigned long oldFlag, in unsigned long newFlag); */
-NS_IMETHODIMP nsMessenger::OnItemPropertyFlagChanged(nsIMsgDBHdr *item, const nsACString &property, uint32_t oldFlag, uint32_t newFlag)
-{
+NS_IMETHODIMP nsMessenger::OnItemUnicharPropertyChanged(
+    nsIMsgFolder *item, const nsACString &property, const char16_t *oldValue,
+    const char16_t *newValue) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-/* void OnItemEvent (in nsIMsgFolder item, in string event); */
-NS_IMETHODIMP nsMessenger::OnItemEvent(nsIMsgFolder *item, const nsACString &event)
-{
+NS_IMETHODIMP nsMessenger::OnItemPropertyFlagChanged(nsIMsgDBHdr *item,
+                                                     const nsACString &property,
+                                                     uint32_t oldFlag,
+                                                     uint32_t newFlag) {
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP nsMessenger::OnItemEvent(nsIMsgFolder *item,
+                                       const nsACString &event) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // Detach/Delete Attachments
 ///////////////////////////////////////////////////////////////////////////////
 
-static const char * GetAttachmentPartId(const char * aAttachmentUrl)
-{
+static const char *GetAttachmentPartId(const char *aAttachmentUrl) {
   static const char partIdPrefix[] = "part=";
-  const char * partId = PL_strstr(aAttachmentUrl, partIdPrefix);
+  const char *partId = PL_strstr(aAttachmentUrl, partIdPrefix);
   return partId ? (partId + sizeof(partIdPrefix) - 1) : nullptr;
 }
 
-static int CompareAttachmentPartId(const char * aAttachUrlLeft, const char * aAttachUrlRight)
-{
+static int CompareAttachmentPartId(const char *aAttachUrlLeft,
+                                   const char *aAttachUrlRight) {
   // part ids are numbers separated by periods, like "1.2.3.4".
-  // we sort by doing a numerical comparison on each item in turn. e.g. "1.4" < "1.25"
-  // shorter entries come before longer entries. e.g. "1.4" < "1.4.1.2"
+  // we sort by doing a numerical comparison on each item in turn. e.g. "1.4" <
+  // "1.25" shorter entries come before longer entries. e.g. "1.4" < "1.4.1.2"
   // return values:
   //  -2  left is a parent of right
   //  -1  left is less than right
   //   0  left == right
   //   1  right is greater than left
   //   2  right is a parent of left
 
-  const char * partIdLeft  = GetAttachmentPartId(aAttachUrlLeft);
-  const char * partIdRight = GetAttachmentPartId(aAttachUrlRight);
+  const char *partIdLeft = GetAttachmentPartId(aAttachUrlLeft);
+  const char *partIdRight = GetAttachmentPartId(aAttachUrlRight);
 
   // for detached attachments the URL does not contain any "part=xx"
-  if(!partIdLeft)
-    partIdLeft = "0";
-
-  if(!partIdRight)
-    partIdRight = "0";
+  if (!partIdLeft) partIdLeft = "0";
+
+  if (!partIdRight) partIdRight = "0";
 
   long idLeft, idRight;
-  do
-  {
-    MOZ_ASSERT(partIdLeft && IS_DIGIT(*partIdLeft), "Invalid character in part id string");
-    MOZ_ASSERT(partIdRight && IS_DIGIT(*partIdRight), "Invalid character in part id string");
-
-    // if the part numbers are different then the numerically smaller one is first
+  do {
+    MOZ_ASSERT(partIdLeft && IS_DIGIT(*partIdLeft),
+               "Invalid character in part id string");
+    MOZ_ASSERT(partIdRight && IS_DIGIT(*partIdRight),
+               "Invalid character in part id string");
+
+    // if the part numbers are different then the numerically smaller one is
+    // first
     char *fixConstLoss;
-    idLeft  = strtol(partIdLeft, &fixConstLoss, 10);
+    idLeft = strtol(partIdLeft, &fixConstLoss, 10);
     partIdLeft = fixConstLoss;
     idRight = strtol(partIdRight, &fixConstLoss, 10);
     partIdRight = fixConstLoss;
-    if (idLeft != idRight)
-      return idLeft < idRight ? -1 : 1;
+    if (idLeft != idRight) return idLeft < idRight ? -1 : 1;
 
     // if one part id is complete but the other isn't, then the shortest one
     // is first (parents before children)
-    if (*partIdLeft != *partIdRight)
-      return *partIdRight ? -2 : 2;
+    if (*partIdLeft != *partIdRight) return *partIdRight ? -2 : 2;
 
     // if both part ids are complete (*partIdLeft == *partIdRight now) then
     // they are equal
-    if (!*partIdLeft)
-      return 0;
+    if (!*partIdLeft) return 0;
 
     MOZ_ASSERT(*partIdLeft == '.', "Invalid character in part id string");
     MOZ_ASSERT(*partIdRight == '.', "Invalid character in part id string");
 
     ++partIdLeft;
     ++partIdRight;
-  }
-  while (true);
+  } while (true);
 }
 
 // ------------------------------------
 
 // struct on purpose -> show that we don't ever want a vtable
-struct msgAttachment
-{
+struct msgAttachment {
   msgAttachment()
-    : mContentType(nullptr),
-      mUrl(nullptr),
-      mDisplayName(nullptr),
-      mMessageUri(nullptr)
-  {
-  }
-
-  ~msgAttachment()
-  {
-    Clear();
-  }
-
-  void Clear()
-  {
+      : mContentType(nullptr),
+        mUrl(nullptr),
+        mDisplayName(nullptr),
+        mMessageUri(nullptr) {}
+
+  ~msgAttachment() { Clear(); }
+
+  void Clear() {
     free(mContentType);
     free(mUrl);
     free(mDisplayName);
     free(mMessageUri);
   }
 
-  bool Init(const char * aContentType, const char * aUrl,
-              const char * aDisplayName, const char * aMessageUri)
-  {
+  bool Init(const char *aContentType, const char *aUrl,
+            const char *aDisplayName, const char *aMessageUri) {
     Clear();
     mContentType = strdup(aContentType);
     mUrl = strdup(aUrl);
     mDisplayName = strdup(aDisplayName);
     mMessageUri = strdup(aMessageUri);
     return (mContentType && mUrl && mDisplayName && mMessageUri);
   }
 
   // take the pointers from aSource
-  void Adopt(msgAttachment & aSource)
-  {
+  void Adopt(msgAttachment &aSource) {
     Clear();
 
     mContentType = aSource.mContentType;
     mUrl = aSource.mUrl;
     mDisplayName = aSource.mDisplayName;
     mMessageUri = aSource.mMessageUri;
 
     aSource.mContentType = nullptr;
     aSource.mUrl = nullptr;
     aSource.mDisplayName = nullptr;
     aSource.mMessageUri = nullptr;
   }
 
-  char* mContentType;
-  char* mUrl;
-  char* mDisplayName;
-  char* mMessageUri;
-
-private:
+  char *mContentType;
+  char *mUrl;
+  char *mDisplayName;
+  char *mMessageUri;
+
+ private:
   // disable by not implementing
-  msgAttachment(const msgAttachment & rhs);
-  msgAttachment & operator=(const msgAttachment & rhs);
+  msgAttachment(const msgAttachment &rhs);
+  msgAttachment &operator=(const msgAttachment &rhs);
 };
 
 // ------------------------------------
 
-class nsAttachmentState
-{
-public:
+class nsAttachmentState {
+ public:
   nsAttachmentState();
   ~nsAttachmentState();
-  nsresult Init(uint32_t aCount,
-                const char **aContentTypeArray,
-                const char **aUrlArray,
-                const char **aDisplayNameArray,
+  nsresult Init(uint32_t aCount, const char **aContentTypeArray,
+                const char **aUrlArray, const char **aDisplayNameArray,
                 const char **aMessageUriArray);
   nsresult PrepareForAttachmentDelete();
 
-private:
-  static int SortAttachmentsByPartId(const void * aLeft, const void * aRight);
-
-public:
-  uint32_t        mCount;
-  uint32_t        mCurIndex;
-  msgAttachment*  mAttachmentArray;
+ private:
+  static int SortAttachmentsByPartId(const void *aLeft, const void *aRight);
+
+ public:
+  uint32_t mCount;
+  uint32_t mCurIndex;
+  msgAttachment *mAttachmentArray;
 };
 
 nsAttachmentState::nsAttachmentState()
-  : mCount(0),
-    mCurIndex(0),
-    mAttachmentArray(nullptr)
-{
-}
-
-nsAttachmentState::~nsAttachmentState()
-{
-  delete[] mAttachmentArray;
-}
-
-nsresult
-nsAttachmentState::Init(uint32_t aCount, const char ** aContentTypeArray,
-                        const char ** aUrlArray, const char ** aDisplayNameArray,
-                        const char ** aMessageUriArray)
-{
+    : mCount(0), mCurIndex(0), mAttachmentArray(nullptr) {}
+
+nsAttachmentState::~nsAttachmentState() { delete[] mAttachmentArray; }
+
+nsresult nsAttachmentState::Init(uint32_t aCount,
+                                 const char **aContentTypeArray,
+                                 const char **aUrlArray,
+                                 const char **aDisplayNameArray,
+                                 const char **aMessageUriArray) {
   MOZ_ASSERT(aCount > 0, "count is invalid");
 
   mCount = aCount;
   mCurIndex = 0;
   delete[] mAttachmentArray;
 
   mAttachmentArray = new msgAttachment[aCount];
-  if (!mAttachmentArray)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  for(uint32_t u = 0; u < aCount; ++u)
-  {
+  if (!mAttachmentArray) return NS_ERROR_OUT_OF_MEMORY;
+
+  for (uint32_t u = 0; u < aCount; ++u) {
     if (!mAttachmentArray[u].Init(aContentTypeArray[u], aUrlArray[u],
-      aDisplayNameArray[u], aMessageUriArray[u]))
+                                  aDisplayNameArray[u], aMessageUriArray[u]))
       return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return NS_OK;
 }
 
-nsresult
-nsAttachmentState::PrepareForAttachmentDelete()
-{
+nsresult nsAttachmentState::PrepareForAttachmentDelete() {
   // this must be called before any processing
-  if (mCurIndex != 0)
-    return NS_ERROR_FAILURE;
-
-  // this prepares the attachment list for use in deletion. In order to prepare, we
-  // sort the attachments in numerical ascending order on their part id, remove all
-  // duplicates and remove any subparts which will be removed automatically by the
-  // removal of the parent.
+  if (mCurIndex != 0) return NS_ERROR_FAILURE;
+
+  // this prepares the attachment list for use in deletion. In order to prepare,
+  // we sort the attachments in numerical ascending order on their part id,
+  // remove all duplicates and remove any subparts which will be removed
+  // automatically by the removal of the parent.
   //
   // e.g. the attachment list processing (showing only part ids)
   // before: 1.11, 1.3, 1.2, 1.2.1.3, 1.4.1.2
   // sorted: 1.2, 1.2.1.3, 1.3, 1.4.1.2, 1.11
   // after:  1.2, 1.3, 1.4.1.2, 1.11
 
   // sort
-  qsort(mAttachmentArray, mCount, sizeof(msgAttachment), SortAttachmentsByPartId);
+  qsort(mAttachmentArray, mCount, sizeof(msgAttachment),
+        SortAttachmentsByPartId);
 
   // remove duplicates and sub-items
   int nCompare;
-  for(uint32_t u = 1; u < mCount;)
-  {
-    nCompare = ::CompareAttachmentPartId(mAttachmentArray[u-1].mUrl, mAttachmentArray[u].mUrl);
-    if (nCompare == 0 || nCompare == -2) // [u-1] is the same as or a parent of [u]
+  for (uint32_t u = 1; u < mCount;) {
+    nCompare = ::CompareAttachmentPartId(mAttachmentArray[u - 1].mUrl,
+                                         mAttachmentArray[u].mUrl);
+    if (nCompare == 0 ||
+        nCompare == -2)  // [u-1] is the same as or a parent of [u]
     {
       // shuffle the array down (and thus keeping the sorted order)
       // this will get rid of the current unnecessary element
-      for (uint32_t i = u + 1; i < mCount; ++i)
-      {
-        mAttachmentArray[i-1].Adopt(mAttachmentArray[i]);
+      for (uint32_t i = u + 1; i < mCount; ++i) {
+        mAttachmentArray[i - 1].Adopt(mAttachmentArray[i]);
       }
       --mCount;
-    }
-    else
-    {
+    } else {
       ++u;
     }
   }
 
   return NS_OK;
 }
 
-int
-nsAttachmentState::SortAttachmentsByPartId(const void * aLeft, const void * aRight)
-{
-  msgAttachment & attachLeft  = *((msgAttachment*) aLeft);
-  msgAttachment & attachRight = *((msgAttachment*) aRight);
+int nsAttachmentState::SortAttachmentsByPartId(const void *aLeft,
+                                               const void *aRight) {
+  msgAttachment &attachLeft = *((msgAttachment *)aLeft);
+  msgAttachment &attachRight = *((msgAttachment *)aRight);
   return ::CompareAttachmentPartId(attachLeft.mUrl, attachRight.mUrl);
 }
 
 // ------------------------------------
 
 class nsDelAttachListener : public nsIStreamListener,
                             public nsIUrlListener,
-                            public nsIMsgCopyServiceListener
-{
-public:
+                            public nsIMsgCopyServiceListener {
+ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSIURLLISTENER
   NS_DECL_NSIMSGCOPYSERVICELISTENER
 
-public:
+ public:
   nsDelAttachListener();
-  nsresult StartProcessing(nsMessenger * aMessenger, nsIMsgWindow * aMsgWindow,
-    nsAttachmentState * aAttach, bool aSaveFirst);
+  nsresult StartProcessing(nsMessenger *aMessenger, nsIMsgWindow *aMsgWindow,
+                           nsAttachmentState *aAttach, bool aSaveFirst);
   nsresult DeleteOriginalMessage();
   void SelectNewMessage();
 
-public:
-  nsAttachmentState * mAttach;                      // list of attachments to process
-  bool mSaveFirst;                                // detach (true) or delete (false)
-  nsCOMPtr<nsIFile> mMsgFile;                       // temporary file (processed mail)
-  nsCOMPtr<nsIOutputStream> mMsgFileStream;         // temporary file (processed mail)
-  nsCOMPtr<nsIMsgMessageService> mMessageService;   // original message service
-  nsCOMPtr<nsIMsgDBHdr> mOriginalMessage;           // original message header
-  nsCOMPtr<nsIMsgFolder> mMessageFolder;            // original message folder
-  nsCOMPtr<nsIMessenger> mMessenger;                // our messenger instance
-  nsCOMPtr<nsIMsgWindow> mMsgWindow;                // our UI window
-  nsMsgKey mNewMessageKey;                          // new message key
+ public:
+  nsAttachmentState *mAttach;                // list of attachments to process
+  bool mSaveFirst;                           // detach (true) or delete (false)
+  nsCOMPtr<nsIFile> mMsgFile;                // temporary file (processed mail)
+  nsCOMPtr<nsIOutputStream> mMsgFileStream;  // temporary file (processed mail)
+  nsCOMPtr<nsIMsgMessageService> mMessageService;  // original message service
+  nsCOMPtr<nsIMsgDBHdr> mOriginalMessage;          // original message header
+  nsCOMPtr<nsIMsgFolder> mMessageFolder;           // original message folder
+  nsCOMPtr<nsIMessenger> mMessenger;               // our messenger instance
+  nsCOMPtr<nsIMsgWindow> mMsgWindow;               // our UI window
+  nsMsgKey mNewMessageKey;                         // new message key
   uint32_t mOrigMsgFlags;
 
-
-   enum {
-      eStarting,
-      eCopyingNewMsg,
-      eUpdatingFolder, // for IMAP
-      eDeletingOldMessage,
-      eSelectingNewMessage
-    } m_state;
-   // temp
+  enum {
+    eStarting,
+    eCopyingNewMsg,
+    eUpdatingFolder,  // for IMAP
+    eDeletingOldMessage,
+    eSelectingNewMessage
+  } m_state;
+  // temp
   bool mWrittenExtra;
   bool mDetaching;
   nsTArray<nsCString> mDetachedFileUris;
 
-private:
+ private:
   virtual ~nsDelAttachListener();
 };
 
 //
 // nsISupports
 //
-NS_IMPL_ISUPPORTS(nsDelAttachListener,
-                   nsIStreamListener,
-                   nsIRequestObserver,
-                   nsIUrlListener,
-                   nsIMsgCopyServiceListener)
+NS_IMPL_ISUPPORTS(nsDelAttachListener, nsIStreamListener, nsIRequestObserver,
+                  nsIUrlListener, nsIMsgCopyServiceListener)
 
 //
 // nsIRequestObserver
 //
 NS_IMETHODIMP
-nsDelAttachListener::OnStartRequest(nsIRequest * aRequest)
-{
+nsDelAttachListener::OnStartRequest(nsIRequest *aRequest) {
   // called when we start processing the StreamMessage request.
   // This is called after OnStartRunningUrl().
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDelAttachListener::OnStopRequest(nsIRequest * aRequest, nsresult aStatusCode)
-{
+nsDelAttachListener::OnStopRequest(nsIRequest *aRequest, nsresult aStatusCode) {
   // called when we have completed processing the StreamMessage request.
   // This is called after OnStopRequest(). This means that we have now
   // received all data of the message and we have completed processing.
   // We now start to copy the processed message from the temporary file
   // back into the message store, replacing the original message.
 
   mMessageFolder->CopyDataDone();
-  if (NS_FAILED(aStatusCode))
-    return aStatusCode;
+  if (NS_FAILED(aStatusCode)) return aStatusCode;
 
   // called when we complete processing of the StreamMessage request.
   // This is called before OnStopRunningUrl().
   nsresult rv;
 
   // copy the file back into the folder. Note: setting msgToReplace only copies
   // metadata, so we do the delete ourselves
   nsCOMPtr<nsIMsgCopyServiceListener> listenerCopyService;
-  rv = this->QueryInterface( NS_GET_IID(nsIMsgCopyServiceListener), getter_AddRefs(listenerCopyService) );
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = this->QueryInterface(NS_GET_IID(nsIMsgCopyServiceListener),
+                            getter_AddRefs(listenerCopyService));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   mMsgFileStream->Close();
   mMsgFileStream = nullptr;
   mNewMessageKey = nsMsgKey_None;
-  nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID);
+  nsCOMPtr<nsIMsgCopyService> copyService =
+      do_GetService(NS_MSGCOPYSERVICE_CONTRACTID);
   m_state = eCopyingNewMsg;
   // clone file because nsIFile on Windows caches the wrong file size.
-  nsCOMPtr <nsIFile> clone;
+  nsCOMPtr<nsIFile> clone;
   mMsgFile->Clone(getter_AddRefs(clone));
-  if (copyService)
-  {
+  if (copyService) {
     nsCString originalKeys;
-    mOriginalMessage->GetStringProperty("keywords", getter_Copies(originalKeys));
-    rv = copyService->CopyFileMessage(clone, mMessageFolder, mOriginalMessage, false,
-                                      mOrigMsgFlags, originalKeys, listenerCopyService, mMsgWindow);
+    mOriginalMessage->GetStringProperty("keywords",
+                                        getter_Copies(originalKeys));
+    rv = copyService->CopyFileMessage(clone, mMessageFolder, mOriginalMessage,
+                                      false, mOrigMsgFlags, originalKeys,
+                                      listenerCopyService, mMsgWindow);
   }
   return rv;
 }
 
 //
 // nsIStreamListener
 //
 
 NS_IMETHODIMP
-nsDelAttachListener::OnDataAvailable(nsIRequest * aRequest,
-                                     nsIInputStream * aInStream, uint64_t aSrcOffset,
-                                     uint32_t aCount)
-{
-  if (!mMsgFileStream)
-    return NS_ERROR_NULL_POINTER;
-  return mMessageFolder->CopyDataToOutputStreamForAppend(aInStream, aCount, mMsgFileStream);
+nsDelAttachListener::OnDataAvailable(nsIRequest *aRequest,
+                                     nsIInputStream *aInStream,
+                                     uint64_t aSrcOffset, uint32_t aCount) {
+  if (!mMsgFileStream) return NS_ERROR_NULL_POINTER;
+  return mMessageFolder->CopyDataToOutputStreamForAppend(aInStream, aCount,
+                                                         mMsgFileStream);
 }
 
 //
 // nsIUrlListener
 //
 
 NS_IMETHODIMP
-nsDelAttachListener::OnStartRunningUrl(nsIURI * aUrl)
-{
+nsDelAttachListener::OnStartRunningUrl(nsIURI *aUrl) {
   // called when we start processing the StreamMessage request. This is
   // called before OnStartRequest().
   return NS_OK;
 }
 
-nsresult nsDelAttachListener::DeleteOriginalMessage()
-{
+nsresult nsDelAttachListener::DeleteOriginalMessage() {
   nsresult rv;
-  nsCOMPtr<nsIMutableArray> messageArray(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  nsCOMPtr<nsIMutableArray> messageArray(
+      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = messageArray->AppendElement(mOriginalMessage);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIMsgCopyServiceListener> listenerCopyService;
 
-  QueryInterface( NS_GET_IID(nsIMsgCopyServiceListener), getter_AddRefs(listenerCopyService) );
+  QueryInterface(NS_GET_IID(nsIMsgCopyServiceListener),
+                 getter_AddRefs(listenerCopyService));
 
   mOriginalMessage = nullptr;
   m_state = eDeletingOldMessage;
-  return mMessageFolder->DeleteMessages(
-    messageArray,         // messages
-    mMsgWindow,           // msgWindow
-    true,              // deleteStorage
-    false,              // isMove
-    listenerCopyService,  // listener
-    false);            // allowUndo
+  return mMessageFolder->DeleteMessages(messageArray,         // messages
+                                        mMsgWindow,           // msgWindow
+                                        true,                 // deleteStorage
+                                        false,                // isMove
+                                        listenerCopyService,  // listener
+                                        false);               // allowUndo
 }
 
-void nsDelAttachListener::SelectNewMessage()
-{
+void nsDelAttachListener::SelectNewMessage() {
   nsCString displayUri;
   // all attachments refer to the same message
-  const char * messageUri = mAttach->mAttachmentArray[0].mMessageUri;
+  const char *messageUri = mAttach->mAttachmentArray[0].mMessageUri;
   mMessenger->GetLastDisplayedMessageUri(displayUri);
-  if (displayUri.Equals(messageUri))
-  {
+  if (displayUri.Equals(messageUri)) {
     mMessageFolder->GenerateMessageURI(mNewMessageKey, displayUri);
-    if (!displayUri.IsEmpty() && mMsgWindow)
-    {
+    if (!displayUri.IsEmpty() && mMsgWindow) {
       nsCOMPtr<nsIMsgWindowCommands> windowCommands;
       mMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
-      if (windowCommands)
-        windowCommands->SelectMessage(displayUri);
+      if (windowCommands) windowCommands->SelectMessage(displayUri);
     }
   }
   mNewMessageKey = nsMsgKey_None;
 }
 
 NS_IMETHODIMP
-nsDelAttachListener::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
-{
+nsDelAttachListener::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode) {
   nsresult rv = NS_OK;
-  const char * messageUri = mAttach->mAttachmentArray[0].mMessageUri;
-  if (mOriginalMessage && !strncmp(messageUri, "imap-message:", 13))
-  {
-    if (m_state == eUpdatingFolder)
-      rv = DeleteOriginalMessage();
+  const char *messageUri = mAttach->mAttachmentArray[0].mMessageUri;
+  if (mOriginalMessage && !strncmp(messageUri, "imap-message:", 13)) {
+    if (m_state == eUpdatingFolder) rv = DeleteOriginalMessage();
   }
   // check if we've deleted the original message, and we know the new msg id.
   else if (m_state == eDeletingOldMessage && mMsgWindow)
     SelectNewMessage();
 
   return rv;
 }
 
 //
 // nsIMsgCopyServiceListener
 //
 
 NS_IMETHODIMP
-nsDelAttachListener::OnStartCopy(void)
-{
+nsDelAttachListener::OnStartCopy(void) {
   // never called?
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDelAttachListener::OnProgress(uint32_t aProgress, uint32_t aProgressMax)
-{
+nsDelAttachListener::OnProgress(uint32_t aProgress, uint32_t aProgressMax) {
   // never called?
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDelAttachListener::SetMessageKey(nsMsgKey aKey)
-{
+nsDelAttachListener::SetMessageKey(nsMsgKey aKey) {
   // called during the copy of the modified message back into the message
   // store to notify us of the message key of the newly created message.
   mNewMessageKey = aKey;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDelAttachListener::GetMessageId(nsACString& aMessageId)
-{
+nsDelAttachListener::GetMessageId(nsACString &aMessageId) {
   // never called?
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsDelAttachListener::OnStopCopy(nsresult aStatus)
-{
-  // only if the currently selected message is the one that we are about to delete then we
-  // change the selection to the new message that we just added. Failures in this code are not fatal.
-  // Note that can only do this if we have the new message key, which we don't always get from IMAP.
-  // delete the original message
-  if (NS_FAILED(aStatus))
-    return aStatus;
+nsDelAttachListener::OnStopCopy(nsresult aStatus) {
+  // only if the currently selected message is the one that we are about to
+  // delete then we change the selection to the new message that we just added.
+  // Failures in this code are not fatal. Note that can only do this if we have
+  // the new message key, which we don't always get from IMAP. delete the
+  // original message
+  if (NS_FAILED(aStatus)) return aStatus;
 
   // check if we've deleted the original message, and we know the new msg id.
-  if (m_state == eDeletingOldMessage && mMsgWindow)
-    SelectNewMessage();
+  if (m_state == eDeletingOldMessage && mMsgWindow) SelectNewMessage();
   // do this for non-imap messages - for imap, we'll do the delete in
   // OnStopRunningUrl. For local messages, we won't get an OnStopRunningUrl
   // notification. And for imap, it's too late to delete the message here,
   // because we'll be updating the folder naturally as a result of
   // running an append url. If we delete the header here, that folder
   // update will think we need to download the header...If we do it
   // in OnStopRunningUrl, we'll issue the delete before we do the
   // update....all nasty stuff.
-  const char * messageUri = mAttach->mAttachmentArray[0].mMessageUri;
+  const char *messageUri = mAttach->mAttachmentArray[0].mMessageUri;
   if (mOriginalMessage && strncmp(messageUri, "imap-message:", 13))
     return DeleteOriginalMessage();
   else
     m_state = eUpdatingFolder;
   return NS_OK;
 }
 
 //
 // local methods
 //
 
-nsDelAttachListener::nsDelAttachListener()
-{
+nsDelAttachListener::nsDelAttachListener() {
   mAttach = nullptr;
   mSaveFirst = false;
   mWrittenExtra = false;
   mNewMessageKey = nsMsgKey_None;
   m_state = eStarting;
 }
 
-nsDelAttachListener::~nsDelAttachListener()
-{
-  if (mAttach)
-  {
+nsDelAttachListener::~nsDelAttachListener() {
+  if (mAttach) {
     delete mAttach;
   }
-  if (mMsgFileStream)
-  {
+  if (mMsgFileStream) {
     mMsgFileStream->Close();
     mMsgFileStream = nullptr;
   }
-  if (mMsgFile)
-  {
+  if (mMsgFile) {
     mMsgFile->Remove(false);
   }
 }
 
-nsresult
-nsDelAttachListener::StartProcessing(nsMessenger * aMessenger, nsIMsgWindow * aMsgWindow,
-                                     nsAttachmentState * aAttach, bool detaching)
-{
-  aMessenger->QueryInterface(NS_GET_IID(nsIMessenger), getter_AddRefs(mMessenger));
+nsresult nsDelAttachListener::StartProcessing(nsMessenger *aMessenger,
+                                              nsIMsgWindow *aMsgWindow,
+                                              nsAttachmentState *aAttach,
+                                              bool detaching) {
+  aMessenger->QueryInterface(NS_GET_IID(nsIMessenger),
+                             getter_AddRefs(mMessenger));
   mMsgWindow = aMsgWindow;
-  mAttach    = aAttach;
+  mAttach = aAttach;
   mDetaching = detaching;
 
   nsresult rv;
 
   // all attachments refer to the same message
-  const char * messageUri = mAttach->mAttachmentArray[0].mMessageUri;
+  const char *messageUri = mAttach->mAttachmentArray[0].mMessageUri;
 
   // get the message service, original message and folder for this message
-  rv = GetMessageServiceFromURI(nsDependentCString(messageUri), getter_AddRefs(mMessageService));
-  NS_ENSURE_SUCCESS(rv,rv);
-  rv = mMessageService->MessageURIToMsgHdr(messageUri, getter_AddRefs(mOriginalMessage));
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = GetMessageServiceFromURI(nsDependentCString(messageUri),
+                                getter_AddRefs(mMessageService));
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = mMessageService->MessageURIToMsgHdr(messageUri,
+                                           getter_AddRefs(mOriginalMessage));
+  NS_ENSURE_SUCCESS(rv, rv);
   rv = mOriginalMessage->GetFolder(getter_AddRefs(mMessageFolder));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   mOriginalMessage->GetFlags(&mOrigMsgFlags);
 
   // ensure that we can store and delete messages in this folder, if we
   // can't then we can't do attachment deleting
   bool canDelete = false;
   mMessageFolder->GetCanDeleteMessages(&canDelete);
   bool canFile = false;
   mMessageFolder->GetCanFileMessages(&canFile);
-  if (!canDelete || !canFile)
-    return NS_ERROR_FAILURE;
-
-  // create an output stream on a temporary file. This stream will save the modified
-  // message data to a file which we will later use to replace the existing message.
-  // The file is removed in the destructor.
+  if (!canDelete || !canFile) return NS_ERROR_FAILURE;
+
+  // create an output stream on a temporary file. This stream will save the
+  // modified message data to a file which we will later use to replace the
+  // existing message. The file is removed in the destructor.
   rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, "nsmail.tmp",
                                        getter_AddRefs(mMsgFile));
-  NS_ENSURE_SUCCESS(rv,rv);
-
-  // For temp file, we should use restrictive 00600 instead of ATTACHMENT_PERMISSION
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  // For temp file, we should use restrictive 00600 instead of
+  // ATTACHMENT_PERMISSION
   rv = mMsgFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
-  NS_ENSURE_SUCCESS(rv,rv);
-
-  rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mMsgFileStream), mMsgFile, -1, ATTACHMENT_PERMISSION);
-
-  // create the additional header for data conversion. This will tell the stream converter
-  // which MIME emitter we want to use, and it will tell the MIME emitter which attachments
-  // should be deleted.
-  const char * partId;
-  const char * nextField;
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mMsgFileStream), mMsgFile,
+                                      -1, ATTACHMENT_PERMISSION);
+
+  // create the additional header for data conversion. This will tell the stream
+  // converter which MIME emitter we want to use, and it will tell the MIME
+  // emitter which attachments should be deleted.
+  const char *partId;
+  const char *nextField;
   nsAutoCString sHeader("attach&del=");
   nsAutoCString detachToHeader("&detachTo=");
-  for (uint32_t u = 0; u < mAttach->mCount; ++u)
-  {
-    if (u > 0)
-    {
+  for (uint32_t u = 0; u < mAttach->mCount; ++u) {
+    if (u > 0) {
       sHeader.Append(',');
-      if (detaching)
-        detachToHeader.Append(',');
+      if (detaching) detachToHeader.Append(',');
     }
     partId = GetAttachmentPartId(mAttach->mAttachmentArray[u].mUrl);
     nextField = PL_strchr(partId, '&');
     sHeader.Append(partId, nextField ? nextField - partId : -1);
-    if (detaching)
-      detachToHeader.Append(mDetachedFileUris[u]);
+    if (detaching) detachToHeader.Append(mDetachedFileUris[u]);
   }
 
-  if (detaching)
-    sHeader.Append(detachToHeader);
+  if (detaching) sHeader.Append(detachToHeader);
   // stream this message to our listener converting it via the attachment mime
-  // converter. The listener will just write the converted message straight to disk.
+  // converter. The listener will just write the converted message straight to
+  // disk.
   nsCOMPtr<nsISupports> listenerSupports;
-  rv = this->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(listenerSupports));
-  NS_ENSURE_SUCCESS(rv,rv);
-  nsCOMPtr<nsIUrlListener> listenerUrlListener = do_QueryInterface(listenerSupports, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = this->QueryInterface(NS_GET_IID(nsISupports),
+                            getter_AddRefs(listenerSupports));
+  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIUrlListener> listenerUrlListener =
+      do_QueryInterface(listenerSupports, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIURI> dummyNull;
   rv = mMessageService->StreamMessage(messageUri, listenerSupports, mMsgWindow,
-                                      listenerUrlListener, true, sHeader,
-                                      false, getter_AddRefs(dummyNull));
-  NS_ENSURE_SUCCESS(rv,rv);
+                                      listenerUrlListener, true, sHeader, false,
+                                      getter_AddRefs(dummyNull));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 // ------------------------------------
 
 NS_IMETHODIMP
-nsMessenger::DetachAttachment(const char * aContentType, const char * aUrl,
-                              const char * aDisplayName, const char * aMessageUri,
-                              bool aSaveFirst, bool withoutWarning = false)
-{
+nsMessenger::DetachAttachment(const char *aContentType, const char *aUrl,
+                              const char *aDisplayName, const char *aMessageUri,
+                              bool aSaveFirst, bool withoutWarning = false) {
   NS_ENSURE_ARG_POINTER(aContentType);
   NS_ENSURE_ARG_POINTER(aUrl);
   NS_ENSURE_ARG_POINTER(aDisplayName);
   NS_ENSURE_ARG_POINTER(aMessageUri);
 
   if (aSaveFirst)
-    return SaveOneAttachment(aContentType, aUrl, aDisplayName, aMessageUri, true);
-  return DetachAttachments(1, &aContentType, &aUrl, &aDisplayName, &aMessageUri, nullptr, withoutWarning);
+    return SaveOneAttachment(aContentType, aUrl, aDisplayName, aMessageUri,
+                             true);
+  return DetachAttachments(1, &aContentType, &aUrl, &aDisplayName, &aMessageUri,
+                           nullptr, withoutWarning);
 }
 
 NS_IMETHODIMP
-nsMessenger::DetachAllAttachments(uint32_t aCount,
-                                  const char ** aContentTypeArray,
-                                  const char ** aUrlArray,
-                                  const char ** aDisplayNameArray,
-                                  const char ** aMessageUriArray,
-                                  bool aSaveFirst,
-                                  bool withoutWarning = false)
-{
+nsMessenger::DetachAllAttachments(
+    uint32_t aCount, const char **aContentTypeArray, const char **aUrlArray,
+    const char **aDisplayNameArray, const char **aMessageUriArray,
+    bool aSaveFirst, bool withoutWarning = false) {
   NS_ENSURE_ARG_MIN(aCount, 1);
   NS_ENSURE_ARG_POINTER(aContentTypeArray);
   NS_ENSURE_ARG_POINTER(aUrlArray);
   NS_ENSURE_ARG_POINTER(aDisplayNameArray);
   NS_ENSURE_ARG_POINTER(aMessageUriArray);
 
   if (aSaveFirst)
-    return SaveAllAttachments(aCount, aContentTypeArray, aUrlArray, aDisplayNameArray, aMessageUriArray, true);
+    return SaveAllAttachments(aCount, aContentTypeArray, aUrlArray,
+                              aDisplayNameArray, aMessageUriArray, true);
   else
-    return DetachAttachments(aCount, aContentTypeArray, aUrlArray, aDisplayNameArray, aMessageUriArray, nullptr, withoutWarning);
+    return DetachAttachments(aCount, aContentTypeArray, aUrlArray,
+                             aDisplayNameArray, aMessageUriArray, nullptr,
+                             withoutWarning);
 }
 
-nsresult
-nsMessenger::DetachAttachments(uint32_t aCount,
-                               const char ** aContentTypeArray,
-                               const char ** aUrlArray,
-                               const char ** aDisplayNameArray,
-                               const char ** aMessageUriArray,
-                               nsTArray<nsCString> *saveFileUris,
-                               bool withoutWarning)
-{
+nsresult nsMessenger::DetachAttachments(
+    uint32_t aCount, const char **aContentTypeArray, const char **aUrlArray,
+    const char **aDisplayNameArray, const char **aMessageUriArray,
+    nsTArray<nsCString> *saveFileUris, bool withoutWarning) {
   // if withoutWarning no dialog for user
-  if (!withoutWarning && NS_FAILED(PromptIfDeleteAttachments(saveFileUris != nullptr, aCount, aDisplayNameArray)))
-      return NS_OK;
+  if (!withoutWarning &&
+      NS_FAILED(PromptIfDeleteAttachments(saveFileUris != nullptr, aCount,
+                                          aDisplayNameArray)))
+    return NS_OK;
 
   nsresult rv = NS_OK;
 
   // ensure that our arguments are valid
-//  char * partId;
-  for (uint32_t u = 0; u < aCount; ++u)
-  {
+  //  char * partId;
+  for (uint32_t u = 0; u < aCount; ++u) {
     // ensure all of the message URI are the same, we cannot process
     // attachments from different messages
-    if (u > 0 && 0 != strcmp(aMessageUriArray[0], aMessageUriArray[u]))
-    {
+    if (u > 0 && 0 != strcmp(aMessageUriArray[0], aMessageUriArray[u])) {
       rv = NS_ERROR_INVALID_ARG;
       break;
     }
 
     // ensure that we don't have deleted messages in this list
-    if (0 == strcmp(aContentTypeArray[u], MIMETYPE_DELETED))
-    {
+    if (0 == strcmp(aContentTypeArray[u], MIMETYPE_DELETED)) {
       rv = NS_ERROR_INVALID_ARG;
       break;
     }
 
     // for the moment we prevent any attachments other than root level
     // attachments being deleted (i.e. you can't delete attachments from a
     // email forwarded as an attachment). We do this by ensuring that the
     // part id only has a single period in it (e.g. "1.2").
-    //TODO: support non-root level attachment delete
-//    partId = ::GetAttachmentPartId(aUrlArray[u]);
-//    if (!partId || PL_strchr(partId, '.') != PL_strrchr(partId, '.'))
-//    {
-//      rv = NS_ERROR_INVALID_ARG;
-//      break;
-//    }
+    // TODO: support non-root level attachment delete
+    //    partId = ::GetAttachmentPartId(aUrlArray[u]);
+    //    if (!partId || PL_strchr(partId, '.') != PL_strrchr(partId, '.'))
+    //    {
+    //      rv = NS_ERROR_INVALID_ARG;
+    //      break;
+    //    }
   }
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     Alert("deleteAttachmentFailure");
     return rv;
   }
 
-  //TODO: ensure that nothing else is processing this message uri at the same time
-
-  //TODO: if any of the selected attachments are messages that contain other
+  // TODO: ensure that nothing else is processing this message uri at the same
+  // time
+
+  // TODO: if any of the selected attachments are messages that contain other
   // attachments we need to warn the user that all sub-attachments of those
   // messages will also be deleted. Best to display a list of them.
 
   // get the listener for running the url
-  nsDelAttachListener * listener = new nsDelAttachListener;
-  if (!listener)
-    return NS_ERROR_OUT_OF_MEMORY;
-  nsCOMPtr<nsISupports> listenerSupports; // auto-delete of the listener with error
-  listener->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(listenerSupports));
-
-  if (saveFileUris)
-    listener->mDetachedFileUris = *saveFileUris;
+  nsDelAttachListener *listener = new nsDelAttachListener;
+  if (!listener) return NS_ERROR_OUT_OF_MEMORY;
+  nsCOMPtr<nsISupports>
+      listenerSupports;  // auto-delete of the listener with error
+  listener->QueryInterface(NS_GET_IID(nsISupports),
+                           getter_AddRefs(listenerSupports));
+
+  if (saveFileUris) listener->mDetachedFileUris = *saveFileUris;
   // create the attachments for use by the listener
-  nsAttachmentState * attach = new nsAttachmentState;
-  if (!attach)
-    return NS_ERROR_OUT_OF_MEMORY;
-  rv = attach->Init(aCount, aContentTypeArray, aUrlArray, aDisplayNameArray, aMessageUriArray);
-  if (NS_SUCCEEDED(rv))
-    rv = attach->PrepareForAttachmentDelete();
-  if (NS_FAILED(rv))
-  {
+  nsAttachmentState *attach = new nsAttachmentState;
+  if (!attach) return NS_ERROR_OUT_OF_MEMORY;
+  rv = attach->Init(aCount, aContentTypeArray, aUrlArray, aDisplayNameArray,
+                    aMessageUriArray);
+  if (NS_SUCCEEDED(rv)) rv = attach->PrepareForAttachmentDelete();
+  if (NS_FAILED(rv)) {
     delete attach;
     return rv;
   }
 
-  // initialize our listener with the attachments and details. The listener takes ownership
-  // of 'attach' immediately irrespective of the return value (error or not).
-  return listener->StartProcessing(this, mMsgWindow, attach, saveFileUris != nullptr);
+  // initialize our listener with the attachments and details. The listener
+  // takes ownership of 'attach' immediately irrespective of the return value
+  // (error or not).
+  return listener->StartProcessing(this, mMsgWindow, attach,
+                                   saveFileUris != nullptr);
 }
 
-nsresult
-nsMessenger::PromptIfDeleteAttachments(bool aSaveFirst,
-                                       uint32_t aCount,
-                                       const char ** aDisplayNameArray)
-{
+nsresult nsMessenger::PromptIfDeleteAttachments(
+    bool aSaveFirst, uint32_t aCount, const char **aDisplayNameArray) {
   nsresult rv = NS_ERROR_FAILURE;
 
   nsCOMPtr<nsIPrompt> dialog(do_GetInterface(mDocShell));
   if (!dialog) return rv;
 
-  if (!mStringBundle)
-  {
+  if (!mStringBundle) {
     rv = InitStringBundle();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // create the list of attachments we are removing
   nsString displayString;
   nsString attachmentList;
-  for (uint32_t u = 0; u < aCount; ++u)
-  {
+  for (uint32_t u = 0; u < aCount; ++u) {
     ConvertAndSanitizeFileName(aDisplayNameArray[u], displayString);
     attachmentList.Append(displayString);
     attachmentList.Append(char16_t('\n'));
   }
-  const char16_t *formatStrings[] = { attachmentList.get() };
+  const char16_t *formatStrings[] = {attachmentList.get()};
 
   // format the message and display
   nsString promptMessage;
-  const char * propertyName = aSaveFirst ?
-    "detachAttachments" : "deleteAttachments";
-  rv = mStringBundle->FormatStringFromName(propertyName, formatStrings, 1,promptMessage);
+  const char *propertyName =
+      aSaveFirst ? "detachAttachments" : "deleteAttachments";
+  rv = mStringBundle->FormatStringFromName(propertyName, formatStrings, 1,
+                                           promptMessage);
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool dialogResult = false;
   rv = dialog->Confirm(nullptr, promptMessage.get(), &dialogResult);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return dialogResult ? NS_OK : NS_ERROR_FAILURE;
 }
-
--- a/mailnews/base/src/nsMessenger.h
+++ b/mailnews/base/src/nsMessenger.h
@@ -16,108 +16,107 @@
 #include "nsIStringBundle.h"
 #include "nsIFile.h"
 #include "nsIFilePicker.h"
 #include "nsWeakReference.h"
 #include "mozIDOMWindow.h"
 #include "nsTArray.h"
 #include "nsIFolderListener.h"
 
-class nsMessenger : public nsIMessenger, public nsSupportsWeakReference, public nsIFolderListener
-{
+class nsMessenger : public nsIMessenger,
+                    public nsSupportsWeakReference,
+                    public nsIFolderListener {
   using PathString = mozilla::PathString;
 
-public:
+ public:
   nsMessenger();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMESSENGER
   NS_DECL_NSIFOLDERLISTENER
 
-  nsresult Alert(const char * stringName);
+  nsresult Alert(const char *stringName);
 
-  nsresult SaveAttachment(nsIFile *file, const nsACString& unescapedUrl,
-                          const nsACString& messageUri, const nsACString& contentType,
-                          void *closure, nsIUrlListener *aListener);
+  nsresult SaveAttachment(nsIFile *file, const nsACString &unescapedUrl,
+                          const nsACString &messageUri,
+                          const nsACString &contentType, void *closure,
+                          nsIUrlListener *aListener);
   nsresult PromptIfFileExists(nsIFile *file);
-  nsresult DetachAttachments(uint32_t aCount,
-                             const char ** aContentTypeArray,
-                             const char ** aUrlArray,
-                             const char ** aDisplayNameArray,
-                             const char ** aMessageUriArray,
+  nsresult DetachAttachments(uint32_t aCount, const char **aContentTypeArray,
+                             const char **aUrlArray,
+                             const char **aDisplayNameArray,
+                             const char **aMessageUriArray,
                              nsTArray<nsCString> *saveFileUris,
                              bool withoutWarning = false);
-  nsresult SaveAllAttachments(uint32_t count,
-                              const char **contentTypeArray,
+  nsresult SaveAllAttachments(uint32_t count, const char **contentTypeArray,
                               const char **urlArray,
                               const char **displayNameArray,
-                              const char **messageUriArray,
-                              bool detaching);
-  nsresult SaveOneAttachment(const char* aContentType,
-                             const char* aURL,
-                             const char* aDisplayName,
-                             const char* aMessageUri,
+                              const char **messageUriArray, bool detaching);
+  nsresult SaveOneAttachment(const char *aContentType, const char *aURL,
+                             const char *aDisplayName, const char *aMessageUri,
                              bool detaching);
 
-protected:
+ protected:
   virtual ~nsMessenger();
 
-  void GetString(const nsString& aStringName, nsString& stringValue);
+  void GetString(const nsString &aStringName, nsString &stringValue);
   nsresult InitStringBundle();
-  nsresult PromptIfDeleteAttachments(bool saveFirst, uint32_t count, const char **displayNameArray);
+  nsresult PromptIfDeleteAttachments(bool saveFirst, uint32_t count,
+                                     const char **displayNameArray);
 
-private:
+ private:
   nsresult GetLastSaveDirectory(nsIFile **aLastSaveAsDir);
-  // if aLocalFile is a dir, we use it.  otherwise, we use the parent of aLocalFile.
+  // if aLocalFile is a dir, we use it.  otherwise, we use the parent of
+  // aLocalFile.
   nsresult SetLastSaveDirectory(nsIFile *aLocalFile);
 
-  nsresult AdjustFileIfNameTooLong(nsIFile* aFile);
+  nsresult AdjustFileIfNameTooLong(nsIFile *aFile);
 
-  nsresult GetSaveAsFile(const nsAString& aMsgFilename, int32_t *aSaveAsFileType,
-                         nsIFile **aSaveAsFile);
+  nsresult GetSaveAsFile(const nsAString &aMsgFilename,
+                         int32_t *aSaveAsFileType, nsIFile **aSaveAsFile);
 
   nsresult GetSaveToDir(nsIFile **aSaveToDir);
   nsresult ShowPicker(nsIFilePicker *aPicker, int16_t *aResult);
 
-  class nsFilePickerShownCallback
-    : public nsIFilePickerShownCallback
-  {
-    virtual ~nsFilePickerShownCallback()
-    { }
+  class nsFilePickerShownCallback : public nsIFilePickerShownCallback {
+    virtual ~nsFilePickerShownCallback() {}
 
-  public:
+   public:
     nsFilePickerShownCallback();
     NS_DECL_ISUPPORTS
 
     NS_IMETHOD Done(int16_t aResult) override;
 
-  public:
+   public:
     bool mPickerDone;
     int16_t mResult;
   };
 
   nsString mId;
   nsCOMPtr<nsITransactionManager> mTxnMgr;
 
   /* rhp - need this to drive message display */
   nsCOMPtr<mozIDOMWindowProxy> mWindow;
-  nsCOMPtr<nsIMsgWindow>       mMsgWindow;
-  nsCOMPtr<nsIDocShell>        mDocShell;
+  nsCOMPtr<nsIMsgWindow> mMsgWindow;
+  nsCOMPtr<nsIDocShell> mDocShell;
 
   // String bundles...
-  nsCOMPtr<nsIStringBundle>   mStringBundle;
+  nsCOMPtr<nsIStringBundle> mStringBundle;
 
   nsCString mCurrentDisplayCharset;
 
-  nsCOMPtr<nsISupports>  mSearchContext;
-  nsCString   mLastDisplayURI; // this used when the user attempts to force a charset reload of a message...we need to get the last displayed
-                               // uri so we can re-display it..
+  nsCOMPtr<nsISupports> mSearchContext;
+  // this used when the user attempts to force a charset reload of a message...
+  // we need to get the last displayed uri so we can re-display it.
+  nsCString mLastDisplayURI;
   nsCString mNavigatingToUri;
   nsTArray<nsCString> mLoadedMsgHistory;
   int32_t mCurHistoryPos;
 };
 
-#define NS_MESSENGER_CID \
-{ /* f436a174-e2c0-4955-9afe-e3feb68aee56 */      \
-  0xf436a174, 0xe2c0, 0x4955,                     \
-    {0x9a, 0xfe, 0xe3, 0xfe, 0xb6, 0x8a, 0xee, 0x56}}
+#define NS_MESSENGER_CID                             \
+  { /* f436a174-e2c0-4955-9afe-e3feb68aee56 */       \
+    0xf436a174, 0xe2c0, 0x4955, {                    \
+      0x9a, 0xfe, 0xe3, 0xfe, 0xb6, 0x8a, 0xee, 0x56 \
+    }                                                \
+  }
 
 #endif
--- a/mailnews/base/src/nsMessengerBootstrap.cpp
+++ b/mailnews/base/src/nsMessengerBootstrap.cpp
@@ -12,72 +12,71 @@
 #include "nsMsgUtils.h"
 #include "nsISupportsPrimitives.h"
 #include "mozIDOMWindow.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 
 NS_IMPL_ISUPPORTS(nsMessengerBootstrap, nsIMessengerWindowService)
 
-nsMessengerBootstrap::nsMessengerBootstrap()
-{
-}
+nsMessengerBootstrap::nsMessengerBootstrap() {}
 
-nsMessengerBootstrap::~nsMessengerBootstrap()
-{
-}
+nsMessengerBootstrap::~nsMessengerBootstrap() {}
 
-NS_IMETHODIMP nsMessengerBootstrap::OpenMessengerWindowWithUri(const char *windowType, const char * aFolderURI, nsMsgKey aMessageKey)
-{
+NS_IMETHODIMP nsMessengerBootstrap::OpenMessengerWindowWithUri(
+    const char *windowType, const char *aFolderURI, nsMsgKey aMessageKey) {
   bool standAloneMsgWindow = false;
   nsAutoCString chromeUrl("chrome://messenger/content/");
-  if (windowType && !strcmp(windowType, "mail:messageWindow"))
-  {
+  if (windowType && !strcmp(windowType, "mail:messageWindow")) {
     chromeUrl.AppendLiteral("messageWindow.xul");
     standAloneMsgWindow = true;
   }
   nsresult rv;
-  nsCOMPtr<nsIMutableArray> argsArray(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  nsCOMPtr<nsIMutableArray> argsArray(
+      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // create scriptable versions of our strings that we can store in our nsIMutableArray....
-  if (aFolderURI)
-  {
-    if (standAloneMsgWindow)
-    {
-      nsCOMPtr <nsIMsgFolder> folder;
-      rv = GetExistingFolder(nsDependentCString(aFolderURI), getter_AddRefs(folder));
+  // create scriptable versions of our strings that we can store in our
+  // nsIMutableArray....
+  if (aFolderURI) {
+    if (standAloneMsgWindow) {
+      nsCOMPtr<nsIMsgFolder> folder;
+      rv = GetExistingFolder(nsDependentCString(aFolderURI),
+                             getter_AddRefs(folder));
       NS_ENSURE_SUCCESS(rv, rv);
       nsAutoCString msgUri;
       folder->GetBaseMessageURI(msgUri);
 
-      nsCOMPtr<nsISupportsCString> scriptableMsgURI (do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
+      nsCOMPtr<nsISupportsCString> scriptableMsgURI(
+          do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
       NS_ENSURE_TRUE(scriptableMsgURI, NS_ERROR_FAILURE);
       msgUri.Append('#');
       msgUri.AppendInt(aMessageKey, 10);
       scriptableMsgURI->SetData(msgUri);
       argsArray->AppendElement(scriptableMsgURI);
     }
-    nsCOMPtr<nsISupportsCString> scriptableFolderURI (do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
+    nsCOMPtr<nsISupportsCString> scriptableFolderURI(
+        do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
     NS_ENSURE_TRUE(scriptableFolderURI, NS_ERROR_FAILURE);
 
     scriptableFolderURI->SetData(nsDependentCString(aFolderURI));
     argsArray->AppendElement(scriptableFolderURI);
 
-    if (!standAloneMsgWindow)
-    {
-      nsCOMPtr<nsISupportsPRUint32> scriptableMessageKey (do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID));
+    if (!standAloneMsgWindow) {
+      nsCOMPtr<nsISupportsPRUint32> scriptableMessageKey(
+          do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID));
       NS_ENSURE_TRUE(scriptableMessageKey, NS_ERROR_FAILURE);
       scriptableMessageKey->SetData(aMessageKey);
       argsArray->AppendElement(scriptableMessageKey);
     }
   }
 
-  nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
+  nsCOMPtr<nsIWindowWatcher> wwatch(
+      do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // we need to use the "mailnews.reuse_thread_window2" pref
   // to determine if we should open a new window, or use an existing one.
   nsCOMPtr<mozIDOMWindowProxy> newWindow;
   return wwatch->OpenWindow(0, chromeUrl.get(), "_blank",
                             "chrome,all,dialog=no", argsArray,
-                             getter_AddRefs(newWindow));
+                            getter_AddRefs(newWindow));
 }
--- a/mailnews/base/src/nsMessengerBootstrap.h
+++ b/mailnews/base/src/nsMessengerBootstrap.h
@@ -1,31 +1,30 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-
 #ifndef __nsMessenger_h
 #define __nsMessenger_h
 
 #include "nscore.h"
 #include "nsIMessengerWindowService.h"
 
-#define NS_MESSENGERBOOTSTRAP_CID                 \
-{ /* 4a85a5d0-cddd-11d2-b7f6-00805f05ffa5 */      \
-  0x4a85a5d0, 0xcddd, 0x11d2,                     \
-  {0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5}}
+#define NS_MESSENGERBOOTSTRAP_CID                    \
+  { /* 4a85a5d0-cddd-11d2-b7f6-00805f05ffa5 */       \
+    0x4a85a5d0, 0xcddd, 0x11d2, {                    \
+      0xb7, 0xf6, 0x00, 0x80, 0x5f, 0x05, 0xff, 0xa5 \
+    }                                                \
+  }
 
-class nsMessengerBootstrap :
-    public nsIMessengerWindowService
-{
-public:
+class nsMessengerBootstrap : public nsIMessengerWindowService {
+ public:
   nsMessengerBootstrap();
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIMESSENGERWINDOWSERVICE
 
-private:
+ private:
   virtual ~nsMessengerBootstrap();
 };
 
 #endif
--- a/mailnews/base/src/nsMessengerContentHandler.cpp
+++ b/mailnews/base/src/nsMessengerContentHandler.cpp
@@ -12,88 +12,81 @@
 #include "nsIWebNavigation.h"
 #include "nsString.h"
 #include "nsMsgBaseCID.h"
 #include "plstr.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIURIMutator.h"
 
-nsMessengerContentHandler::nsMessengerContentHandler()
-{
-}
+nsMessengerContentHandler::nsMessengerContentHandler() {}
 
-/* the following macro actually implement addref, release and query interface for our component. */
+/* the following macro actually implement addref, release and query interface
+ * for our component. */
 NS_IMPL_ISUPPORTS(nsMessengerContentHandler, nsIContentHandler)
 
-nsMessengerContentHandler::~nsMessengerContentHandler()
-{
-}
+nsMessengerContentHandler::~nsMessengerContentHandler() {}
 
-NS_IMETHODIMP nsMessengerContentHandler::HandleContent(const char * aContentType,
-                                                nsIInterfaceRequestor* aWindowContext, nsIRequest *request)
-{
+NS_IMETHODIMP nsMessengerContentHandler::HandleContent(
+    const char* aContentType, nsIInterfaceRequestor* aWindowContext,
+    nsIRequest* request) {
   nsresult rv = NS_OK;
-  if (!request)
-    return NS_ERROR_NULL_POINTER;
+  if (!request) return NS_ERROR_NULL_POINTER;
 
-  // First of all, get the content type and make sure it is a content type we know how to handle!
+  // First of all, get the content type and make sure it is a content type we
+  // know how to handle!
   if (PL_strcasecmp(aContentType, "application/x-message-display") == 0) {
     nsCOMPtr<nsIURI> aUri;
     nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
     if (!aChannel) return NS_ERROR_FAILURE;
 
     rv = aChannel->GetURI(getter_AddRefs(aUri));
-    if (aUri)
-    {
+    if (aUri) {
       rv = request->Cancel(NS_ERROR_ABORT);
-      if (NS_SUCCEEDED(rv))
-      {
+      if (NS_SUCCEEDED(rv)) {
         nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(aUri);
-        if (mailnewsurl)
-        {
+        if (mailnewsurl) {
           nsAutoCString queryPart;
           mailnewsurl->GetQuery(queryPart);
           queryPart.Replace(queryPart.Find("type=message/rfc822"),
                             sizeof("type=message/rfc822") - 1,
                             "type=application/x-message-display");
           // Don't mutate/clone here.
           rv = mailnewsurl->SetQueryInternal(queryPart);
           NS_ENSURE_SUCCESS(rv, rv);
           rv = OpenWindow(aUri);
-        }
-        else
-        {
+        } else {
           // Not an nsIMsgMailNewsUrl, so maybe a file URL, like opening a
           // message attachment (.eml file in a temp directory).
           nsAutoCString scheme;
           rv = aUri->GetScheme(scheme);
           NS_ENSURE_SUCCESS(rv, rv);
           if (scheme.Equals("file")) {
             // Add a special bit like in MsgOpenFromFile().
             rv = NS_MutateURI(aUri)
-                   .SetQuery(NS_LITERAL_CSTRING("type=application/x-message-display"))
-                   .Finalize(aUri);
+                     .SetQuery(NS_LITERAL_CSTRING(
+                         "type=application/x-message-display"))
+                     .Finalize(aUri);
             NS_ENSURE_SUCCESS(rv, rv);
           }
           rv = OpenWindow(aUri);
         }
       }
     }
   }
 
   return rv;
 }
 
-// Utility function to open a message display window and and load the message in it.
-nsresult nsMessengerContentHandler::OpenWindow(nsIURI* aURI)
-{
+// Utility function to open a message display window and and load the message in
+// it.
+nsresult nsMessengerContentHandler::OpenWindow(nsIURI* aURI) {
   NS_ENSURE_ARG_POINTER(aURI);
 
-  nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
-  if (!wwatch)
-    return NS_ERROR_FAILURE;
+  nsCOMPtr<nsIWindowWatcher> wwatch =
+      do_GetService("@mozilla.org/embedcomp/window-watcher;1");
+  if (!wwatch) return NS_ERROR_FAILURE;
 
   nsCOMPtr<mozIDOMWindowProxy> newWindow;
   return wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul",
-                 "_blank", "all,chrome,dialog=no,status,toolbar", aURI,
-                 getter_AddRefs(newWindow));
+                            "_blank", "all,chrome,dialog=no,status,toolbar",
+                            aURI, getter_AddRefs(newWindow));
 }
--- a/mailnews/base/src/nsMessengerContentHandler.h
+++ b/mailnews/base/src/nsMessengerContentHandler.h
@@ -1,20 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "nsIContentHandler.h"
 #include "nsIURI.h"
 
-class nsMessengerContentHandler : public nsIContentHandler
-{
-public:
+class nsMessengerContentHandler : public nsIContentHandler {
+ public:
   nsMessengerContentHandler();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSICONTENTHANDLER
 
-private:
+ private:
   virtual ~nsMessengerContentHandler();
   nsresult OpenWindow(nsIURI* aURI);
 };
--- a/mailnews/base/src/nsMessengerOSXIntegration.h
+++ b/mailnews/base/src/nsMessengerOSXIntegration.h
@@ -10,51 +10,57 @@
 #include "nsIFolderListener.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIObserver.h"
 #include "nsIAlertsService.h"
 #include "mozINewMailListener.h"
 
-#define NS_MESSENGEROSXINTEGRATION_CID \
-  {0xaa83266, 0x4225, 0x4c4b, \
-  {0x93, 0xf8, 0x94, 0xb1, 0x82, 0x58, 0x6f, 0x93}}
+#define NS_MESSENGEROSXINTEGRATION_CID               \
+  {                                                  \
+    0xaa83266, 0x4225, 0x4c4b, {                     \
+      0x93, 0xf8, 0x94, 0xb1, 0x82, 0x58, 0x6f, 0x93 \
+    }                                                \
+  }
 
 class nsIStringBundle;
 
 class nsMessengerOSXIntegration : public nsIMessengerOSIntegration,
                                   public nsIFolderListener,
                                   public nsIObserver,
-                                  public mozINewMailListener
-{
-public:
+                                  public mozINewMailListener {
+ public:
   nsMessengerOSXIntegration();
   virtual nsresult Init();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMESSENGEROSINTEGRATION
   NS_DECL_NSIFOLDERLISTENER
   NS_DECL_NSIOBSERVER
   NS_DECL_MOZINEWMAILLISTENER
 
-private:
+ private:
   virtual ~nsMessengerOSXIntegration();
 
-  nsresult ShowAlertMessage(const nsAString& aAlertTitle, const nsAString& aAlertText, const nsACString& aFolderURI);
+  nsresult ShowAlertMessage(const nsAString& aAlertTitle,
+                            const nsAString& aAlertText,
+                            const nsACString& aFolderURI);
   nsresult OnAlertFinished();
-  nsresult OnAlertClicked(const char16_t * aAlertCookie);
+  nsresult OnAlertClicked(const char16_t* aAlertCookie);
 #ifdef MOZ_SUITE
   nsresult OnAlertClickedSimple();
 #endif
-  nsresult GetStringBundle(nsIStringBundle **aBundle);
-  void FillToolTipInfo(nsIMsgFolder *aFolder, int32_t aNewCount);
-  nsresult GetFirstFolderWithNewMail(nsIMsgFolder* aFolder, nsCString& aFolderURI);
+  nsresult GetStringBundle(nsIStringBundle** aBundle);
+  void FillToolTipInfo(nsIMsgFolder* aFolder, int32_t aNewCount);
+  nsresult GetFirstFolderWithNewMail(nsIMsgFolder* aFolder,
+                                     nsCString& aFolderURI);
   nsresult BadgeDockIcon();
   nsresult RestoreDockIcon();
   nsresult BounceDockIcon();
-  nsresult GetNewMailAuthors(nsIMsgFolder* aFolder, nsString& aAuthors, int32_t aNewCount, int32_t* aNotDisplayed);
+  nsresult GetNewMailAuthors(nsIMsgFolder* aFolder, nsString& aAuthors,
+                             int32_t aNewCount, int32_t* aNotDisplayed);
 
   int32_t mUnreadTotal;
   int32_t mUnreadChat;
 };
 
-#endif // __nsMessengerOSXIntegration_h
+#endif  // __nsMessengerOSXIntegration_h
--- a/mailnews/base/src/nsMessengerOSXIntegration.mm
+++ b/mailnews/base/src/nsMessengerOSXIntegration.mm
@@ -57,212 +57,182 @@
 #define kBiffAnimateDockIconPref "mail.biff.animate_dock_icon"
 #define kMaxDisplayCount 10
 #define kNewChatMessageTopic "new-directed-incoming-message"
 #define kUnreadImCountChangedTopic "unread-im-count-changed"
 
 using namespace mozilla::mailnews;
 
 // HACK: Limitations in Focus/SetFocus on Mac (see bug 465446)
-nsresult FocusAppNative()
-{
+nsresult FocusAppNative() {
   ProcessSerialNumber psn;
 
-  if (::GetCurrentProcess(&psn) != 0)
-   return NS_ERROR_FAILURE;
+  if (::GetCurrentProcess(&psn) != 0) return NS_ERROR_FAILURE;
 
-  if (::SetFrontProcess(&psn) != 0)
-   return NS_ERROR_FAILURE;
+  if (::SetFrontProcess(&psn) != 0) return NS_ERROR_FAILURE;
 
   return NS_OK;
 }
 
-static void openMailWindow(const nsCString& aUri)
-{
+static void openMailWindow(const nsCString &aUri) {
   nsresult rv;
-  nsCOMPtr<nsIMsgMailSession> mailSession ( do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
-  if (NS_FAILED(rv))
-    return;
+  nsCOMPtr<nsIMsgMailSession> mailSession(do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) return;
 
   nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
   rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
-  if (topMostMsgWindow)
-  {
-    if (!aUri.IsEmpty())
-    {
+  if (topMostMsgWindow) {
+    if (!aUri.IsEmpty()) {
       nsCOMPtr<nsIMsgMailNewsUrl> msgUri(do_CreateInstance(NS_MAILBOXURL_CONTRACTID, &rv));
-      if (NS_FAILED(rv))
-        return;
+      if (NS_FAILED(rv)) return;
 
       rv = msgUri->SetSpecInternal(aUri);
-      if (NS_FAILED(rv))
-        return;
+      if (NS_FAILED(rv)) return;
 
       bool isMessageUri = false;
       msgUri->GetIsMessageUri(&isMessageUri);
-      if (isMessageUri)
-      {
+      if (isMessageUri) {
         nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
-        if (NS_FAILED(rv))
-          return;
+        if (NS_FAILED(rv)) return;
 
-        // SeaMonkey only supports message uris, whereas Thunderbird only
-        // supports message headers. This should be simplified/removed when
-        // bug 507593 is implemented.
+          // SeaMonkey only supports message uris, whereas Thunderbird only
+          // supports message headers. This should be simplified/removed when
+          // bug 507593 is implemented.
 #ifdef MOZ_SUITE
         nsCOMPtr<mozIDOMWindowProxy> newWindow;
-        wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul",
-                           "_blank", "all,chrome,dialog=no,status,toolbar", msgUri,
+        wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul", "_blank",
+                           "all,chrome,dialog=no,status,toolbar", msgUri,
                            getter_AddRefs(newWindow));
 #else
         nsCOMPtr<nsIMessenger> messenger(do_CreateInstance(NS_MESSENGER_CONTRACTID, &rv));
-        if (NS_FAILED(rv))
-          return;
+        if (NS_FAILED(rv)) return;
 
         nsCOMPtr<nsIMsgDBHdr> msgHdr;
         messenger->MsgHdrFromURI(aUri, getter_AddRefs(msgHdr));
-        if (msgHdr)
-        {
+        if (msgHdr) {
           nsCOMPtr<mozIDOMWindowProxy> newWindow;
-          wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul",
-                             "_blank", "all,chrome,dialog=no,status,toolbar", msgHdr,
+          wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul", "_blank",
+                             "all,chrome,dialog=no,status,toolbar", msgHdr,
                              getter_AddRefs(newWindow));
         }
 #endif
-      }
-      else
-      {
+      } else {
         nsCOMPtr<nsIMsgWindowCommands> windowCommands;
         topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
-        if (windowCommands)
-          windowCommands->SelectFolder(aUri);
+        if (windowCommands) windowCommands->SelectFolder(aUri);
       }
     }
 
     FocusAppNative();
     nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
     if (domWindow) {
       nsCOMPtr<nsPIDOMWindowOuter> privateWindow = nsPIDOMWindowOuter::From(domWindow);
       privateWindow->Focus();
     }
-  }
-  else
-  {
+  } else {
     // the user doesn't have a mail window open already so open one for them...
     nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
-      do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
+        do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
     // if we want to preselect the first account with new mail,
     // here is where we would try to generate a uri to pass in
     // (and add code to the messenger window service to make that work)
     if (messengerWindowService)
-      messengerWindowService->OpenMessengerWindowWithUri(
-                                "mail:3pane", aUri.get(), nsMsgKey_None);
+      messengerWindowService->OpenMessengerWindowWithUri("mail:3pane", aUri.get(), nsMsgKey_None);
   }
 }
 
-nsMessengerOSXIntegration::nsMessengerOSXIntegration()
-{
+nsMessengerOSXIntegration::nsMessengerOSXIntegration() {
   mUnreadTotal = 0;
   mUnreadChat = 0;
 }
 
-nsMessengerOSXIntegration::~nsMessengerOSXIntegration()
-{
-  RestoreDockIcon();
-}
+nsMessengerOSXIntegration::~nsMessengerOSXIntegration() { RestoreDockIcon(); }
 
 NS_IMPL_ADDREF(nsMessengerOSXIntegration)
 NS_IMPL_RELEASE(nsMessengerOSXIntegration)
 
 NS_INTERFACE_MAP_BEGIN(nsMessengerOSXIntegration)
-   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMessengerOSIntegration)
-   NS_INTERFACE_MAP_ENTRY(nsIMessengerOSIntegration)
-   NS_INTERFACE_MAP_ENTRY(nsIFolderListener)
-   NS_INTERFACE_MAP_ENTRY(nsIObserver)
-   NS_INTERFACE_MAP_ENTRY(mozINewMailListener)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMessengerOSIntegration)
+  NS_INTERFACE_MAP_ENTRY(nsIMessengerOSIntegration)
+  NS_INTERFACE_MAP_ENTRY(nsIFolderListener)
+  NS_INTERFACE_MAP_ENTRY(nsIObserver)
+  NS_INTERFACE_MAP_ENTRY(mozINewMailListener)
 NS_INTERFACE_MAP_END
 
-
-nsresult
-nsMessengerOSXIntegration::Init()
-{
+nsresult nsMessengerOSXIntegration::Init() {
   nsresult rv;
-  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
+  nsCOMPtr<nsIObserverService> observerService =
+      do_GetService("@mozilla.org/observer-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   return observerService->AddObserver(this, "mail-startup-done", false);
 }
 
 NS_IMETHODIMP
-nsMessengerOSXIntegration::OnItemPropertyChanged(nsIMsgFolder *, const nsACString &, char const *, char const *)
-{
+nsMessengerOSXIntegration::OnItemPropertyChanged(nsIMsgFolder *, const nsACString &, char const *,
+                                                 char const *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerOSXIntegration::OnItemUnicharPropertyChanged(nsIMsgFolder *, const nsACString &, const char16_t *, const char16_t *)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsMessengerOSXIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *)
-{
+nsMessengerOSXIntegration::OnItemUnicharPropertyChanged(nsIMsgFolder *, const nsACString &,
+                                                        const char16_t *, const char16_t *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerOSXIntegration::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
-{
-  if (!strcmp(aTopic, "alertfinished"))
-    return OnAlertFinished();
+nsMessengerOSXIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *) { return NS_OK; }
 
-  if (!strcmp(aTopic, "alertclickcallback"))
-    return OnAlertClicked(aData);
+NS_IMETHODIMP
+nsMessengerOSXIntegration::Observe(nsISupports *aSubject, const char *aTopic,
+                                   const char16_t *aData) {
+  if (!strcmp(aTopic, "alertfinished")) return OnAlertFinished();
+
+  if (!strcmp(aTopic, "alertclickcallback")) return OnAlertClicked(aData);
 
 #ifdef MOZ_SUITE
   // SeaMonkey does most of the GUI work in JS code when clicking on a mail
   // notification, so it needs an extra function here
-  if (!strcmp(aTopic, "alertclicksimplecallback"))
-    return OnAlertClickedSimple();
+  if (!strcmp(aTopic, "alertclicksimplecallback")) return OnAlertClickedSimple();
 #endif
 
   if (!strcmp(aTopic, "mail-startup-done")) {
     nsresult rv;
-    nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
+    nsCOMPtr<nsIObserverService> observerService =
+        do_GetService("@mozilla.org/observer-service;1", &rv);
     if (NS_SUCCEEDED(rv)) {
       observerService->RemoveObserver(this, "mail-startup-done");
 
       bool chatEnabled = false;
       nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-      if (NS_SUCCEEDED(rv))
-        rv = pref->GetBoolPref(kChatEnabledPref, &chatEnabled);
+      if (NS_SUCCEEDED(rv)) rv = pref->GetBoolPref(kChatEnabledPref, &chatEnabled);
       if (NS_SUCCEEDED(rv) && chatEnabled) {
         observerService->AddObserver(this, kNewChatMessageTopic, false);
         observerService->AddObserver(this, kUnreadImCountChangedTopic, false);
       }
     }
 
     // Register with the new mail service for changes to the unread message count
-    nsCOMPtr<mozINewMailNotificationService> newmail
-      = do_GetService(MOZ_NEWMAILNOTIFICATIONSERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv); // This should really be an assert with a helpful message
+    nsCOMPtr<mozINewMailNotificationService> newmail =
+        do_GetService(MOZ_NEWMAILNOTIFICATIONSERVICE_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, rv);  // This should really be an assert with a helpful message
     rv = newmail->AddListener(this, mozINewMailNotificationService::count);
-    NS_ENSURE_SUCCESS(rv, rv); // This should really be an assert with a helpful message
+    NS_ENSURE_SUCCESS(rv, rv);  // This should really be an assert with a helpful message
 
     // Get the initial unread count. Ignore return value; if code above didn't fail, this won't
     rv = newmail->GetMessageCount(&mUnreadTotal);
     BadgeDockIcon();
 
     // register with the mail sesson for folder events
     // we care about new count, biff status
     nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    return mailSession->AddFolderListener(this, nsIFolderListener::boolPropertyChanged | nsIFolderListener::intPropertyChanged);
+    return mailSession->AddFolderListener(
+        this, nsIFolderListener::boolPropertyChanged | nsIFolderListener::intPropertyChanged);
   }
 
   if (!strcmp(aTopic, kNewChatMessageTopic)) {
     // We don't have to bother about checking if the window is already focused
     // before attempting to bounce the dock icon, as BounceDockIcon is
     // implemented by a getAttention call which won't do anything if the window
     // requesting attention is already focused.
     return BounceDockIcon();
@@ -277,457 +247,358 @@ nsMessengerOSXIntegration::Observe(nsISu
     NS_ENSURE_SUCCESS(rv, rv);
 
     return BadgeDockIcon();
   }
 
   return NS_OK;
 }
 
-nsresult
-nsMessengerOSXIntegration::GetStringBundle(nsIStringBundle **aBundle)
-{
+nsresult nsMessengerOSXIntegration::GetStringBundle(nsIStringBundle **aBundle) {
   NS_ENSURE_ARG_POINTER(aBundle);
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
   nsCOMPtr<nsIStringBundle> bundle;
   if (bundleService && NS_SUCCEEDED(rv))
-    bundleService->CreateBundle("chrome://messenger/locale/messenger.properties", getter_AddRefs(bundle));
+    bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
+                                getter_AddRefs(bundle));
   bundle.forget(aBundle);
   return rv;
 }
 
-void
-nsMessengerOSXIntegration::FillToolTipInfo(nsIMsgFolder *aFolder, int32_t aNewCount)
-{
-  if (aFolder)
-  {
+void nsMessengerOSXIntegration::FillToolTipInfo(nsIMsgFolder *aFolder, int32_t aNewCount) {
+  if (aFolder) {
     nsString authors;
     int32_t numNotDisplayed;
     nsresult rv = GetNewMailAuthors(aFolder, authors, aNewCount, &numNotDisplayed);
 
     // If all senders are vetoed, the authors string will be empty.
-    if (NS_FAILED(rv) || authors.IsEmpty())
-      return;
+    if (NS_FAILED(rv) || authors.IsEmpty()) return;
 
     // If this isn't the root folder, get it so we can report for it.
     // GetRootFolder always returns the server's root, so calling on the root itself is fine.
     nsCOMPtr<nsIMsgFolder> rootFolder;
     aFolder->GetRootFolder(getter_AddRefs(rootFolder));
-    if (!rootFolder)
-      return;
+    if (!rootFolder) return;
 
     nsString accountName;
     rootFolder->GetPrettyName(accountName);
 
     nsCOMPtr<nsIStringBundle> bundle;
     GetStringBundle(getter_AddRefs(bundle));
-    if (bundle)
-    {
+    if (bundle) {
       nsAutoString numNewMsgsText;
       numNewMsgsText.AppendInt(aNewCount);
       nsString finalText;
       nsCString uri;
       aFolder->GetURI(uri);
 
-      if (numNotDisplayed > 0)
-      {
+      if (numNotDisplayed > 0) {
         nsAutoString numNotDisplayedText;
         numNotDisplayedText.AppendInt(numNotDisplayed);
-        const char16_t *formatStrings[3] = { numNewMsgsText.get(), authors.get(), numNotDisplayedText.get() };
-        bundle->FormatStringFromName("macBiffNotification_messages_extra",
-                                     formatStrings,
-                                     3,
+        const char16_t *formatStrings[3] = {numNewMsgsText.get(), authors.get(),
+                                            numNotDisplayedText.get()};
+        bundle->FormatStringFromName("macBiffNotification_messages_extra", formatStrings, 3,
                                      finalText);
-      }
-      else
-      {
-        const char16_t *formatStrings[2] = { numNewMsgsText.get(), authors.get() };
+      } else {
+        const char16_t *formatStrings[2] = {numNewMsgsText.get(), authors.get()};
 
-        if (aNewCount == 1)
-        {
-          bundle->FormatStringFromName("macBiffNotification_message",
-                                       formatStrings,
-                                       2,
-                                       finalText);
+        if (aNewCount == 1) {
+          bundle->FormatStringFromName("macBiffNotification_message", formatStrings, 2, finalText);
           // Since there is only 1 message, use the most recent mail's URI instead of the folder's
           nsCOMPtr<nsIMsgDatabase> db;
           rv = aFolder->GetMsgDatabase(getter_AddRefs(db));
-          if (NS_SUCCEEDED(rv) && db)
-          {
+          if (NS_SUCCEEDED(rv) && db) {
             uint32_t numNewKeys;
             uint32_t *newMessageKeys;
             rv = db->GetNewList(&numNewKeys, &newMessageKeys);
-            if (NS_SUCCEEDED(rv))
-            {
+            if (NS_SUCCEEDED(rv)) {
               nsCOMPtr<nsIMsgDBHdr> hdr;
-              rv = db->GetMsgHdrForKey(newMessageKeys[numNewKeys - 1],
-                                       getter_AddRefs(hdr));
-              if (NS_SUCCEEDED(rv) && hdr)
-                aFolder->GetUriForMsg(hdr, uri);
+              rv = db->GetMsgHdrForKey(newMessageKeys[numNewKeys - 1], getter_AddRefs(hdr));
+              if (NS_SUCCEEDED(rv) && hdr) aFolder->GetUriForMsg(hdr, uri);
             }
             free(newMessageKeys);
           }
-        }
-        else
-          bundle->FormatStringFromName("macBiffNotification_messages",
-                                       formatStrings,
-                                       2,
-                                       finalText);
+        } else
+          bundle->FormatStringFromName("macBiffNotification_messages", formatStrings, 2, finalText);
       }
       ShowAlertMessage(accountName, finalText, uri);
-    } // if we got a bundle
-  } // if we got a folder
+    }  // if we got a bundle
+  }    // if we got a folder
 }
 
-nsresult
-nsMessengerOSXIntegration::ShowAlertMessage(const nsAString& aAlertTitle,
-                                            const nsAString& aAlertText,
-                                            const nsACString& aFolderURI)
-{
+nsresult nsMessengerOSXIntegration::ShowAlertMessage(const nsAString &aAlertTitle,
+                                                     const nsAString &aAlertText,
+                                                     const nsACString &aFolderURI) {
   nsCOMPtr<nsIAlertsService> alertsService = mozilla::components::Alerts::Service();
   nsresult rv = alertsService ? NS_OK : NS_ERROR_UNEXPECTED;
   // If we have an nsIAlertsService implementation, use it:
-  if (NS_SUCCEEDED(rv))
-  {
-    alertsService->ShowAlertNotification(EmptyString(),
-                                         aAlertTitle, aAlertText, true,
-                                         NS_ConvertASCIItoUTF16(aFolderURI),
-                                         this, EmptyString(),
-                                         NS_LITERAL_STRING("auto"),
-                                         EmptyString(), EmptyString(),
-                                         nullptr,
-                                         false,
-                                         false);
+  if (NS_SUCCEEDED(rv)) {
+    alertsService->ShowAlertNotification(EmptyString(), aAlertTitle, aAlertText, true,
+                                         NS_ConvertASCIItoUTF16(aFolderURI), this, EmptyString(),
+                                         NS_LITERAL_STRING("auto"), EmptyString(), EmptyString(),
+                                         nullptr, false, false);
   }
 
   BounceDockIcon();
 
-  if (NS_FAILED(rv))
-    OnAlertFinished();
+  if (NS_FAILED(rv)) OnAlertFinished();
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsMessengerOSXIntegration::OnItemIntPropertyChanged(nsIMsgFolder *aFolder,
-                                                    const nsACString &aProperty,
-                                                    int64_t aOldValue,
-                                                    int64_t aNewValue)
-{
+                                                    const nsACString &aProperty, int64_t aOldValue,
+                                                    int64_t aNewValue) {
   // if we got new mail show an alert
-  if (aNewValue == nsIMsgFolder::nsMsgBiffState_NewMail)
-  {
+  if (aNewValue == nsIMsgFolder::nsMsgBiffState_NewMail) {
     bool performingBiff = false;
     nsCOMPtr<nsIMsgIncomingServer> server;
     aFolder->GetServer(getter_AddRefs(server));
-    if (server)
-      server->GetPerformingBiff(&performingBiff);
-    if (!performingBiff)
-      return NS_OK; // kick out right now...
+    if (server) server->GetPerformingBiff(&performingBiff);
+    if (!performingBiff) return NS_OK;  // kick out right now...
 
     // Biff happens for the root folder, but we want info for the child with new mail
     nsCString folderUri;
     GetFirstFolderWithNewMail(aFolder, folderUri);
     nsCOMPtr<nsIMsgFolder> childFolder;
-    nsresult rv = aFolder->GetChildWithURI(folderUri, true, true,
-                                           getter_AddRefs(childFolder));
-    if (NS_FAILED(rv) || !childFolder)
-      return NS_ERROR_FAILURE;
+    nsresult rv = aFolder->GetChildWithURI(folderUri, true, true, getter_AddRefs(childFolder));
+    if (NS_FAILED(rv) || !childFolder) return NS_ERROR_FAILURE;
 
     int32_t numNewMessages = 0;
     childFolder->GetNumNewMessages(true, &numNewMessages);
     FillToolTipInfo(childFolder, numNewMessages);
-  }
-  else if (aProperty.Equals(kNewMailReceived))
-  {
+  } else if (aProperty.Equals(kNewMailReceived)) {
     FillToolTipInfo(aFolder, aNewValue);
   }
   return NS_OK;
 }
 
-nsresult
-nsMessengerOSXIntegration::OnAlertClicked(const char16_t* aAlertCookie)
-{
+nsresult nsMessengerOSXIntegration::OnAlertClicked(const char16_t *aAlertCookie) {
   openMailWindow(NS_ConvertUTF16toUTF8(aAlertCookie));
   return NS_OK;
 }
 
 #ifdef MOZ_SUITE
-nsresult
-nsMessengerOSXIntegration::OnAlertClickedSimple()
-{
+nsresult nsMessengerOSXIntegration::OnAlertClickedSimple() {
   // SeaMonkey only function; only focus the app here, rest of the work will
   // be done in suite/mailnews/mailWidgets.xml
   FocusAppNative();
   return NS_OK;
 }
 #endif
 
-nsresult
-nsMessengerOSXIntegration::OnAlertFinished()
-{
-  return NS_OK;
-}
+nsresult nsMessengerOSXIntegration::OnAlertFinished() { return NS_OK; }
 
-nsresult
-nsMessengerOSXIntegration::BounceDockIcon()
-{
+nsresult nsMessengerOSXIntegration::BounceDockIcon() {
   nsresult rv;
   nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool bounceDockIcon = false;
   rv = prefBranch->GetBoolPref(kBiffAnimateDockIconPref, &bounceDockIcon);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!bounceDockIcon)
-    return NS_OK;
+  if (!bounceDockIcon) return NS_OK;
 
   nsCOMPtr<nsIWindowMediator> mediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
-  if (mediator)
-  {
+  if (mediator) {
     nsCOMPtr<mozIDOMWindowProxy> domWindow;
     mediator->GetMostRecentWindow(u"mail:3pane", getter_AddRefs(domWindow));
-    if (domWindow)
-    {
-      nsPIDOMWindowOuter* outer = nsPIDOMWindowOuter::From(domWindow);
-      nsPIDOMWindowInner* inner = outer->GetCurrentInnerWindow();
+    if (domWindow) {
+      nsPIDOMWindowOuter *outer = nsPIDOMWindowOuter::From(domWindow);
+      nsPIDOMWindowInner *inner = outer->GetCurrentInnerWindow();
       if (inner) {
         mozilla::IgnoredErrorResult rv;
         nsGlobalWindowInner::Cast(inner)->GetAttention(rv);
       }
     }
   }
   return NS_OK;
 }
 
-nsresult
-nsMessengerOSXIntegration::RestoreDockIcon()
-{
+nsresult nsMessengerOSXIntegration::RestoreDockIcon() {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   id tile = [[NSApplication sharedApplication] dockTile];
-  [tile setBadgeLabel: nil];
+  [tile setBadgeLabel:nil];
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
-nsresult
-nsMessengerOSXIntegration::BadgeDockIcon()
-{
+nsresult nsMessengerOSXIntegration::BadgeDockIcon() {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   int32_t unreadCount = mUnreadTotal + mUnreadChat;
   // If count is less than one, we should restore the original dock icon.
-  if (unreadCount < 1)
-  {
+  if (unreadCount < 1) {
     RestoreDockIcon();
     return NS_OK;
   }
 
   // Draw the number, first giving extensions a chance to modify.
   // Extensions might wish to transform "1000" into "100+" or some
   // other short string. Getting back the empty string will cause
   // nothing to be drawn and us to return early.
   nsresult rv;
-  nsCOMPtr<nsIObserverService> os
-    (do_GetService("@mozilla.org/observer-service;1", &rv));
-  if (NS_FAILED(rv))
-  {
+  nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1", &rv));
+  if (NS_FAILED(rv)) {
     RestoreDockIcon();
     return rv;
   }
 
-  nsCOMPtr<nsISupportsString> str
-    (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv));
-  if (NS_FAILED(rv))
-  {
+  nsCOMPtr<nsISupportsString> str(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) {
     RestoreDockIcon();
     return rv;
   }
 
   nsAutoString total;
   total.AppendInt(unreadCount);
   str->SetData(total);
-  os->NotifyObservers(str, "before-unread-count-display",
-                      total.get());
+  os->NotifyObservers(str, "before-unread-count-display", total.get());
   nsAutoString badgeString;
   str->GetData(badgeString);
-  if (badgeString.IsEmpty())
-  {
+  if (badgeString.IsEmpty()) {
     RestoreDockIcon();
     return NS_OK;
   }
 
   id tile = [[NSApplication sharedApplication] dockTile];
-  [tile setBadgeLabel:[NSString stringWithFormat:@"%S", (const unichar*)badgeString.get()]];
+  [tile setBadgeLabel:[NSString stringWithFormat:@"%S", (const unichar *)badgeString.get()]];
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
-nsMessengerOSXIntegration::OnItemPropertyFlagChanged(nsIMsgDBHdr *item, const nsACString &property, uint32_t oldFlag, uint32_t newFlag)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsMessengerOSXIntegration::OnItemAdded(nsIMsgFolder *, nsISupports *)
-{
+nsMessengerOSXIntegration::OnItemPropertyFlagChanged(nsIMsgDBHdr *item, const nsACString &property,
+                                                     uint32_t oldFlag, uint32_t newFlag) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsMessengerOSXIntegration::OnItemAdded(nsIMsgFolder *, nsISupports *) { return NS_OK; }
+
+NS_IMETHODIMP
 nsMessengerOSXIntegration::OnItemBoolPropertyChanged(nsIMsgFolder *aItem,
-                                                     const nsACString &aProperty,
-                                                     bool aOldValue,
-                                                     bool aNewValue)
-{
+                                                     const nsACString &aProperty, bool aOldValue,
+                                                     bool aNewValue) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerOSXIntegration::OnItemEvent(nsIMsgFolder *, const nsACString &)
-{
-  return NS_OK;
-}
+nsMessengerOSXIntegration::OnItemEvent(nsIMsgFolder *, const nsACString &) { return NS_OK; }
 
-nsresult
-nsMessengerOSXIntegration::GetNewMailAuthors(nsIMsgFolder* aFolder,
-                                             nsString& aAuthors,
-                                             int32_t aNewCount,
-                                             int32_t* aNotDisplayed)
-{
+nsresult nsMessengerOSXIntegration::GetNewMailAuthors(nsIMsgFolder *aFolder, nsString &aAuthors,
+                                                      int32_t aNewCount, int32_t *aNotDisplayed) {
   // Get a list of names or email addresses for the folder's authors
   // with new mail. Note that we only process the most recent "new"
   // mail (aNewCount), working from most recently added. Duplicates
   // are removed, and names are displayed to a set limit
   // (kMaxDisplayCount) with the remaining count being returned in
   // aNotDisplayed. Extension developers can listen for
   // "newmail-notification-requested" and then make a decision about
   // including a given author or not. As a result, it is possible that
   // the resulting length of aAuthors will be 0.
   nsCOMPtr<nsIMsgDatabase> db;
   nsresult rv = aFolder->GetMsgDatabase(getter_AddRefs(db));
   uint32_t numNewKeys = 0;
-  if (NS_SUCCEEDED(rv) && db)
-  {
-    nsCOMPtr<nsIObserverService> os =
-      do_GetService("@mozilla.org/observer-service;1", &rv);
+  if (NS_SUCCEEDED(rv) && db) {
+    nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Get proper l10n list separator -- ", " in English
     nsCOMPtr<nsIStringBundle> bundle;
     GetStringBundle(getter_AddRefs(bundle));
-    if (!bundle)
-      return NS_ERROR_FAILURE;
+    if (!bundle) return NS_ERROR_FAILURE;
 
     uint32_t *newMessageKeys;
     rv = db->GetNewList(&numNewKeys, &newMessageKeys);
-    if (NS_SUCCEEDED(rv))
-    {
+    if (NS_SUCCEEDED(rv)) {
       nsString listSeparator;
       bundle->GetStringFromName("macBiffNotification_separator", listSeparator);
 
       int32_t displayed = 0;
-      for (int32_t i = numNewKeys - 1; i >= 0; i--, aNewCount--)
-      {
-        if (0 == aNewCount || displayed == kMaxDisplayCount)
-          break;
+      for (int32_t i = numNewKeys - 1; i >= 0; i--, aNewCount--) {
+        if (0 == aNewCount || displayed == kMaxDisplayCount) break;
 
         nsCOMPtr<nsIMsgDBHdr> hdr;
-        rv = db->GetMsgHdrForKey(newMessageKeys[i],
-                                 getter_AddRefs(hdr));
-        if (NS_SUCCEEDED(rv) && hdr)
-        {
+        rv = db->GetMsgHdrForKey(newMessageKeys[i], getter_AddRefs(hdr));
+        if (NS_SUCCEEDED(rv) && hdr) {
           nsString author;
           rv = hdr->GetMime2DecodedAuthor(author);
-          if (NS_FAILED(rv))
-            continue;
+          if (NS_FAILED(rv)) continue;
 
           nsString name;
           ExtractName(DecodedHeader(author), name);
 
           // Give extensions a chance to suppress notifications for this author
-          nsCOMPtr<nsISupportsPRBool> notify =
-            do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID);
+          nsCOMPtr<nsISupportsPRBool> notify = do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID);
 
           notify->SetData(true);
-          os->NotifyObservers(notify, "newmail-notification-requested",
-                              author.get());
+          os->NotifyObservers(notify, "newmail-notification-requested", author.get());
 
           bool includeSender;
           notify->GetData(&includeSender);
 
           // Don't add unwanted or duplicate names
-          if (includeSender && aAuthors.Find(name, true) == -1)
-          {
-            if (displayed > 0)
-              aAuthors.Append(listSeparator);
+          if (includeSender && aAuthors.Find(name, true) == -1) {
+            if (displayed > 0) aAuthors.Append(listSeparator);
             aAuthors.Append(name);
             displayed++;
           }
         }
       }
     }
     free(newMessageKeys);
   }
   *aNotDisplayed = aNewCount;
   return rv;
 }
 
-nsresult
-nsMessengerOSXIntegration::GetFirstFolderWithNewMail(nsIMsgFolder* aFolder, nsCString& aFolderURI)
-{
+nsresult nsMessengerOSXIntegration::GetFirstFolderWithNewMail(nsIMsgFolder *aFolder,
+                                                              nsCString &aFolderURI) {
   // Find the subfolder in aFolder with new mail and return the folderURI
-  if (aFolder)
-  {
+  if (aFolder) {
     nsCOMPtr<nsIMsgFolder> msgFolder;
     // enumerate over the folders under this root folder till we find one with new mail....
     nsCOMPtr<nsIArray> allFolders;
     nsresult rv = aFolder->GetDescendants(getter_AddRefs(allFolders));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsISimpleEnumerator> enumerator;
     rv = allFolders->Enumerate(getter_AddRefs(enumerator));
-    if (NS_SUCCEEDED(rv) && enumerator)
-    {
+    if (NS_SUCCEEDED(rv) && enumerator) {
       nsCOMPtr<nsISupports> supports;
       int32_t numNewMessages = 0;
       bool hasMore = false;
-      while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore)
-      {
+      while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
         rv = enumerator->GetNext(getter_AddRefs(supports));
-        if (NS_SUCCEEDED(rv) && supports)
-        {
+        if (NS_SUCCEEDED(rv) && supports) {
           msgFolder = do_QueryInterface(supports, &rv);
-          if (msgFolder)
-          {
+          if (msgFolder) {
             numNewMessages = 0;
             msgFolder->GetNumNewMessages(false, &numNewMessages);
-            if (numNewMessages)
-              break; // kick out of the while loop
+            if (numNewMessages) break;  // kick out of the while loop
           }
-        } // if we have a folder
-      }  // if we have more potential folders to enumerate
-    }  // if enumerator
+        }  // if we have a folder
+      }    // if we have more potential folders to enumerate
+    }      // if enumerator
 
-    if (msgFolder)
-      msgFolder->GetURI(aFolderURI);
+    if (msgFolder) msgFolder->GetURI(aFolderURI);
   }
 
   return NS_OK;
 }
 
 /*
  * Method implementations for mozINewMailListener
  */
 NS_IMETHODIMP
-nsMessengerOSXIntegration::OnCountChanged(uint32_t count)
-{
+nsMessengerOSXIntegration::OnCountChanged(uint32_t count) {
   mUnreadTotal = count;
   BadgeDockIcon();
   return NS_OK;
 }
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -52,439 +52,391 @@
 #include "mozilla/mailnews/MimeHeaderParser.h"
 
 #define ALERT_CHROME_URL "chrome://messenger/content/newmailalert.xul"
 #define NEW_MAIL_ALERT_ICON "chrome://messenger/skin/icons/new-mail-alert.png"
 #define SHOW_ALERT_PREF "mail.biff.show_alert"
 #define SHOW_ALERT_PREVIEW_LENGTH "mail.biff.alert.preview_length"
 #define SHOW_ALERT_PREVIEW_LENGTH_DEFAULT 40
 #define SHOW_ALERT_PREVIEW "mail.biff.alert.show_preview"
-#define SHOW_ALERT_SENDER  "mail.biff.alert.show_sender"
+#define SHOW_ALERT_SENDER "mail.biff.alert.show_sender"
 #define SHOW_ALERT_SUBJECT "mail.biff.alert.show_subject"
-#define SHOW_ALERT_SYSTEM  "mail.biff.use_system_alert"
+#define SHOW_ALERT_SYSTEM "mail.biff.use_system_alert"
 
 using namespace mozilla::mailnews;
 
-static void openMailWindow(const nsACString& aFolderUri)
-{
+static void openMailWindow(const nsACString &aFolderUri) {
   nsresult rv;
-  nsCOMPtr<nsIMsgMailSession> mailSession ( do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
-  if (NS_FAILED(rv))
-    return;
+  nsCOMPtr<nsIMsgMailSession> mailSession(
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) return;
 
   nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
   rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
-  if (topMostMsgWindow)
-  {
-    if (!aFolderUri.IsEmpty())
-    {
+  if (topMostMsgWindow) {
+    if (!aFolderUri.IsEmpty()) {
       nsCOMPtr<nsIMsgWindowCommands> windowCommands;
       topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
-      if (windowCommands)
-        windowCommands->SelectFolder(aFolderUri);
+      if (windowCommands) windowCommands->SelectFolder(aFolderUri);
     }
 
     nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
     if (domWindow) {
-      nsCOMPtr<nsPIDOMWindowOuter> privateWindow = nsPIDOMWindowOuter::From(domWindow);
+      nsCOMPtr<nsPIDOMWindowOuter> privateWindow =
+          nsPIDOMWindowOuter::From(domWindow);
       privateWindow->Focus();
     }
-  }
-  else
-  {
+  } else {
     // the user doesn't have a mail window open already so open one for them...
     nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
-      do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
+        do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
     // if we want to preselect the first account with new mail,
     // here is where we would try to generate a uri to pass in
     // (and add code to the messenger window service to make that work)
     if (messengerWindowService)
       messengerWindowService->OpenMessengerWindowWithUri(
-                                "mail:3pane", nsCString(aFolderUri).get(), nsMsgKey_None);
+          "mail:3pane", nsCString(aFolderUri).get(), nsMsgKey_None);
   }
 }
 
-nsMessengerUnixIntegration::nsMessengerUnixIntegration()
-{
+nsMessengerUnixIntegration::nsMessengerUnixIntegration() {
   mAlertInProgress = false;
   mFoldersWithNewMail = do_CreateInstance(NS_ARRAY_CONTRACTID);
 }
 
 NS_IMPL_ISUPPORTS(nsMessengerUnixIntegration, nsIFolderListener, nsIObserver,
-                   nsIMessengerOSIntegration, nsIUrlListener)
+                  nsIMessengerOSIntegration, nsIUrlListener)
 
-nsresult
-nsMessengerUnixIntegration::Init()
-{
+nsresult nsMessengerUnixIntegration::Init() {
   nsresult rv;
 
-  nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
-  return mailSession->AddFolderListener(this, nsIFolderListener::intPropertyChanged);
+  nsCOMPtr<nsIMsgMailSession> mailSession =
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+  return mailSession->AddFolderListener(this,
+                                        nsIFolderListener::intPropertyChanged);
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemPropertyChanged(nsIMsgFolder *, const nsACString &, char const *, char const *)
-{
+nsMessengerUnixIntegration::OnItemPropertyChanged(nsIMsgFolder *,
+                                                  const nsACString &,
+                                                  char const *, char const *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemUnicharPropertyChanged(nsIMsgFolder *, const nsACString &, const char16_t *, const char16_t *)
-{
+nsMessengerUnixIntegration::OnItemUnicharPropertyChanged(nsIMsgFolder *,
+                                                         const nsACString &,
+                                                         const char16_t *,
+                                                         const char16_t *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *)
-{
+nsMessengerUnixIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *) {
   return NS_OK;
 }
 
-nsresult nsMessengerUnixIntegration::GetStringBundle(nsIStringBundle **aBundle)
-{
+nsresult nsMessengerUnixIntegration::GetStringBundle(
+    nsIStringBundle **aBundle) {
   NS_ENSURE_ARG_POINTER(aBundle);
   nsCOMPtr<nsIStringBundleService> bundleService =
-    mozilla::services::GetStringBundleService();
+      mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
                               getter_AddRefs(bundle));
   bundle.forget(aBundle);
   return NS_OK;
 }
 
-bool
-nsMessengerUnixIntegration::BuildNotificationTitle(nsIMsgFolder *aFolder, nsIStringBundle *aBundle, nsString &aTitle)
-{
+bool nsMessengerUnixIntegration::BuildNotificationTitle(
+    nsIMsgFolder *aFolder, nsIStringBundle *aBundle, nsString &aTitle) {
   nsString accountName;
   aFolder->GetPrettyName(accountName);
 
   int32_t numNewMessages = 0;
   aFolder->GetNumNewMessages(true, &numNewMessages);
 
-  if (!numNewMessages)
-    return false;
+  if (!numNewMessages) return false;
 
   nsAutoString numNewMsgsText;
   numNewMsgsText.AppendInt(numNewMessages);
 
-  const char16_t *formatStrings[] =
-  {
-    accountName.get(), numNewMsgsText.get()
-  };
+  const char16_t *formatStrings[] = {accountName.get(), numNewMsgsText.get()};
 
-  aBundle->FormatStringFromName(numNewMessages == 1 ?
-                                  "newMailNotification_message" :
-                                  "newMailNotification_messages",
+  aBundle->FormatStringFromName(numNewMessages == 1
+                                    ? "newMailNotification_message"
+                                    : "newMailNotification_messages",
                                 formatStrings, 2, aTitle);
   return true;
 }
 
 /* This comparator lets us sort an nsCOMArray of nsIMsgDBHdr's by
  * their dateInSeconds attributes in ascending order.
  */
-static int
-nsMsgDbHdrTimestampComparator(nsIMsgDBHdr *aElement1,
-                              nsIMsgDBHdr *aElement2,
-                              void *aData)
-{
+static int nsMsgDbHdrTimestampComparator(nsIMsgDBHdr *aElement1,
+                                         nsIMsgDBHdr *aElement2, void *aData) {
   uint32_t aElement1Timestamp;
   nsresult rv = aElement1->GetDateInSeconds(&aElement1Timestamp);
-  if (NS_FAILED(rv))
-    return 0;
+  if (NS_FAILED(rv)) return 0;
 
   uint32_t aElement2Timestamp;
   rv = aElement2->GetDateInSeconds(&aElement2Timestamp);
-  if (NS_FAILED(rv))
-    return 0;
+  if (NS_FAILED(rv)) return 0;
 
   return aElement1Timestamp - aElement2Timestamp;
 }
 
-
-bool
-nsMessengerUnixIntegration::BuildNotificationBody(nsIMsgDBHdr *aHdr,
-                                                  nsIStringBundle *aBundle,
-                                                  nsString &aBody)
-{
+bool nsMessengerUnixIntegration::BuildNotificationBody(nsIMsgDBHdr *aHdr,
+                                                       nsIStringBundle *aBundle,
+                                                       nsString &aBody) {
   nsAutoString alertBody;
 
   bool showPreview = true;
   bool showSubject = true;
   bool showSender = true;
   int32_t previewLength = SHOW_ALERT_PREVIEW_LENGTH_DEFAULT;
 
   nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
-  if (!prefBranch)
-    return false;
+  if (!prefBranch) return false;
 
   prefBranch->GetBoolPref(SHOW_ALERT_PREVIEW, &showPreview);
   prefBranch->GetBoolPref(SHOW_ALERT_SENDER, &showSender);
   prefBranch->GetBoolPref(SHOW_ALERT_SUBJECT, &showSubject);
   prefBranch->GetIntPref(SHOW_ALERT_PREVIEW_LENGTH, &previewLength);
 
   nsCOMPtr<nsIMsgFolder> folder;
   aHdr->GetFolder(getter_AddRefs(folder));
 
-  if (!folder)
-    return false;
+  if (!folder) return false;
 
   nsCString msgURI;
   folder->GetUriForMsg(aHdr, msgURI);
 
   bool localOnly;
 
   size_t msgURIIndex = mFetchingURIs.IndexOf(msgURI);
-  if (msgURIIndex == mFetchingURIs.NoIndex)
-  {
+  if (msgURIIndex == mFetchingURIs.NoIndex) {
     localOnly = false;
     mFetchingURIs.AppendElement(msgURI);
-  }
-  else
+  } else
     localOnly = true;
 
   nsMsgKey messageKey;
-  if (NS_FAILED(aHdr->GetMessageKey(&messageKey)))
-    return false;
+  if (NS_FAILED(aHdr->GetMessageKey(&messageKey))) return false;
 
   bool asyncResult = false;
-  nsresult rv = folder->FetchMsgPreviewText(&messageKey, 1,
-                                            localOnly, this,
+  nsresult rv = folder->FetchMsgPreviewText(&messageKey, 1, localOnly, this,
                                             &asyncResult);
   // If we're still waiting on getting the message previews,
   // bail early.  We'll come back later when the async operation
   // finishes.
-  if (NS_FAILED(rv) || asyncResult)
-    return false;
+  if (NS_FAILED(rv) || asyncResult) return false;
 
   // If we got here, that means that we've retrieved the message preview,
   // so we can stop tracking it with our mFetchingURIs array.
   if (msgURIIndex != mFetchingURIs.NoIndex)
     mFetchingURIs.RemoveElementAt(msgURIIndex);
 
   nsCString utf8previewString;
-  if (showPreview &&
-      NS_FAILED(aHdr->GetStringProperty("preview", getter_Copies(utf8previewString))))
+  if (showPreview && NS_FAILED(aHdr->GetStringProperty(
+                         "preview", getter_Copies(utf8previewString))))
     return false;
 
   // need listener that mailbox is remote such as IMAP
   // to generate preview message
   nsString previewString;
   CopyUTF8toUTF16(utf8previewString, previewString);
 
   nsString subject;
   if (showSubject && NS_FAILED(aHdr->GetMime2DecodedSubject(subject)))
     return false;
 
   nsString author;
-  if (showSender)
-  {
+  if (showSender) {
     nsString fullHeader;
-    if (NS_FAILED(aHdr->GetMime2DecodedAuthor(fullHeader)))
-      return false;
+    if (NS_FAILED(aHdr->GetMime2DecodedAuthor(fullHeader))) return false;
 
     ExtractName(DecodedHeader(fullHeader), author);
   }
 
-  if (showSubject && showSender)
-  {
+  if (showSubject && showSender) {
     nsString msgTitle;
-    const char16_t *formatStrings[] =
-    {
-      subject.get(), author.get()
-    };
+    const char16_t *formatStrings[] = {subject.get(), author.get()};
     aBundle->FormatStringFromName("newMailNotification_messagetitle",
-        formatStrings, 2, msgTitle);
+                                  formatStrings, 2, msgTitle);
     alertBody.Append(msgTitle);
-  }
-  else if (showSubject)
+  } else if (showSubject)
     alertBody.Append(subject);
   else if (showSender)
     alertBody.Append(author);
 
-  if (showPreview && (showSubject || showSender))
-  {
+  if (showPreview && (showSubject || showSender)) {
     alertBody.AppendLiteral("\n");
   }
 
-  if (showPreview)
-    alertBody.Append(StringHead(previewString, previewLength));
+  if (showPreview) alertBody.Append(StringHead(previewString, previewLength));
 
-  if (alertBody.IsEmpty())
-    return false;
+  if (alertBody.IsEmpty()) return false;
 
   aBody.Assign(alertBody);
   return true;
 }
 
-nsresult nsMessengerUnixIntegration::ShowAlertMessage(const nsAString& aAlertTitle, const nsAString& aAlertText, const nsACString& aFolderURI)
-{
+nsresult nsMessengerUnixIntegration::ShowAlertMessage(
+    const nsAString &aAlertTitle, const nsAString &aAlertText,
+    const nsACString &aFolderURI) {
   nsresult rv;
-  // if we are already in the process of showing an alert, don't try to show another....
-  if (mAlertInProgress)
-    return NS_OK;
+  // if we are already in the process of showing an alert, don't try to show
+  // another....
+  if (mAlertInProgress) return NS_OK;
 
   mAlertInProgress = true;
 
-  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // determine if we should use libnotify or the built-in alert system
   bool useSystemAlert = true;
   prefBranch->GetBoolPref(SHOW_ALERT_SYSTEM, &useSystemAlert);
 
   if (useSystemAlert) {
-    nsCOMPtr<nsIAlertsService> alertsService(do_GetService(NS_SYSTEMALERTSERVICE_CONTRACTID, &rv));
+    nsCOMPtr<nsIAlertsService> alertsService(
+        do_GetService(NS_SYSTEMALERTSERVICE_CONTRACTID, &rv));
     if (NS_SUCCEEDED(rv)) {
-      rv = alertsService->ShowAlertNotification(NS_LITERAL_STRING(NEW_MAIL_ALERT_ICON),
-                                                aAlertTitle,
-                                                aAlertText,
-                                                false,
-                                                NS_ConvertASCIItoUTF16(aFolderURI),
-                                                this,
-                                                EmptyString(),
-                                                NS_LITERAL_STRING("auto"),
-                                                EmptyString(),
-                                                EmptyString(),
-                                                nullptr,
-                                                false,
-                                                false);
-      if (NS_SUCCEEDED(rv))
-        return rv;
+      rv = alertsService->ShowAlertNotification(
+          NS_LITERAL_STRING(NEW_MAIL_ALERT_ICON), aAlertTitle, aAlertText,
+          false, NS_ConvertASCIItoUTF16(aFolderURI), this, EmptyString(),
+          NS_LITERAL_STRING("auto"), EmptyString(), EmptyString(), nullptr,
+          false, false);
+      if (NS_SUCCEEDED(rv)) return rv;
     }
   }
   AlertFinished();
   rv = ShowNewAlertNotification(false);
 
-  if (NS_FAILED(rv)) // go straight to showing the system tray icon.
+  if (NS_FAILED(rv))  // go straight to showing the system tray icon.
     AlertFinished();
 
   return rv;
 }
 
-// Opening Thunderbird's new mail alert notification window for not supporting libnotify
-// aUserInitiated --> true if we are opening the alert notification in response to a user action
+// Opening Thunderbird's new mail alert notification window for not supporting
+// libnotify aUserInitiated --> true if we are opening the alert notification in
+// response to a user action
 //                    like clicking on the biff icon
-nsresult nsMessengerUnixIntegration::ShowNewAlertNotification(bool aUserInitiated)
-{
-
+nsresult nsMessengerUnixIntegration::ShowNewAlertNotification(
+    bool aUserInitiated) {
   nsresult rv;
 
-  // if we are already in the process of showing an alert, don't try to show another....
-  if (mAlertInProgress)
-    return NS_OK;
+  // if we are already in the process of showing an alert, don't try to show
+  // another....
+  if (mAlertInProgress) return NS_OK;
 
   nsCOMPtr<nsIMutableArray> argsArray = do_CreateInstance(NS_ARRAY_CONTRACTID);
-  if (!argsArray)
-    return NS_ERROR_FAILURE;
+  if (!argsArray) return NS_ERROR_FAILURE;
 
   // pass in the array of folders with unread messages
-  nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
+  nsCOMPtr<nsISupportsInterfacePointer> ifptr =
+      do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   ifptr->SetData(mFoldersWithNewMail);
   ifptr->SetDataIID(&NS_GET_IID(nsIArray));
   argsArray->AppendElement(ifptr);
 
   // pass in the observer
   ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
-  nsCOMPtr <nsISupports> supports = do_QueryInterface(static_cast<nsIMessengerOSIntegration*>(this));
+  nsCOMPtr<nsISupports> supports =
+      do_QueryInterface(static_cast<nsIMessengerOSIntegration *>(this));
   ifptr->SetData(supports);
   ifptr->SetDataIID(&NS_GET_IID(nsIObserver));
   argsArray->AppendElement(ifptr);
 
   // pass in the animation flag
-  nsCOMPtr<nsISupportsPRBool> scriptableUserInitiated (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
+  nsCOMPtr<nsISupportsPRBool> scriptableUserInitiated(
+      do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   scriptableUserInitiated->SetData(aUserInitiated);
   argsArray->AppendElement(scriptableUserInitiated);
 
   nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
   nsCOMPtr<mozIDOMWindowProxy> newWindow;
 
   mAlertInProgress = true;
   rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
                           "chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
                           getter_AddRefs(newWindow));
 
-  if (NS_FAILED(rv))
-    AlertFinished();
+  if (NS_FAILED(rv)) AlertFinished();
 
   return rv;
 }
 
-nsresult nsMessengerUnixIntegration::AlertFinished()
-{
+nsresult nsMessengerUnixIntegration::AlertFinished() {
   mAlertInProgress = false;
   return NS_OK;
 }
 
-nsresult nsMessengerUnixIntegration::AlertClicked()
-{
+nsresult nsMessengerUnixIntegration::AlertClicked() {
   nsCString folderURI;
   GetFirstFolderWithNewMail(folderURI);
   openMailWindow(folderURI);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
-{
-  if (strcmp(aTopic, "alertfinished") == 0)
-    return AlertFinished();
-  if (strcmp(aTopic, "alertclickcallback") == 0)
-    return AlertClicked();
+nsMessengerUnixIntegration::Observe(nsISupports *aSubject, const char *aTopic,
+                                    const char16_t *aData) {
+  if (strcmp(aTopic, "alertfinished") == 0) return AlertFinished();
+  if (strcmp(aTopic, "alertclickcallback") == 0) return AlertClicked();
 
   return NS_OK;
 }
 
-void nsMessengerUnixIntegration::FillToolTipInfo()
-{
+void nsMessengerUnixIntegration::FillToolTipInfo() {
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv,);
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  NS_ENSURE_SUCCESS(rv, );
 
   bool showAlert = true;
   prefBranch->GetBoolPref(SHOW_ALERT_PREF, &showAlert);
-  if (!showAlert)
-    return;
+  if (!showAlert) return;
 
   nsCString folderUri;
   GetFirstFolderWithNewMail(folderUri);
 
   uint32_t count = 0;
   NS_ENSURE_SUCCESS_VOID(mFoldersWithNewMail->GetLength(&count));
 
   nsWeakPtr weakReference;
   nsCOMPtr<nsIMsgFolder> folder = nullptr;
   nsCOMPtr<nsIMsgFolder> folderWithNewMail = nullptr;
 
   uint32_t i;
-  for (i = 0; i < count && !folderWithNewMail; i++)
-  {
+  for (i = 0; i < count && !folderWithNewMail; i++) {
     weakReference = do_QueryElementAt(mFoldersWithNewMail, i);
     folder = do_QueryReferent(weakReference);
     folder->GetChildWithURI(folderUri, true, true,
                             getter_AddRefs(folderWithNewMail));
   }
 
-  if (folder && folderWithNewMail)
-  {
+  if (folder && folderWithNewMail) {
     nsCOMPtr<nsIStringBundle> bundle;
     GetStringBundle(getter_AddRefs(bundle));
 
-    if (!bundle)
-      return;
+    if (!bundle) return;
 
     // Create the notification title
     nsString alertTitle;
-    if (!BuildNotificationTitle(folder, bundle, alertTitle))
-      return;
+    if (!BuildNotificationTitle(folder, bundle, alertTitle)) return;
 
     // Let's get the new mail for this folder
     nsCOMPtr<nsIMsgDatabase> db;
     if (NS_FAILED(folderWithNewMail->GetMsgDatabase(getter_AddRefs(db))))
       return;
 
     uint32_t numNewKeys = 0;
     uint32_t *newMessageKeys;
@@ -503,259 +455,229 @@ void nsMessengerUnixIntegration::FillToo
     if (NS_FAILED(GetMRUTimestampForFolder(folder, &lastMRUTime)))
       lastMRUTime = 0;
 
     // Next, add the new message headers to an nsCOMArray.  We
     // only add message headers that are newer than lastMRUTime.
     nsCOMArray<nsIMsgDBHdr> newMsgHdrs;
     for (unsigned int i = 0; i < numNewKeys; ++i) {
       nsCOMPtr<nsIMsgDBHdr> hdr;
-      if (NS_FAILED(db->GetMsgHdrForKey(newMessageKeys[i], getter_AddRefs(hdr))))
+      if (NS_FAILED(
+              db->GetMsgHdrForKey(newMessageKeys[i], getter_AddRefs(hdr))))
         continue;
 
       uint32_t dateInSeconds = 0;
       hdr->GetDateInSeconds(&dateInSeconds);
 
-      if (dateInSeconds > lastMRUTime)
-        newMsgHdrs.AppendObject(hdr);
-
+      if (dateInSeconds > lastMRUTime) newMsgHdrs.AppendObject(hdr);
     }
 
     // At this point, we don't need newMessageKeys any more,
     // so let's free it.
     free(newMessageKeys);
 
     // If we didn't happen to add any message headers, bail out
-    if (!newMsgHdrs.Count())
-      return;
+    if (!newMsgHdrs.Count()) return;
 
     // Sort the message headers by dateInSeconds, in ascending
     // order
     newMsgHdrs.Sort(nsMsgDbHdrTimestampComparator, nullptr);
 
     nsString alertBody;
 
     // Build the body text of the notification.
-    if (!BuildNotificationBody(newMsgHdrs[0], bundle, alertBody))
-      return;
+    if (!BuildNotificationBody(newMsgHdrs[0], bundle, alertBody)) return;
 
     // Show the notification
     ShowAlertMessage(alertTitle, alertBody, EmptyCString());
 
     // Find the last, and therefore newest message header
     // in our nsCOMArray
     nsCOMPtr<nsIMsgDBHdr> lastMsgHdr = newMsgHdrs[newMsgHdrs.Count() - 1];
 
     uint32_t dateInSeconds = 0;
-    if (NS_FAILED(lastMsgHdr->GetDateInSeconds(&dateInSeconds)))
-      return;
+    if (NS_FAILED(lastMsgHdr->GetDateInSeconds(&dateInSeconds))) return;
 
     // Write the newest message timestamp to the appropriate
     // mapping in our hashtable of MRUTime's.
     PutMRUTimestampForFolder(folder, dateInSeconds);
-  } // if we got a folder
+  }  // if we got a folder
 }
 
-// Get the first top level folder which we know has new mail, then enumerate over
-// all the subfolders looking for the first real folder with new mail.
+// Get the first top level folder which we know has new mail, then enumerate
+// over all the subfolders looking for the first real folder with new mail.
 // Return the folderURI for that folder.
-nsresult nsMessengerUnixIntegration::GetFirstFolderWithNewMail(nsACString& aFolderURI)
-{
+nsresult nsMessengerUnixIntegration::GetFirstFolderWithNewMail(
+    nsACString &aFolderURI) {
   NS_ENSURE_TRUE(mFoldersWithNewMail, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIMsgFolder> folder;
   nsWeakPtr weakReference;
 
   uint32_t count = 0;
   nsresult rv = mFoldersWithNewMail->GetLength(&count);
-  if (NS_FAILED(rv) || !count)  // kick out if we don't have any folders with new mail
+  if (NS_FAILED(rv) ||
+      !count)  // kick out if we don't have any folders with new mail
     return NS_OK;
 
   uint32_t i;
-  for(i = 0; i < count; i++)
-  {
+  for (i = 0; i < count; i++) {
     weakReference = do_QueryElementAt(mFoldersWithNewMail, i);
     folder = do_QueryReferent(weakReference);
 
     // We only want to find folders which haven't been notified
     // yet.  This is specific to Thunderbird.  In Seamonkey, we
     // just return 0, and we don't care about timestamps anymore.
     uint32_t lastMRUTime = 0;
     rv = GetMRUTimestampForFolder(folder, &lastMRUTime);
-    if (NS_FAILED(rv))
-      lastMRUTime = 0;
+    if (NS_FAILED(rv)) lastMRUTime = 0;
 
-    if (!folder)
-      continue;
-    // enumerate over the folders under this root folder till we find one with new mail....
+    if (!folder) continue;
+    // enumerate over the folders under this root folder till we find one with
+    // new mail....
     nsCOMPtr<nsIMsgFolder> msgFolder;
     nsCOMPtr<nsIArray> allFolders;
     rv = folder->GetDescendants(getter_AddRefs(allFolders));
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t subfolderCount = 0;
     allFolders->GetLength(&subfolderCount);
     uint32_t j;
-    for (j = 0; j < subfolderCount; j++)
-    {
+    for (j = 0; j < subfolderCount; j++) {
       nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryElementAt(allFolders, j);
 
-      if (!msgFolder)
-        continue;
+      if (!msgFolder) continue;
 
       uint32_t flags;
       rv = msgFolder->GetFlags(&flags);
 
-      if (NS_FAILED(rv))
-        continue;
+      if (NS_FAILED(rv)) continue;
 
       bool notify =
-        // Any folder which is an inbox or ...
-        flags & nsMsgFolderFlags::Inbox ||
-        // any non-special or non-virtual folder. In other words, we don't
-        // notify for Drafts|Trash|SentMail|Templates|Junk|Archive|Queue or virtual.
-        !(flags & (nsMsgFolderFlags::SpecialUse | nsMsgFolderFlags::Virtual));
+          // Any folder which is an inbox or ...
+          flags & nsMsgFolderFlags::Inbox ||
+          // any non-special or non-virtual folder. In other words, we don't
+          // notify for Drafts|Trash|SentMail|Templates|Junk|Archive|Queue or
+          // virtual.
+          !(flags & (nsMsgFolderFlags::SpecialUse | nsMsgFolderFlags::Virtual));
 
-      if (!notify)
-        continue;
+      if (!notify) continue;
 
       nsCString folderURI;
       msgFolder->GetURI(folderURI);
       bool hasNew = false;
       rv = msgFolder->GetHasNewMessages(&hasNew);
 
-      if (NS_FAILED(rv))
-        continue;
+      if (NS_FAILED(rv)) continue;
 
       // Grab the MRUTime property from the folder
       nsCString dateStr;
       msgFolder->GetStringProperty(MRU_TIME_PROPERTY, dateStr);
-      uint32_t MRUTime = (uint32_t) dateStr.ToInteger(&rv, 10);
-      if (NS_FAILED(rv))
-        MRUTime = 0;
+      uint32_t MRUTime = (uint32_t)dateStr.ToInteger(&rv, 10);
+      if (NS_FAILED(rv)) MRUTime = 0;
 
-      if (hasNew && MRUTime > lastMRUTime)
-      {
+      if (hasNew && MRUTime > lastMRUTime) {
         rv = msgFolder->GetURI(aFolderURI);
         NS_ENSURE_SUCCESS(rv, rv);
         return NS_OK;
       }
     }  // if we have more potential folders to enumerate
   }
 
   // If we got here, then something when pretty wrong.
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemPropertyFlagChanged(nsIMsgDBHdr *item, const nsACString &property, uint32_t oldFlag, uint32_t newFlag)
-{
+nsMessengerUnixIntegration::OnItemPropertyFlagChanged(
+    nsIMsgDBHdr *item, const nsACString &property, uint32_t oldFlag,
+    uint32_t newFlag) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemAdded(nsIMsgFolder *, nsISupports *)
-{
+nsMessengerUnixIntegration::OnItemAdded(nsIMsgFolder *, nsISupports *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemBoolPropertyChanged(nsIMsgFolder *aItem,
-                                                      const nsACString &aProperty,
-                                                      bool aOldValue,
-                                                      bool aNewValue)
-{
+nsMessengerUnixIntegration::OnItemBoolPropertyChanged(
+    nsIMsgFolder *aItem, const nsACString &aProperty, bool aOldValue,
+    bool aNewValue) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemEvent(nsIMsgFolder *, const nsACString &)
-{
+nsMessengerUnixIntegration::OnItemEvent(nsIMsgFolder *, const nsACString &) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnItemIntPropertyChanged(nsIMsgFolder *aItem, const nsACString &aProperty, int64_t aOldValue, int64_t aNewValue)
-{
+nsMessengerUnixIntegration::OnItemIntPropertyChanged(
+    nsIMsgFolder *aItem, const nsACString &aProperty, int64_t aOldValue,
+    int64_t aNewValue) {
   nsCString atomName;
   // if we got new mail show an icon in the system tray
-  if (aProperty.Equals(kBiffState) && mFoldersWithNewMail)
-  {
+  if (aProperty.Equals(kBiffState) && mFoldersWithNewMail) {
     nsWeakPtr weakFolder = do_GetWeakReference(aItem);
     uint32_t indexInNewArray;
     nsresult rv = mFoldersWithNewMail->IndexOf(0, weakFolder, &indexInNewArray);
     bool folderFound = NS_SUCCEEDED(rv);
 
-    if (aNewValue == nsIMsgFolder::nsMsgBiffState_NewMail)
-    {
+    if (aNewValue == nsIMsgFolder::nsMsgBiffState_NewMail) {
       // only show a system tray icon iff we are performing biff
       // (as opposed to the user getting new mail)
       bool performingBiff = false;
       nsCOMPtr<nsIMsgIncomingServer> server;
       aItem->GetServer(getter_AddRefs(server));
-      if (server)
-        server->GetPerformingBiff(&performingBiff);
-      if (!performingBiff)
-        return NS_OK; // kick out right now...
+      if (server) server->GetPerformingBiff(&performingBiff);
+      if (!performingBiff) return NS_OK;  // kick out right now...
 
-      if (!folderFound)
-        mFoldersWithNewMail->AppendElement(weakFolder);
+      if (!folderFound) mFoldersWithNewMail->AppendElement(weakFolder);
       // now regenerate the tooltip
       FillToolTipInfo();
-    }
-    else if (aNewValue == nsIMsgFolder::nsMsgBiffState_NoMail)
-    {
+    } else if (aNewValue == nsIMsgFolder::nsMsgBiffState_NoMail) {
       if (folderFound) {
         mFoldersWithNewMail->RemoveElementAt(indexInNewArray);
       }
     }
-  } // if the biff property changed
-  else if (aProperty.Equals(kNewMailReceived))
-  {
+  }  // if the biff property changed
+  else if (aProperty.Equals(kNewMailReceived)) {
     FillToolTipInfo();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnStartRunningUrl(nsIURI *aUrl)
-{
-  return NS_OK;
-}
+nsMessengerUnixIntegration::OnStartRunningUrl(nsIURI *aUrl) { return NS_OK; }
 
 NS_IMETHODIMP
-nsMessengerUnixIntegration::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
-{
+nsMessengerUnixIntegration::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode) {
   if (NS_SUCCEEDED(aExitCode))
     // preview fetch is done.
     FillToolTipInfo();
   return NS_OK;
 }
 
-nsresult
-nsMessengerUnixIntegration::GetMRUTimestampForFolder(nsIMsgFolder *aFolder,
-                                                     uint32_t *aLastMRUTime)
-{
+nsresult nsMessengerUnixIntegration::GetMRUTimestampForFolder(
+    nsIMsgFolder *aFolder, uint32_t *aLastMRUTime) {
   nsCOMPtr<nsIMsgFolder> rootFolder = nullptr;
   nsresult rv = aFolder->GetRootFolder(getter_AddRefs(rootFolder));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString rootFolderURI;
   rootFolder->GetURI(rootFolderURI);
-  if (!mLastMRUTimes.Get(rootFolderURI, aLastMRUTime))
-    aLastMRUTime = 0;
+  if (!mLastMRUTimes.Get(rootFolderURI, aLastMRUTime)) aLastMRUTime = 0;
 
   return NS_OK;
 }
 
-nsresult
-nsMessengerUnixIntegration::PutMRUTimestampForFolder(nsIMsgFolder *aFolder,
-                                                     uint32_t aLastMRUTime)
-{
+nsresult nsMessengerUnixIntegration::PutMRUTimestampForFolder(
+    nsIMsgFolder *aFolder, uint32_t aLastMRUTime) {
   nsresult rv;
   nsCOMPtr<nsIMsgFolder> rootFolder = nullptr;
   rv = aFolder->GetRootFolder(getter_AddRefs(rootFolder));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString rootFolderURI;
   rootFolder->GetURI(rootFolderURI);
   mLastMRUTimes.Put(rootFolderURI, aLastMRUTime);
--- a/mailnews/base/src/nsMessengerUnixIntegration.h
+++ b/mailnews/base/src/nsMessengerUnixIntegration.h
@@ -10,51 +10,63 @@
 #include "nsIFolderListener.h"
 #include "nsIUrlListener.h"
 #include "nsIMutableArray.h"
 #include "nsIStringBundle.h"
 #include "nsIObserver.h"
 #include "nsDataHashtable.h"
 #include "nsTArray.h"
 
-#define NS_MESSENGERUNIXINTEGRATION_CID \
-  {0xf62f3d3a, 0x1dd1, 0x11b2, \
-    {0xa5, 0x16, 0xef, 0xad, 0xb1, 0x31, 0x61, 0x5c}}
+#define NS_MESSENGERUNIXINTEGRATION_CID              \
+  {                                                  \
+    0xf62f3d3a, 0x1dd1, 0x11b2, {                    \
+      0xa5, 0x16, 0xef, 0xad, 0xb1, 0x31, 0x61, 0x5c \
+    }                                                \
+  }
 
 class nsIStringBundle;
 
 class nsMessengerUnixIntegration : public nsIFolderListener,
                                    public nsIObserver,
                                    public nsIUrlListener,
-                                   public nsIMessengerOSIntegration
-{
-public:
+                                   public nsIMessengerOSIntegration {
+ public:
   nsMessengerUnixIntegration();
   virtual nsresult Init();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMESSENGEROSINTEGRATION
   NS_DECL_NSIFOLDERLISTENER
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIURLLISTENER
 
-private:
+ private:
   virtual ~nsMessengerUnixIntegration() {}
-  nsresult ShowAlertMessage(const nsAString& aAlertTitle, const nsAString& aAlertText, const nsACString& aFolderURI);
-  nsresult GetFirstFolderWithNewMail(nsACString& aFolderURI);
+  nsresult ShowAlertMessage(const nsAString &aAlertTitle,
+                            const nsAString &aAlertText,
+                            const nsACString &aFolderURI);
+  nsresult GetFirstFolderWithNewMail(nsACString &aFolderURI);
   nsresult GetStringBundle(nsIStringBundle **aBundle);
   nsresult AlertFinished();
   nsresult AlertClicked();
   void FillToolTipInfo();
-  nsresult GetMRUTimestampForFolder(nsIMsgFolder *aFolder, uint32_t *aLastMRUTime);
+  nsresult GetMRUTimestampForFolder(nsIMsgFolder *aFolder,
+                                    uint32_t *aLastMRUTime);
 
-  bool BuildNotificationBody(nsIMsgDBHdr *aHdr, nsIStringBundle *Bundle, nsString &aBody);
-  bool BuildNotificationTitle(nsIMsgFolder *aFolder, nsIStringBundle *aBundle, nsString &aTitle);
+  bool BuildNotificationBody(nsIMsgDBHdr *aHdr, nsIStringBundle *Bundle,
+                             nsString &aBody);
+  bool BuildNotificationTitle(nsIMsgFolder *aFolder, nsIStringBundle *aBundle,
+                              nsString &aTitle);
   nsresult ShowNewAlertNotification(bool aUserInitiated);
-  nsresult PutMRUTimestampForFolder(nsIMsgFolder *aFolder, uint32_t aLastMRUTime);
+  nsresult PutMRUTimestampForFolder(nsIMsgFolder *aFolder,
+                                    uint32_t aLastMRUTime);
 
-  nsCOMPtr<nsIMutableArray> mFoldersWithNewMail;  // keep track of all the root folders with pending new mail
+  nsCOMPtr<nsIMutableArray>
+      mFoldersWithNewMail;  // keep track of all the root folders with pending
+                            // new mail
   bool mAlertInProgress;
-  nsDataHashtable<nsCStringHashKey, uint32_t> mLastMRUTimes; // We keep track of the last time we did a new mail notification for each account
+  nsDataHashtable<nsCStringHashKey, uint32_t>
+      mLastMRUTimes;  // We keep track of the last time we did a new mail
+                      // notification for each account
   nsTArray<nsCString> mFetchingURIs;
 };
 
-#endif // __nsMessengerUnixIntegration_h
+#endif  // __nsMessengerUnixIntegration_h
--- a/mailnews/base/src/nsMessengerWinIntegration.cpp
+++ b/mailnews/base/src/nsMessengerWinIntegration.cpp
@@ -49,949 +49,890 @@
 #include "nsIMutableArray.h"
 #include "nsArrayUtils.h"
 
 #include "mozilla/Components.h"
 #include <stdlib.h>
 #define PROFILE_COMMANDLINE_ARG u" -profile "
 
 #define NOTIFICATIONCLASSNAME "MailBiffNotificationMessageWindow"
-#define UNREADMAILNODEKEY u"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"
+#define UNREADMAILNODEKEY \
+  u"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"
 #define DOUBLE_QUOTE '"'
 #define MAIL_COMMANDLINE_ARG u" -mail"
 #define IDI_MAILBIFF 32576
-#define UNREAD_UPDATE_INTERVAL  (20 * 1000)  // 20 seconds
+#define UNREAD_UPDATE_INTERVAL (20 * 1000)  // 20 seconds
 #define ALERT_CHROME_URL "chrome://messenger/content/newmailalert.xul"
 #define NEW_MAIL_ALERT_ICON "chrome://messenger/skin/icons/new-mail-alert.png"
-#define SHOW_ALERT_PREF     "mail.biff.show_alert"
+#define SHOW_ALERT_PREF "mail.biff.show_alert"
 #define SHOW_TRAY_ICON_PREF "mail.biff.show_tray_icon"
-#define SHOW_BALLOON_PREF   "mail.biff.show_balloon"
+#define SHOW_BALLOON_PREF "mail.biff.show_balloon"
 #define SHOW_NEW_ALERT_PREF "mail.biff.show_new_alert"
-#define ALERT_ORIGIN_PREF   "ui.alertNotificationOrigin"
+#define ALERT_ORIGIN_PREF "ui.alertNotificationOrigin"
 
 // since we are including windows.h in this file, undefine get user name....
 #ifdef GetUserName
-#undef GetUserName
+#  undef GetUserName
 #endif
 
 #ifndef NIIF_USER
-#define NIIF_USER       0x00000004
+#  define NIIF_USER 0x00000004
 #endif
 
 #ifndef NIIF_NOSOUND
-#define NIIF_NOSOUND    0x00000010
+#  define NIIF_NOSOUND 0x00000010
 #endif
 
 #ifndef NIN_BALOONUSERCLICK
-#define NIN_BALLOONUSERCLICK (WM_USER + 5)
+#  define NIN_BALLOONUSERCLICK (WM_USER + 5)
 #endif
 
 using namespace mozilla;
 
 // begin shameless copying from nsNativeAppSupportWin
-HWND hwndForDOMWindow( mozIDOMWindowProxy *window )
-{
-  if ( !window ) {
+HWND hwndForDOMWindow(mozIDOMWindowProxy *window) {
+  if (!window) {
     return 0;
   }
   nsCOMPtr<nsPIDOMWindowOuter> pidomwindow = nsPIDOMWindowOuter::From(window);
 
   nsCOMPtr<nsIBaseWindow> ppBaseWindow =
-    do_QueryInterface( pidomwindow->GetDocShell() );
-  if (!ppBaseWindow)
-    return 0;
+      do_QueryInterface(pidomwindow->GetDocShell());
+  if (!ppBaseWindow) return 0;
 
   nsCOMPtr<nsIWidget> ppWidget;
-  ppBaseWindow->GetMainWidget( getter_AddRefs( ppWidget ) );
+  ppBaseWindow->GetMainWidget(getter_AddRefs(ppWidget));
 
-  return (HWND)( ppWidget->GetNativeData( NS_NATIVE_WIDGET ) );
+  return (HWND)(ppWidget->GetNativeData(NS_NATIVE_WIDGET));
 }
 
-static void activateWindow( mozIDOMWindowProxy *win )
-{
+static void activateWindow(mozIDOMWindowProxy *win) {
   // Try to get native window handle.
-  HWND hwnd = hwndForDOMWindow( win );
-  if ( hwnd )
-  {
+  HWND hwnd = hwndForDOMWindow(win);
+  if (hwnd) {
     // Restore the window if it is minimized.
-    if ( ::IsIconic( hwnd ) )
-      ::ShowWindow( hwnd, SW_RESTORE );
+    if (::IsIconic(hwnd)) ::ShowWindow(hwnd, SW_RESTORE);
     // Use the OS call, if possible.
-    ::SetForegroundWindow( hwnd );
+    ::SetForegroundWindow(hwnd);
   } else {
     // Use internal method.
     nsCOMPtr<nsPIDOMWindowOuter> privateWindow = nsPIDOMWindowOuter::From(win);
     privateWindow->Focus();
   }
 }
 // end shameless copying from nsNativeAppWinSupport.cpp
 
-static void openMailWindow(const nsACString& aFolderUri)
-{
+static void openMailWindow(const nsACString &aFolderUri) {
   nsresult rv;
-  nsCOMPtr<nsIMsgMailSession> mailSession ( do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
-  if (NS_FAILED(rv))
-    return;
+  nsCOMPtr<nsIMsgMailSession> mailSession(
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) return;
 
   nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
   rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
-  if (topMostMsgWindow)
-  {
+  if (topMostMsgWindow) {
     nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
-    if (domWindow)
-    {
-      if (!aFolderUri.IsEmpty())
-      {
+    if (domWindow) {
+      if (!aFolderUri.IsEmpty()) {
         nsCOMPtr<nsIMsgWindowCommands> windowCommands;
         topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
-        if (windowCommands)
-          windowCommands->SelectFolder(aFolderUri);
+        if (windowCommands) windowCommands->SelectFolder(aFolderUri);
       }
       activateWindow(domWindow);
       return;
     }
   }
 
   {
     // the user doesn't have a mail window open already so open one for them...
     nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
-      do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
+        do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
     // if we want to preselect the first account with new mail,
     // here is where we would try to generate a uri to pass in
     // (and add code to the messenger window service to make that work)
     if (messengerWindowService)
       messengerWindowService->OpenMessengerWindowWithUri(
-                                "mail:3pane", nsCString(aFolderUri).get(), nsMsgKey_None);
+          "mail:3pane", nsCString(aFolderUri).get(), nsMsgKey_None);
   }
 }
 
-static void CALLBACK delayedSingleClick(HWND msgWindow, UINT msg, INT_PTR idEvent, DWORD dwTime)
-{
+static void CALLBACK delayedSingleClick(HWND msgWindow, UINT msg,
+                                        INT_PTR idEvent, DWORD dwTime) {
   ::KillTimer(msgWindow, idEvent);
 
   // single clicks on the biff icon should re-open the alert notification
   nsresult rv = NS_OK;
   nsCOMPtr<nsIMessengerOSIntegration> integrationService =
-    do_GetService(NS_MESSENGEROSINTEGRATION_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv))
-  {
+      do_GetService(NS_MESSENGEROSINTEGRATION_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) {
     // we know we are dealing with the windows integration object
-    nsMessengerWinIntegration * winIntegrationService = static_cast<nsMessengerWinIntegration*>
-                                                                   (static_cast<nsIMessengerOSIntegration*>(integrationService.get()));
-    winIntegrationService->ShowNewAlertNotification(true, EmptyString(), EmptyString());
+    nsMessengerWinIntegration *winIntegrationService =
+        static_cast<nsMessengerWinIntegration *>(
+            static_cast<nsIMessengerOSIntegration *>(integrationService.get()));
+    winIntegrationService->ShowNewAlertNotification(true, EmptyString(),
+                                                    EmptyString());
   }
 }
 
 // Window proc.
-static LRESULT CALLBACK MessageWindowProc( HWND msgWindow, UINT msg, WPARAM wp, LPARAM lp )
-{
-  if (msg == WM_USER)
-  {
-    if (lp == WM_LBUTTONDOWN)
-    {
+static LRESULT CALLBACK MessageWindowProc(HWND msgWindow, UINT msg, WPARAM wp,
+                                          LPARAM lp) {
+  if (msg == WM_USER) {
+    if (lp == WM_LBUTTONDOWN) {
       // the only way to tell a single left click
-      // from a double left click is to fire a timer which gets cleared if we end up getting
-      // a WM_LBUTTONDBLK event.
-      ::SetTimer(msgWindow, 1, GetDoubleClickTime(), (TIMERPROC) delayedSingleClick);
-    }
-    else if (lp == WM_LBUTTONDBLCLK || lp == NIN_BALLOONUSERCLICK)
-    {
+      // from a double left click is to fire a timer which gets cleared if we
+      // end up getting a WM_LBUTTONDBLK event.
+      ::SetTimer(msgWindow, 1, GetDoubleClickTime(),
+                 (TIMERPROC)delayedSingleClick);
+    } else if (lp == WM_LBUTTONDBLCLK || lp == NIN_BALLOONUSERCLICK) {
       ::KillTimer(msgWindow, 1);
       openMailWindow(EmptyCString());
     }
   }
 
   return TRUE;
 }
 
 static HWND msgWindow;
 
 // Create: Register class and create window.
-static nsresult Create()
-{
-  if (msgWindow)
-    return NS_OK;
+static nsresult Create() {
+  if (msgWindow) return NS_OK;
 
-  WNDCLASS classStruct = { 0,                          // style
-                           &MessageWindowProc,         // lpfnWndProc
-                           0,                          // cbClsExtra
-                           0,                          // cbWndExtra
-                           0,                          // hInstance
-                           0,                          // hIcon
-                           0,                          // hCursor
-                           0,                          // hbrBackground
-                           0,                          // lpszMenuName
-                           NOTIFICATIONCLASSNAME };    // lpszClassName
+  WNDCLASS classStruct = {0,                       // style
+                          &MessageWindowProc,      // lpfnWndProc
+                          0,                       // cbClsExtra
+                          0,                       // cbWndExtra
+                          0,                       // hInstance
+                          0,                       // hIcon
+                          0,                       // hCursor
+                          0,                       // hbrBackground
+                          0,                       // lpszMenuName
+                          NOTIFICATIONCLASSNAME};  // lpszClassName
 
   // Register the window class.
-  NS_ENSURE_TRUE( ::RegisterClass( &classStruct ), NS_ERROR_FAILURE );
+  NS_ENSURE_TRUE(::RegisterClass(&classStruct), NS_ERROR_FAILURE);
   // Create the window.
-  NS_ENSURE_TRUE( msgWindow = ::CreateWindow( NOTIFICATIONCLASSNAME,
-                                              0,          // title
-                                              WS_CAPTION, // style
-                                              0,0,0,0,    // x, y, cx, cy
-                                              0,          // parent
-                                              0,          // menu
-                                              0,          // instance
-                                              0 ),        // create struct
-                  NS_ERROR_FAILURE );
+  NS_ENSURE_TRUE(msgWindow = ::CreateWindow(NOTIFICATIONCLASSNAME,
+                                            0,           // title
+                                            WS_CAPTION,  // style
+                                            0, 0, 0, 0,  // x, y, cx, cy
+                                            0,           // parent
+                                            0,           // menu
+                                            0,           // instance
+                                            0),          // create struct
+                 NS_ERROR_FAILURE);
   return NS_OK;
 }
 
-
-nsMessengerWinIntegration::nsMessengerWinIntegration()
-{
+nsMessengerWinIntegration::nsMessengerWinIntegration() {
   mUnreadTimerActive = false;
 
   mBiffIconVisible = false;
   mSuppressBiffIcon = false;
   mAlertInProgress = false;
   mBiffIconInitialized = false;
   mFoldersWithNewMail = do_CreateInstance(NS_ARRAY_CONTRACTID);
 }
 
-nsMessengerWinIntegration::~nsMessengerWinIntegration()
-{
+nsMessengerWinIntegration::~nsMessengerWinIntegration() {
   if (mUnreadCountUpdateTimer) {
     mUnreadCountUpdateTimer->Cancel();
     mUnreadCountUpdateTimer = nullptr;
   }
 
   // one last attempt, update the registry
   mozilla::DebugOnly<nsresult> rv = UpdateRegistryWithCurrent();
   NS_ASSERTION(NS_SUCCEEDED(rv), "failed to update registry on shutdown");
   DestroyBiffIcon();
 }
 
 NS_IMPL_ADDREF(nsMessengerWinIntegration)
 NS_IMPL_RELEASE(nsMessengerWinIntegration)
 
 NS_INTERFACE_MAP_BEGIN(nsMessengerWinIntegration)
-   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMessengerOSIntegration)
-   NS_INTERFACE_MAP_ENTRY(nsIMessengerOSIntegration)
-   NS_INTERFACE_MAP_ENTRY(nsIFolderListener)
-   NS_INTERFACE_MAP_ENTRY(nsIObserver)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMessengerOSIntegration)
+  NS_INTERFACE_MAP_ENTRY(nsIMessengerOSIntegration)
+  NS_INTERFACE_MAP_ENTRY(nsIFolderListener)
+  NS_INTERFACE_MAP_ENTRY(nsIObserver)
 NS_INTERFACE_MAP_END
 
-
-nsresult
-nsMessengerWinIntegration::ResetCurrent()
-{
+nsresult nsMessengerWinIntegration::ResetCurrent() {
   mInboxURI.Truncate();
   mEmail.Truncate();
 
   mCurrentUnreadCount = -1;
   mLastUnreadCountWrittenToRegistry = -1;
 
   mDefaultAccountMightHaveAnInbox = true;
   return NS_OK;
 }
 
-NOTIFYICONDATAW sBiffIconData = { (DWORD)NOTIFYICONDATAW_V2_SIZE,
-                                  0,
-                                  2,
-                                  NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO,
-                                  WM_USER,
-                                  0,
-                                  L"",
-                                  0,
-                                  0,
-                                  L"",
-                                  { 30000 },
-                                  L"",
-                                  NIIF_USER | NIIF_NOSOUND };
+NOTIFYICONDATAW sBiffIconData = {(DWORD)NOTIFYICONDATAW_V2_SIZE,
+                                 0,
+                                 2,
+                                 NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO,
+                                 WM_USER,
+                                 0,
+                                 L"",
+                                 0,
+                                 0,
+                                 L"",
+                                 {30000},
+                                 L"",
+                                 NIIF_USER | NIIF_NOSOUND};
 // allow for the null terminator
-static const uint32_t kMaxTooltipSize = sizeof(sBiffIconData.szTip) /
-                                        sizeof(sBiffIconData.szTip[0]) - 1;
-static const uint32_t kMaxBalloonSize = sizeof(sBiffIconData.szInfo) /
-                                        sizeof(sBiffIconData.szInfo[0]) - 1;
-static const uint32_t kMaxBalloonTitle = sizeof(sBiffIconData.szInfoTitle) /
-                                         sizeof(sBiffIconData.szInfoTitle[0]) - 1;
+static const uint32_t kMaxTooltipSize =
+    sizeof(sBiffIconData.szTip) / sizeof(sBiffIconData.szTip[0]) - 1;
+static const uint32_t kMaxBalloonSize =
+    sizeof(sBiffIconData.szInfo) / sizeof(sBiffIconData.szInfo[0]) - 1;
+static const uint32_t kMaxBalloonTitle =
+    sizeof(sBiffIconData.szInfoTitle) / sizeof(sBiffIconData.szInfoTitle[0]) -
+    1;
 
-void nsMessengerWinIntegration::InitializeBiffStatusIcon()
-{
+void nsMessengerWinIntegration::InitializeBiffStatusIcon() {
   // initialize our biff status bar icon
   Create();
 
-  sBiffIconData.hWnd = (HWND) msgWindow;
-  sBiffIconData.hIcon = ::LoadIcon( ::GetModuleHandle( NULL ), MAKEINTRESOURCE(IDI_MAILBIFF) );
+  sBiffIconData.hWnd = (HWND)msgWindow;
+  sBiffIconData.hIcon =
+      ::LoadIcon(::GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAILBIFF));
 
   mBiffIconInitialized = true;
 }
 
-nsresult
-nsMessengerWinIntegration::Init()
-{
+nsresult nsMessengerWinIntegration::Init() {
   nsresult rv;
 
-  nsCOMPtr <nsIMsgAccountManager> accountManager =
-    do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgAccountManager> accountManager =
+      do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // because we care if the default server changes
   rv = accountManager->AddRootFolderListener(this);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgMailSession> mailSession =
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // because we care if the unread total count changes
-  rv = mailSession->AddFolderListener(this, nsIFolderListener::boolPropertyChanged | nsIFolderListener::intPropertyChanged);
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = mailSession->AddFolderListener(
+      this, nsIFolderListener::boolPropertyChanged |
+                nsIFolderListener::intPropertyChanged);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // get current profile path for the commandliner
   nsCOMPtr<nsIProperties> directoryService =
-    do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+      do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIFile> profilePath;
-  rv = directoryService->Get(NS_APP_USER_PROFILE_50_DIR,
-                             NS_GET_IID(nsIFile),
+  rv = directoryService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
                              getter_AddRefs(profilePath));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   rv = profilePath->GetPath(mProfilePath);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // get application path
   WCHAR appPath[_MAX_PATH] = {0};
   ::GetModuleFileNameW(nullptr, appPath, sizeof(appPath));
   mAppName.Assign((char16_t *)appPath);
 
   rv = ResetCurrent();
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemPropertyChanged(nsIMsgFolder *, const nsACString &, char const *, char const *)
-{
+nsMessengerWinIntegration::OnItemPropertyChanged(nsIMsgFolder *,
+                                                 const nsACString &,
+                                                 char const *, char const *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemUnicharPropertyChanged(nsIMsgFolder *, const nsACString &, const char16_t *, const char16_t *)
-{
+nsMessengerWinIntegration::OnItemUnicharPropertyChanged(nsIMsgFolder *,
+                                                        const nsACString &,
+                                                        const char16_t *,
+                                                        const char16_t *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *)
-{
+nsMessengerWinIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *) {
   return NS_OK;
 }
 
-nsresult nsMessengerWinIntegration::GetStringBundle(nsIStringBundle **aBundle)
-{
+nsresult nsMessengerWinIntegration::GetStringBundle(nsIStringBundle **aBundle) {
   NS_ENSURE_ARG_POINTER(aBundle);
   nsCOMPtr<nsIStringBundleService> bundleService =
-    mozilla::services::GetStringBundleService();
+      mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
                               getter_AddRefs(bundle));
   bundle.forget(aBundle);
   return NS_OK;
 }
 
 #ifndef MOZ_THUNDERBIRD
-nsresult nsMessengerWinIntegration::ShowAlertMessage(const nsString& aAlertTitle,
-                                                     const nsString& aAlertText,
-                                                     const nsACString& aFolderURI)
-{
+nsresult nsMessengerWinIntegration::ShowAlertMessage(
+    const nsString &aAlertTitle, const nsString &aAlertText,
+    const nsACString &aFolderURI) {
   nsresult rv;
 
-  // if we are already in the process of showing an alert, don't try to show another....
-  if (mAlertInProgress)
-    return NS_OK;
+  // if we are already in the process of showing an alert, don't try to show
+  // another....
+  if (mAlertInProgress) return NS_OK;
 
-  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool showBalloon = false;
   prefBranch->GetBoolPref(SHOW_BALLOON_PREF, &showBalloon);
   sBiffIconData.szInfo[0] = '\0';
   if (showBalloon) {
-    ::wcsncpy( sBiffIconData.szInfoTitle, aAlertTitle.get(), kMaxBalloonTitle);
-    ::wcsncpy( sBiffIconData.szInfo, aAlertText.get(), kMaxBalloonSize);
+    ::wcsncpy(sBiffIconData.szInfoTitle, aAlertTitle.get(), kMaxBalloonTitle);
+    ::wcsncpy(sBiffIconData.szInfo, aAlertText.get(), kMaxBalloonSize);
   }
 
   bool showAlert = true;
   prefBranch->GetBoolPref(SHOW_ALERT_PREF, &showAlert);
 
-  if (showAlert)
-  {
-    nsCOMPtr<nsIAlertsService> alertsService = mozilla::components::Alerts::Service();
-    if (alertsService)
-    {
-      rv = alertsService->ShowAlertNotification(NS_LITERAL_STRING(NEW_MAIL_ALERT_ICON), aAlertTitle,
-                                                aAlertText, true,
-                                                NS_ConvertASCIItoUTF16(aFolderURI), this,
-                                                EmptyString(),
-                                                NS_LITERAL_STRING("auto"),
-                                                EmptyString(), EmptyString(),
-                                                nullptr,
-                                                false,
-                                                false);
+  if (showAlert) {
+    nsCOMPtr<nsIAlertsService> alertsService =
+        mozilla::components::Alerts::Service();
+    if (alertsService) {
+      rv = alertsService->ShowAlertNotification(
+          NS_LITERAL_STRING(NEW_MAIL_ALERT_ICON), aAlertTitle, aAlertText, true,
+          NS_ConvertASCIItoUTF16(aFolderURI), this, EmptyString(),
+          NS_LITERAL_STRING("auto"), EmptyString(), EmptyString(), nullptr,
+          false, false);
       mAlertInProgress = true;
     }
   }
 
-  if (!showAlert || NS_FAILED(rv)) // go straight to showing the system tray icon.
+  if (!showAlert ||
+      NS_FAILED(rv))  // go straight to showing the system tray icon.
     AlertFinished();
 
   return rv;
 }
 #endif
 // Opening Thunderbird's new mail alert notification window
-// aUserInitiated --> true if we are opening the alert notification in response to a user action
-//                    like clicking on the biff icon
-nsresult nsMessengerWinIntegration::ShowNewAlertNotification(bool aUserInitiated, const nsString& aAlertTitle, const nsString& aAlertText)
-{
+// aUserInitiated --> true if we are opening the alert notification in response
+//                    to a user action like clicking on the biff icon
+nsresult nsMessengerWinIntegration::ShowNewAlertNotification(
+    bool aUserInitiated, const nsString &aAlertTitle,
+    const nsString &aAlertText) {
   nsresult rv;
 
-  // if we are already in the process of showing an alert, don't try to show another....
-  if (mAlertInProgress)
-    return NS_OK;
+  // if we are already in the process of showing an alert, don't try to show
+  // another....
+  if (mAlertInProgress) return NS_OK;
 
-  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool showBalloon = false;
   prefBranch->GetBoolPref(SHOW_BALLOON_PREF, &showBalloon);
   sBiffIconData.szInfo[0] = '\0';
   if (showBalloon) {
-    ::wcsncpy( sBiffIconData.szInfoTitle, aAlertTitle.get(), kMaxBalloonTitle);
-    ::wcsncpy( sBiffIconData.szInfo, aAlertText.get(), kMaxBalloonSize);
+    ::wcsncpy(sBiffIconData.szInfoTitle, aAlertTitle.get(), kMaxBalloonTitle);
+    ::wcsncpy(sBiffIconData.szInfo, aAlertText.get(), kMaxBalloonSize);
   }
 
   bool showAlert = true;
 
-  if (prefBranch)
-    prefBranch->GetBoolPref(SHOW_ALERT_PREF, &showAlert);
+  if (prefBranch) prefBranch->GetBoolPref(SHOW_ALERT_PREF, &showAlert);
 
   // check if we are allowed to show a notification
   if (showAlert) {
     QUERY_USER_NOTIFICATION_STATE qstate;
 
     if (SUCCEEDED(SHQueryUserNotificationState(&qstate))) {
       if (qstate != QUNS_ACCEPTS_NOTIFICATIONS) {
         showAlert = false;
       }
     }
   }
 
-  if (showAlert)
-  {
-    nsCOMPtr<nsIMutableArray> argsArray(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  if (showAlert) {
+    nsCOMPtr<nsIMutableArray> argsArray(
+        do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // pass in the array of folders with unread messages
-    nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
+    nsCOMPtr<nsISupportsInterfacePointer> ifptr =
+        do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     ifptr->SetData(mFoldersWithNewMail);
     ifptr->SetDataIID(&NS_GET_IID(nsIArray));
     rv = argsArray->AppendElement(ifptr);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // pass in the observer
     ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr <nsISupports> supports = do_QueryInterface(static_cast<nsIMessengerOSIntegration*>(this));
+    nsCOMPtr<nsISupports> supports =
+        do_QueryInterface(static_cast<nsIMessengerOSIntegration *>(this));
     ifptr->SetData(supports);
     ifptr->SetDataIID(&NS_GET_IID(nsIObserver));
     rv = argsArray->AppendElement(ifptr);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // pass in the animation flag
-    nsCOMPtr<nsISupportsPRBool> scriptableUserInitiated (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
+    nsCOMPtr<nsISupportsPRBool> scriptableUserInitiated(
+        do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     scriptableUserInitiated->SetData(aUserInitiated);
     rv = argsArray->AppendElement(scriptableUserInitiated);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // pass in the alert origin
-    nsCOMPtr<nsISupportsPRUint8> scriptableOrigin (do_CreateInstance(NS_SUPPORTS_PRUINT8_CONTRACTID));
+    nsCOMPtr<nsISupportsPRUint8> scriptableOrigin(
+        do_CreateInstance(NS_SUPPORTS_PRUINT8_CONTRACTID));
     NS_ENSURE_TRUE(scriptableOrigin, NS_ERROR_FAILURE);
     scriptableOrigin->SetData(0);
     int32_t origin = 0;
     origin = LookAndFeel::GetInt(LookAndFeel::eIntID_AlertNotificationOrigin);
     scriptableOrigin->SetData(origin);
 
     rv = argsArray->AppendElement(scriptableOrigin);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
+    nsCOMPtr<nsIWindowWatcher> wwatch(
+        do_GetService(NS_WINDOWWATCHER_CONTRACTID));
     nsCOMPtr<mozIDOMWindowProxy> newWindow;
     rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
-                "chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
-                 getter_AddRefs(newWindow));
+                            "chrome,dialog=yes,titlebar=no,popup=yes",
+                            argsArray, getter_AddRefs(newWindow));
 
     mAlertInProgress = true;
   }
 
-  // if the user has turned off the mail alert, or  openWindow generated an error,
-  // then go straight to the system tray.
-  if (!showAlert || NS_FAILED(rv))
-    AlertFinished();
+  // if the user has turned off the mail alert, or  openWindow generated an
+  // error, then go straight to the system tray.
+  if (!showAlert || NS_FAILED(rv)) AlertFinished();
 
   return rv;
 }
 
-nsresult nsMessengerWinIntegration::AlertFinished()
-{
+nsresult nsMessengerWinIntegration::AlertFinished() {
   // okay, we are done showing the alert
   // now put an icon in the system tray, if allowed
   bool showTrayIcon = !mSuppressBiffIcon || sBiffIconData.szInfo[0];
-  if (showTrayIcon)
-  {
-    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
-    if (prefBranch)
-      prefBranch->GetBoolPref(SHOW_TRAY_ICON_PREF, &showTrayIcon);
+  if (showTrayIcon) {
+    nsCOMPtr<nsIPrefBranch> prefBranch(
+        do_GetService(NS_PREFSERVICE_CONTRACTID));
+    if (prefBranch) prefBranch->GetBoolPref(SHOW_TRAY_ICON_PREF, &showTrayIcon);
   }
-  if (showTrayIcon)
-  {
+  if (showTrayIcon) {
     GenericShellNotify(NIM_ADD);
     mBiffIconVisible = true;
   }
   mSuppressBiffIcon = false;
   mAlertInProgress = false;
   return NS_OK;
 }
 
-nsresult nsMessengerWinIntegration::AlertClicked()
-{
+nsresult nsMessengerWinIntegration::AlertClicked() {
   nsresult rv;
-  nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgMailSession> mailSession =
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
   rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
-  if (topMostMsgWindow)
-  {
+  if (topMostMsgWindow) {
     nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
-    if (domWindow)
-    {
+    if (domWindow) {
       activateWindow(domWindow);
       return NS_OK;
     }
   }
-  // make sure we don't insert the icon in the system tray since the user clicked on the alert.
+  // make sure we don't insert the icon in the system tray since the user
+  // clicked on the alert.
   mSuppressBiffIcon = true;
   nsCString folderURI;
   GetFirstFolderWithNewMail(folderURI);
   openMailWindow(folderURI);
   return NS_OK;
 }
 
 #ifdef MOZ_SUITE
-nsresult nsMessengerWinIntegration::AlertClickedSimple()
-{
+nsresult nsMessengerWinIntegration::AlertClickedSimple() {
   mSuppressBiffIcon = true;
   return NS_OK;
 }
 #endif
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
-{
-  if (strcmp(aTopic, "alertfinished") == 0)
-      return AlertFinished();
+nsMessengerWinIntegration::Observe(nsISupports *aSubject, const char *aTopic,
+                                   const char16_t *aData) {
+  if (strcmp(aTopic, "alertfinished") == 0) return AlertFinished();
 
-  if (strcmp(aTopic, "alertclickcallback") == 0)
-      return AlertClicked();
+  if (strcmp(aTopic, "alertclickcallback") == 0) return AlertClicked();
 
 #ifdef MOZ_SUITE
   // SeaMonkey does most of the GUI work in JS code when clicking on a mail
   // notification, so it needs an extra function here
   if (strcmp(aTopic, "alertclicksimplecallback") == 0)
-      return AlertClickedSimple();
+    return AlertClickedSimple();
 #endif
 
   return NS_OK;
 }
 
-static void EscapeAmpersands(nsString& aToolTip)
-{
+static void EscapeAmpersands(nsString &aToolTip) {
   // First, check to see whether we have any ampersands.
   int32_t pos = aToolTip.FindChar('&');
-  if (pos == kNotFound)
-    return;
+  if (pos == kNotFound) return;
 
   // Next, see if we only have bare ampersands.
   pos = MsgFind(aToolTip, "&&", false, pos);
 
   // Windows tooltip code removes one ampersand from each run,
   // then collapses pairs of amperands. This means that in the easy case,
   // we need to replace each ampersand with three.
-  MsgReplaceSubstring(aToolTip, NS_LITERAL_STRING("&"), NS_LITERAL_STRING("&&&"));
-  if (pos == kNotFound)
-    return;
+  MsgReplaceSubstring(aToolTip, NS_LITERAL_STRING("&"),
+                      NS_LITERAL_STRING("&&&"));
+  if (pos == kNotFound) return;
 
   // We inserted too many ampersands. Remove some.
   for (;;) {
     pos = MsgFind(aToolTip, "&&&&&&", false, pos);
-    if (pos == kNotFound)
-      return;
+    if (pos == kNotFound) return;
 
     aToolTip.Cut(pos, 1);
     pos += 2;
   }
 }
 
-void nsMessengerWinIntegration::FillToolTipInfo()
-{
+void nsMessengerWinIntegration::FillToolTipInfo() {
   // iterate over all the folders in mFoldersWithNewMail
   nsString accountName;
   nsCString hostName;
   nsString toolTipLine;
   nsAutoString toolTipText;
   nsAutoString animatedAlertText;
   nsCOMPtr<nsIMsgFolder> folder;
   nsWeakPtr weakReference;
   int32_t numNewMessages = 0;
 
   uint32_t count = 0;
   NS_ENSURE_SUCCESS_VOID(mFoldersWithNewMail->GetLength(&count));
 
-  for (uint32_t index = 0; index < count; index++)
-  {
+  for (uint32_t index = 0; index < count; index++) {
     weakReference = do_QueryElementAt(mFoldersWithNewMail, index);
     folder = do_QueryReferent(weakReference);
-    if (folder)
-    {
+    if (folder) {
       folder->GetPrettyName(accountName);
 
       numNewMessages = 0;
       folder->GetNumNewMessages(true, &numNewMessages);
       nsCOMPtr<nsIStringBundle> bundle;
       GetStringBundle(getter_AddRefs(bundle));
-      if (bundle)
-      {
+      if (bundle) {
         nsAutoString numNewMsgsText;
         numNewMsgsText.AppendInt(numNewMessages);
 
-        const char16_t *formatStrings[] =
-        {
-          numNewMsgsText.get(),
+        const char16_t *formatStrings[] = {
+            numNewMsgsText.get(),
         };
 
         nsString finalText;
         if (numNewMessages == 1)
-          bundle->FormatStringFromName("biffNotification_message", formatStrings, 1, finalText);
+          bundle->FormatStringFromName("biffNotification_message",
+                                       formatStrings, 1, finalText);
         else
-          bundle->FormatStringFromName("biffNotification_messages", formatStrings, 1, finalText);
+          bundle->FormatStringFromName("biffNotification_messages",
+                                       formatStrings, 1, finalText);
 
-        // the alert message is special...we actually only want to show the first account with
-        // new mail in the alert.
-        if (animatedAlertText.IsEmpty()) // if we haven't filled in the animated alert text yet
+        // the alert message is special...we actually only want to show the
+        // first account with new mail in the alert.
+        if (animatedAlertText.IsEmpty())  // if we haven't filled in the
+                                          // animated alert text yet
           animatedAlertText = finalText;
 
         toolTipLine.Append(accountName);
         toolTipLine.Append(' ');
         toolTipLine.Append(finalText);
         EscapeAmpersands(toolTipLine);
 
         // only add this new string if it will fit without truncation....
         if (toolTipLine.Length() + toolTipText.Length() <= kMaxTooltipSize)
           toolTipText.Append(toolTipLine);
 
         // clear out the tooltip line for the next folder
         toolTipLine.Assign('\n');
-      } // if we got a bundle
-    } // if we got a folder
-  } // for each folder
+      }  // if we got a bundle
+    }    // if we got a folder
+  }      // for each folder
 
-  ::wcsncpy( sBiffIconData.szTip, toolTipText.get(), kMaxTooltipSize);
+  ::wcsncpy(sBiffIconData.szTip, toolTipText.get(), kMaxTooltipSize);
 
-  if (!mBiffIconVisible)
-  {
+  if (!mBiffIconVisible) {
 #ifndef MOZ_THUNDERBIRD
-  nsresult rv;
-  bool showNewAlert = false;
-  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS_VOID(rv);
+    nsresult rv;
+    bool showNewAlert = false;
+    nsCOMPtr<nsIPrefBranch> prefBranch(
+        do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+    NS_ENSURE_SUCCESS_VOID(rv);
 
-  prefBranch->GetBoolPref(SHOW_NEW_ALERT_PREF, &showNewAlert);
-  if (!showNewAlert)
-    ShowAlertMessage(accountName, animatedAlertText, EmptyCString());
-  else
+    prefBranch->GetBoolPref(SHOW_NEW_ALERT_PREF, &showNewAlert);
+    if (!showNewAlert)
+      ShowAlertMessage(accountName, animatedAlertText, EmptyCString());
+    else
 #endif
-    ShowNewAlertNotification(false, accountName, animatedAlertText);
-  }
-  else
-   GenericShellNotify( NIM_MODIFY);
+      ShowNewAlertNotification(false, accountName, animatedAlertText);
+  } else
+    GenericShellNotify(NIM_MODIFY);
 }
 
-// Get the first top level folder which we know has new mail, then enumerate over
-// all the subfolders looking for the first real folder with new mail.
+// Get the first top level folder which we know has new mail, then enumerate
+// over all the subfolders looking for the first real folder with new mail.
 // Return the folderURI for that folder.
-nsresult nsMessengerWinIntegration::GetFirstFolderWithNewMail(nsACString& aFolderURI)
-{
+nsresult nsMessengerWinIntegration::GetFirstFolderWithNewMail(
+    nsACString &aFolderURI) {
   NS_ENSURE_TRUE(mFoldersWithNewMail, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIMsgFolder> folder;
   nsWeakPtr weakReference;
   int32_t numNewMessages = 0;
 
   uint32_t count = 0;
   nsresult rv = mFoldersWithNewMail->GetLength(&count);
-  if (NS_FAILED(rv) || !count)  // kick out if we don't have any folders with new mail
-    return NS_OK;
+  // kick out if we don't have any folders with new mail
+  if (NS_FAILED(rv) || !count) return NS_OK;
 
   weakReference = do_QueryElementAt(mFoldersWithNewMail, 0);
   folder = do_QueryReferent(weakReference);
 
-  if (folder)
-  {
+  if (folder) {
     nsCOMPtr<nsIMsgFolder> msgFolder;
-    // enumerate over the folders under this root folder till we find one with new mail....
+    // enumerate over the folders under this root folder till we find one with
+    // new mail....
     nsCOMPtr<nsIArray> allFolders;
     rv = folder->GetDescendants(getter_AddRefs(allFolders));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsISimpleEnumerator> enumerator;
     rv = allFolders->Enumerate(getter_AddRefs(enumerator));
-    if (NS_SUCCEEDED(rv) && enumerator)
-    {
+    if (NS_SUCCEEDED(rv) && enumerator) {
       nsCOMPtr<nsISupports> supports;
       bool hasMore = false;
-      while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore)
-      {
+      while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
         rv = enumerator->GetNext(getter_AddRefs(supports));
-        if (NS_SUCCEEDED(rv) && supports)
-        {
+        if (NS_SUCCEEDED(rv) && supports) {
           msgFolder = do_QueryInterface(supports, &rv);
-          if (msgFolder)
-          {
+          if (msgFolder) {
             numNewMessages = 0;
             msgFolder->GetNumNewMessages(false, &numNewMessages);
-            if (numNewMessages)
-              break; // kick out of the while loop
+            if (numNewMessages) break;  // kick out of the while loop
           }
-        } // if we have a folder
-      }  // if we have more potential folders to enumerate
-    }  // if enumerator
+        }  // if we have a folder
+      }    // if we have more potential folders to enumerate
+    }      // if enumerator
 
-    if (msgFolder)
-      msgFolder->GetURI(aFolderURI);
+    if (msgFolder) msgFolder->GetURI(aFolderURI);
   }
 
   return NS_OK;
 }
 
-void nsMessengerWinIntegration::DestroyBiffIcon()
-{
+void nsMessengerWinIntegration::DestroyBiffIcon() {
   GenericShellNotify(NIM_DELETE);
-  // Don't call DestroyIcon().  see http://bugzilla.mozilla.org/show_bug.cgi?id=134745
+  // Don't call DestroyIcon().
+  // See http://bugzilla.mozilla.org/show_bug.cgi?id=134745
 }
 
-void nsMessengerWinIntegration::GenericShellNotify(DWORD aMessage)
-{
-  ::Shell_NotifyIconW( aMessage, &sBiffIconData );
+void nsMessengerWinIntegration::GenericShellNotify(DWORD aMessage) {
+  ::Shell_NotifyIconW(aMessage, &sBiffIconData);
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemPropertyFlagChanged(nsIMsgDBHdr *item, const nsACString &property, uint32_t oldFlag, uint32_t newFlag)
-{
+nsMessengerWinIntegration::OnItemPropertyFlagChanged(nsIMsgDBHdr *item,
+                                                     const nsACString &property,
+                                                     uint32_t oldFlag,
+                                                     uint32_t newFlag) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemAdded(nsIMsgFolder *, nsISupports *)
-{
+nsMessengerWinIntegration::OnItemAdded(nsIMsgFolder *, nsISupports *) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemBoolPropertyChanged(nsIMsgFolder *aItem,
-                                                         const nsACString &aProperty,
-                                                         bool aOldValue,
-                                                         bool aNewValue)
-{
+nsMessengerWinIntegration::OnItemBoolPropertyChanged(
+    nsIMsgFolder *aItem, const nsACString &aProperty, bool aOldValue,
+    bool aNewValue) {
   if (aProperty.Equals(kDefaultServer)) {
     nsresult rv;
 
     // this property changes multiple times
     // on account deletion or when the user changes their
     // default account.  ResetCurrent() will set
     // mInboxURI to null, so we use that
     // to prevent us from attempting to remove
     // something from the registry that has already been removed
     if (!mInboxURI.IsEmpty() && !mEmail.IsEmpty()) {
       rv = RemoveCurrentFromRegistry();
-      NS_ENSURE_SUCCESS(rv,rv);
+      NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // reset so we'll go get the new default server next time
     rv = ResetCurrent();
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     rv = UpdateUnreadCount();
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemEvent(nsIMsgFolder *, const nsACString &)
-{
+nsMessengerWinIntegration::OnItemEvent(nsIMsgFolder *, const nsACString &) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMessengerWinIntegration::OnItemIntPropertyChanged(nsIMsgFolder *aItem, const nsACString &aProperty, int64_t aOldValue, int64_t aNewValue)
-{
+nsMessengerWinIntegration::OnItemIntPropertyChanged(nsIMsgFolder *aItem,
+                                                    const nsACString &aProperty,
+                                                    int64_t aOldValue,
+                                                    int64_t aNewValue) {
   // if we got new mail show a icon in the system tray
-  if (aProperty.Equals(kBiffState) && mFoldersWithNewMail)
-  {
+  if (aProperty.Equals(kBiffState) && mFoldersWithNewMail) {
     nsWeakPtr weakFolder = do_GetWeakReference(aItem);
     uint32_t indexInNewArray;
     nsresult rv = mFoldersWithNewMail->IndexOf(0, weakFolder, &indexInNewArray);
     bool folderFound = NS_SUCCEEDED(rv);
 
-    if (!mBiffIconInitialized)
-      InitializeBiffStatusIcon();
+    if (!mBiffIconInitialized) InitializeBiffStatusIcon();
 
-    if (aNewValue == nsIMsgFolder::nsMsgBiffState_NewMail)
-    {
+    if (aNewValue == nsIMsgFolder::nsMsgBiffState_NewMail) {
       // if the icon is not already visible, only show a system tray icon iff
       // we are performing biff (as opposed to the user getting new mail)
-      if (!mBiffIconVisible)
-      {
+      if (!mBiffIconVisible) {
         bool performingBiff = false;
         nsCOMPtr<nsIMsgIncomingServer> server;
         aItem->GetServer(getter_AddRefs(server));
-        if (server)
-          server->GetPerformingBiff(&performingBiff);
-        if (!performingBiff)
-          return NS_OK; // kick out right now...
+        if (server) server->GetPerformingBiff(&performingBiff);
+        if (!performingBiff) return NS_OK;  // kick out right now...
       }
-      if (!folderFound)
-        mFoldersWithNewMail->InsertElementAt(weakFolder, 0);
+      if (!folderFound) mFoldersWithNewMail->InsertElementAt(weakFolder, 0);
       // now regenerate the tooltip
       FillToolTipInfo();
-    }
-    else if (aNewValue == nsIMsgFolder::nsMsgBiffState_NoMail)
-    {
-      // we are always going to remove the icon whenever we get our first no mail
-      // notification.
+    } else if (aNewValue == nsIMsgFolder::nsMsgBiffState_NoMail) {
+      // we are always going to remove the icon whenever we get our first no
+      // mail notification.
 
-      // avoid a race condition where we are told to remove the icon before we've actually
-      // added it to the system tray. This happens when the user reads a new message before
-      // the animated alert has gone away.
-      if (mAlertInProgress)
-        mSuppressBiffIcon = true;
+      // avoid a race condition where we are told to remove the icon before
+      // we've actually added it to the system tray. This happens when the user
+      // reads a new message before the animated alert has gone away.
+      if (mAlertInProgress) mSuppressBiffIcon = true;
 
-      if (folderFound)
-        mFoldersWithNewMail->RemoveElementAt(indexInNewArray);
-      if (mBiffIconVisible)
-      {
+      if (folderFound) mFoldersWithNewMail->RemoveElementAt(indexInNewArray);
+      if (mBiffIconVisible) {
         mBiffIconVisible = false;
         GenericShellNotify(NIM_DELETE);
       }
     }
-  } // if the biff property changed
+  }  // if the biff property changed
 
   if (aProperty.Equals(kTotalUnreadMessages)) {
     nsCString itemURI;
     nsresult rv;
     rv = aItem->GetURI(itemURI);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    if (mInboxURI.Equals(itemURI))
-      mCurrentUnreadCount = aNewValue;
+    if (mInboxURI.Equals(itemURI)) mCurrentUnreadCount = aNewValue;
 
     // If the timer isn't running yet, then we immediately update the
     // registry and then start a one-shot timer. If the Unread counter
     // has toggled zero / nonzero, we also update immediately.
     // Otherwise, if the timer is running, defer the update. This means
     // that all counter updates that occur within the timer interval are
     // batched into a single registry update, to avoid hitting the
     // registry too frequently. We also do a final update on shutdown,
     // regardless of the timer.
     if (!mUnreadTimerActive ||
-         (!mCurrentUnreadCount && mLastUnreadCountWrittenToRegistry) ||
-         (mCurrentUnreadCount && mLastUnreadCountWrittenToRegistry < 1)) {
+        (!mCurrentUnreadCount && mLastUnreadCountWrittenToRegistry) ||
+        (mCurrentUnreadCount && mLastUnreadCountWrittenToRegistry < 1)) {
       rv = UpdateUnreadCount();
-      NS_ENSURE_SUCCESS(rv,rv);
+      NS_ENSURE_SUCCESS(rv, rv);
       // If timer wasn't running, start it.
-      if (!mUnreadTimerActive)
-        rv = SetupUnreadCountUpdateTimer();
+      if (!mUnreadTimerActive) rv = SetupUnreadCountUpdateTimer();
     }
   }
   return NS_OK;
 }
 
-void
-nsMessengerWinIntegration::OnUnreadCountUpdateTimer(nsITimer *timer, void *osIntegration)
-{
-  nsMessengerWinIntegration *winIntegration = (nsMessengerWinIntegration*)osIntegration;
+void nsMessengerWinIntegration::OnUnreadCountUpdateTimer(nsITimer *timer,
+                                                         void *osIntegration) {
+  nsMessengerWinIntegration *winIntegration =
+      (nsMessengerWinIntegration *)osIntegration;
 
   winIntegration->mUnreadTimerActive = false;
   mozilla::DebugOnly<nsresult> rv = winIntegration->UpdateUnreadCount();
   NS_ASSERTION(NS_SUCCEEDED(rv), "updating unread count failed");
 }
 
-nsresult
-nsMessengerWinIntegration::RemoveCurrentFromRegistry()
-{
-  // If Windows XP, open the registry and get rid of old account registry entries
-  // If there is a email prefix, get it and use it to build the registry key.
-  // Otherwise, just the email address will be the registry key.
+nsresult nsMessengerWinIntegration::RemoveCurrentFromRegistry() {
+  // If Windows XP, open the registry and get rid of old account registry
+  // entries If there is a email prefix, get it and use it to build the registry
+  // key. Otherwise, just the email address will be the registry key.
   nsAutoString currentUnreadMailCountKey;
   if (!mEmailPrefix.IsEmpty()) {
     currentUnreadMailCountKey.Assign(mEmailPrefix);
     currentUnreadMailCountKey.Append(NS_ConvertASCIItoUTF16(mEmail));
-  }
-  else
+  } else
     CopyASCIItoUTF16(mEmail, currentUnreadMailCountKey);
 
   WCHAR registryUnreadMailCountKey[_MAX_PATH] = {0};
   // Enumerate through registry entries to delete the key matching
   // currentUnreadMailCountKey
   int index = 0;
-  while (SUCCEEDED(SHEnumerateUnreadMailAccountsW(HKEY_CURRENT_USER,
-                                                  index,
-                                                  registryUnreadMailCountKey,
-                                                  sizeof(registryUnreadMailCountKey))))
-  {
-    if (wcscmp(registryUnreadMailCountKey, currentUnreadMailCountKey.get())==0) {
+  while (SUCCEEDED(SHEnumerateUnreadMailAccountsW(
+      HKEY_CURRENT_USER, index, registryUnreadMailCountKey,
+      sizeof(registryUnreadMailCountKey)))) {
+    if (wcscmp(registryUnreadMailCountKey, currentUnreadMailCountKey.get()) ==
+        0) {
       nsAutoString deleteKey;
       deleteKey.Assign(UNREADMAILNODEKEY);
       deleteKey.Append(currentUnreadMailCountKey.get());
 
       if (!deleteKey.IsEmpty()) {
         // delete this key and berak out of the loop
-        RegDeleteKey(HKEY_CURRENT_USER,
-                     NS_ConvertUTF16toUTF8(deleteKey).get());
+        RegDeleteKey(HKEY_CURRENT_USER, NS_ConvertUTF16toUTF8(deleteKey).get());
         break;
-      }
-      else {
+      } else {
         index++;
       }
-    }
-    else {
+    } else {
       index++;
     }
   }
   return NS_OK;
 }
 
-nsresult
-nsMessengerWinIntegration::UpdateRegistryWithCurrent()
-{
-  if (mInboxURI.IsEmpty() || mEmail.IsEmpty())
-    return NS_OK;
+nsresult nsMessengerWinIntegration::UpdateRegistryWithCurrent() {
+  if (mInboxURI.IsEmpty() || mEmail.IsEmpty()) return NS_OK;
 
   // only update the registry if the count has changed
   // and if the unread count is valid
-  if ((mCurrentUnreadCount < 0) || (mCurrentUnreadCount == mLastUnreadCountWrittenToRegistry))
+  if ((mCurrentUnreadCount < 0) ||
+      (mCurrentUnreadCount == mLastUnreadCountWrittenToRegistry))
     return NS_OK;
 
   // commandliner has to be built in the form of statement
   // which can be open the mailer app to the default user account
   // For given profile 'foo', commandliner will be built as
   // ""<absolute path to application>" -p foo -mail" where absolute
   // path to application is extracted from mAppName
   nsAutoString commandLinerForAppLaunch;
@@ -999,139 +940,125 @@ nsMessengerWinIntegration::UpdateRegistr
   commandLinerForAppLaunch.Append(mAppName);
   commandLinerForAppLaunch.Append(DOUBLE_QUOTE);
   commandLinerForAppLaunch.AppendLiteral(PROFILE_COMMANDLINE_ARG);
   commandLinerForAppLaunch.Append(DOUBLE_QUOTE);
   commandLinerForAppLaunch.Append(mProfilePath);
   commandLinerForAppLaunch.Append(DOUBLE_QUOTE);
   commandLinerForAppLaunch.AppendLiteral(MAIL_COMMANDLINE_ARG);
 
-  if (!commandLinerForAppLaunch.IsEmpty())
-  {
+  if (!commandLinerForAppLaunch.IsEmpty()) {
     nsAutoString pBuffer;
 
     if (!mEmailPrefix.IsEmpty()) {
       pBuffer.Assign(mEmailPrefix);
       pBuffer.Append(NS_ConvertASCIItoUTF16(mEmail));
-    }
-    else
+    } else
       CopyASCIItoUTF16(mEmail, pBuffer);
 
     // Write the info into the registry
-    SHSetUnreadMailCountW(pBuffer.get(),
-                          mCurrentUnreadCount,
+    SHSetUnreadMailCountW(pBuffer.get(), mCurrentUnreadCount,
                           commandLinerForAppLaunch.get());
   }
 
   // do this last
   mLastUnreadCountWrittenToRegistry = mCurrentUnreadCount;
 
   return NS_OK;
 }
 
-nsresult
-nsMessengerWinIntegration::SetupInbox()
-{
+nsresult nsMessengerWinIntegration::SetupInbox() {
   nsresult rv;
 
   // get default account
-  nsCOMPtr <nsIMsgAccountManager> accountManager =
-    do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgAccountManager> accountManager =
+      do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr <nsIMsgAccount> account;
+  nsCOMPtr<nsIMsgAccount> account;
   rv = accountManager->GetDefaultAccount(getter_AddRefs(account));
   NS_ENSURE_SUCCESS(rv, rv);
   if (!account) {
     // this can happen if we launch mail on a new profile
     // we don't have a default account yet
     mDefaultAccountMightHaveAnInbox = false;
     return NS_OK;
   }
 
   // get incoming server
-  nsCOMPtr <nsIMsgIncomingServer> server;
+  nsCOMPtr<nsIMsgIncomingServer> server;
   rv = account->GetIncomingServer(getter_AddRefs(server));
-  NS_ENSURE_SUCCESS(rv,rv);
-  if (!server)
-    return NS_ERROR_FAILURE;
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (!server) return NS_ERROR_FAILURE;
 
   nsCString type;
   rv = server->GetType(type);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // we only care about imap and pop3
   if (type.EqualsLiteral("imap") || type.EqualsLiteral("pop3")) {
     // imap and pop3 account should have an Inbox
     mDefaultAccountMightHaveAnInbox = true;
 
     mEmailPrefix.Truncate();
 
     // Get user's email address
     nsCOMPtr<nsIMsgIdentity> identity;
     rv = account->GetDefaultIdentity(getter_AddRefs(identity));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    if (!identity)
-      return NS_ERROR_FAILURE;
+    if (!identity) return NS_ERROR_FAILURE;
 
     rv = identity->GetEmail(mEmail);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIMsgFolder> rootMsgFolder;
     rv = server->GetRootMsgFolder(getter_AddRefs(rootMsgFolder));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    if (!rootMsgFolder)
-      return NS_ERROR_FAILURE;
+    if (!rootMsgFolder) return NS_ERROR_FAILURE;
 
-    nsCOMPtr <nsIMsgFolder> inboxFolder;
+    nsCOMPtr<nsIMsgFolder> inboxFolder;
     rootMsgFolder->GetFolderWithFlags(nsMsgFolderFlags::Inbox,
                                       getter_AddRefs(inboxFolder));
     NS_ENSURE_TRUE(inboxFolder, NS_ERROR_FAILURE);
 
     rv = inboxFolder->GetURI(mInboxURI);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     rv = inboxFolder->GetNumUnread(false, &mCurrentUnreadCount);
-    NS_ENSURE_SUCCESS(rv,rv);
-  }
-  else {
+    NS_ENSURE_SUCCESS(rv, rv);
+  } else {
     // the default account is valid, but it's not something
     // that we expect to have an inbox.  (local folders, news accounts)
     // set this flag to avoid calling SetupInbox() every time
     // the timer goes off.
     mDefaultAccountMightHaveAnInbox = false;
   }
 
   return NS_OK;
 }
 
-nsresult
-nsMessengerWinIntegration::UpdateUnreadCount()
-{
+nsresult nsMessengerWinIntegration::UpdateUnreadCount() {
   nsresult rv;
 
   if (mDefaultAccountMightHaveAnInbox && mInboxURI.IsEmpty()) {
     rv = SetupInbox();
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return UpdateRegistryWithCurrent();
 }
 
-nsresult
-nsMessengerWinIntegration::SetupUnreadCountUpdateTimer()
-{
+nsresult nsMessengerWinIntegration::SetupUnreadCountUpdateTimer() {
   mUnreadTimerActive = true;
   if (mUnreadCountUpdateTimer)
     mUnreadCountUpdateTimer->Cancel();
   else
     mUnreadCountUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
 
-  mUnreadCountUpdateTimer->InitWithNamedFuncCallback(OnUnreadCountUpdateTimer,
-                                                     (void *)this,
-                                                     UNREAD_UPDATE_INTERVAL,
-                                                     nsITimer::TYPE_ONE_SHOT,
-                                                     "nsMessengerWinIntegration::OnUnreadCountUpdateTimer");
+  mUnreadCountUpdateTimer->InitWithNamedFuncCallback(
+      OnUnreadCountUpdateTimer, (void *)this, UNREAD_UPDATE_INTERVAL,
+      nsITimer::TYPE_ONE_SHOT,
+      "nsMessengerWinIntegration::OnUnreadCountUpdateTimer");
 
   return NS_OK;
 }
--- a/mailnews/base/src/nsMessengerWinIntegration.h
+++ b/mailnews/base/src/nsMessengerWinIntegration.h
@@ -14,86 +14,94 @@
 #include "nsIMessengerOSIntegration.h"
 #include "nsIFolderListener.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIMutableArray.h"
 #include "nsIObserver.h"
 
-#define NS_MESSENGERWININTEGRATION_CID \
-  {0xf62f3d3a, 0x1dd1, 0x11b2, \
-    {0xa5, 0x16, 0xef, 0xad, 0xb1, 0x31, 0x61, 0x5c}}
+#define NS_MESSENGERWININTEGRATION_CID               \
+  {                                                  \
+    0xf62f3d3a, 0x1dd1, 0x11b2, {                    \
+      0xa5, 0x16, 0xef, 0xad, 0xb1, 0x31, 0x61, 0x5c \
+    }                                                \
+  }
 
 class nsIStringBundle;
 
 class nsMessengerWinIntegration : public nsIMessengerOSIntegration,
                                   public nsIFolderListener,
-                                  public nsIObserver
-{
-public:
+                                  public nsIObserver {
+ public:
   nsMessengerWinIntegration();
   virtual nsresult Init();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMESSENGEROSINTEGRATION
   NS_DECL_NSIFOLDERLISTENER
   NS_DECL_NSIOBSERVER
 
-  nsresult ShowNewAlertNotification(bool aUserInitiated, const nsString& aAlertTitle, const nsString& aAlertText);
+  nsresult ShowNewAlertNotification(bool aUserInitiated,
+                                    const nsString& aAlertTitle,
+                                    const nsString& aAlertText);
 #ifndef MOZ_THUNDERBIRD
-  nsresult ShowAlertMessage(const nsString& aAlertTitle, const nsString& aAlertText, const nsACString& aFolderURI);
+  nsresult ShowAlertMessage(const nsString& aAlertTitle,
+                            const nsString& aAlertText,
+                            const nsACString& aFolderURI);
 #endif
 
-private:
+ private:
   virtual ~nsMessengerWinIntegration();
   nsresult AlertFinished();
   nsresult AlertClicked();
 #ifdef MOZ_SUITE
   nsresult AlertClickedSimple();
 #endif
 
   void InitializeBiffStatusIcon();
   void FillToolTipInfo();
   void GenericShellNotify(DWORD aMessage);
   void DestroyBiffIcon();
 
   nsresult GetFirstFolderWithNewMail(nsACString& aFolderURI);
 
-  nsresult GetStringBundle(nsIStringBundle **aBundle);
-  nsCOMPtr<nsIMutableArray> mFoldersWithNewMail;  // keep track of all the root folders with pending new mail
+  nsresult GetStringBundle(nsIStringBundle** aBundle);
+  nsCOMPtr<nsIMutableArray>
+      mFoldersWithNewMail;  // keep track of all the root folders with pending
+                            // new mail
 
   bool mBiffIconVisible;
   bool mBiffIconInitialized;
   bool mSuppressBiffIcon;
   bool mAlertInProgress;
 
   // "might" because we don't know until we check
   // what type of server is associated with the default account
-  bool            mDefaultAccountMightHaveAnInbox;
+  bool mDefaultAccountMightHaveAnInbox;
 
   // True if the timer is running
   bool mUnreadTimerActive;
 
   nsresult ResetCurrent();
   nsresult RemoveCurrentFromRegistry();
   nsresult UpdateRegistryWithCurrent();
   nsresult SetupInbox();
 
   nsresult SetupUnreadCountUpdateTimer();
-  static void OnUnreadCountUpdateTimer(nsITimer *timer, void *osIntegration);
+  static void OnUnreadCountUpdateTimer(nsITimer* timer, void* osIntegration);
   nsresult UpdateUnreadCount();
 
-  nsCOMPtr <nsITimer> mUnreadCountUpdateTimer;
+  nsCOMPtr<nsITimer> mUnreadCountUpdateTimer;
 
   nsCString mInboxURI;
   nsCString mEmail;
 
-  nsString  mAppName;
-  nsString  mEmailPrefix;
+  nsString mAppName;
+  nsString mEmailPrefix;
 
   nsString mProfilePath;
 
-  int32_t   mCurrentUnreadCount;
-  int32_t   mLastUnreadCountWrittenToRegistry;
+  int32_t mCurrentUnreadCount;
+  int32_t mLastUnreadCountWrittenToRegistry;
 };
 
-#endif // __nsMessengerWinIntegration_h
+#endif  // __nsMessengerWinIntegration_h