Bug 1546364 - Reformat to Google coding style in mailnews/base/src (part 2). rs=reformat
authorJorg K <jorgk@jorgk.com>
Thu, 16 May 2019 13:01:43 +0200
changeset 26633 8e708fca38cc203419b6b41158bf6c2b32e64ba1
parent 26632 7e3a1808d30d74cd63009b3a518d417566dd206d
child 26634 0c6818af6df76464c9186d66cd58415a5d4b5e6d
push id15931
push usermozilla@jorgk.com
push dateFri, 17 May 2019 21:50:38 +0000
treeherdercomm-central@8e708fca38cc [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 2). rs=reformat # ignore-this-changeset
mailnews/base/src/nsMsgAccount.cpp
mailnews/base/src/nsMsgAccount.h
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgAccountManager.h
mailnews/base/src/nsMsgBiffManager.cpp
mailnews/base/src/nsMsgBiffManager.h
mailnews/base/src/nsMsgContentPolicy.cpp
mailnews/base/src/nsMsgContentPolicy.h
mailnews/base/src/nsMsgCopyService.cpp
mailnews/base/src/nsMsgCopyService.h
--- a/mailnews/base/src/nsMsgAccount.cpp
+++ b/mailnews/base/src/nsMsgAccount.cpp
@@ -1,14 +1,13 @@
 /* -*- 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/. */
 
-
 #include "prprf.h"
 #include "plstr.h"
 #include "prmem.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsCRTGlue.h"
 #include "nsCOMPtr.h"
 #include "nsIMsgFolderNotificationService.h"
@@ -22,199 +21,180 @@
 #include "nsServiceManagerUtils.h"
 #include "nsMemory.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
 #include "nsArrayUtils.h"
 
 NS_IMPL_ISUPPORTS(nsMsgAccount, nsIMsgAccount)
 
-nsMsgAccount::nsMsgAccount()
-  : mTriedToGetServer(false)
-{
-}
+nsMsgAccount::nsMsgAccount() : mTriedToGetServer(false) {}
 
-nsMsgAccount::~nsMsgAccount()
-{
-}
+nsMsgAccount::~nsMsgAccount() {}
 
-nsresult
-nsMsgAccount::getPrefService()
-{
-  if (m_prefs)
-    return NS_OK;
+nsresult nsMsgAccount::getPrefService() {
+  if (m_prefs) return NS_OK;
 
   nsresult rv;
   NS_ENSURE_FALSE(m_accountKey.IsEmpty(), NS_ERROR_NOT_INITIALIZED);
   nsCOMPtr<nsIPrefService> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString accountRoot("mail.account.");
   accountRoot.Append(m_accountKey);
   accountRoot.Append('.');
   return prefs->GetBranch(accountRoot.get(), getter_AddRefs(m_prefs));
 }
 
 NS_IMETHODIMP
-nsMsgAccount::GetIncomingServer(nsIMsgIncomingServer **aIncomingServer)
-{
+nsMsgAccount::GetIncomingServer(nsIMsgIncomingServer **aIncomingServer) {
   NS_ENSURE_ARG_POINTER(aIncomingServer);
 
   // create the incoming server lazily
   if (!mTriedToGetServer && !m_incomingServer) {
     mTriedToGetServer = true;
     // ignore the error (and return null), but it's still bad so warn
     mozilla::DebugOnly<nsresult> rv = createIncomingServer();
-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "couldn't lazily create the server\n");
+    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                         "couldn't lazily create the server\n");
   }
 
   NS_IF_ADDREF(*aIncomingServer = m_incomingServer);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccount::CreateServer()
-{
-  if (m_incomingServer)
-    return NS_ERROR_ALREADY_INITIALIZED;
+nsMsgAccount::CreateServer() {
+  if (m_incomingServer) return NS_ERROR_ALREADY_INITIALIZED;
   return createIncomingServer();
 }
 
-nsresult
-nsMsgAccount::createIncomingServer()
-{
+nsresult nsMsgAccount::createIncomingServer() {
   // from here, load mail.account.myaccount.server
   // Load the incoming server
   //
   // ex) mail.account.myaccount.server = "myserver"
 
   nsresult rv = getPrefService();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // get the "server" pref
   nsCString serverKey;
   rv = m_prefs->GetCharPref("server", serverKey);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // get the server from the account manager
   nsCOMPtr<nsIMsgAccountManager> accountManager =
-           do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+      do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgIncomingServer> server;
   rv = accountManager->GetIncomingServer(serverKey, getter_AddRefs(server));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // store the server in this structure
   m_incomingServer = server;
   accountManager->NotifyServerLoaded(server);
 
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer *aIncomingServer)
-{
+nsMsgAccount::SetIncomingServer(nsIMsgIncomingServer *aIncomingServer) {
   NS_ENSURE_ARG_POINTER(aIncomingServer);
 
   nsCString key;
   nsresult rv = aIncomingServer->GetKey(key);
 
   if (NS_SUCCEEDED(rv)) {
     rv = getPrefService();
     NS_ENSURE_SUCCESS(rv, rv);
     m_prefs->SetCharPref("server", key);
   }
 
   m_incomingServer = aIncomingServer;
 
   bool serverValid;
-  (void) aIncomingServer->GetValid(&serverValid);
+  (void)aIncomingServer->GetValid(&serverValid);
   // only notify server loaded if server is valid so
   // account manager only gets told about finished accounts.
-  if (serverValid)
-  {
+  if (serverValid) {
     // this is the point at which we can notify listeners about the
     // creation of the root folder, which implies creation of the new server.
     nsCOMPtr<nsIMsgFolder> rootFolder;
     rv = aIncomingServer->GetRootFolder(getter_AddRefs(rootFolder));
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsIFolderListener> mailSession =
-             do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+        do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     mailSession->OnItemAdded(nullptr, rootFolder);
-    nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID, &rv));
+    nsCOMPtr<nsIMsgFolderNotificationService> notifier(
+        do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     notifier->NotifyFolderAdded(rootFolder);
 
-    nsCOMPtr<nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-    if (NS_SUCCEEDED(rv))
-      accountManager->NotifyServerLoaded(aIncomingServer);
+    nsCOMPtr<nsIMsgAccountManager> accountManager =
+        do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+    if (NS_SUCCEEDED(rv)) accountManager->NotifyServerLoaded(aIncomingServer);
 
-    // Force built-in folders to be created and discovered. Then, notify listeners
-    // about them.
+    // Force built-in folders to be created and discovered. Then, notify
+    // listeners about them.
     nsCOMPtr<nsISimpleEnumerator> enumerator;
     rv = rootFolder->GetSubFolders(getter_AddRefs(enumerator));
     NS_ENSURE_SUCCESS(rv, rv);
 
     bool hasMore;
-    while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore)
-    {
+    while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
       nsCOMPtr<nsISupports> item;
       enumerator->GetNext(getter_AddRefs(item));
 
       nsCOMPtr<nsIMsgFolder> msgFolder(do_QueryInterface(item));
-      if (!msgFolder)
-        continue;
+      if (!msgFolder) continue;
       mailSession->OnItemAdded(rootFolder, msgFolder);
       notifier->NotifyFolderAdded(msgFolder);
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccount::GetIdentities(nsIArray **_retval)
-{
+nsMsgAccount::GetIdentities(nsIArray **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   NS_ENSURE_TRUE(m_identities, NS_ERROR_FAILURE);
 
   NS_IF_ADDREF(*_retval = m_identities);
   return NS_OK;
 }
 
 /*
  * set up the m_identities array
  * do not call this more than once or we'll leak.
  */
-nsresult
-nsMsgAccount::createIdentities()
-{
+nsresult nsMsgAccount::createIdentities() {
   NS_ENSURE_FALSE(m_identities, NS_ERROR_FAILURE);
 
   nsresult rv;
   m_identities = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString identityKey;
   rv = getPrefService();
   NS_ENSURE_SUCCESS(rv, rv);
 
   m_prefs->GetCharPref("identities", identityKey);
-  if (identityKey.IsEmpty())    // not an error if no identities, but
-    return NS_OK;               // strtok will be unhappy
+  if (identityKey.IsEmpty())  // not an error if no identities, but
+    return NS_OK;             // strtok will be unhappy
   // get the server from the account manager
   nsCOMPtr<nsIMsgAccountManager> accountManager =
-           do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+      do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  char* newStr = identityKey.BeginWriting();
-  char* token = NS_strtok(",", &newStr);
+  char *newStr = identityKey.BeginWriting();
+  char *token = NS_strtok(",", &newStr);
 
   // temporaries used inside the loop
   nsCOMPtr<nsIMsgIdentity> identity;
   nsAutoCString key;
 
   // iterate through id1,id2, etc
   while (token) {
     key = token;
@@ -230,39 +210,35 @@ nsMsgAccount::createIdentities()
 
     // advance to next key, if any
     token = NS_strtok(",", &newStr);
   }
 
   return rv;
 }
 
-
 /* attribute nsIMsgIdentity defaultIdentity; */
 NS_IMETHODIMP
-nsMsgAccount::GetDefaultIdentity(nsIMsgIdentity **aDefaultIdentity)
-{
+nsMsgAccount::GetDefaultIdentity(nsIMsgIdentity **aDefaultIdentity) {
   NS_ENSURE_ARG_POINTER(aDefaultIdentity);
   NS_ENSURE_TRUE(m_identities, NS_ERROR_NOT_INITIALIZED);
 
   *aDefaultIdentity = nullptr;
   uint32_t count;
   nsresult rv = m_identities->GetLength(&count);
   NS_ENSURE_SUCCESS(rv, rv);
-  if (count == 0)
-    return NS_OK;
+  if (count == 0) return NS_OK;
 
   nsCOMPtr<nsIMsgIdentity> identity = do_QueryElementAt(m_identities, 0, &rv);
   identity.forget(aDefaultIdentity);
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgAccount::SetDefaultIdentity(nsIMsgIdentity *aDefaultIdentity)
-{
+nsMsgAccount::SetDefaultIdentity(nsIMsgIdentity *aDefaultIdentity) {
   NS_ENSURE_TRUE(m_identities, NS_ERROR_FAILURE);
 
   uint32_t position = 0;
   nsresult rv = m_identities->IndexOf(0, aDefaultIdentity, &position);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = m_identities->RemoveElementAt(position);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -272,56 +248,52 @@ nsMsgAccount::SetDefaultIdentity(nsIMsgI
   NS_ENSURE_SUCCESS(rv, rv);
 
   return saveIdentitiesPref();
 }
 
 // add the identity to m_identities, but don't fiddle with the
 // prefs. The assumption here is that the pref for this identity is
 // already set.
-nsresult
-nsMsgAccount::addIdentityInternal(nsIMsgIdentity *identity)
-{
+nsresult nsMsgAccount::addIdentityInternal(nsIMsgIdentity *identity) {
   NS_ENSURE_TRUE(m_identities, NS_ERROR_FAILURE);
 
   return m_identities->AppendElement(identity);
 }
 
 /* void addIdentity (in nsIMsgIdentity identity); */
 NS_IMETHODIMP
-nsMsgAccount::AddIdentity(nsIMsgIdentity *identity)
-{
+nsMsgAccount::AddIdentity(nsIMsgIdentity *identity) {
   NS_ENSURE_ARG_POINTER(identity);
 
   // hack hack - need to add this to the list of identities.
   // for now just treat this as a Setxxx accessor
   // when this is actually implemented, don't refcount the default identity
   nsCString key;
   nsresult rv = identity->GetKey(key);
 
   if (NS_SUCCEEDED(rv)) {
     nsCString identityList;
     m_prefs->GetCharPref("identities", identityList);
 
     nsAutoCString newIdentityList(identityList);
 
-    nsAutoCString testKey;      // temporary to strip whitespace
-    bool foundIdentity = false; // if the input identity is found
+    nsAutoCString testKey;       // temporary to strip whitespace
+    bool foundIdentity = false;  // if the input identity is found
 
     if (!identityList.IsEmpty()) {
       char *newStr = identityList.BeginWriting();
       char *token = NS_strtok(",", &newStr);
 
       // look for the identity key that we're adding
       while (token) {
         testKey = token;
         testKey.StripWhitespace();
 
-        if (testKey.Equals(key))
-          foundIdentity = true;
+        if (testKey.Equals(key)) foundIdentity = true;
 
         token = NS_strtok(",", &newStr);
       }
     }
 
     // if it didn't already exist, append it
     if (!foundIdentity) {
       if (newIdentityList.IsEmpty())
@@ -336,18 +308,17 @@ nsMsgAccount::AddIdentity(nsIMsgIdentity
   }
 
   // now add it to the in-memory list
   return addIdentityInternal(identity);
 }
 
 /* void removeIdentity (in nsIMsgIdentity identity); */
 NS_IMETHODIMP
-nsMsgAccount::RemoveIdentity(nsIMsgIdentity *aIdentity)
-{
+nsMsgAccount::RemoveIdentity(nsIMsgIdentity *aIdentity) {
   NS_ENSURE_ARG_POINTER(aIdentity);
   NS_ENSURE_TRUE(m_identities, NS_ERROR_FAILURE);
 
   uint32_t count = 0;
   m_identities->GetLength(&count);
   // At least one identity must stay after the delete.
   NS_ENSURE_TRUE(count > 1, NS_ERROR_FAILURE);
 
@@ -359,77 +330,68 @@ nsMsgAccount::RemoveIdentity(nsIMsgIdent
   m_identities->RemoveElementAt(pos);
 
   // clear out the actual pref values associated with the identity
   aIdentity->ClearAllValues();
 
   return saveIdentitiesPref();
 }
 
-nsresult
-nsMsgAccount::saveIdentitiesPref()
-{
+nsresult nsMsgAccount::saveIdentitiesPref() {
   nsAutoCString newIdentityList;
 
   // Iterate over the existing identities and build the pref value,
   // a string of identity keys: id1, id2, idX...
   uint32_t count;
   nsresult rv = m_identities->GetLength(&count);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString key;
-  for (uint32_t index = 0; index < count; index++)
-  {
-    nsCOMPtr<nsIMsgIdentity> identity = do_QueryElementAt(m_identities, index, &rv);
-    if (identity)
-    {
+  for (uint32_t index = 0; index < count; index++) {
+    nsCOMPtr<nsIMsgIdentity> identity =
+        do_QueryElementAt(m_identities, index, &rv);
+    if (identity) {
       identity->GetKey(key);
 
       if (!index) {
         newIdentityList = key;
-      }
-      else
-      {
+      } else {
         newIdentityList.Append(',');
         newIdentityList.Append(key);
       }
     }
   }
 
   // Save the pref.
   m_prefs->SetCharPref("identities", newIdentityList);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccount::GetKey(nsACString& accountKey)
-{
+NS_IMETHODIMP nsMsgAccount::GetKey(nsACString &accountKey) {
   accountKey = m_accountKey;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccount::SetKey(const nsACString& accountKey)
-{
+nsMsgAccount::SetKey(const nsACString &accountKey) {
   m_accountKey = accountKey;
   m_prefs = nullptr;
   m_identities = nullptr;
   return createIdentities();
 }
 
 NS_IMETHODIMP
-nsMsgAccount::ToString(nsAString& aResult)
-{
+nsMsgAccount::ToString(nsAString &aResult) {
   nsAutoString val;
   aResult.AssignLiteral("[nsIMsgAccount: ");
   aResult.Append(NS_ConvertASCIItoUTF16(m_accountKey));
   aResult.Append(']');
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccount::ClearAllValues()
-{
+nsMsgAccount::ClearAllValues() {
   nsresult rv = getPrefService();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return m_prefs->DeleteBranch("");
 }
--- a/mailnews/base/src/nsMsgAccount.h
+++ b/mailnews/base/src/nsMsgAccount.h
@@ -4,35 +4,32 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nscore.h"
 #include "nsIMsgAccount.h"
 #include "nsIPrefBranch.h"
 #include "nsString.h"
 #include "nsIMutableArray.h"
 
-class nsMsgAccount : public nsIMsgAccount
-{
-
-public:
+class nsMsgAccount : public nsIMsgAccount {
+ public:
   nsMsgAccount();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMSGACCOUNT
 
-private:
+ private:
   virtual ~nsMsgAccount();
   nsCString m_accountKey;
   nsCOMPtr<nsIPrefBranch> m_prefs;
   nsCOMPtr<nsIMsgIncomingServer> m_incomingServer;
 
   nsCOMPtr<nsIMutableArray> m_identities;
 
   nsresult getPrefService();
   nsresult createIncomingServer();
   nsresult createIdentities();
   nsresult saveIdentitiesPref();
   nsresult addIdentityInternal(nsIMsgIdentity* identity);
 
   // Have we tried to get the server yet?
   bool mTriedToGetServer;
 };
-
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -64,236 +64,219 @@
 #include "nsIMsgFilterList.h"
 #include "nsDirectoryServiceUtils.h"
 #include "mozilla/Services.h"
 #include "nsIFileStreams.h"
 #include "nsIOutputStream.h"
 #include "nsISafeOutputStream.h"
 
 #define PREF_MAIL_ACCOUNTMANAGER_ACCOUNTS "mail.accountmanager.accounts"
-#define PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT "mail.accountmanager.defaultaccount"
-#define PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER "mail.accountmanager.localfoldersserver"
+#define PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT \
+  "mail.accountmanager.defaultaccount"
+#define PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER \
+  "mail.accountmanager.localfoldersserver"
 #define PREF_MAIL_SERVER_PREFIX "mail.server."
 #define ACCOUNT_PREFIX "account"
 #define SERVER_PREFIX "server"
 #define ID_PREFIX "id"
 #define ABOUT_TO_GO_OFFLINE_TOPIC "network:offline-about-to-go-offline"
 #define ACCOUNT_DELIMITER ','
 #define APPEND_ACCOUNTS_VERSION_PREF_NAME "append_preconfig_accounts.version"
 #define MAILNEWS_ROOT_PREF "mailnews."
-#define PREF_MAIL_ACCOUNTMANAGER_APPEND_ACCOUNTS "mail.accountmanager.appendaccounts"
+#define PREF_MAIL_ACCOUNTMANAGER_APPEND_ACCOUNTS \
+  "mail.accountmanager.appendaccounts"
 
 static NS_DEFINE_CID(kMsgAccountCID, NS_MSGACCOUNT_CID);
 static NS_DEFINE_CID(kMsgFolderCacheCID, NS_MSGFOLDERCACHE_CID);
 
 #define SEARCH_FOLDER_FLAG "searchFolderFlag"
 #define SEARCH_FOLDER_FLAG_LEN (sizeof(SEARCH_FOLDER_FLAG) - 1)
 
 const char *kSearchFolderUriProp = "searchFolderUri";
 
 bool nsMsgAccountManager::m_haveShutdown = false;
 bool nsMsgAccountManager::m_shutdownInProgress = false;
 
-NS_IMPL_ISUPPORTS(nsMsgAccountManager,
-                              nsIMsgAccountManager,
-                              nsIObserver,
-                              nsISupportsWeakReference,
-                              nsIUrlListener,
-                              nsIFolderListener)
-
-nsMsgAccountManager::nsMsgAccountManager() :
-  m_accountsLoaded(false),
-  m_emptyTrashInProgress(false),
-  m_cleanupInboxInProgress(false),
-  m_userAuthenticated(false),
-  m_loadingVirtualFolders(false),
-  m_virtualFoldersLoaded(false)
-{
-}
-
-nsMsgAccountManager::~nsMsgAccountManager()
-{
-  if(!m_haveShutdown)
-  {
+NS_IMPL_ISUPPORTS(nsMsgAccountManager, nsIMsgAccountManager, nsIObserver,
+                  nsISupportsWeakReference, nsIUrlListener, nsIFolderListener)
+
+nsMsgAccountManager::nsMsgAccountManager()
+    : m_accountsLoaded(false),
+      m_emptyTrashInProgress(false),
+      m_cleanupInboxInProgress(false),
+      m_userAuthenticated(false),
+      m_loadingVirtualFolders(false),
+      m_virtualFoldersLoaded(false) {}
+
+nsMsgAccountManager::~nsMsgAccountManager() {
+  if (!m_haveShutdown) {
     Shutdown();
-    //Don't remove from Observer service in Shutdown because Shutdown also gets called
-    //from xpcom shutdown observer.  And we don't want to remove from the service in that case.
+    // Don't remove from Observer service in Shutdown because Shutdown also gets
+    // called from xpcom shutdown observer.  And we don't want to remove from
+    // the service in that case.
     nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
-    if (observerService)
-    {
+        mozilla::services::GetObserverService();
+    if (observerService) {
       observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       observerService->RemoveObserver(this, "quit-application-granted");
       observerService->RemoveObserver(this, ABOUT_TO_GO_OFFLINE_TOPIC);
       observerService->RemoveObserver(this, "sleep_notification");
     }
   }
 }
 
-nsresult nsMsgAccountManager::Init()
-{
+nsresult nsMsgAccountManager::Init() {
   nsresult rv;
 
   m_prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIObserverService> observerService =
-           mozilla::services::GetObserverService();
-  if (observerService)
-  {
+      mozilla::services::GetObserverService();
+  if (observerService) {
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
-    observerService->AddObserver(this, "quit-application-granted" , true);
+    observerService->AddObserver(this, "quit-application-granted", true);
     observerService->AddObserver(this, ABOUT_TO_GO_OFFLINE_TOPIC, true);
     observerService->AddObserver(this, "profile-before-change", true);
     observerService->AddObserver(this, "sleep_notification", true);
   }
 
   // Make sure PSM gets initialized before any accounts use certificates.
   net_EnsurePSMInit();
 
   return NS_OK;
 }
 
-nsresult nsMsgAccountManager::Shutdown()
-{
-  if (m_haveShutdown)     // do not shutdown twice
+nsresult nsMsgAccountManager::Shutdown() {
+  if (m_haveShutdown)  // do not shutdown twice
     return NS_OK;
 
   nsresult rv;
 
   SaveVirtualFolders();
 
-  nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
-  if (msgDBService)
-  {
-    nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(m_virtualFolderListeners);
+  nsCOMPtr<nsIMsgDBService> msgDBService =
+      do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
+  if (msgDBService) {
+    nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator
+        iter(m_virtualFolderListeners);
     RefPtr<VirtualFolderChangeListener> listener;
 
-    while (iter.HasMore())
-    {
+    while (iter.HasMore()) {
       listener = iter.GetNext();
       msgDBService->UnregisterPendingListener(listener);
     }
   }
-  if(m_msgFolderCache)
-    WriteToFolderCache(m_msgFolderCache);
+  if (m_msgFolderCache) WriteToFolderCache(m_msgFolderCache);
   (void)ShutdownServers();
   (void)UnloadAccounts();
 
-  //shutdown removes nsIIncomingServer listener from biff manager, so do it after accounts have been unloaded
-  nsCOMPtr<nsIMsgBiffManager> biffService = do_GetService(NS_MSGBIFFMANAGER_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && biffService)
-    biffService->Shutdown();
-
-  //shutdown removes nsIIncomingServer listener from purge service, so do it after accounts have been unloaded
-  nsCOMPtr<nsIMsgPurgeService> purgeService = do_GetService(NS_MSGPURGESERVICE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && purgeService)
-    purgeService->Shutdown();
+  // shutdown removes nsIIncomingServer listener from biff manager, so do it
+  // after accounts have been unloaded
+  nsCOMPtr<nsIMsgBiffManager> biffService =
+      do_GetService(NS_MSGBIFFMANAGER_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv) && biffService) biffService->Shutdown();
+
+  // shutdown removes nsIIncomingServer listener from purge service, so do it
+  // after accounts have been unloaded
+  nsCOMPtr<nsIMsgPurgeService> purgeService =
+      do_GetService(NS_MSGPURGESERVICE_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv) && purgeService) purgeService->Shutdown();
 
   m_msgFolderCache = nullptr;
   m_haveShutdown = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetShutdownInProgress(bool *_retval)
-{
-    NS_ENSURE_ARG_POINTER(_retval);
-    *_retval = m_shutdownInProgress;
-    return NS_OK;
+nsMsgAccountManager::GetShutdownInProgress(bool *_retval) {
+  NS_ENSURE_ARG_POINTER(_retval);
+  *_retval = m_shutdownInProgress;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetUserNeedsToAuthenticate(bool *aRetval)
-{
+nsMsgAccountManager::GetUserNeedsToAuthenticate(bool *aRetval) {
   NS_ENSURE_ARG_POINTER(aRetval);
   if (!m_userAuthenticated)
     return m_prefs->GetBoolPref("mail.password_protect_local_cache", aRetval);
   *aRetval = !m_userAuthenticated;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::SetUserNeedsToAuthenticate(bool aUserNeedsToAuthenticate)
-{
+nsMsgAccountManager::SetUserNeedsToAuthenticate(bool aUserNeedsToAuthenticate) {
   m_userAuthenticated = !aUserNeedsToAuthenticate;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData)
-{
-  if(!strcmp(aTopic,NS_XPCOM_SHUTDOWN_OBSERVER_ID))
-  {
+NS_IMETHODIMP nsMsgAccountManager::Observe(nsISupports *aSubject,
+                                           const char *aTopic,
+                                           const char16_t *someData) {
+  if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
     Shutdown();
     return NS_OK;
   }
-  if (!strcmp(aTopic, "quit-application-granted"))
-  {
+  if (!strcmp(aTopic, "quit-application-granted")) {
     // CleanupOnExit will set m_shutdownInProgress to true.
     CleanupOnExit();
     return NS_OK;
   }
-  if (!strcmp(aTopic, ABOUT_TO_GO_OFFLINE_TOPIC))
-  {
+  if (!strcmp(aTopic, ABOUT_TO_GO_OFFLINE_TOPIC)) {
     nsAutoString dataString(NS_LITERAL_STRING("offline"));
-    if (someData)
-    {
+    if (someData) {
       nsAutoString someDataString(someData);
-      if (dataString.Equals(someDataString))
-        CloseCachedConnections();
+      if (dataString.Equals(someDataString)) CloseCachedConnections();
     }
     return NS_OK;
   }
-  if (!strcmp(aTopic, "sleep_notification"))
-    return CloseCachedConnections();
-
-  if (!strcmp(aTopic, "profile-before-change"))
-  {
+  if (!strcmp(aTopic, "sleep_notification")) return CloseCachedConnections();
+
+  if (!strcmp(aTopic, "profile-before-change")) {
     Shutdown();
     return NS_OK;
   }
 
- return NS_OK;
+  return NS_OK;
 }
 
-void
-nsMsgAccountManager::getUniqueAccountKey(nsCString& aResult)
-{
+void nsMsgAccountManager::getUniqueAccountKey(nsCString &aResult) {
   int32_t lastKey = 0;
   nsresult rv;
-  nsCOMPtr<nsIPrefService> prefservice(do_GetService(NS_PREFSERVICE_CONTRACTID,
-                                       &rv));
+  nsCOMPtr<nsIPrefService> prefservice(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIPrefBranch> prefBranch;
     prefservice->GetBranch("", getter_AddRefs(prefBranch));
 
     rv = prefBranch->GetIntPref("mail.account.lastKey", &lastKey);
     if (NS_FAILED(rv) || lastKey == 0) {
       // If lastKey pref does not contain a valid value, loop over existing
       // pref names mail.account.* .
       nsCOMPtr<nsIPrefBranch> prefBranchAccount;
-      rv = prefservice->GetBranch("mail.account.", getter_AddRefs(prefBranchAccount));
+      rv = prefservice->GetBranch("mail.account.",
+                                  getter_AddRefs(prefBranchAccount));
       if (NS_SUCCEEDED(rv)) {
         uint32_t prefCount;
         char **prefList;
         rv = prefBranchAccount->GetChildList("", &prefCount, &prefList);
         if (NS_SUCCEEDED(rv)) {
           // Pref names are of the format accountX.
           // Find the maximum value of 'X' used so far.
           for (uint32_t i = 0; i < prefCount; i++) {
             nsCString prefName;
             prefName.Assign(prefList[i]);
-            if (StringBeginsWith(prefName, NS_LITERAL_CSTRING(ACCOUNT_PREFIX))) {
+            if (StringBeginsWith(prefName,
+                                 NS_LITERAL_CSTRING(ACCOUNT_PREFIX))) {
               int32_t dotPos = prefName.FindChar('.');
               if (dotPos != kNotFound) {
                 nsCString keyString(Substring(prefName, strlen(ACCOUNT_PREFIX),
                                               dotPos - strlen(ACCOUNT_PREFIX)));
                 int32_t thisKey = keyString.ToInteger(&rv);
-                if (NS_SUCCEEDED(rv))
-                  lastKey = std::max(lastKey, thisKey);
+                if (NS_SUCCEEDED(rv)) lastKey = std::max(lastKey, thisKey);
               }
             }
           }
           NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefList);
         }
       }
     }
 
@@ -310,174 +293,157 @@ nsMsgAccountManager::getUniqueAccountKey
     do {
       aResult = ACCOUNT_PREFIX;
       aResult.AppendInt(i++);
       GetAccount(aResult, getter_AddRefs(account));
     } while (account);
   }
 }
 
-void
-nsMsgAccountManager::GetUniqueServerKey(nsACString& aResult)
-{
+void nsMsgAccountManager::GetUniqueServerKey(nsACString &aResult) {
   nsAutoCString prefResult;
   bool usePrefsScan = true;
   nsresult rv;
-  nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID,
-                                       &rv));
-  if (NS_FAILED(rv))
-    usePrefsScan = false;
+  nsCOMPtr<nsIPrefService> prefService(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) usePrefsScan = false;
 
   // Loop over existing pref names mail.server.server(lastKey).type
   nsCOMPtr<nsIPrefBranch> prefBranchServer;
-  if (prefService)
-  {
-    rv = prefService->GetBranch(PREF_MAIL_SERVER_PREFIX, getter_AddRefs(prefBranchServer));
-    if (NS_FAILED(rv))
-      usePrefsScan = false;
+  if (prefService) {
+    rv = prefService->GetBranch(PREF_MAIL_SERVER_PREFIX,
+                                getter_AddRefs(prefBranchServer));
+    if (NS_FAILED(rv)) usePrefsScan = false;
   }
 
-  if (usePrefsScan)
-  {
+  if (usePrefsScan) {
     nsAutoCString type;
     nsAutoCString typeKey;
-    for (uint32_t lastKey = 1; ; lastKey++)
-    {
+    for (uint32_t lastKey = 1;; lastKey++) {
       aResult.AssignLiteral(SERVER_PREFIX);
       aResult.AppendInt(lastKey);
       typeKey.Assign(aResult);
       typeKey.AppendLiteral(".type");
       prefBranchServer->GetCharPref(typeKey.get(), type);
-      if (type.IsEmpty()) // a server slot with no type is considered empty
+      if (type.IsEmpty())  // a server slot with no type is considered empty
         return;
     }
-  }
-  else
-  {
+  } else {
     // If pref service fails, try to find a free serverX key
     // by checking which keys exist.
     nsAutoCString internalResult;
     nsCOMPtr<nsIMsgIncomingServer> server;
     uint32_t i = 1;
     do {
       aResult.AssignLiteral(SERVER_PREFIX);
       aResult.AppendInt(i++);
       m_incomingServers.Get(aResult, getter_AddRefs(server));
     } while (server);
     return;
   }
 }
 
-nsresult
-nsMsgAccountManager::CreateIdentity(nsIMsgIdentity **_retval)
-{
+nsresult nsMsgAccountManager::CreateIdentity(nsIMsgIdentity **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   nsresult rv;
   nsAutoCString key;
   nsCOMPtr<nsIMsgIdentity> identity;
   int32_t i = 1;
   do {
     key.AssignLiteral(ID_PREFIX);
     key.AppendInt(i++);
     m_identities.Get(key, getter_AddRefs(identity));
   } while (identity);
 
   rv = createKeyedIdentity(key, _retval);
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetIdentity(const nsACString& key, nsIMsgIdentity **_retval)
-{
+nsMsgAccountManager::GetIdentity(const nsACString &key,
+                                 nsIMsgIdentity **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   nsresult rv = NS_OK;
   *_retval = nullptr;
 
-  if (!key.IsEmpty())
-  {
+  if (!key.IsEmpty()) {
     nsCOMPtr<nsIMsgIdentity> identity;
     m_identities.Get(key, getter_AddRefs(identity));
     if (identity)
       identity.forget(_retval);
-    else // identity doesn't exist. create it.
+    else  // identity doesn't exist. create it.
       rv = createKeyedIdentity(key, _retval);
   }
 
   return rv;
 }
 
 /*
  * the shared identity-creation code
  * create an identity and add it to the accountmanager's list.
  */
-nsresult
-nsMsgAccountManager::createKeyedIdentity(const nsACString& key,
-                                         nsIMsgIdentity ** aIdentity)
-{
+nsresult nsMsgAccountManager::createKeyedIdentity(const nsACString &key,
+                                                  nsIMsgIdentity **aIdentity) {
   nsresult rv;
   nsCOMPtr<nsIMsgIdentity> identity =
       do_CreateInstance(NS_MSGIDENTITY_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   identity->SetKey(key);
   m_identities.Put(key, identity);
   identity.forget(aIdentity);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::CreateIncomingServer(const nsACString&  username,
-                                          const nsACString& hostname,
-                                          const nsACString& type,
-                                          nsIMsgIncomingServer **_retval)
-{
+nsMsgAccountManager::CreateIncomingServer(const nsACString &username,
+                                          const nsACString &hostname,
+                                          const nsACString &type,
+                                          nsIMsgIncomingServer **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
 
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString key;
   GetUniqueServerKey(key);
   rv = createKeyedServer(key, username, hostname, type, _retval);
-  if (*_retval)
-  {
+  if (*_retval) {
     nsCString defaultStore;
     m_prefs->GetCharPref("mail.serverDefaultStoreContractID", defaultStore);
     (*_retval)->SetCharValue("storeContractID", defaultStore);
 
     // From when we first create the account until we have created some folders,
     // we can change the store type.
     (*_retval)->SetBoolValue("canChangeStoreType", true);
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetIncomingServer(const nsACString& key,
-                                       nsIMsgIncomingServer **_retval)
-{
+nsMsgAccountManager::GetIncomingServer(const nsACString &key,
+                                       nsIMsgIncomingServer **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
   nsresult rv;
 
-  if (m_incomingServers.Get(key, _retval))
-    return NS_OK;
+  if (m_incomingServers.Get(key, _retval)) return NS_OK;
 
   // server doesn't exist, so create it
   // this is really horrible because we are doing our own prefname munging
   // instead of leaving it up to the incoming server.
   // this should be fixed somehow so that we can create the incoming server
   // and then read from the incoming server's attributes
 
   // in order to create the right kind of server, we have to look
   // at the pref for this server to get the username, hostname, and type
   nsAutoCString serverPrefPrefix(PREF_MAIL_SERVER_PREFIX);
   serverPrefPrefix.Append(key);
 
   nsCString serverType;
-  nsAutoCString serverPref (serverPrefPrefix);
+  nsAutoCString serverPref(serverPrefPrefix);
   serverPref.AppendLiteral(".type");
   rv = m_prefs->GetCharPref(serverPref.get(), serverType);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_INITIALIZED);
 
   //
   // .userName
   serverPref = serverPrefPrefix;
   serverPref.AppendLiteral(".userName");
@@ -491,29 +457,30 @@ nsMsgAccountManager::GetIncomingServer(c
   rv = m_prefs->GetCharPref(serverPref.get(), hostname);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_INITIALIZED);
 
   return createKeyedServer(key, username, hostname, serverType, _retval);
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::RemoveIncomingServer(nsIMsgIncomingServer *aServer,
-                                          bool aRemoveFiles)
-{
+                                          bool aRemoveFiles) {
   NS_ENSURE_ARG_POINTER(aServer);
 
   nsCString serverKey;
   nsresult rv = aServer->GetKey(serverKey);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  LogoutOfServer(aServer); // close cached connections and forget session password
+  // close cached connections and forget session password
+  LogoutOfServer(aServer);
 
   // invalidate the FindServer() cache if we are removing the cached server
   if (m_lastFindServerResult == aServer)
-    SetLastServerFound(nullptr, EmptyCString(), EmptyCString(), 0, EmptyCString());
+    SetLastServerFound(nullptr, EmptyCString(), EmptyCString(), 0,
+                       EmptyCString());
 
   m_incomingServers.Remove(serverKey);
 
   nsCOMPtr<nsIMsgFolder> rootFolder;
   nsCOMPtr<nsIArray> allDescendants;
 
   rv = aServer->GetRootFolder(getter_AddRefs(rootFolder));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -521,803 +488,735 @@ nsMsgAccountManager::RemoveIncomingServe
   rv = rootFolder->GetDescendants(getter_AddRefs(allDescendants));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t cnt = 0;
   rv = allDescendants->GetLength(&cnt);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgFolderNotificationService> notifier =
-           do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
+      do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID);
   nsCOMPtr<nsIFolderListener> mailSession =
-           do_GetService(NS_MSGMAILSESSION_CONTRACTID);
-
-  for (uint32_t i = 0; i < cnt; i++)
-  {
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID);
+
+  for (uint32_t i = 0; i < cnt; i++) {
     nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendants, i);
-    if (folder)
-    {
+    if (folder) {
       folder->ForceDBClosed();
-      if (notifier)
-        notifier->NotifyFolderDeleted(folder);
-      if (mailSession)
-      {
+      if (notifier) notifier->NotifyFolderDeleted(folder);
+      if (mailSession) {
         nsCOMPtr<nsIMsgFolder> parentFolder;
         folder->GetParent(getter_AddRefs(parentFolder));
         mailSession->OnItemRemoved(parentFolder, folder);
       }
     }
   }
-  if (notifier)
-    notifier->NotifyFolderDeleted(rootFolder);
-  if (mailSession)
-    mailSession->OnItemRemoved(nullptr, rootFolder);
+  if (notifier) notifier->NotifyFolderDeleted(rootFolder);
+  if (mailSession) mailSession->OnItemRemoved(nullptr, rootFolder);
 
   removeListenersFromFolder(rootFolder);
   NotifyServerUnloaded(aServer);
-  if (aRemoveFiles)
-  {
+  if (aRemoveFiles) {
     rv = aServer->RemoveFiles();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // now clear out the server once and for all.
   // watch out! could be scary
   aServer->ClearAllValues();
   rootFolder->Shutdown(true);
   return rv;
 }
 
 /*
  * create a server when you know the key and the type
  */
-nsresult
-nsMsgAccountManager::createKeyedServer(const nsACString& key,
-                                       const nsACString& username,
-                                       const nsACString& hostname,
-                                       const nsACString& type,
-                                       nsIMsgIncomingServer ** aServer)
-{
+nsresult nsMsgAccountManager::createKeyedServer(
+    const nsACString &key, const nsACString &username,
+    const nsACString &hostname, const nsACString &type,
+    nsIMsgIncomingServer **aServer) {
   nsresult rv;
   *aServer = nullptr;
 
-  //construct the contractid
+  // construct the contractid
   nsAutoCString serverContractID(NS_MSGINCOMINGSERVER_CONTRACTID_PREFIX);
   serverContractID += type;
 
   // finally, create the server
   // (This will fail if type is from an extension that has been removed)
   nsCOMPtr<nsIMsgIncomingServer> server =
-           do_CreateInstance(serverContractID.get(), &rv);
+      do_CreateInstance(serverContractID.get(), &rv);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
 
   int32_t port;
-  nsCOMPtr <nsIMsgIncomingServer> existingServer;
+  nsCOMPtr<nsIMsgIncomingServer> existingServer;
   server->SetKey(key);
   server->SetType(type);
   server->SetUsername(username);
   server->SetHostName(hostname);
   server->GetPort(&port);
-  FindRealServer(username, hostname, type, port, getter_AddRefs(existingServer));
+  FindRealServer(username, hostname, type, port,
+                 getter_AddRefs(existingServer));
   // don't allow duplicate servers.
-  if (existingServer)
-    return NS_ERROR_FAILURE;
+  if (existingServer) return NS_ERROR_FAILURE;
 
   m_incomingServers.Put(key, server);
 
   // now add all listeners that are supposed to be
   // waiting on root folders
   nsCOMPtr<nsIMsgFolder> rootFolder;
   rv = server->GetRootFolder(getter_AddRefs(rootFolder));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsTObserverArray<nsCOMPtr<nsIFolderListener> >::ForwardIterator iter(mFolderListeners);
-  while (iter.HasMore())
-  {
+  nsTObserverArray<nsCOMPtr<nsIFolderListener> >::ForwardIterator iter(
+      mFolderListeners);
+  while (iter.HasMore()) {
     rootFolder->AddFolderListener(iter.GetNext());
   }
 
   server.forget(aServer);
   return NS_OK;
 }
 
-void
-nsMsgAccountManager::removeListenersFromFolder(nsIMsgFolder *aFolder)
-{
-  nsTObserverArray<nsCOMPtr<nsIFolderListener> >::ForwardIterator iter(mFolderListeners);
-  while (iter.HasMore())
-  {
+void nsMsgAccountManager::removeListenersFromFolder(nsIMsgFolder *aFolder) {
+  nsTObserverArray<nsCOMPtr<nsIFolderListener> >::ForwardIterator iter(
+      mFolderListeners);
+  while (iter.HasMore()) {
     aFolder->RemoveFolderListener(iter.GetNext());
   }
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::RemoveAccount(nsIMsgAccount *aAccount,
-                                   bool aRemoveFiles = false)
-{
+                                   bool aRemoveFiles = false) {
   NS_ENSURE_ARG_POINTER(aAccount);
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool accountRemoved = m_accounts.RemoveElement(aAccount);
 
-  rv  = OutputAccountsPref();
+  rv = OutputAccountsPref();
   // If we couldn't write out the pref, restore the account.
-  if (NS_FAILED(rv) && accountRemoved)
-  {
+  if (NS_FAILED(rv) && accountRemoved) {
     m_accounts.AppendElement(aAccount);
     return rv;
   }
 
   // If it's the default, choose a new default account.
-  if (m_defaultAccount.get() == aAccount)
-    AutosetDefaultAccount();
+  if (m_defaultAccount.get() == aAccount) AutosetDefaultAccount();
 
   // XXX - need to figure out if this is the last time this server is
   // being used, and only send notification then.
   // (and only remove from hashtable then too!)
   nsCOMPtr<nsIMsgIncomingServer> server;
   rv = aAccount->GetIncomingServer(getter_AddRefs(server));
-  if (NS_SUCCEEDED(rv) && server)
-    RemoveIncomingServer(server, aRemoveFiles);
+  if (NS_SUCCEEDED(rv) && server) RemoveIncomingServer(server, aRemoveFiles);
 
   nsCOMPtr<nsIArray> identityArray;
   rv = aAccount->GetIdentities(getter_AddRefs(identityArray));
   if (NS_SUCCEEDED(rv)) {
     uint32_t count = 0;
     identityArray->GetLength(&count);
     uint32_t i;
-    for (i = 0; i < count; i++)
-    {
-      nsCOMPtr<nsIMsgIdentity> identity( do_QueryElementAt(identityArray, i, &rv));
+    for (i = 0; i < count; i++) {
+      nsCOMPtr<nsIMsgIdentity> identity(
+          do_QueryElementAt(identityArray, i, &rv));
       bool identityStillUsed = false;
       // for each identity, see if any existing account still uses it,
       // and if not, clear it.
       // Note that we are also searching here accounts with missing servers from
       //  unloaded extension types.
-      if (NS_SUCCEEDED(rv))
-      {
+      if (NS_SUCCEEDED(rv)) {
         uint32_t index;
-        for (index = 0; index < m_accounts.Length() && !identityStillUsed; index++)
-        {
+        for (index = 0; index < m_accounts.Length() && !identityStillUsed;
+             index++) {
           nsCOMPtr<nsIArray> existingIdentitiesArray;
 
-          rv = m_accounts[index]->GetIdentities(getter_AddRefs(existingIdentitiesArray));
+          rv = m_accounts[index]->GetIdentities(
+              getter_AddRefs(existingIdentitiesArray));
           uint32_t pos;
-          if (NS_SUCCEEDED(existingIdentitiesArray->IndexOf(0, identity, &pos)))
-          {
+          if (NS_SUCCEEDED(
+                  existingIdentitiesArray->IndexOf(0, identity, &pos))) {
             identityStillUsed = true;
             break;
           }
         }
       }
       // clear out all identity information if no other account uses it.
-      if (!identityStillUsed)
-        identity->ClearAllValues();
+      if (!identityStillUsed) identity->ClearAllValues();
     }
   }
 
   // It is not a critical problem if this fails as the account was already
   // removed from the list of accounts so should not ever be referenced.
   // Just print it out for debugging.
   rv = aAccount->ClearAllValues();
   NS_ASSERTION(NS_SUCCEEDED(rv), "removing of account prefs failed");
   return NS_OK;
 }
 
-nsresult
-nsMsgAccountManager::OutputAccountsPref()
-{
+nsresult nsMsgAccountManager::OutputAccountsPref() {
   nsCString accountKey;
   mAccountKeyList.Truncate();
 
-  for (uint32_t index = 0; index < m_accounts.Length(); index++)
-  {
+  for (uint32_t index = 0; index < m_accounts.Length(); index++) {
     m_accounts[index]->GetKey(accountKey);
-    if (index)
-      mAccountKeyList.Append(ACCOUNT_DELIMITER);
+    if (index) mAccountKeyList.Append(ACCOUNT_DELIMITER);
     mAccountKeyList.Append(accountKey);
   }
   return m_prefs->SetCharPref(PREF_MAIL_ACCOUNTMANAGER_ACCOUNTS,
                               mAccountKeyList);
 }
 
 /**
  * Get the default account. If no default account, return null.
  */
 NS_IMETHODIMP
-nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount **aDefaultAccount)
-{
+nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount **aDefaultAccount) {
   NS_ENSURE_ARG_POINTER(aDefaultAccount);
 
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!m_defaultAccount) {
     nsCString defaultKey;
-    rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT, defaultKey);
+    rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT,
+                              defaultKey);
     if (NS_SUCCEEDED(rv)) {
       rv = GetAccount(defaultKey, getter_AddRefs(m_defaultAccount));
       if (NS_SUCCEEDED(rv) && m_defaultAccount) {
         bool canBeDefault = false;
         rv = CheckDefaultAccount(m_defaultAccount, canBeDefault);
-        if (NS_FAILED(rv) || !canBeDefault)
-          m_defaultAccount = nullptr;
+        if (NS_FAILED(rv) || !canBeDefault) m_defaultAccount = nullptr;
       }
     }
   }
 
   NS_IF_ADDREF(*aDefaultAccount = m_defaultAccount);
   return NS_OK;
 }
 
 /**
  * Check if the given account can be default.
  */
-nsresult
-nsMsgAccountManager::CheckDefaultAccount(nsIMsgAccount *aAccount, bool &aCanBeDefault)
-{
+nsresult nsMsgAccountManager::CheckDefaultAccount(nsIMsgAccount *aAccount,
+                                                  bool &aCanBeDefault) {
   aCanBeDefault = false;
   nsCOMPtr<nsIMsgIncomingServer> server;
   // Server could be null if created by an unloaded extension.
   nsresult rv = aAccount->GetIncomingServer(getter_AddRefs(server));
   NS_ENSURE_SUCCESS(rv, rv);
   if (server) {
     // Check if server can be default.
     rv = server->GetCanBeDefaultServer(&aCanBeDefault);
   }
   return rv;
 }
 
 /**
  * Pick the first account that can be default and make it the default.
  */
-nsresult
-nsMsgAccountManager::AutosetDefaultAccount()
-{
-  for (nsIMsgAccount* account : m_accounts) {
+nsresult nsMsgAccountManager::AutosetDefaultAccount() {
+  for (nsIMsgAccount *account : m_accounts) {
     bool canBeDefault = false;
     nsresult rv = CheckDefaultAccount(account, canBeDefault);
     if (NS_SUCCEEDED(rv) && canBeDefault) {
       return SetDefaultAccount(account);
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::SetDefaultAccount(nsIMsgAccount *aDefaultAccount)
-{
-  if (!aDefaultAccount)
-    return NS_ERROR_INVALID_ARG;
-
-  if (m_defaultAccount != aDefaultAccount)
-  {
+nsMsgAccountManager::SetDefaultAccount(nsIMsgAccount *aDefaultAccount) {
+  if (!aDefaultAccount) return NS_ERROR_INVALID_ARG;
+
+  if (m_defaultAccount != aDefaultAccount) {
     bool canBeDefault = false;
     nsresult rv = CheckDefaultAccount(aDefaultAccount, canBeDefault);
     if (NS_FAILED(rv) || !canBeDefault) {
       // Report failure if we were explicitly asked to use an unusable server.
       return NS_ERROR_INVALID_ARG;
     }
     nsCOMPtr<nsIMsgAccount> oldAccount = m_defaultAccount;
     m_defaultAccount = aDefaultAccount;
-    (void) setDefaultAccountPref(aDefaultAccount);
-    (void) notifyDefaultServerChange(oldAccount, aDefaultAccount);
+    (void)setDefaultAccountPref(aDefaultAccount);
+    (void)notifyDefaultServerChange(oldAccount, aDefaultAccount);
   }
   return NS_OK;
 }
 
 // fire notifications
-nsresult
-nsMsgAccountManager::notifyDefaultServerChange(nsIMsgAccount *aOldAccount,
-                                               nsIMsgAccount *aNewAccount)
-{
+nsresult nsMsgAccountManager::notifyDefaultServerChange(
+    nsIMsgAccount *aOldAccount, nsIMsgAccount *aNewAccount) {
   nsresult rv;
 
   nsCOMPtr<nsIMsgIncomingServer> server;
   nsCOMPtr<nsIMsgFolder> rootFolder;
 
   // first tell old server it's no longer the default
   if (aOldAccount) {
     rv = aOldAccount->GetIncomingServer(getter_AddRefs(server));
     if (NS_SUCCEEDED(rv) && server) {
       rv = server->GetRootFolder(getter_AddRefs(rootFolder));
       if (NS_SUCCEEDED(rv) && rootFolder)
-        rootFolder->NotifyBoolPropertyChanged(kDefaultServer,
-                                              true, false);
+        rootFolder->NotifyBoolPropertyChanged(kDefaultServer, true, false);
     }
   }
 
-    // now tell new server it is.
+  // now tell new server it is.
   if (aNewAccount) {
     rv = aNewAccount->GetIncomingServer(getter_AddRefs(server));
     if (NS_SUCCEEDED(rv) && server) {
       rv = server->GetRootFolder(getter_AddRefs(rootFolder));
       if (NS_SUCCEEDED(rv) && rootFolder)
-        rootFolder->NotifyBoolPropertyChanged(kDefaultServer,
-                                              false, true);
+        rootFolder->NotifyBoolPropertyChanged(kDefaultServer, false, true);
     }
   }
 
-  if (aOldAccount && aNewAccount)  //only notify if the user goes and changes default account
-  {
+  // only notify if the user goes and changes default account
+  if (aOldAccount && aNewAccount) {
     nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
+        mozilla::services::GetObserverService();
 
     if (observerService)
-      observerService->NotifyObservers(nullptr,"mailDefaultAccountChanged",nullptr);
+      observerService->NotifyObservers(nullptr, "mailDefaultAccountChanged",
+                                       nullptr);
   }
 
   return NS_OK;
 }
 
-nsresult
-nsMsgAccountManager::setDefaultAccountPref(nsIMsgAccount* aDefaultAccount)
-{
+nsresult nsMsgAccountManager::setDefaultAccountPref(
+    nsIMsgAccount *aDefaultAccount) {
   nsresult rv;
 
   if (aDefaultAccount) {
     nsCString key;
     rv = aDefaultAccount->GetKey(key);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = m_prefs->SetCharPref(PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT, key);
-    NS_ENSURE_SUCCESS(rv,rv);
-  }
-  else
+    NS_ENSURE_SUCCESS(rv, rv);
+  } else
     m_prefs->ClearUserPref(PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT);
 
   return NS_OK;
 }
 
-void nsMsgAccountManager::LogoutOfServer(nsIMsgIncomingServer *aServer)
-{
-  if (!aServer)
-    return;
+void nsMsgAccountManager::LogoutOfServer(nsIMsgIncomingServer *aServer) {
+  if (!aServer) return;
   mozilla::DebugOnly<nsresult> rv = aServer->Shutdown();
   NS_ASSERTION(NS_SUCCEEDED(rv), "Shutdown of server failed");
   rv = aServer->ForgetSessionPassword();
-  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remove the password associated with server");
+  NS_ASSERTION(NS_SUCCEEDED(rv),
+               "failed to remove the password associated with server");
 }
 
-NS_IMETHODIMP nsMsgAccountManager::GetFolderCache(nsIMsgFolderCache* *aFolderCache)
-{
+NS_IMETHODIMP nsMsgAccountManager::GetFolderCache(
+    nsIMsgFolderCache **aFolderCache) {
   NS_ENSURE_ARG_POINTER(aFolderCache);
   nsresult rv = NS_OK;
 
-  if (!m_msgFolderCache)
-  {
+  if (!m_msgFolderCache) {
     m_msgFolderCache = do_CreateInstance(kMsgFolderCacheCID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIFile> cacheFile;
     rv = NS_GetSpecialDirectory(NS_APP_MESSENGER_FOLDER_CACHE_50_FILE,
                                 getter_AddRefs(cacheFile));
     NS_ENSURE_SUCCESS(rv, rv);
     m_msgFolderCache->Init(cacheFile);
   }
 
   NS_IF_ADDREF(*aFolderCache = m_msgFolderCache);
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetAccounts(nsIArray **_retval)
-{
+nsMsgAccountManager::GetAccounts(nsIArray **_retval) {
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMutableArray> accounts(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  nsCOMPtr<nsIMutableArray> accounts(
+      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  for (uint32_t index = 0; index < m_accounts.Length(); index++)
-  {
+  for (uint32_t index = 0; index < m_accounts.Length(); index++) {
     nsCOMPtr<nsIMsgAccount> existingAccount(m_accounts[index]);
     nsCOMPtr<nsIMsgIncomingServer> server;
     existingAccount->GetIncomingServer(getter_AddRefs(server));
-    if (!server)
-      continue;
-    if (server)
-    {
+    if (!server) continue;
+    if (server) {
       bool hidden = false;
       server->GetHidden(&hidden);
-      if (hidden)
-        continue;
+      if (hidden) continue;
     }
     accounts->AppendElement(existingAccount);
   }
   accounts.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetAllIdentities(nsIArray **_retval)
-{
+nsMsgAccountManager::GetAllIdentities(nsIArray **_retval) {
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMutableArray> result(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIArray> identities;
 
   for (uint32_t i = 0; i < m_accounts.Length(); ++i) {
     rv = m_accounts[i]->GetIdentities(getter_AddRefs(identities));
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     uint32_t idCount;
     rv = identities->GetLength(&idCount);
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     for (uint32_t j = 0; j < idCount; ++j) {
       nsCOMPtr<nsIMsgIdentity> identity(do_QueryElementAt(identities, j, &rv));
-      if (NS_FAILED(rv))
-        continue;
+      if (NS_FAILED(rv)) continue;
 
       nsAutoCString key;
       rv = identity->GetKey(key);
-      if (NS_FAILED(rv))
-        continue;
+      if (NS_FAILED(rv)) continue;
 
       uint32_t resultCount;
       rv = result->GetLength(&resultCount);
-      if (NS_FAILED(rv))
-        continue;
+      if (NS_FAILED(rv)) continue;
 
       bool found = false;
       for (uint32_t k = 0; k < resultCount && !found; ++k) {
-        nsCOMPtr<nsIMsgIdentity> thisIdentity(do_QueryElementAt(result, k, &rv));
-        if (NS_FAILED(rv))
-          continue;
+        nsCOMPtr<nsIMsgIdentity> thisIdentity(
+            do_QueryElementAt(result, k, &rv));
+        if (NS_FAILED(rv)) continue;
 
         nsAutoCString thisKey;
         rv = thisIdentity->GetKey(thisKey);
-        if (NS_FAILED(rv))
-          continue;
-
-        if (key == thisKey)
-          found = true;
+        if (NS_FAILED(rv)) continue;
+
+        if (key == thisKey) found = true;
       }
 
-      if (!found)
-        result->AppendElement(identity);
+      if (!found) result->AppendElement(identity);
     }
   }
   result.forget(_retval);
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetAllServers(nsIArray **_retval)
-{
+nsMsgAccountManager::GetAllServers(nsIArray **_retval) {
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMutableArray> servers(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  nsCOMPtr<nsIMutableArray> servers(
+      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
-    nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
-    if (!server)
-      continue;
+    nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
+    if (!server) continue;
 
     bool hidden = false;
     server->GetHidden(&hidden);
-    if (hidden)
-      continue;
+    if (hidden) continue;
 
     nsCString type;
     if (NS_FAILED(server->GetType(type))) {
       NS_WARNING("server->GetType() failed");
       continue;
     }
 
     if (!type.EqualsLiteral("im")) {
       servers->AppendElement(server);
     }
   }
 
   servers.forget(_retval);
   return rv;
 }
 
-nsresult
-nsMsgAccountManager::LoadAccounts()
-{
+nsresult nsMsgAccountManager::LoadAccounts() {
   nsresult rv;
 
   // for now safeguard multiple calls to this function
-  if (m_accountsLoaded)
-    return NS_OK;
-
-  nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+  if (m_accountsLoaded) return NS_OK;
+
+  nsCOMPtr<nsIMsgMailSession> mailSession =
+      do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
 
   if (NS_SUCCEEDED(rv))
-    mailSession->AddFolderListener(this, nsIFolderListener::added |
-                                         nsIFolderListener::removed |
-                                         nsIFolderListener::intPropertyChanged);
+    mailSession->AddFolderListener(
+        this, nsIFolderListener::added | nsIFolderListener::removed |
+                  nsIFolderListener::intPropertyChanged);
   // If we have code trying to do things after we've unloaded accounts,
   // ignore it.
-  if (m_shutdownInProgress || m_haveShutdown)
-    return NS_ERROR_FAILURE;
-
-  //Ensure biff service has started
+  if (m_shutdownInProgress || m_haveShutdown) return NS_ERROR_FAILURE;
+
+  // Ensure biff service has started
   nsCOMPtr<nsIMsgBiffManager> biffService =
-           do_GetService(NS_MSGBIFFMANAGER_CONTRACTID, &rv);
-
-  if (NS_SUCCEEDED(rv))
-    biffService->Init();
-
-  //Ensure purge service has started
+      do_GetService(NS_MSGBIFFMANAGER_CONTRACTID, &rv);
+
+  if (NS_SUCCEEDED(rv)) biffService->Init();
+
+  // Ensure purge service has started
   nsCOMPtr<nsIMsgPurgeService> purgeService =
-           do_GetService(NS_MSGPURGESERVICE_CONTRACTID, &rv);
-
-  if (NS_SUCCEEDED(rv))
-    purgeService->Init();
-
-  nsCOMPtr<nsIPrefService> prefservice(do_GetService(NS_PREFSERVICE_CONTRACTID,
-                                       &rv));
+      do_GetService(NS_MSGPURGESERVICE_CONTRACTID, &rv);
+
+  if (NS_SUCCEEDED(rv)) purgeService->Init();
+
+  nsCOMPtr<nsIPrefService> prefservice(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Ensure messenger OS integration service has started
   // note, you can't expect the integrationService to be there
   // we don't have OS integration on all platforms.
   nsCOMPtr<nsIMessengerOSIntegration> integrationService =
-           do_GetService(NS_MESSENGEROSINTEGRATION_CONTRACTID, &rv);
+      do_GetService(NS_MESSENGEROSINTEGRATION_CONTRACTID, &rv);
 
   // mail.accountmanager.accounts is the main entry point for all accounts
   nsCString accountList;
   rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_ACCOUNTS, accountList);
 
   /**
    * Check to see if we need to add pre-configured accounts.
    * Following prefs are important to note in understanding the procedure here.
    *
    * 1. pref("mailnews.append_preconfig_accounts.version", version number);
-   * This pref registers the current version in the user prefs file. A default value
-   * is stored in mailnews.js file. If a given vendor needs to add more preconfigured
-   * accounts, the default version number can be increased. Comparing version
-   * number from user's prefs file and the default one from mailnews.js, we
-   * can add new accounts and any other version level changes that need to be done.
+   * This pref registers the current version in the user prefs file. A default
+   * value is stored in mailnews.js file. If a given vendor needs to add more
+   * preconfigured accounts, the default version number can be increased.
+   * Comparing version number from user's prefs file and the default one from
+   * mailnews.js, we can add new accounts and any other version level changes
+   * that need to be done.
    *
-   * 2. pref("mail.accountmanager.appendaccounts", <comma separated account list>);
-   * This pref contains the list of pre-configured accounts that ISP/Vendor wants to
-   * to add to the existing accounts list.
+   * 2. pref("mail.accountmanager.appendaccounts", <comma sep. account list>);
+   * This pref contains the list of pre-configured accounts that ISP/Vendor
+   * wants to add to the existing accounts list.
    */
   nsCOMPtr<nsIPrefBranch> defaultsPrefBranch;
-  rv = prefservice->GetDefaultBranch(MAILNEWS_ROOT_PREF, getter_AddRefs(defaultsPrefBranch));
+  rv = prefservice->GetDefaultBranch(MAILNEWS_ROOT_PREF,
+                                     getter_AddRefs(defaultsPrefBranch));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrefBranch> prefBranch;
   rv = prefservice->GetBranch(MAILNEWS_ROOT_PREF, getter_AddRefs(prefBranch));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  int32_t appendAccountsCurrentVersion=0;
-  int32_t appendAccountsDefaultVersion=0;
-  rv = prefBranch->GetIntPref(APPEND_ACCOUNTS_VERSION_PREF_NAME, &appendAccountsCurrentVersion);
+  int32_t appendAccountsCurrentVersion = 0;
+  int32_t appendAccountsDefaultVersion = 0;
+  rv = prefBranch->GetIntPref(APPEND_ACCOUNTS_VERSION_PREF_NAME,
+                              &appendAccountsCurrentVersion);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = defaultsPrefBranch->GetIntPref(APPEND_ACCOUNTS_VERSION_PREF_NAME, &appendAccountsDefaultVersion);
+  rv = defaultsPrefBranch->GetIntPref(APPEND_ACCOUNTS_VERSION_PREF_NAME,
+                                      &appendAccountsDefaultVersion);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Update the account list if needed
   if ((appendAccountsCurrentVersion <= appendAccountsDefaultVersion)) {
-
     // Get a list of pre-configured accounts
     nsCString appendAccountList;
     rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_APPEND_ACCOUNTS,
                               appendAccountList);
     appendAccountList.StripWhitespace();
 
     // If there are pre-configured accounts, we need to add them to the
     // existing list.
-    if (!appendAccountList.IsEmpty())
-    {
-      if (!accountList.IsEmpty())
-      {
+    if (!appendAccountList.IsEmpty()) {
+      if (!accountList.IsEmpty()) {
         // Tokenize the data and add each account
         // in the user's current mailnews account list
         nsTArray<nsCString> accountsArray;
         ParseString(accountList, ACCOUNT_DELIMITER, accountsArray);
         uint32_t i = accountsArray.Length();
 
         // Append each account in the pre-configured account list
         ParseString(appendAccountList, ACCOUNT_DELIMITER, accountsArray);
 
         // Now add each account that does not already appear in the list
-        for (; i < accountsArray.Length(); i++)
-        {
-          if (accountsArray.IndexOf(accountsArray[i]) == i)
-          {
+        for (; i < accountsArray.Length(); i++) {
+          if (accountsArray.IndexOf(accountsArray[i]) == i) {
             accountList.Append(ACCOUNT_DELIMITER);
             accountList.Append(accountsArray[i]);
           }
         }
-      }
-      else
-      {
+      } else {
         accountList = appendAccountList;
       }
-      // Increase the version number so that updates will happen as and when needed
-      rv = prefBranch->SetIntPref(APPEND_ACCOUNTS_VERSION_PREF_NAME, appendAccountsCurrentVersion + 1);
+      // Increase the version number so that updates will happen as and when
+      // needed
+      rv = prefBranch->SetIntPref(APPEND_ACCOUNTS_VERSION_PREF_NAME,
+                                  appendAccountsCurrentVersion + 1);
     }
   }
 
   // It is ok to return null accounts like when we create new profile.
   m_accountsLoaded = true;
   m_haveShutdown = false;
 
-  if (accountList.IsEmpty())
-      return NS_OK;
+  if (accountList.IsEmpty()) return NS_OK;
 
   /* parse accountList and run loadAccount on each string, comma-separated */
   nsCOMPtr<nsIMsgAccount> account;
   // Tokenize the data and add each account
   // in the user's current mailnews account list
   nsTArray<nsCString> accountsArray;
   ParseString(accountList, ACCOUNT_DELIMITER, accountsArray);
 
   // These are the duplicate accounts we found. We keep track of these
   // because if any other server defers to one of these accounts, we need
   // to defer to the correct account.
   nsCOMArray<nsIMsgAccount> dupAccounts;
 
   // Now add each account that does not already appear in the list
-  for (uint32_t i = 0; i < accountsArray.Length(); i++)
-  {
+  for (uint32_t i = 0; i < accountsArray.Length(); i++) {
     // if we've already seen this exact account, advance to the next account.
     // After the loop, we'll notice that we don't have as many actual accounts
     // as there were accounts in the pref, and rewrite the pref.
-    if (accountsArray.IndexOf(accountsArray[i]) != i)
-      continue;
+    if (accountsArray.IndexOf(accountsArray[i]) != i) continue;
 
     // get the "server" pref to see if we already have an account with this
     // server. If we do, we ignore this account.
     nsAutoCString serverKeyPref("mail.account.");
     serverKeyPref += accountsArray[i];
 
     nsCOMPtr<nsIPrefBranch> accountPrefBranch;
     rv = prefservice->GetBranch(serverKeyPref.get(),
                                 getter_AddRefs(accountPrefBranch));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     serverKeyPref += ".server";
     nsCString serverKey;
     rv = m_prefs->GetCharPref(serverKeyPref.get(), serverKey);
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     nsCOMPtr<nsIMsgAccount> serverAccount;
     findAccountByServerKey(serverKey, getter_AddRefs(serverAccount));
     // If we have an existing account with the same server, ignore this account
-    if (serverAccount)
-      continue;
-
-    if (NS_FAILED(createKeyedAccount(accountsArray[i],
-                                     getter_AddRefs(account))) || !account)
-    {
+    if (serverAccount) continue;
+
+    if (NS_FAILED(
+            createKeyedAccount(accountsArray[i], getter_AddRefs(account))) ||
+        !account) {
       NS_WARNING("unexpected entry in account list; prefs corrupt?");
       continue;
     }
 
     // See nsIMsgAccount.idl for a description of the secondsToLeaveUnavailable
     //  and timeFoundUnavailable preferences
     nsAutoCString toLeavePref(PREF_MAIL_SERVER_PREFIX);
     toLeavePref.Append(serverKey);
-    nsAutoCString unavailablePref(toLeavePref); // this is the server-specific prefix
+    nsAutoCString unavailablePref(
+        toLeavePref);  // this is the server-specific prefix
     unavailablePref.AppendLiteral(".timeFoundUnavailable");
     toLeavePref.AppendLiteral(".secondsToLeaveUnavailable");
     int32_t secondsToLeave = 0;
     int32_t timeUnavailable = 0;
 
     m_prefs->GetIntPref(toLeavePref.get(), &secondsToLeave);
 
     // force load of accounts (need to find a better way to do this)
     nsCOMPtr<nsIArray> identities;
     account->GetIdentities(getter_AddRefs(identities));
 
     rv = account->CreateServer();
     bool deleteAccount = NS_FAILED(rv);
 
-    if (secondsToLeave)
-    { // we need to process timeUnavailable
-      if (NS_SUCCEEDED(rv)) // clear the time if server is available
+    if (secondsToLeave) {    // we need to process timeUnavailable
+      if (NS_SUCCEEDED(rv))  // clear the time if server is available
       {
         m_prefs->ClearUserPref(unavailablePref.get());
       }
       // NS_ERROR_NOT_AVAILABLE signifies a server that could not be
       // instantiated, presumably because of an invalid type.
-      else if (rv == NS_ERROR_NOT_AVAILABLE)
-      {
+      else if (rv == NS_ERROR_NOT_AVAILABLE) {
         m_prefs->GetIntPref(unavailablePref.get(), &timeUnavailable);
-        if (!timeUnavailable)
-        { // we need to set it, this must be the first time unavailable
+        if (!timeUnavailable) {  // we need to set it, this must be the first
+                                 // time unavailable
           uint32_t nowSeconds;
           PRTime2Seconds(PR_Now(), &nowSeconds);
           m_prefs->SetIntPref(unavailablePref.get(), nowSeconds);
           deleteAccount = false;
         }
       }
     }
 
-    if (rv == NS_ERROR_NOT_AVAILABLE && timeUnavailable != 0)
-    { // Our server is still unavailable. Have we timed out yet?
+    // Our server is still unavailable. Have we timed out yet?
+    if (rv == NS_ERROR_NOT_AVAILABLE && timeUnavailable != 0) {
       uint32_t nowSeconds;
       PRTime2Seconds(PR_Now(), &nowSeconds);
       if ((int32_t)nowSeconds < timeUnavailable + secondsToLeave)
         deleteAccount = false;
     }
 
-    if (deleteAccount)
-    {
+    if (deleteAccount) {
       dupAccounts.AppendObject(account);
       m_accounts.RemoveElement(account);
     }
   }
 
   // Check if we removed one or more of the accounts in the pref string.
   // If so, rewrite the pref string.
-  if (accountsArray.Length() != m_accounts.Length())
-    OutputAccountsPref();
+  if (accountsArray.Length() != m_accounts.Length()) OutputAccountsPref();
 
   int32_t cnt = dupAccounts.Count();
   nsCOMPtr<nsIMsgAccount> dupAccount;
 
   // Go through the accounts seeing if any existing server is deferred to
   // an account we removed. If so, fix the deferral. Then clean up the prefs
   // for the removed account.
-  for (int32_t i = 0; i < cnt; i++)
-  {
+  for (int32_t i = 0; i < cnt; i++) {
     dupAccount = dupAccounts[i];
     for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
       /*
        * This loop gets run for every incoming server, and is passed a
        * duplicate account. It checks that the server is not deferred to the
        * duplicate account. If it is, then it looks up the information for the
        * duplicate account's server (username, hostName, type), and finds an
        * account with a server with the same username, hostname, and type, and
        * if it finds one, defers to that account instead. Generally, this will
        * be a Local Folders account, since 2.0 has a bug where duplicate Local
        * Folders accounts are created.
        */
-      nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
+      nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
       nsCString type;
       server->GetType(type);
-      if (type.EqualsLiteral("pop3"))
-      {
+      if (type.EqualsLiteral("pop3")) {
         nsCString deferredToAccount;
         // Get the pref directly, because the GetDeferredToAccount accessor
         // attempts to fix broken deferrals, but we know more about what the
         // deferred to account was.
         server->GetCharValue("deferred_to_account", deferredToAccount);
-        if (!deferredToAccount.IsEmpty())
-        {
+        if (!deferredToAccount.IsEmpty()) {
           nsCString dupAccountKey;
           dupAccount->GetKey(dupAccountKey);
-          if (deferredToAccount.Equals(dupAccountKey))
-          {
+          if (deferredToAccount.Equals(dupAccountKey)) {
             nsresult rv;
             nsCString accountPref("mail.account.");
             nsCString dupAccountServerKey;
             accountPref.Append(dupAccountKey);
             accountPref.AppendLiteral(".server");
             nsCOMPtr<nsIPrefService> prefservice(
-              do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+                do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
             if (NS_FAILED(rv)) {
               continue;
             }
             nsCOMPtr<nsIPrefBranch> prefBranch(
-              do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+                do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
             if (NS_FAILED(rv)) {
               continue;
             }
-            rv = prefBranch->GetCharPref(accountPref.get(),
-                                         dupAccountServerKey);
+            rv =
+                prefBranch->GetCharPref(accountPref.get(), dupAccountServerKey);
             if (NS_FAILED(rv)) {
               continue;
             }
             nsCOMPtr<nsIPrefBranch> serverPrefBranch;
             nsCString serverKeyPref(PREF_MAIL_SERVER_PREFIX);
             serverKeyPref.Append(dupAccountServerKey);
             serverKeyPref.Append('.');
             rv = prefservice->GetBranch(serverKeyPref.get(),
@@ -1328,86 +1227,78 @@ nsMsgAccountManager::LoadAccounts()
             nsCString userName;
             nsCString hostName;
             nsCString type;
             serverPrefBranch->GetCharPref("userName", userName);
             serverPrefBranch->GetCharPref("hostname", hostName);
             serverPrefBranch->GetCharPref("type", type);
             // Find a server with the same info.
             nsCOMPtr<nsIMsgAccountManager> accountManager =
-                     do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+                do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
             if (NS_FAILED(rv)) {
               continue;
             }
             nsCOMPtr<nsIMsgIncomingServer> server;
             accountManager->FindServer(userName, hostName, type,
                                        getter_AddRefs(server));
-            if (server)
-            {
+            if (server) {
               nsCOMPtr<nsIMsgAccount> replacement;
               accountManager->FindAccountForServer(server,
                                                    getter_AddRefs(replacement));
-              if (replacement)
-              {
+              if (replacement) {
                 nsCString accountKey;
                 replacement->GetKey(accountKey);
                 if (!accountKey.IsEmpty())
                   server->SetCharValue("deferred_to_account", accountKey);
               }
             }
           }
         }
       }
     }
 
     nsAutoCString accountKeyPref("mail.account.");
     nsCString dupAccountKey;
     dupAccount->GetKey(dupAccountKey);
-    if (dupAccountKey.IsEmpty())
-      continue;
+    if (dupAccountKey.IsEmpty()) continue;
     accountKeyPref += dupAccountKey;
 
     nsCOMPtr<nsIPrefBranch> accountPrefBranch;
     rv = prefservice->GetBranch(accountKeyPref.get(),
                                 getter_AddRefs(accountPrefBranch));
-    if (accountPrefBranch)
-      accountPrefBranch->DeleteBranch("");
+    if (accountPrefBranch) accountPrefBranch->DeleteBranch("");
   }
 
   // Make sure we have an account that points at the local folders server
   nsCString localFoldersServerKey;
   rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER,
                             localFoldersServerKey);
 
-  if (!localFoldersServerKey.IsEmpty())
-  {
+  if (!localFoldersServerKey.IsEmpty()) {
     nsCOMPtr<nsIMsgIncomingServer> server;
     rv = GetIncomingServer(localFoldersServerKey, getter_AddRefs(server));
-    if (server)
-    {
+    if (server) {
       nsCOMPtr<nsIMsgAccount> localFoldersAccount;
-      findAccountByServerKey(localFoldersServerKey, getter_AddRefs(localFoldersAccount));
+      findAccountByServerKey(localFoldersServerKey,
+                             getter_AddRefs(localFoldersAccount));
       // If we don't have an existing account pointing at the local folders
       // server, we're going to add one.
-      if (!localFoldersAccount)
-      {
+      if (!localFoldersAccount) {
         nsCOMPtr<nsIMsgAccount> account;
-        (void) CreateAccount(getter_AddRefs(account));
-        if (account)
-          account->SetIncomingServer(server);
+        (void)CreateAccount(getter_AddRefs(account));
+        if (account) account->SetIncomingServer(server);
       }
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::ReactivateAccounts()
-{
-  for (nsIMsgAccount* account : m_accounts) {
+nsMsgAccountManager::ReactivateAccounts() {
+  for (nsIMsgAccount *account : m_accounts) {
     // This will error out if the account already has its server, or
     // if this isn't the account that the extension is trying to reactivate.
     if (NS_SUCCEEDED(account->CreateServer())) {
       nsCOMPtr<nsIMsgIncomingServer> server;
       account->GetIncomingServer(getter_AddRefs(server));
       // This triggers all of the notifications required by the UI.
       account->SetIncomingServer(server);
     }
@@ -1418,306 +1309,271 @@ nsMsgAccountManager::ReactivateAccounts(
 // this routine goes through all the identities and makes sure
 // that the special folders for each identity have the
 // correct special folder flags set, e.g, the Sent folder has
 // the sent flag set.
 //
 // it also goes through all the spam settings for each account
 // and makes sure the folder flags are set there, too
 NS_IMETHODIMP
-nsMsgAccountManager::SetSpecialFolders()
-{
+nsMsgAccountManager::SetSpecialFolders() {
   nsCOMPtr<nsIArray> identities;
   GetAllIdentities(getter_AddRefs(identities));
 
   uint32_t idCount = 0;
   identities->GetLength(&idCount);
 
   uint32_t id;
   nsCString identityKey;
 
-  for (id = 0; id < idCount; id++)
-  {
+  for (id = 0; id < idCount; id++) {
     nsresult rv;
-    nsCOMPtr<nsIMsgIdentity> thisIdentity(do_QueryElementAt(identities, id, &rv));
-    if (NS_FAILED(rv))
-      continue;
-
-    if (NS_SUCCEEDED(rv) && thisIdentity)
-    {
+    nsCOMPtr<nsIMsgIdentity> thisIdentity(
+        do_QueryElementAt(identities, id, &rv));
+    if (NS_FAILED(rv)) continue;
+
+    if (NS_SUCCEEDED(rv) && thisIdentity) {
       nsCString folderUri;
       nsCOMPtr<nsIMsgFolder> folder;
 
       thisIdentity->GetFccFolder(folderUri);
       if (!folderUri.IsEmpty() &&
-          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder))))
-      {
-        nsCOMPtr <nsIMsgFolder> parent;
+          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder)))) {
+        nsCOMPtr<nsIMsgFolder> parent;
         rv = folder->GetParent(getter_AddRefs(parent));
         if (NS_SUCCEEDED(rv) && parent)
           rv = folder->SetFlag(nsMsgFolderFlags::SentMail);
       }
 
       thisIdentity->GetDraftFolder(folderUri);
       if (!folderUri.IsEmpty() &&
-          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder))))
-      {
-        nsCOMPtr <nsIMsgFolder> parent;
+          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder)))) {
+        nsCOMPtr<nsIMsgFolder> parent;
         rv = folder->GetParent(getter_AddRefs(parent));
         if (NS_SUCCEEDED(rv) && parent)
           rv = folder->SetFlag(nsMsgFolderFlags::Drafts);
       }
 
       thisIdentity->GetArchiveFolder(folderUri);
       if (!folderUri.IsEmpty() &&
-          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder))))
-      {
-        nsCOMPtr <nsIMsgFolder> parent;
+          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder)))) {
+        nsCOMPtr<nsIMsgFolder> parent;
         rv = folder->GetParent(getter_AddRefs(parent));
         if (NS_SUCCEEDED(rv) && parent) {
           bool archiveEnabled;
           thisIdentity->GetArchiveEnabled(&archiveEnabled);
           if (archiveEnabled)
             rv = folder->SetFlag(nsMsgFolderFlags::Archive);
           else
             rv = folder->ClearFlag(nsMsgFolderFlags::Archive);
         }
       }
 
       thisIdentity->GetStationeryFolder(folderUri);
       if (!folderUri.IsEmpty() &&
-          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder))))
-      {
-        nsCOMPtr <nsIMsgFolder> parent;
+          NS_SUCCEEDED(GetOrCreateFolder(folderUri, getter_AddRefs(folder)))) {
+        nsCOMPtr<nsIMsgFolder> parent;
         rv = folder->GetParent(getter_AddRefs(parent));
         if (NS_SUCCEEDED(rv) && parent)
           folder->SetFlag(nsMsgFolderFlags::Templates);
       }
     }
   }
 
   // XXX todo
   // get all servers
   // get all spam settings for each server
   // set the JUNK folder flag on the spam folders, right?
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::UnloadAccounts()
-{
+nsMsgAccountManager::UnloadAccounts() {
   // release the default account
-  m_defaultAccount=nullptr;
+  m_defaultAccount = nullptr;
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
-    nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
-    if (!server)
-      continue;
+    nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
+    if (!server) continue;
     nsresult rv;
     NotifyServerUnloaded(server);
 
     nsCOMPtr<nsIMsgFolder> rootFolder;
     rv = server->GetRootFolder(getter_AddRefs(rootFolder));
     if (NS_SUCCEEDED(rv)) {
       removeListenersFromFolder(rootFolder);
 
       rootFolder->Shutdown(true);
     }
   }
 
-  m_accounts.Clear();          // will release all elements
+  m_accounts.Clear();  // will release all elements
   m_identities.Clear();
   m_incomingServers.Clear();
   mAccountKeyList.Truncate();
-  SetLastServerFound(nullptr, EmptyCString(), EmptyCString(), 0, EmptyCString());
-
-  if (m_accountsLoaded)
-  {
+  SetLastServerFound(nullptr, EmptyCString(), EmptyCString(), 0,
+                     EmptyCString());
+
+  if (m_accountsLoaded) {
     nsCOMPtr<nsIMsgMailSession> mailSession =
-      do_GetService(NS_MSGMAILSESSION_CONTRACTID);
-    if (mailSession)
-      mailSession->RemoveFolderListener(this);
+        do_GetService(NS_MSGMAILSESSION_CONTRACTID);
+    if (mailSession) mailSession->RemoveFolderListener(this);
     m_accountsLoaded = false;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::ShutdownServers()
-{
+nsMsgAccountManager::ShutdownServers() {
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
-    nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
-    if (server)
-      server->Shutdown();
+    nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
+    if (server) server->Shutdown();
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::CloseCachedConnections()
-{
+nsMsgAccountManager::CloseCachedConnections() {
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
-    nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
-    if (server)
-      server->CloseCachedConnections();
+    nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
+    if (server) server->CloseCachedConnections();
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::CleanupOnExit()
-{
+nsMsgAccountManager::CleanupOnExit() {
   // This can get called multiple times, and potentially re-entrantly.
   // So add some protection against that.
-  if (m_shutdownInProgress)
-    return NS_OK;
+  if (m_shutdownInProgress) return NS_OK;
 
   m_shutdownInProgress = true;
 
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
-    nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
+    nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
 
     bool emptyTrashOnExit = false;
     bool cleanupInboxOnExit = false;
     nsresult rv;
 
-    if (WeAreOffline())
-      break;
-
-    if (!server)
-      continue;
+    if (WeAreOffline()) break;
+
+    if (!server) continue;
 
     server->GetEmptyTrashOnExit(&emptyTrashOnExit);
-    nsCOMPtr <nsIImapIncomingServer> imapserver = do_QueryInterface(server);
-    if (imapserver)
-    {
+    nsCOMPtr<nsIImapIncomingServer> imapserver = do_QueryInterface(server);
+    if (imapserver) {
       imapserver->GetCleanupInboxOnExit(&cleanupInboxOnExit);
       imapserver->SetShuttingDown(true);
     }
-    if (emptyTrashOnExit || cleanupInboxOnExit)
-    {
+    if (emptyTrashOnExit || cleanupInboxOnExit) {
       nsCOMPtr<nsIMsgFolder> root;
       server->GetRootFolder(getter_AddRefs(root));
       nsCString type;
       server->GetType(type);
-      if (root)
-      {
+      if (root) {
         nsString passwd;
         bool serverRequiresPasswordForAuthentication = true;
         bool isImap = type.EqualsLiteral("imap");
-        if (isImap)
-        {
-          server->GetServerRequiresPasswordForBiff(&serverRequiresPasswordForAuthentication);
+        if (isImap) {
+          server->GetServerRequiresPasswordForBiff(
+              &serverRequiresPasswordForAuthentication);
           server->GetPassword(passwd);
         }
-        if (!isImap || (isImap && (!serverRequiresPasswordForAuthentication || !passwd.IsEmpty())))
-        {
+        if (!isImap || (isImap && (!serverRequiresPasswordForAuthentication ||
+                                   !passwd.IsEmpty()))) {
           nsCOMPtr<nsIUrlListener> urlListener;
           nsCOMPtr<nsIMsgAccountManager> accountManager =
-                   do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-          if (NS_FAILED(rv))
-            continue;
-
-          if (isImap)
-            urlListener = do_QueryInterface(accountManager, &rv);
-
-          if (isImap && cleanupInboxOnExit)
-          {
+              do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+          if (NS_FAILED(rv)) continue;
+
+          if (isImap) urlListener = do_QueryInterface(accountManager, &rv);
+
+          if (isImap && cleanupInboxOnExit) {
             nsCOMPtr<nsISimpleEnumerator> enumerator;
             rv = root->GetSubFolders(getter_AddRefs(enumerator));
-            if (NS_SUCCEEDED(rv))
-            {
+            if (NS_SUCCEEDED(rv)) {
               bool hasMore;
               while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) &&
-                     hasMore)
-              {
+                     hasMore) {
                 nsCOMPtr<nsISupports> item;
                 enumerator->GetNext(getter_AddRefs(item));
 
                 nsCOMPtr<nsIMsgFolder> inboxFolder(do_QueryInterface(item));
-                if (!inboxFolder)
-                  continue;
+                if (!inboxFolder) continue;
 
                 uint32_t flags;
                 inboxFolder->GetFlags(&flags);
-                if (flags & nsMsgFolderFlags::Inbox)
-                {
-                  rv = inboxFolder->Compact(urlListener, nullptr /* msgwindow */);
+                if (flags & nsMsgFolderFlags::Inbox) {
+                  rv = inboxFolder->Compact(urlListener,
+                                            nullptr /* msgwindow */);
                   if (NS_SUCCEEDED(rv))
                     accountManager->SetFolderDoingCleanupInbox(inboxFolder);
                   break;
                 }
               }
             }
           }
 
-          if (emptyTrashOnExit)
-          {
+          if (emptyTrashOnExit) {
             rv = root->EmptyTrash(nullptr, urlListener);
             if (isImap && NS_SUCCEEDED(rv))
               accountManager->SetFolderDoingEmptyTrash(root);
           }
 
-          if (isImap && urlListener)
-          {
+          if (isImap && urlListener) {
             nsCOMPtr<nsIThread> thread(do_GetCurrentThread());
 
             bool inProgress = false;
-            if (cleanupInboxOnExit)
-            {
-              int32_t loopCount = 0; // used to break out after 5 seconds
+            if (cleanupInboxOnExit) {
+              int32_t loopCount = 0;  // used to break out after 5 seconds
               accountManager->GetCleanupInboxInProgress(&inProgress);
-              while (inProgress && loopCount++ < 5000)
-              {
+              while (inProgress && loopCount++ < 5000) {
                 accountManager->GetCleanupInboxInProgress(&inProgress);
                 PR_CEnterMonitor(root);
                 PR_CWait(root, PR_MicrosecondsToInterval(1000UL));
                 PR_CExitMonitor(root);
-                NS_ProcessPendingEvents(thread, PR_MicrosecondsToInterval(1000UL));
+                NS_ProcessPendingEvents(thread,
+                                        PR_MicrosecondsToInterval(1000UL));
               }
             }
-            if (emptyTrashOnExit)
-            {
+            if (emptyTrashOnExit) {
               accountManager->GetEmptyTrashInProgress(&inProgress);
               int32_t loopCount = 0;
-              while (inProgress && loopCount++ < 5000)
-              {
+              while (inProgress && loopCount++ < 5000) {
                 accountManager->GetEmptyTrashInProgress(&inProgress);
                 PR_CEnterMonitor(root);
                 PR_CWait(root, PR_MicrosecondsToInterval(1000UL));
                 PR_CExitMonitor(root);
-                NS_ProcessPendingEvents(thread, PR_MicrosecondsToInterval(1000UL));
+                NS_ProcessPendingEvents(thread,
+                                        PR_MicrosecondsToInterval(1000UL));
               }
             }
           }
         }
       }
     }
   }
 
   // Try to do this early on in the shutdown process before
   // necko shuts itself down.
   CloseCachedConnections();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::WriteToFolderCache(nsIMsgFolderCache *folderCache)
-{
+nsMsgAccountManager::WriteToFolderCache(nsIMsgFolderCache *folderCache) {
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
     iter.Data()->WriteToFolderCache(folderCache);
   }
   return folderCache ? folderCache->Close() : NS_ERROR_FAILURE;
 }
 
-nsresult
-nsMsgAccountManager::createKeyedAccount(const nsCString& key,
-                                        nsIMsgAccount ** aAccount)
-{
-
+nsresult nsMsgAccountManager::createKeyedAccount(const nsCString &key,
+                                                 nsIMsgAccount **aAccount) {
   nsresult rv;
   nsCOMPtr<nsIMsgAccount> account = do_CreateInstance(kMsgAccountCID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   account->SetKey(key);
 
   m_accounts.AppendElement(account);
 
@@ -1730,816 +1586,747 @@ nsMsgAccountManager::createKeyedAccount(
   }
 
   m_prefs->SetCharPref(PREF_MAIL_ACCOUNTMANAGER_ACCOUNTS, mAccountKeyList);
   account.forget(aAccount);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::CreateAccount(nsIMsgAccount **_retval)
-{
+nsMsgAccountManager::CreateAccount(nsIMsgAccount **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
 
   nsAutoCString key;
   getUniqueAccountKey(key);
 
   return createKeyedAccount(key, _retval);
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetAccount(const nsACString& aKey, nsIMsgAccount **aAccount)
-{
+nsMsgAccountManager::GetAccount(const nsACString &aKey,
+                                nsIMsgAccount **aAccount) {
   NS_ENSURE_ARG_POINTER(aAccount);
   *aAccount = nullptr;
 
-  for (uint32_t i = 0; i < m_accounts.Length(); ++i)
-  {
+  for (uint32_t i = 0; i < m_accounts.Length(); ++i) {
     nsCOMPtr<nsIMsgAccount> account(m_accounts[i]);
     nsCString key;
     account->GetKey(key);
-    if (key.Equals(aKey))
-    {
+    if (key.Equals(aKey)) {
       account.forget(aAccount);
       break;
     }
   }
 
   // If not found, create on demand.
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::FindServerIndex(nsIMsgIncomingServer* server, int32_t* result)
-{
+nsMsgAccountManager::FindServerIndex(nsIMsgIncomingServer *server,
+                                     int32_t *result) {
   NS_ENSURE_ARG_POINTER(server);
   NS_ENSURE_ARG_POINTER(result);
 
   nsCString key;
   nsresult rv = server->GetKey(key);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // do this by account because the account list is in order
   uint32_t i;
-  for (i = 0; i < m_accounts.Length(); ++i)
-  {
+  for (i = 0; i < m_accounts.Length(); ++i) {
     nsCOMPtr<nsIMsgIncomingServer> server;
     rv = m_accounts[i]->GetIncomingServer(getter_AddRefs(server));
-    if (!server || NS_FAILED(rv))
-      continue;
+    if (!server || NS_FAILED(rv)) continue;
 
     nsCString serverKey;
     rv = server->GetKey(serverKey);
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     // stop when found,
     // index will be set to the current index
-    if (serverKey.Equals(key))
-      break;
+    if (serverKey.Equals(key)) break;
   }
 
   // Even if the search failed, we can return index.
   // This means that all servers not in the array return an index higher
   // than all "registered" servers.
   *result = i;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::AddIncomingServerListener(nsIIncomingServerListener *serverListener)
-{
+NS_IMETHODIMP nsMsgAccountManager::AddIncomingServerListener(
+    nsIIncomingServerListener *serverListener) {
   m_incomingServerListeners.AppendObject(serverListener);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::RemoveIncomingServerListener(nsIIncomingServerListener *serverListener)
-{
+NS_IMETHODIMP nsMsgAccountManager::RemoveIncomingServerListener(
+    nsIIncomingServerListener *serverListener) {
   m_incomingServerListeners.RemoveObject(serverListener);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::NotifyServerLoaded(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgAccountManager::NotifyServerLoaded(
+    nsIMsgIncomingServer *server) {
   int32_t count = m_incomingServerListeners.Count();
-  for(int32_t i = 0; i < count; i++)
-  {
-    nsIIncomingServerListener* listener = m_incomingServerListeners[i];
+  for (int32_t i = 0; i < count; i++) {
+    nsIIncomingServerListener *listener = m_incomingServerListeners[i];
     listener->OnServerLoaded(server);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::NotifyServerUnloaded(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgAccountManager::NotifyServerUnloaded(
+    nsIMsgIncomingServer *server) {
   NS_ENSURE_ARG_POINTER(server);
 
   int32_t count = m_incomingServerListeners.Count();
-  server->SetFilterList(nullptr); // clear this to cut shutdown leaks. we are always passing valid non-null server here.
-
-  for(int32_t i = 0; i < count; i++)
-  {
-    nsIIncomingServerListener* listener = m_incomingServerListeners[i];
+  // Clear this to cut shutdown leaks. We are always passing valid non-null
+  // server here.
+  server->SetFilterList(nullptr);
+
+  for (int32_t i = 0; i < count; i++) {
+    nsIIncomingServerListener *listener = m_incomingServerListeners[i];
     listener->OnServerUnloaded(server);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::NotifyServerChanged(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgAccountManager::NotifyServerChanged(
+    nsIMsgIncomingServer *server) {
   int32_t count = m_incomingServerListeners.Count();
-  for(int32_t i = 0; i < count; i++)
-  {
-    nsIIncomingServerListener* listener = m_incomingServerListeners[i];
+  for (int32_t i = 0; i < count; i++) {
+    nsIIncomingServerListener *listener = m_incomingServerListeners[i];
     listener->OnServerChanged(server);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::FindServerByURI(nsIURI *aURI, bool aRealFlag,
-                                nsIMsgIncomingServer** aResult)
-{
+                                     nsIMsgIncomingServer **aResult) {
   NS_ENSURE_ARG_POINTER(aURI);
 
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get username and hostname and port so we can get the server
   nsAutoCString username;
   nsAutoCString escapedUsername;
   rv = aURI->GetUserPass(escapedUsername);
   if (NS_SUCCEEDED(rv) && !escapedUsername.IsEmpty())
-    MsgUnescapeString(escapedUsername, 0,  username);
+    MsgUnescapeString(escapedUsername, 0, username);
 
   nsAutoCString hostname;
   nsAutoCString escapedHostname;
   rv = aURI->GetHost(escapedHostname);
   if (NS_SUCCEEDED(rv) && !escapedHostname.IsEmpty())
     MsgUnescapeString(escapedHostname, 0, hostname);
 
   nsAutoCString type;
   rv = aURI->GetScheme(type);
-  if (NS_SUCCEEDED(rv) && !type.IsEmpty())
-  {
+  if (NS_SUCCEEDED(rv) && !type.IsEmpty()) {
     // now modify type if pop or news
-    if (type.EqualsLiteral("pop"))
-      type.AssignLiteral("pop3");
+    if (type.EqualsLiteral("pop")) type.AssignLiteral("pop3");
     // we use "nntp" in the server list so translate it here.
     else if (type.EqualsLiteral("news"))
       type.AssignLiteral("nntp");
     // we use "any" as the wildcard type.
     else if (type.EqualsLiteral("any"))
       type.Truncate();
   }
 
   int32_t port = 0;
   // check the port of the scheme is not 'none' or blank
-  if (!(type.EqualsLiteral("none") || type.IsEmpty()))
-  {
+  if (!(type.EqualsLiteral("none") || type.IsEmpty())) {
     rv = aURI->GetPort(&port);
     // Set the port to zero if we got a -1 (use default)
-    if (NS_SUCCEEDED(rv) && (port == -1))
-      port = 0;
+    if (NS_SUCCEEDED(rv) && (port == -1)) port = 0;
   }
 
   return findServerInternal(username, hostname, type, port, aRealFlag, aResult);
 }
 
-nsresult
-nsMsgAccountManager::findServerInternal(const nsACString& username,
-                                        const nsACString& hostname,
-                                        const nsACString& type,
-                                        int32_t port,
-                                        bool aRealFlag,
-                                        nsIMsgIncomingServer** aResult)
-{
+nsresult nsMsgAccountManager::findServerInternal(
+    const nsACString &username, const nsACString &hostname,
+    const nsACString &type, int32_t port, bool aRealFlag,
+    nsIMsgIncomingServer **aResult) {
   // If 'aRealFlag' is set then we want to scan all existing accounts
   // to make sure there's no duplicate including those whose host and/or
   // user names have been changed.
-  if (!aRealFlag &&
-      (m_lastFindServerUserName.Equals(username)) &&
+  if (!aRealFlag && (m_lastFindServerUserName.Equals(username)) &&
       (m_lastFindServerHostName.Equals(hostname)) &&
-      (m_lastFindServerType.Equals(type)) &&
-      (m_lastFindServerPort == port) &&
-      m_lastFindServerResult)
-  {
+      (m_lastFindServerType.Equals(type)) && (m_lastFindServerPort == port) &&
+      m_lastFindServerResult) {
     NS_ADDREF(*aResult = m_lastFindServerResult);
     return NS_OK;
   }
 
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
     // Find matching server by user+host+type+port.
-    nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
-
-    if (!server)
-      continue;
+    nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
+
+    if (!server) continue;
 
     nsresult rv;
     nsCString thisHostname;
     if (aRealFlag)
       rv = server->GetRealHostName(thisHostname);
     else
       rv = server->GetHostName(thisHostname);
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     nsCString thisUsername;
     if (aRealFlag)
       rv = server->GetRealUsername(thisUsername);
     else
       rv = server->GetUsername(thisUsername);
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     nsCString thisType;
     rv = server->GetType(thisType);
-    if (NS_FAILED(rv))
-      continue;
-
-    int32_t thisPort = -1; // use the default port identifier
+    if (NS_FAILED(rv)) continue;
+
+    int32_t thisPort = -1;  // use the default port identifier
     // Don't try and get a port for the 'none' scheme
-    if (!thisType.EqualsLiteral("none"))
-    {
+    if (!thisType.EqualsLiteral("none")) {
       rv = server->GetPort(&thisPort);
       if (NS_FAILED(rv)) {
         continue;
       }
     }
 
-    // treat "" as a wild card, so if the caller passed in "" for the desired attribute
-    // treat it as a match
+    // treat "" as a wild card, so if the caller passed in "" for the desired
+    // attribute treat it as a match
     if ((type.IsEmpty() || thisType.Equals(type)) &&
-        (hostname.IsEmpty() || thisHostname.Equals(hostname, nsCaseInsensitiveCStringComparator())) &&
+        (hostname.IsEmpty() ||
+         thisHostname.Equals(hostname, nsCaseInsensitiveCStringComparator())) &&
         (!(port != 0) || (port == thisPort)) &&
-        (username.IsEmpty() || thisUsername.Equals(username)))
-    {
+        (username.IsEmpty() || thisUsername.Equals(username))) {
       // stop on first find; cache for next time
       if (!aRealFlag)
         SetLastServerFound(server, hostname, username, port, type);
 
       NS_ADDREF(*aResult = server);  // Was populated from member variable.
       return NS_OK;
     }
   }
 
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::FindServer(const nsACString& username,
-                                const nsACString& hostname,
-                                const nsACString& type,
-                                nsIMsgIncomingServer** aResult)
-{
+nsMsgAccountManager::FindServer(const nsACString &username,
+                                const nsACString &hostname,
+                                const nsACString &type,
+                                nsIMsgIncomingServer **aResult) {
   return findServerInternal(username, hostname, type, 0, false, aResult);
 }
 
 // Interface called by UI js only (always return true).
 NS_IMETHODIMP
-nsMsgAccountManager::FindRealServer(const nsACString& username,
-                                    const nsACString& hostname,
-                                    const nsACString& type,
-                                    int32_t port,
-                                    nsIMsgIncomingServer** aResult)
-{
+nsMsgAccountManager::FindRealServer(const nsACString &username,
+                                    const nsACString &hostname,
+                                    const nsACString &type, int32_t port,
+                                    nsIMsgIncomingServer **aResult) {
   *aResult = nullptr;
   findServerInternal(username, hostname, type, port, true, aResult);
   return NS_OK;
 }
 
-void
-nsMsgAccountManager::findAccountByServerKey(const nsCString &aKey,
-                                            nsIMsgAccount **aResult)
-{
+void nsMsgAccountManager::findAccountByServerKey(const nsCString &aKey,
+                                                 nsIMsgAccount **aResult) {
   *aResult = nullptr;
 
-  for (uint32_t i = 0; i < m_accounts.Length(); ++i)
-  {
+  for (uint32_t i = 0; i < m_accounts.Length(); ++i) {
     nsCOMPtr<nsIMsgIncomingServer> server;
     nsresult rv = m_accounts[i]->GetIncomingServer(getter_AddRefs(server));
-    if (!server || NS_FAILED(rv))
-      continue;
+    if (!server || NS_FAILED(rv)) continue;
 
     nsCString key;
     rv = server->GetKey(key);
-    if (NS_FAILED(rv))
-      continue;
+    if (NS_FAILED(rv)) continue;
 
     // if the keys are equal, the servers are equal
-    if (key.Equals(aKey))
-    {
+    if (key.Equals(aKey)) {
       NS_ADDREF(*aResult = m_accounts[i]);
-      break; // stop on first found account
+      break;  // stop on first found account
     }
   }
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::FindAccountForServer(nsIMsgIncomingServer *server,
-                                            nsIMsgAccount **aResult)
-{
+                                          nsIMsgAccount **aResult) {
   NS_ENSURE_ARG_POINTER(aResult);
 
-  if (!server)
-  {
+  if (!server) {
     (*aResult) = nullptr;
     return NS_OK;
   }
 
   nsresult rv;
 
   nsCString key;
   rv = server->GetKey(key);
   NS_ENSURE_SUCCESS(rv, rv);
 
   findAccountByServerKey(key, aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetFirstIdentityForServer(nsIMsgIncomingServer *aServer, nsIMsgIdentity **aIdentity)
-{
+nsMsgAccountManager::GetFirstIdentityForServer(nsIMsgIncomingServer *aServer,
+                                               nsIMsgIdentity **aIdentity) {
   NS_ENSURE_ARG_POINTER(aServer);
   NS_ENSURE_ARG_POINTER(aIdentity);
 
   nsCOMPtr<nsIArray> identities;
   nsresult rv = GetIdentitiesForServer(aServer, getter_AddRefs(identities));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // not all servers have identities
   // for example, Local Folders
   uint32_t numIdentities;
   rv = identities->GetLength(&numIdentities);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (numIdentities > 0)
-  {
+  if (numIdentities > 0) {
     nsCOMPtr<nsIMsgIdentity> identity(do_QueryElementAt(identities, 0, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     identity.forget(aIdentity);
-  }
-  else
+  } else
     *aIdentity = nullptr;
   return rv;
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::GetIdentitiesForServer(nsIMsgIncomingServer *server,
-                                            nsIArray **_retval)
-{
+                                            nsIArray **_retval) {
   NS_ENSURE_ARG_POINTER(server);
   NS_ENSURE_ARG_POINTER(_retval);
   nsresult rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMutableArray> identities(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  nsCOMPtr<nsIMutableArray> identities(
+      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString serverKey;
   rv = server->GetKey(serverKey);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  for (uint32_t i = 0; i < m_accounts.Length(); ++i)
-  {
+  for (uint32_t i = 0; i < m_accounts.Length(); ++i) {
     nsCOMPtr<nsIMsgAccount> account(m_accounts[i]);
 
     nsCOMPtr<nsIMsgIncomingServer> thisServer;
     rv = account->GetIncomingServer(getter_AddRefs(thisServer));
-    if (NS_FAILED(rv) || !thisServer)
-      continue;
+    if (NS_FAILED(rv) || !thisServer) continue;
 
     nsAutoCString thisServerKey;
     rv = thisServer->GetKey(thisServerKey);
-    if (serverKey.Equals(thisServerKey))
-    {
+    if (serverKey.Equals(thisServerKey)) {
       nsCOMPtr<nsIArray> theseIdentities;
       rv = account->GetIdentities(getter_AddRefs(theseIdentities));
-      if (NS_SUCCEEDED(rv))
-      {
+      if (NS_SUCCEEDED(rv)) {
         uint32_t theseLength;
         rv = theseIdentities->GetLength(&theseLength);
-        if (NS_SUCCEEDED(rv))
-        {
-          for (uint32_t j = 0; j < theseLength; ++j)
-          {
-            nsCOMPtr<nsISupports> id(do_QueryElementAt(theseIdentities, j, &rv));
-            if (NS_SUCCEEDED(rv))
-              identities->AppendElement(id);
+        if (NS_SUCCEEDED(rv)) {
+          for (uint32_t j = 0; j < theseLength; ++j) {
+            nsCOMPtr<nsISupports> id(
+                do_QueryElementAt(theseIdentities, j, &rv));
+            if (NS_SUCCEEDED(rv)) identities->AppendElement(id);
           }
         }
       }
     }
   }
 
   identities.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::GetServersForIdentity(nsIMsgIdentity *aIdentity,
-                                           nsIArray **_retval)
-{
+                                           nsIArray **_retval) {
   NS_ENSURE_ARG_POINTER(aIdentity);
 
   nsresult rv;
   rv = LoadAccounts();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMutableArray> servers(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  nsCOMPtr<nsIMutableArray> servers(
+      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  for (uint32_t i = 0; i < m_accounts.Length(); ++i)
-  {
+  for (uint32_t i = 0; i < m_accounts.Length(); ++i) {
     nsCOMPtr<nsIArray> identities;
     if (NS_FAILED(m_accounts[i]->GetIdentities(getter_AddRefs(identities))))
       continue;
 
     uint32_t idCount = 0;
-    if (NS_FAILED(identities->GetLength(&idCount)))
-      continue;
+    if (NS_FAILED(identities->GetLength(&idCount))) continue;
 
     uint32_t id;
     nsCString identityKey;
     rv = aIdentity->GetKey(identityKey);
-    for (id = 0; id < idCount; id++)
-    {
-      nsCOMPtr<nsIMsgIdentity> thisIdentity(do_QueryElementAt(identities, id, &rv));
-      if (NS_SUCCEEDED(rv))
-      {
+    for (id = 0; id < idCount; id++) {
+      nsCOMPtr<nsIMsgIdentity> thisIdentity(
+          do_QueryElementAt(identities, id, &rv));
+      if (NS_SUCCEEDED(rv)) {
         nsCString thisIdentityKey;
         rv = thisIdentity->GetKey(thisIdentityKey);
 
-        if (NS_SUCCEEDED(rv) && identityKey.Equals(thisIdentityKey))
-        {
+        if (NS_SUCCEEDED(rv) && identityKey.Equals(thisIdentityKey)) {
           nsCOMPtr<nsIMsgIncomingServer> thisServer;
           rv = m_accounts[i]->GetIncomingServer(getter_AddRefs(thisServer));
-          if (thisServer && NS_SUCCEEDED(rv))
-          {
+          if (thisServer && NS_SUCCEEDED(rv)) {
             servers->AppendElement(thisServer);
             break;
           }
         }
       }
     }
   }
   servers.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::AddRootFolderListener(nsIFolderListener *aListener)
-{
+nsMsgAccountManager::AddRootFolderListener(nsIFolderListener *aListener) {
   NS_ENSURE_TRUE(aListener, NS_OK);
   mFolderListeners.AppendElement(aListener);
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
     nsCOMPtr<nsIMsgFolder> rootFolder;
     nsresult rv = iter.Data()->GetRootFolder(getter_AddRefs(rootFolder));
     if (NS_FAILED(rv)) {
       continue;
     }
     rv = rootFolder->AddFolderListener(aListener);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::RemoveRootFolderListener(nsIFolderListener *aListener)
-{
+nsMsgAccountManager::RemoveRootFolderListener(nsIFolderListener *aListener) {
   NS_ENSURE_TRUE(aListener, NS_OK);
   mFolderListeners.RemoveElement(aListener);
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
     nsCOMPtr<nsIMsgFolder> rootFolder;
     nsresult rv = iter.Data()->GetRootFolder(getter_AddRefs(rootFolder));
     if (NS_FAILED(rv)) {
       continue;
     }
     rv = rootFolder->RemoveFolderListener(aListener);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::SetLocalFoldersServer(nsIMsgIncomingServer *aServer)
-{
+NS_IMETHODIMP nsMsgAccountManager::SetLocalFoldersServer(
+    nsIMsgIncomingServer *aServer) {
   NS_ENSURE_ARG_POINTER(aServer);
   nsCString key;
   nsresult rv = aServer->GetKey(key);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return m_prefs->SetCharPref(PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER, key);
 }
 
-NS_IMETHODIMP nsMsgAccountManager::GetLocalFoldersServer(nsIMsgIncomingServer **aServer)
-{
+NS_IMETHODIMP nsMsgAccountManager::GetLocalFoldersServer(
+    nsIMsgIncomingServer **aServer) {
   NS_ENSURE_ARG_POINTER(aServer);
 
   nsCString serverKey;
 
-  nsresult rv = m_prefs->GetCharPref(PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER, serverKey);
-
-  if (NS_SUCCEEDED(rv) && !serverKey.IsEmpty())
-  {
+  nsresult rv = m_prefs->GetCharPref(
+      PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER, serverKey);
+
+  if (NS_SUCCEEDED(rv) && !serverKey.IsEmpty()) {
     rv = GetIncomingServer(serverKey, aServer);
-    if (NS_SUCCEEDED(rv))
-      return rv;
+    if (NS_SUCCEEDED(rv)) return rv;
     // otherwise, we're going to fall through to looking for an existing local
     // folders account, because now we fail creating one if one already exists.
   }
 
   // try ("nobody","Local Folders","none"), and work down to any "none" server.
-  rv = FindServer(NS_LITERAL_CSTRING("nobody"), NS_LITERAL_CSTRING("Local Folders"),
+  rv = FindServer(NS_LITERAL_CSTRING("nobody"),
+                  NS_LITERAL_CSTRING("Local Folders"),
                   NS_LITERAL_CSTRING("none"), aServer);
-  if (NS_FAILED(rv) || !*aServer)
-  {
-      rv = FindServer(NS_LITERAL_CSTRING("nobody"), EmptyCString(), NS_LITERAL_CSTRING("none"), aServer);
+  if (NS_FAILED(rv) || !*aServer) {
+    rv = FindServer(NS_LITERAL_CSTRING("nobody"), EmptyCString(),
+                    NS_LITERAL_CSTRING("none"), aServer);
+    if (NS_FAILED(rv) || !*aServer) {
+      rv = FindServer(EmptyCString(), NS_LITERAL_CSTRING("Local Folders"),
+                      NS_LITERAL_CSTRING("none"), aServer);
       if (NS_FAILED(rv) || !*aServer)
-      {
-          rv = FindServer(EmptyCString(), NS_LITERAL_CSTRING("Local Folders"),
-                          NS_LITERAL_CSTRING("none"), aServer);
-          if (NS_FAILED(rv) || !*aServer)
-              rv = FindServer(EmptyCString(), EmptyCString(), NS_LITERAL_CSTRING("none"), aServer);
-      }
+        rv = FindServer(EmptyCString(), EmptyCString(),
+                        NS_LITERAL_CSTRING("none"), aServer);
+    }
   }
 
   NS_ENSURE_SUCCESS(rv, rv);
-  if (!*aServer)
-    return NS_ERROR_FAILURE;
+  if (!*aServer) return NS_ERROR_FAILURE;
 
   // we don't want the Smart Mailboxes server to be the local server.
   bool hidden;
   (*aServer)->GetHidden(&hidden);
-  if (hidden)
-    return NS_ERROR_FAILURE;
+  if (hidden) return NS_ERROR_FAILURE;
 
   rv = SetLocalFoldersServer(*aServer);
   return rv;
 }
 
-nsresult nsMsgAccountManager::GetLocalFoldersPrettyName(nsString &localFoldersName)
-{
+nsresult nsMsgAccountManager::GetLocalFoldersPrettyName(
+    nsString &localFoldersName) {
   // we don't want "nobody at Local Folders" to show up in the
   // folder pane, so we set the pretty name to a localized "Local Folders"
   nsCOMPtr<nsIStringBundle> bundle;
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> sBundleService =
-    mozilla::services::GetStringBundleService();
+      mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
 
-  rv = sBundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
-                                    getter_AddRefs(bundle));
+  rv = sBundleService->CreateBundle(
+      "chrome://messenger/locale/messenger.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return bundle->GetStringFromName("localFolders", localFoldersName);
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::CreateLocalMailAccount()
-{
+nsMsgAccountManager::CreateLocalMailAccount() {
   // create the server
   nsCOMPtr<nsIMsgIncomingServer> server;
-  nsresult rv = CreateIncomingServer(NS_LITERAL_CSTRING("nobody"),
-                            NS_LITERAL_CSTRING("Local Folders"),
-                            NS_LITERAL_CSTRING("none"), getter_AddRefs(server));
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsresult rv = CreateIncomingServer(
+      NS_LITERAL_CSTRING("nobody"), NS_LITERAL_CSTRING("Local Folders"),
+      NS_LITERAL_CSTRING("none"), getter_AddRefs(server));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsString localFoldersName;
   rv = GetLocalFoldersPrettyName(localFoldersName);
   NS_ENSURE_SUCCESS(rv, rv);
   server->SetPrettyName(localFoldersName);
 
   nsCOMPtr<nsINoIncomingServer> noServer;
   noServer = do_QueryInterface(server, &rv);
   if (NS_FAILED(rv)) return rv;
 
   // create the directory structure for old 4.x "Local Mail"
   // under <profile dir>/Mail/Local Folders or
   // <"mail.directory" pref>/Local Folders
-  nsCOMPtr <nsIFile> mailDir;
+  nsCOMPtr<nsIFile> mailDir;
   bool dirExists;
 
   // we want <profile>/Mail
   rv = NS_GetSpecialDirectory(NS_APP_MAIL_50_DIR, getter_AddRefs(mailDir));
   if (NS_FAILED(rv)) return rv;
 
   rv = mailDir->Exists(&dirExists);
   if (NS_SUCCEEDED(rv) && !dirExists)
     rv = mailDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
   if (NS_FAILED(rv)) return rv;
 
   // set the default local path for "none"
   rv = server->SetDefaultLocalPath(mailDir);
   if (NS_FAILED(rv)) return rv;
 
   // Create an account when valid server values are established.
-  // This will keep the status of accounts sane by avoiding the addition of incomplete accounts.
+  // This will keep the status of accounts sane by avoiding the addition of
+  // incomplete accounts.
   nsCOMPtr<nsIMsgAccount> account;
   rv = CreateAccount(getter_AddRefs(account));
   if (NS_FAILED(rv)) return rv;
 
   // notice, no identity for local mail
   // hook the server to the account
   // after we set the server's local path
   // (see bug #66018)
   account->SetIncomingServer(server);
 
   // remember this as the local folders server
   return SetLocalFoldersServer(server);
 }
 
-  // nsIUrlListener methods
+// nsIUrlListener methods
+
+NS_IMETHODIMP
+nsMsgAccountManager::OnStartRunningUrl(nsIURI *aUrl) { return NS_OK; }
 
 NS_IMETHODIMP
-nsMsgAccountManager::OnStartRunningUrl(nsIURI * aUrl)
-{
+nsMsgAccountManager::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode) {
+  if (aUrl) {
+    nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aUrl);
+    if (imapUrl) {
+      nsImapAction imapAction = nsIImapUrl::nsImapTest;
+      imapUrl->GetImapAction(&imapAction);
+      switch (imapAction) {
+        case nsIImapUrl::nsImapExpungeFolder:
+          if (m_folderDoingCleanupInbox) {
+            PR_CEnterMonitor(m_folderDoingCleanupInbox);
+            PR_CNotifyAll(m_folderDoingCleanupInbox);
+            m_cleanupInboxInProgress = false;
+            PR_CExitMonitor(m_folderDoingCleanupInbox);
+            m_folderDoingCleanupInbox = nullptr;  // reset to nullptr
+          }
+          break;
+        case nsIImapUrl::nsImapDeleteAllMsgs:
+          if (m_folderDoingEmptyTrash) {
+            PR_CEnterMonitor(m_folderDoingEmptyTrash);
+            PR_CNotifyAll(m_folderDoingEmptyTrash);
+            m_emptyTrashInProgress = false;
+            PR_CExitMonitor(m_folderDoingEmptyTrash);
+            m_folderDoingEmptyTrash = nullptr;  // reset to nullptr;
+          }
+          break;
+        default:
+          break;
+      }
+    }
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
-{
-  if (aUrl)
-  {
-    nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aUrl);
-    if (imapUrl)
-    {
-      nsImapAction imapAction = nsIImapUrl::nsImapTest;
-      imapUrl->GetImapAction(&imapAction);
-      switch(imapAction)
-      {
-        case nsIImapUrl::nsImapExpungeFolder:
-          if (m_folderDoingCleanupInbox)
-          {
-            PR_CEnterMonitor(m_folderDoingCleanupInbox);
-            PR_CNotifyAll(m_folderDoingCleanupInbox);
-            m_cleanupInboxInProgress = false;
-            PR_CExitMonitor(m_folderDoingCleanupInbox);
-            m_folderDoingCleanupInbox=nullptr;   //reset to nullptr
-          }
-          break;
-        case nsIImapUrl::nsImapDeleteAllMsgs:
-          if (m_folderDoingEmptyTrash)
-          {
-            PR_CEnterMonitor(m_folderDoingEmptyTrash);
-            PR_CNotifyAll(m_folderDoingEmptyTrash);
-            m_emptyTrashInProgress = false;
-            PR_CExitMonitor(m_folderDoingEmptyTrash);
-            m_folderDoingEmptyTrash = nullptr;  //reset to nullptr;
-          }
-          break;
-        default:
-          break;
-       }
-     }
-   }
-   return NS_OK;
-}
-
-NS_IMETHODIMP
-nsMsgAccountManager::SetFolderDoingEmptyTrash(nsIMsgFolder *folder)
-{
+nsMsgAccountManager::SetFolderDoingEmptyTrash(nsIMsgFolder *folder) {
   m_folderDoingEmptyTrash = folder;
   m_emptyTrashInProgress = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetEmptyTrashInProgress(bool *bVal)
-{
+nsMsgAccountManager::GetEmptyTrashInProgress(bool *bVal) {
   NS_ENSURE_ARG_POINTER(bVal);
   *bVal = m_emptyTrashInProgress;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::SetFolderDoingCleanupInbox(nsIMsgFolder *folder)
-{
+nsMsgAccountManager::SetFolderDoingCleanupInbox(nsIMsgFolder *folder) {
   m_folderDoingCleanupInbox = folder;
   m_cleanupInboxInProgress = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetCleanupInboxInProgress(bool *bVal)
-{
+nsMsgAccountManager::GetCleanupInboxInProgress(bool *bVal) {
   NS_ENSURE_ARG_POINTER(bVal);
   *bVal = m_cleanupInboxInProgress;
   return NS_OK;
 }
 
-void
-nsMsgAccountManager::SetLastServerFound(nsIMsgIncomingServer *server, const nsACString& hostname,
-                                        const nsACString& username, const int32_t port, const nsACString& type)
-{
+void nsMsgAccountManager::SetLastServerFound(nsIMsgIncomingServer *server,
+                                             const nsACString &hostname,
+                                             const nsACString &username,
+                                             const int32_t port,
+                                             const nsACString &type) {
   m_lastFindServerResult = server;
   m_lastFindServerHostName = hostname;
   m_lastFindServerUserName = username;
   m_lastFindServerPort = port;
   m_lastFindServerType = type;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::SaveAccountInfo()
-{
+nsMsgAccountManager::SaveAccountInfo() {
   nsresult rv;
   nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   return pref->SavePrefFile(nullptr);
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetChromePackageName(const nsACString& aExtensionName, nsACString& aChromePackageName)
-{
+nsMsgAccountManager::GetChromePackageName(const nsACString &aExtensionName,
+                                          nsACString &aChromePackageName) {
   nsresult rv;
-  nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsICategoryManager> catman =
+      do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsISimpleEnumerator> e;
-  rv = catman->EnumerateCategory(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS, getter_AddRefs(e));
-  if(NS_SUCCEEDED(rv) && e) {
+  rv = catman->EnumerateCategory(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS,
+                                 getter_AddRefs(e));
+  if (NS_SUCCEEDED(rv) && e) {
     while (true) {
       nsCOMPtr<nsISupports> supports;
       rv = e->GetNext(getter_AddRefs(supports));
       nsCOMPtr<nsISupportsCString> catEntry = do_QueryInterface(supports);
-      if (NS_FAILED(rv) || !catEntry)
-        break;
+      if (NS_FAILED(rv) || !catEntry) break;
 
       nsAutoCString entryString;
       rv = catEntry->GetData(entryString);
-      if (NS_FAILED(rv))
-         break;
+      if (NS_FAILED(rv)) break;
 
       nsCString contractidString;
-      rv = catman->GetCategoryEntry(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS, entryString,
-                                    contractidString);
-      if (NS_FAILED(rv))
-        break;
-
-      nsCOMPtr <nsIMsgAccountManagerExtension> extension = do_GetService(contractidString.get(), &rv);
-      if (NS_FAILED(rv) || !extension)
-        break;
+      rv = catman->GetCategoryEntry(MAILNEWS_ACCOUNTMANAGER_EXTENSIONS,
+                                    entryString, contractidString);
+      if (NS_FAILED(rv)) break;
+
+      nsCOMPtr<nsIMsgAccountManagerExtension> extension =
+          do_GetService(contractidString.get(), &rv);
+      if (NS_FAILED(rv) || !extension) break;
 
       nsCString name;
       rv = extension->GetName(name);
-      if (NS_FAILED(rv))
-        break;
+      if (NS_FAILED(rv)) break;
 
       if (name.Equals(aExtensionName))
         return extension->GetChromePackageName(aChromePackageName);
     }
   }
   return NS_ERROR_UNEXPECTED;
 }
 
-class VFChangeListenerEvent : public mozilla::Runnable
-{
-public:
+class VFChangeListenerEvent : public mozilla::Runnable {
+ public:
   VFChangeListenerEvent(VirtualFolderChangeListener *vfChangeListener,
                         nsIMsgFolder *virtFolder, nsIMsgDatabase *virtDB)
-    : mozilla::Runnable("VFChangeListenerEvent")
-    , mVFChangeListener(vfChangeListener), mFolder(virtFolder), mDB(virtDB)
-  {}
-
-  NS_IMETHOD Run()
-  {
-    if (mVFChangeListener)
-      mVFChangeListener->ProcessUpdateEvent(mFolder, mDB);
+      : mozilla::Runnable("VFChangeListenerEvent"),
+        mVFChangeListener(vfChangeListener),
+        mFolder(virtFolder),
+        mDB(virtDB) {}
+
+  NS_IMETHOD Run() {
+    if (mVFChangeListener) mVFChangeListener->ProcessUpdateEvent(mFolder, mDB);
     return NS_OK;
   }
 
-private:
+ private:
   RefPtr<VirtualFolderChangeListener> mVFChangeListener;
   nsCOMPtr<nsIMsgFolder> mFolder;
   nsCOMPtr<nsIMsgDatabase> mDB;
 };
 
 NS_IMPL_ISUPPORTS(VirtualFolderChangeListener, nsIDBChangeListener)
 
-VirtualFolderChangeListener::VirtualFolderChangeListener() :
-  m_searchOnMsgStatus(false), m_batchingEvents(false)
-{}
-
-nsresult VirtualFolderChangeListener::Init()
-{
-  nsCOMPtr <nsIMsgDatabase> msgDB;
-  nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
-
-  nsresult rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(msgDB));
-  if (NS_SUCCEEDED(rv) && msgDB)
-  {
+VirtualFolderChangeListener::VirtualFolderChangeListener()
+    : m_searchOnMsgStatus(false), m_batchingEvents(false) {}
+
+nsresult VirtualFolderChangeListener::Init() {
+  nsCOMPtr<nsIMsgDatabase> msgDB;
+  nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
+
+  nsresult rv = m_virtualFolder->GetDBFolderInfoAndDB(
+      getter_AddRefs(dbFolderInfo), getter_AddRefs(msgDB));
+  if (NS_SUCCEEDED(rv) && msgDB) {
     nsCString searchTermString;
     dbFolderInfo->GetCharProperty("searchStr", searchTermString);
-    nsCOMPtr<nsIMsgFilterService> filterService = do_GetService(NS_MSGFILTERSERVICE_CONTRACTID, &rv);
+    nsCOMPtr<nsIMsgFilterService> filterService =
+        do_GetService(NS_MSGFILTERSERVICE_CONTRACTID, &rv);
     nsCOMPtr<nsIMsgFilterList> filterList;
-    rv = filterService->GetTempFilterList(m_virtualFolder, getter_AddRefs(filterList));
+    rv = filterService->GetTempFilterList(m_virtualFolder,
+                                          getter_AddRefs(filterList));
     NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr <nsIMsgFilter> tempFilter;
-    filterList->CreateFilter(NS_LITERAL_STRING("temp"), getter_AddRefs(tempFilter));
+    nsCOMPtr<nsIMsgFilter> tempFilter;
+    filterList->CreateFilter(NS_LITERAL_STRING("temp"),
+                             getter_AddRefs(tempFilter));
     NS_ENSURE_SUCCESS(rv, rv);
     filterList->ParseCondition(tempFilter, searchTermString.get());
     NS_ENSURE_SUCCESS(rv, rv);
     m_searchSession = do_CreateInstance(NS_MSGSEARCHSESSION_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIMutableArray> searchTerms;
     rv = tempFilter->GetSearchTerms(getter_AddRefs(searchTerms));
@@ -2548,561 +2335,528 @@ nsresult VirtualFolderChangeListener::In
     // we add the search scope right before we match the header,
     // because we don't want the search scope caching the body input
     // stream, because that holds onto the mailbox file, breaking
     // compaction.
 
     // add each item in termsArray to the search session
     uint32_t numTerms;
     searchTerms->Count(&numTerms);
-    for (uint32_t i = 0; i < numTerms; i++)
-    {
+    for (uint32_t i = 0; i < numTerms; i++) {
       nsCOMPtr<nsIMsgSearchTerm> searchTerm(do_QueryElementAt(searchTerms, i));
       nsMsgSearchAttribValue attrib;
       searchTerm->GetAttrib(&attrib);
-      if (attrib == nsMsgSearchAttrib::MsgStatus)
-        m_searchOnMsgStatus = true;
+      if (attrib == nsMsgSearchAttrib::MsgStatus) m_searchOnMsgStatus = true;
       m_searchSession->AppendTerm(searchTerm);
     }
   }
   return rv;
 }
 
-  /**
-   * nsIDBChangeListener
-   */
+/**
+ * nsIDBChangeListener
+ */
 
 NS_IMETHODIMP
-VirtualFolderChangeListener::OnHdrPropertyChanged(nsIMsgDBHdr *aHdrChanged, bool aPreChange, uint32_t *aStatus,
-                                                 nsIDBChangeListener *aInstigator)
-{
+VirtualFolderChangeListener::OnHdrPropertyChanged(
+    nsIMsgDBHdr *aHdrChanged, bool aPreChange, uint32_t *aStatus,
+    nsIDBChangeListener *aInstigator) {
   const uint32_t kMatch = 0x1;
   const uint32_t kRead = 0x2;
   const uint32_t kNew = 0x4;
   NS_ENSURE_ARG_POINTER(aHdrChanged);
   NS_ENSURE_ARG_POINTER(aStatus);
 
   uint32_t flags;
   bool match;
   nsCOMPtr<nsIMsgDatabase> msgDB;
   nsresult rv = m_folderWatching->GetMsgDatabase(getter_AddRefs(msgDB));
   NS_ENSURE_SUCCESS(rv, rv);
   // we don't want any early returns from this function, until we've
   // called ClearScopes on the search session.
-  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail, m_folderWatching);
+  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail,
+                                m_folderWatching);
   rv = m_searchSession->MatchHdr(aHdrChanged, msgDB, &match);
   m_searchSession->ClearScopes();
   NS_ENSURE_SUCCESS(rv, rv);
   aHdrChanged->GetFlags(&flags);
 
-  if (aPreChange) // We're looking at the old header, save status
+  if (aPreChange)  // We're looking at the old header, save status
   {
     *aStatus = 0;
-    if (match)
-      *aStatus |= kMatch;
-    if (flags & nsMsgMessageFlags::Read)
-      *aStatus |= kRead;
-    if (flags & nsMsgMessageFlags::New)
-      *aStatus |= kNew;
+    if (match) *aStatus |= kMatch;
+    if (flags & nsMsgMessageFlags::Read) *aStatus |= kRead;
+    if (flags & nsMsgMessageFlags::New) *aStatus |= kNew;
     return NS_OK;
   }
 
   // This is the post change section where changes are detected
 
   bool wasMatch = *aStatus & kMatch;
-  if (!match && !wasMatch) // header not in virtual folder
+  if (!match && !wasMatch)  // header not in virtual folder
     return NS_OK;
 
   int32_t totalDelta = 0, unreadDelta = 0, newDelta = 0;
 
   if (match) {
     totalDelta++;
-    if (!(flags & nsMsgMessageFlags::Read))
-      unreadDelta++;
-    if (flags & nsMsgMessageFlags::New)
-      newDelta++;
+    if (!(flags & nsMsgMessageFlags::Read)) unreadDelta++;
+    if (flags & nsMsgMessageFlags::New) newDelta++;
   }
 
   if (wasMatch) {
     totalDelta--;
     if (!(*aStatus & kRead)) unreadDelta--;
     if (*aStatus & kNew) newDelta--;
   }
 
-  if ( !(unreadDelta || totalDelta || newDelta) )
-    return NS_OK;
+  if (!(unreadDelta || totalDelta || newDelta)) return NS_OK;
 
   nsCOMPtr<nsIMsgDatabase> virtDatabase;
   nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
   rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
-                        getter_AddRefs(virtDatabase));
+                                             getter_AddRefs(virtDatabase));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (unreadDelta)
-    dbFolderInfo->ChangeNumUnreadMessages(unreadDelta);
-
-  if (newDelta)
-  {
+  if (unreadDelta) dbFolderInfo->ChangeNumUnreadMessages(unreadDelta);
+
+  if (newDelta) {
     int32_t numNewMessages;
     m_virtualFolder->GetNumNewMessages(false, &numNewMessages);
     m_virtualFolder->SetNumNewMessages(numNewMessages + newDelta);
     m_virtualFolder->SetHasNewMessages(numNewMessages + newDelta > 0);
   }
 
-  if (totalDelta)
-  {
+  if (totalDelta) {
     dbFolderInfo->ChangeNumMessages(totalDelta);
     nsCString searchUri;
     m_virtualFolder->GetURI(searchUri);
     msgDB->UpdateHdrInCache(searchUri.get(), aHdrChanged, totalDelta == 1);
   }
 
-    PostUpdateEvent(m_virtualFolder, virtDatabase);
+  PostUpdateEvent(m_virtualFolder, virtDatabase);
 
   return NS_OK;
 }
 
-void VirtualFolderChangeListener::DecrementNewMsgCount()
-{
+void VirtualFolderChangeListener::DecrementNewMsgCount() {
   int32_t numNewMessages;
   m_virtualFolder->GetNumNewMessages(false, &numNewMessages);
-  if (numNewMessages > 0)
-    numNewMessages--;
+  if (numNewMessages > 0) numNewMessages--;
   m_virtualFolder->SetNumNewMessages(numNewMessages);
-  if (!numNewMessages)
-    m_virtualFolder->SetHasNewMessages(false);
+  if (!numNewMessages) m_virtualFolder->SetHasNewMessages(false);
 }
 
-NS_IMETHODIMP VirtualFolderChangeListener::OnHdrFlagsChanged(nsIMsgDBHdr *aHdrChanged, uint32_t aOldFlags, uint32_t aNewFlags, nsIDBChangeListener *aInstigator)
-{
-  nsCOMPtr <nsIMsgDatabase> msgDB;
+NS_IMETHODIMP VirtualFolderChangeListener::OnHdrFlagsChanged(
+    nsIMsgDBHdr *aHdrChanged, uint32_t aOldFlags, uint32_t aNewFlags,
+    nsIDBChangeListener *aInstigator) {
+  nsCOMPtr<nsIMsgDatabase> msgDB;
 
   nsresult rv = m_folderWatching->GetMsgDatabase(getter_AddRefs(msgDB));
   bool oldMatch = false, newMatch = false;
   // we don't want any early returns from this function, until we've
   // called ClearScopes 0n the search session.
-  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail, m_folderWatching);
+  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail,
+                                m_folderWatching);
   rv = m_searchSession->MatchHdr(aHdrChanged, msgDB, &newMatch);
-  if (NS_SUCCEEDED(rv) && m_searchOnMsgStatus)
-  {
+  if (NS_SUCCEEDED(rv) && m_searchOnMsgStatus) {
     // if status is a search criteria, check if the header matched before
     // it changed, in order to determine if we need to bump the counts.
     aHdrChanged->SetFlags(aOldFlags);
     rv = m_searchSession->MatchHdr(aHdrChanged, msgDB, &oldMatch);
-    aHdrChanged->SetFlags(aNewFlags); // restore new flags even on match failure.
-  }
-  else
+    // restore new flags even on match failure.
+    aHdrChanged->SetFlags(aNewFlags);
+  } else
     oldMatch = newMatch;
   m_searchSession->ClearScopes();
   NS_ENSURE_SUCCESS(rv, rv);
-  // we don't want to change the total counts if this virtual folder is open in a view,
-  // because we won't remove the header from view while it's open. On the other hand,
-  // it's hard to fix the count when the user clicks away to another folder, w/o re-running
-  // the search, or setting some sort of pending count change.
-  // Maybe this needs to be handled in the view code...the view could do the same calculation
-  // and also keep track of the counts changed. Then, when the view was closed, if it's a virtual
-  // folder, it could update the counts for the db.
-  if (oldMatch != newMatch || (oldMatch && (aOldFlags & nsMsgMessageFlags::Read) != (aNewFlags & nsMsgMessageFlags::Read)))
-  {
-    nsCOMPtr <nsIMsgDatabase> virtDatabase;
-    nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
-
-    rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
+  // we don't want to change the total counts if this virtual folder is open in
+  // a view, because we won't remove the header from view while it's open. On
+  // the other hand, it's hard to fix the count when the user clicks away to
+  // another folder, w/o re-running the search, or setting some sort of pending
+  // count change. Maybe this needs to be handled in the view code...the view
+  // could do the same calculation and also keep track of the counts changed.
+  // Then, when the view was closed, if it's a virtual folder, it could update
+  // the counts for the db.
+  if (oldMatch != newMatch ||
+      (oldMatch && (aOldFlags & nsMsgMessageFlags::Read) !=
+                       (aNewFlags & nsMsgMessageFlags::Read))) {
+    nsCOMPtr<nsIMsgDatabase> virtDatabase;
+    nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
+
+    rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
+                                               getter_AddRefs(virtDatabase));
     NS_ENSURE_SUCCESS(rv, rv);
-    int32_t totalDelta = 0,  unreadDelta = 0;
-    if (oldMatch != newMatch)
-    {
- //     bool isOpen = false;
-//      nsCOMPtr <nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID);
-//      if (mailSession && aFolder)
-//        mailSession->IsFolderOpenInWindow(m_virtualFolder, &isOpen);
-      // we can't remove headers that no longer match - but we might add headers that newly match, someday.
-//      if (!isOpen)
-        totalDelta = (oldMatch) ? -1 : 1;
+    int32_t totalDelta = 0, unreadDelta = 0;
+    if (oldMatch != newMatch) {
+      // bool isOpen = false;
+      // nsCOMPtr<nsIMsgMailSession> mailSession =
+      //     do_GetService(NS_MSGMAILSESSION_CONTRACTID);
+      // if (mailSession && aFolder)
+      //   mailSession->IsFolderOpenInWindow(m_virtualFolder, &isOpen);
+      // we can't remove headers that no longer match - but we might add headers
+      // that newly match, someday.
+      // if (!isOpen)
+      totalDelta = (oldMatch) ? -1 : 1;
     }
     bool msgHdrIsRead;
     aHdrChanged->GetIsRead(&msgHdrIsRead);
-    if (oldMatch == newMatch) // read flag changed state
+    if (oldMatch == newMatch)  // read flag changed state
       unreadDelta = (msgHdrIsRead) ? -1 : 1;
-    else if (oldMatch) // else header should removed
+    else if (oldMatch)  // else header should removed
       unreadDelta = (aOldFlags & nsMsgMessageFlags::Read) ? 0 : -1;
-    else               // header should be added
+    else  // header should be added
       unreadDelta = (aNewFlags & nsMsgMessageFlags::Read) ? 0 : 1;
-    if (unreadDelta)
-      dbFolderInfo->ChangeNumUnreadMessages(unreadDelta);
-    if (totalDelta)
-      dbFolderInfo->ChangeNumMessages(totalDelta);
+    if (unreadDelta) dbFolderInfo->ChangeNumUnreadMessages(unreadDelta);
+    if (totalDelta) dbFolderInfo->ChangeNumMessages(totalDelta);
     if (unreadDelta == -1 && aOldFlags & nsMsgMessageFlags::New)
       DecrementNewMsgCount();
 
-    if (totalDelta)
-    {
+    if (totalDelta) {
       nsCString searchUri;
       m_virtualFolder->GetURI(searchUri);
       msgDB->UpdateHdrInCache(searchUri.get(), aHdrChanged, totalDelta == 1);
     }
 
     PostUpdateEvent(m_virtualFolder, virtDatabase);
-  }
-  else if (oldMatch && (aOldFlags & nsMsgMessageFlags::New) &&
-           !(aNewFlags & nsMsgMessageFlags::New))
+  } else if (oldMatch && (aOldFlags & nsMsgMessageFlags::New) &&
+             !(aNewFlags & nsMsgMessageFlags::New))
     DecrementNewMsgCount();
 
   return rv;
 }
 
-NS_IMETHODIMP VirtualFolderChangeListener::OnHdrDeleted(nsIMsgDBHdr *aHdrDeleted, nsMsgKey aParentKey, int32_t aFlags, nsIDBChangeListener *aInstigator)
-{
-  nsCOMPtr <nsIMsgDatabase> msgDB;
+NS_IMETHODIMP VirtualFolderChangeListener::OnHdrDeleted(
+    nsIMsgDBHdr *aHdrDeleted, nsMsgKey aParentKey, int32_t aFlags,
+    nsIDBChangeListener *aInstigator) {
+  nsCOMPtr<nsIMsgDatabase> msgDB;
 
   nsresult rv = m_folderWatching->GetMsgDatabase(getter_AddRefs(msgDB));
   NS_ENSURE_SUCCESS(rv, rv);
   bool match = false;
-  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail, m_folderWatching);
+  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail,
+                                m_folderWatching);
   // Since the notifier went to the trouble of passing in the msg flags,
   // we should use them when doing the match.
   uint32_t msgFlags;
   aHdrDeleted->GetFlags(&msgFlags);
   aHdrDeleted->SetFlags(aFlags);
   rv = m_searchSession->MatchHdr(aHdrDeleted, msgDB, &match);
   aHdrDeleted->SetFlags(msgFlags);
   m_searchSession->ClearScopes();
-  if (match)
-  {
-    nsCOMPtr <nsIMsgDatabase> virtDatabase;
-    nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
-
-    rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
+  if (match) {
+    nsCOMPtr<nsIMsgDatabase> virtDatabase;
+    nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
+
+    rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
+                                               getter_AddRefs(virtDatabase));
     NS_ENSURE_SUCCESS(rv, rv);
     bool msgHdrIsRead;
     aHdrDeleted->GetIsRead(&msgHdrIsRead);
-    if (!msgHdrIsRead)
-      dbFolderInfo->ChangeNumUnreadMessages(-1);
+    if (!msgHdrIsRead) dbFolderInfo->ChangeNumUnreadMessages(-1);
     dbFolderInfo->ChangeNumMessages(-1);
-    if (aFlags & nsMsgMessageFlags::New)
-    {
+    if (aFlags & nsMsgMessageFlags::New) {
       int32_t numNewMessages;
       m_virtualFolder->GetNumNewMessages(false, &numNewMessages);
       m_virtualFolder->SetNumNewMessages(numNewMessages - 1);
-      if (numNewMessages == 1)
-        m_virtualFolder->SetHasNewMessages(false);
+      if (numNewMessages == 1) m_virtualFolder->SetHasNewMessages(false);
     }
 
     nsCString searchUri;
     m_virtualFolder->GetURI(searchUri);
     msgDB->UpdateHdrInCache(searchUri.get(), aHdrDeleted, false);
 
     PostUpdateEvent(m_virtualFolder, virtDatabase);
   }
   return rv;
 }
 
-NS_IMETHODIMP VirtualFolderChangeListener::OnHdrAdded(nsIMsgDBHdr *aNewHdr, nsMsgKey aParentKey, int32_t aFlags, nsIDBChangeListener *aInstigator)
-{
+NS_IMETHODIMP VirtualFolderChangeListener::OnHdrAdded(
+    nsIMsgDBHdr *aNewHdr, nsMsgKey aParentKey, int32_t aFlags,
+    nsIDBChangeListener *aInstigator) {
   nsCOMPtr<nsIMsgDatabase> msgDB;
 
   nsresult rv = m_folderWatching->GetMsgDatabase(getter_AddRefs(msgDB));
   NS_ENSURE_SUCCESS(rv, rv);
   bool match = false;
-  if (!m_searchSession)
-    return NS_ERROR_NULL_POINTER;
-
-  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail, m_folderWatching);
+  if (!m_searchSession) return NS_ERROR_NULL_POINTER;
+
+  m_searchSession->AddScopeTerm(nsMsgSearchScope::offlineMail,
+                                m_folderWatching);
   rv = m_searchSession->MatchHdr(aNewHdr, msgDB, &match);
   m_searchSession->ClearScopes();
-  if (match)
-  {
-    nsCOMPtr <nsIMsgDatabase> virtDatabase;
-    nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
-
-    rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
+  if (match) {
+    nsCOMPtr<nsIMsgDatabase> virtDatabase;
+    nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
+
+    rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
+                                               getter_AddRefs(virtDatabase));
     NS_ENSURE_SUCCESS(rv, rv);
     bool msgHdrIsRead;
     uint32_t msgFlags;
     aNewHdr->GetIsRead(&msgHdrIsRead);
     aNewHdr->GetFlags(&msgFlags);
-    if (!msgHdrIsRead)
-      dbFolderInfo->ChangeNumUnreadMessages(1);
-    if (msgFlags & nsMsgMessageFlags::New)
-    {
+    if (!msgHdrIsRead) dbFolderInfo->ChangeNumUnreadMessages(1);
+    if (msgFlags & nsMsgMessageFlags::New) {
       int32_t numNewMessages;
       m_virtualFolder->GetNumNewMessages(false, &numNewMessages);
       m_virtualFolder->SetHasNewMessages(true);
       m_virtualFolder->SetNumNewMessages(numNewMessages + 1);
     }
     nsCString searchUri;
     m_virtualFolder->GetURI(searchUri);
     msgDB->UpdateHdrInCache(searchUri.get(), aNewHdr, true);
     dbFolderInfo->ChangeNumMessages(1);
     PostUpdateEvent(m_virtualFolder, virtDatabase);
   }
   return rv;
 }
 
-NS_IMETHODIMP VirtualFolderChangeListener::OnParentChanged(nsMsgKey aKeyChanged, nsMsgKey oldParent, nsMsgKey newParent, nsIDBChangeListener *aInstigator)
-{
+NS_IMETHODIMP VirtualFolderChangeListener::OnParentChanged(
+    nsMsgKey aKeyChanged, nsMsgKey oldParent, nsMsgKey newParent,
+    nsIDBChangeListener *aInstigator) {
   return NS_OK;
 }
 
-NS_IMETHODIMP VirtualFolderChangeListener::OnAnnouncerGoingAway(nsIDBChangeAnnouncer *instigator)
-{
-  nsCOMPtr <nsIMsgDatabase> msgDB = do_QueryInterface(instigator);
-  if (msgDB)
-    msgDB->RemoveListener(this);
+NS_IMETHODIMP VirtualFolderChangeListener::OnAnnouncerGoingAway(
+    nsIDBChangeAnnouncer *instigator) {
+  nsCOMPtr<nsIMsgDatabase> msgDB = do_QueryInterface(instigator);
+  if (msgDB) msgDB->RemoveListener(this);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-VirtualFolderChangeListener::OnEvent(nsIMsgDatabase *aDB, const char *aEvent)
-{
+VirtualFolderChangeListener::OnEvent(nsIMsgDatabase *aDB, const char *aEvent) {
   return NS_OK;
 }
 
-
-NS_IMETHODIMP VirtualFolderChangeListener::OnReadChanged(nsIDBChangeListener *aInstigator)
-{
+NS_IMETHODIMP VirtualFolderChangeListener::OnReadChanged(
+    nsIDBChangeListener *aInstigator) {
   return NS_OK;
 }
 
-NS_IMETHODIMP VirtualFolderChangeListener::OnJunkScoreChanged(nsIDBChangeListener *aInstigator)
-{
+NS_IMETHODIMP VirtualFolderChangeListener::OnJunkScoreChanged(
+    nsIDBChangeListener *aInstigator) {
   return NS_OK;
 }
 
-nsresult VirtualFolderChangeListener::PostUpdateEvent(nsIMsgFolder *virtualFolder,
-                                                  nsIMsgDatabase *virtDatabase)
-{
-  if (m_batchingEvents)
-    return NS_OK;
+nsresult VirtualFolderChangeListener::PostUpdateEvent(
+    nsIMsgFolder *virtualFolder, nsIMsgDatabase *virtDatabase) {
+  if (m_batchingEvents) return NS_OK;
   m_batchingEvents = true;
-  nsCOMPtr<nsIRunnable> event = new VFChangeListenerEvent(this, virtualFolder,
-                                                          virtDatabase);
+  nsCOMPtr<nsIRunnable> event =
+      new VFChangeListenerEvent(this, virtualFolder, virtDatabase);
   return NS_DispatchToCurrentThread(event);
 }
 
 void VirtualFolderChangeListener::ProcessUpdateEvent(nsIMsgFolder *virtFolder,
-                                                     nsIMsgDatabase *virtDB)
-{
+                                                     nsIMsgDatabase *virtDB) {
   m_batchingEvents = false;
-  virtFolder->UpdateSummaryTotals(true); // force update from db.
+  virtFolder->UpdateSummaryTotals(true);  // force update from db.
   virtDB->Commit(nsMsgDBCommitType::kLargeCommit);
 }
 
-nsresult nsMsgAccountManager::GetVirtualFoldersFile(nsCOMPtr<nsIFile>& aFile)
-{
+nsresult nsMsgAccountManager::GetVirtualFoldersFile(nsCOMPtr<nsIFile> &aFile) {
   nsCOMPtr<nsIFile> profileDir;
-  nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));
+  nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
+                                       getter_AddRefs(profileDir));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = profileDir->AppendNative(nsDependentCString("virtualFolders.dat"));
-  if (NS_SUCCEEDED(rv))
-    aFile = profileDir;
+  if (NS_SUCCEEDED(rv)) aFile = profileDir;
   return rv;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::LoadVirtualFolders()
-{
-  nsCOMPtr <nsIFile> file;
+NS_IMETHODIMP nsMsgAccountManager::LoadVirtualFolders() {
+  nsCOMPtr<nsIFile> file;
   GetVirtualFoldersFile(file);
-  if (!file)
-    return NS_ERROR_FAILURE;
-
-  if (m_virtualFoldersLoaded)
-    return NS_OK;
+  if (!file) return NS_ERROR_FAILURE;
+
+  if (m_virtualFoldersLoaded) return NS_OK;
 
   m_loadingVirtualFolders = true;
 
   nsresult rv;
-  nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
-  if (msgDBService)
-  {
-     NS_ENSURE_SUCCESS(rv, rv);
-     nsCOMPtr<nsIFileInputStream> fileStream = do_CreateInstance(NS_LOCALFILEINPUTSTREAM_CONTRACTID, &rv);
-     NS_ENSURE_SUCCESS(rv, rv);
-
-     rv = fileStream->Init(file,  PR_RDONLY, 0664, false);
-     nsCOMPtr <nsILineInputStream> lineInputStream(do_QueryInterface(fileStream));
+  nsCOMPtr<nsIMsgDBService> msgDBService =
+      do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
+  if (msgDBService) {
+    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIFileInputStream> fileStream =
+        do_CreateInstance(NS_LOCALFILEINPUTSTREAM_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    rv = fileStream->Init(file, PR_RDONLY, 0664, false);
+    nsCOMPtr<nsILineInputStream> lineInputStream(do_QueryInterface(fileStream));
 
     bool isMore = true;
     nsAutoCString buffer;
     int32_t version = -1;
     nsCOMPtr<nsIMsgFolder> virtualFolder;
     nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
 
-    while (isMore &&
-           NS_SUCCEEDED(lineInputStream->ReadLine(buffer, &isMore)))
-    {
-      if (!buffer.IsEmpty())
-      {
-        if (version == -1)
-        {
+    while (isMore && NS_SUCCEEDED(lineInputStream->ReadLine(buffer, &isMore))) {
+      if (!buffer.IsEmpty()) {
+        if (version == -1) {
           buffer.Cut(0, 8);
           nsresult irv;
           version = buffer.ToInteger(&irv);
           continue;
         }
-        if (StringBeginsWith(buffer, NS_LITERAL_CSTRING("uri=")))
-        {
+        if (StringBeginsWith(buffer, NS_LITERAL_CSTRING("uri="))) {
           buffer.Cut(0, 4);
           dbFolderInfo = nullptr;
 
           rv = GetOrCreateFolder(buffer, getter_AddRefs(virtualFolder));
           NS_ENSURE_SUCCESS(rv, rv);
 
           nsCOMPtr<nsIMsgFolder> grandParent;
           nsCOMPtr<nsIMsgFolder> oldParent;
           nsCOMPtr<nsIMsgFolder> parentFolder;
           bool isServer;
           // This loop handles creating virtual folders without an existing
           // parent.
-          do
-          {
+          do {
             // need to add the folder as a sub-folder of its parent.
             int32_t lastSlash = buffer.RFindChar('/');
-            if (lastSlash == kNotFound)
-              break;
+            if (lastSlash == kNotFound) break;
             nsDependentCSubstring parentUri(buffer, 0, lastSlash);
             // hold a reference so it won't get deleted before it's parented.
             oldParent = parentFolder;
 
             rv = GetOrCreateFolder(parentUri, getter_AddRefs(parentFolder));
             NS_ENSURE_SUCCESS(rv, rv);
 
             nsAutoString currentFolderNameStr;
             nsAutoCString currentFolderNameCStr;
-            MsgUnescapeString(nsCString(Substring(buffer, lastSlash + 1, buffer.Length())), 0, currentFolderNameCStr);
+            MsgUnescapeString(
+                nsCString(Substring(buffer, lastSlash + 1, buffer.Length())), 0,
+                currentFolderNameCStr);
             CopyUTF8toUTF16(currentFolderNameCStr, currentFolderNameStr);
             nsCOMPtr<nsIMsgFolder> childFolder;
             nsCOMPtr<nsIMsgDatabase> db;
             // force db to get created.
             // XXX TODO: is this SetParent() right? Won't it screw up if virtual
             // folder is nested >2 deep? Leave for now, but revisit when getting
             // rid of dangling folders (BenC).
             virtualFolder->SetParent(parentFolder);
             rv = virtualFolder->GetMsgDatabase(getter_AddRefs(db));
             if (rv == NS_MSG_ERROR_FOLDER_SUMMARY_MISSING)
               msgDBService->CreateNewDB(virtualFolder, getter_AddRefs(db));
             if (db)
               rv = db->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
             else
               break;
 
-            parentFolder->AddSubfolder(currentFolderNameStr, getter_AddRefs(childFolder));
+            parentFolder->AddSubfolder(currentFolderNameStr,
+                                       getter_AddRefs(childFolder));
             virtualFolder->SetFlag(nsMsgFolderFlags::Virtual);
-            if (childFolder)
-              parentFolder->NotifyItemAdded(childFolder);
+            if (childFolder) parentFolder->NotifyItemAdded(childFolder);
             // here we make sure if our parent is rooted - if not, we're
             // going to loop and add our parent as a child of its grandparent
             // and repeat until we get to the server, or a folder that
             // has its parent set.
             parentFolder->GetParent(getter_AddRefs(grandParent));
             parentFolder->GetIsServer(&isServer);
             buffer.SetLength(lastSlash);
           } while (!grandParent && !isServer);
-        }
-        else if (dbFolderInfo && StringBeginsWith(buffer, NS_LITERAL_CSTRING("scope=")))
-        {
+        } else if (dbFolderInfo &&
+                   StringBeginsWith(buffer, NS_LITERAL_CSTRING("scope="))) {
           buffer.Cut(0, 6);
-          // if this is a cross folder virtual folder, we have a list of folders uris,
-          // and we have to add a pending listener for each of them.
-          if (!buffer.IsEmpty())
-          {
+          // if this is a cross folder virtual folder, we have a list of folders
+          // uris, and we have to add a pending listener for each of them.
+          if (!buffer.IsEmpty()) {
             ParseAndVerifyVirtualFolderScope(buffer);
             dbFolderInfo->SetCharProperty(kSearchFolderUriProp, buffer);
             AddVFListenersForVF(virtualFolder, buffer, msgDBService);
           }
-        }
-        else if (dbFolderInfo && StringBeginsWith(buffer, NS_LITERAL_CSTRING("terms=")))
-        {
+        } else if (dbFolderInfo &&
+                   StringBeginsWith(buffer, NS_LITERAL_CSTRING("terms="))) {
           buffer.Cut(0, 6);
           dbFolderInfo->SetCharProperty("searchStr", buffer);
-        }
-        else if (dbFolderInfo && StringBeginsWith(buffer, NS_LITERAL_CSTRING("searchOnline=")))
-        {
+        } else if (dbFolderInfo &&
+                   StringBeginsWith(buffer,
+                                    NS_LITERAL_CSTRING("searchOnline="))) {
           buffer.Cut(0, 13);
-          dbFolderInfo->SetBooleanProperty("searchOnline", buffer.EqualsLiteral("true"));
-        }
-        else if (dbFolderInfo &&
-                 Substring(buffer, 0, SEARCH_FOLDER_FLAG_LEN + 1)
-                   .Equals(SEARCH_FOLDER_FLAG"="))
-        {
+          dbFolderInfo->SetBooleanProperty("searchOnline",
+                                           buffer.EqualsLiteral("true"));
+        } else if (dbFolderInfo &&
+                   Substring(buffer, 0, SEARCH_FOLDER_FLAG_LEN + 1)
+                       .Equals(SEARCH_FOLDER_FLAG "=")) {
           buffer.Cut(0, SEARCH_FOLDER_FLAG_LEN + 1);
           dbFolderInfo->SetCharProperty(SEARCH_FOLDER_FLAG, buffer);
         }
       }
     }
   }
 
   m_loadingVirtualFolders = false;
   m_virtualFoldersLoaded = true;
   return rv;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::SaveVirtualFolders()
-{
-  if (!m_virtualFoldersLoaded)
-    return NS_OK;
+NS_IMETHODIMP nsMsgAccountManager::SaveVirtualFolders() {
+  if (!m_virtualFoldersLoaded) return NS_OK;
 
   nsCOMPtr<nsIFile> file;
   GetVirtualFoldersFile(file);
 
   // Open a buffered, safe output stream
   nsCOMPtr<nsIOutputStream> outStream;
-  nsresult rv = MsgNewSafeBufferedFileOutputStream(getter_AddRefs(outStream),
-                                                   file,
-                                                   PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
-                                                   0664);
+  nsresult rv = MsgNewSafeBufferedFileOutputStream(
+      getter_AddRefs(outStream), file, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE,
+      0664);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WriteLineToOutputStream("version=", "1", outStream);
   for (auto iter = m_incomingServers.Iter(); !iter.Done(); iter.Next()) {
-    nsCOMPtr<nsIMsgIncomingServer>& server = iter.Data();
-    if (server)
-    {
-      nsCOMPtr <nsIMsgFolder> rootFolder;
+    nsCOMPtr<nsIMsgIncomingServer> &server = iter.Data();
+    if (server) {
+      nsCOMPtr<nsIMsgFolder> rootFolder;
       server->GetRootFolder(getter_AddRefs(rootFolder));
-      if (rootFolder)
-      {
-        nsCOMPtr <nsIArray> virtualFolders;
-        nsresult rv = rootFolder->GetFoldersWithFlags(nsMsgFolderFlags::Virtual,
-                                             getter_AddRefs(virtualFolders));
+      if (rootFolder) {
+        nsCOMPtr<nsIArray> virtualFolders;
+        nsresult rv = rootFolder->GetFoldersWithFlags(
+            nsMsgFolderFlags::Virtual, getter_AddRefs(virtualFolders));
         if (NS_FAILED(rv)) {
           continue;
         }
         uint32_t vfCount;
         virtualFolders->GetLength(&vfCount);
-        for (uint32_t folderIndex = 0; folderIndex < vfCount; folderIndex++)
-        {
-          nsCOMPtr<nsIMsgFolder> msgFolder(do_QueryElementAt(virtualFolders, folderIndex));
+        for (uint32_t folderIndex = 0; folderIndex < vfCount; folderIndex++) {
+          nsCOMPtr<nsIMsgFolder> msgFolder(
+              do_QueryElementAt(virtualFolders, folderIndex));
           nsCOMPtr<nsIMsgDatabase> db;
           nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
-          rv = msgFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(db)); // force db to get created.
-          if (dbFolderInfo)
-          {
+          rv = msgFolder->GetDBFolderInfoAndDB(
+              getter_AddRefs(dbFolderInfo),
+              getter_AddRefs(db));  // force db to get created.
+          if (dbFolderInfo) {
             nsCString srchFolderUri;
             nsCString searchTerms;
             nsCString regexScope;
             nsCString vfFolderFlag;
             bool searchOnline = false;
-            dbFolderInfo->GetBooleanProperty("searchOnline", false, &searchOnline);
+            dbFolderInfo->GetBooleanProperty("searchOnline", false,
+                                             &searchOnline);
             dbFolderInfo->GetCharProperty(kSearchFolderUriProp, srchFolderUri);
             dbFolderInfo->GetCharProperty("searchStr", searchTerms);
             // logically searchFolderFlag is an int, but since we want to
             // write out a string, get it as a string.
             dbFolderInfo->GetCharProperty(SEARCH_FOLDER_FLAG, vfFolderFlag);
             nsCString uri;
             msgFolder->GetURI(uri);
-            if (!srchFolderUri.IsEmpty() && !searchTerms.IsEmpty())
-            {
+            if (!srchFolderUri.IsEmpty() && !searchTerms.IsEmpty()) {
               WriteLineToOutputStream("uri=", uri.get(), outStream);
               if (!vfFolderFlag.IsEmpty())
-                WriteLineToOutputStream(SEARCH_FOLDER_FLAG"=", vfFolderFlag.get(), outStream);
+                WriteLineToOutputStream(SEARCH_FOLDER_FLAG "=",
+                                        vfFolderFlag.get(), outStream);
               WriteLineToOutputStream("scope=", srchFolderUri.get(), outStream);
               WriteLineToOutputStream("terms=", searchTerms.get(), outStream);
-              WriteLineToOutputStream("searchOnline=", searchOnline ? "true" : "false", outStream);
+              WriteLineToOutputStream(
+                  "searchOnline=", searchOnline ? "true" : "false", outStream);
             }
           }
         }
       }
     }
   }
 
   nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(outStream, &rv);
@@ -3111,448 +2865,412 @@ NS_IMETHODIMP nsMsgAccountManager::SaveV
     rv = safeStream->Finish();
     if (NS_FAILED(rv)) {
       NS_WARNING("failed to save personal dictionary file! possible data loss");
     }
   }
   return rv;
 }
 
-nsresult nsMsgAccountManager::WriteLineToOutputStream(const char *prefix, const char * line, nsIOutputStream *outputStream)
-{
+nsresult nsMsgAccountManager::WriteLineToOutputStream(
+    const char *prefix, const char *line, nsIOutputStream *outputStream) {
   uint32_t writeCount;
   outputStream->Write(prefix, strlen(prefix), &writeCount);
   outputStream->Write(line, strlen(line), &writeCount);
   outputStream->Write("\n", 1, &writeCount);
   return NS_OK;
 }
 
 /**
  * Parse the '|' separated folder uri string into individual folders, verify
  * that the folders are real. If we were to add things like wildcards, we
  * could implement the expansion into real folders here.
  *
  * @param buffer On input, list of folder uri's, on output, verified list.
  */
-void nsMsgAccountManager::ParseAndVerifyVirtualFolderScope(nsCString &buffer)
-{
+void nsMsgAccountManager::ParseAndVerifyVirtualFolderScope(nsCString &buffer) {
   nsCString verifiedFolders;
   nsTArray<nsCString> folderUris;
   ParseString(buffer, '|', folderUris);
   nsCOMPtr<nsIMsgIncomingServer> server;
   nsCOMPtr<nsIMsgFolder> parent;
 
-  for (uint32_t i = 0; i < folderUris.Length(); i++)
-  {
+  for (uint32_t i = 0; i < folderUris.Length(); i++) {
     nsCOMPtr<nsIMsgFolder> realFolder;
     nsresult rv = GetOrCreateFolder(folderUris[i], getter_AddRefs(realFolder));
     if (!NS_SUCCEEDED(rv)) {
       continue;
     }
     realFolder->GetParent(getter_AddRefs(parent));
-    if (!parent)
-      continue;
+    if (!parent) continue;
     realFolder->GetServer(getter_AddRefs(server));
-    if (!server)
-      continue;
-    if (!verifiedFolders.IsEmpty())
-      verifiedFolders.Append('|');
+    if (!server) continue;
+    if (!verifiedFolders.IsEmpty()) verifiedFolders.Append('|');
     verifiedFolders.Append(folderUris[i]);
   }
   buffer.Assign(verifiedFolders);
 }
 
 // This conveniently works to add a single folder as well.
-nsresult nsMsgAccountManager::AddVFListenersForVF(nsIMsgFolder *virtualFolder,
-                                                  const nsCString& srchFolderUris,
-                                                  nsIMsgDBService *msgDBService)
-{
+nsresult nsMsgAccountManager::AddVFListenersForVF(
+    nsIMsgFolder *virtualFolder, const nsCString &srchFolderUris,
+    nsIMsgDBService *msgDBService) {
   nsTArray<nsCString> folderUris;
   ParseString(srchFolderUris, '|', folderUris);
 
-  for (uint32_t i = 0; i < folderUris.Length(); i++)
-  {
+  for (uint32_t i = 0; i < folderUris.Length(); i++) {
     nsCOMPtr<nsIMsgFolder> realFolder;
     nsresult rv = GetOrCreateFolder(folderUris[i], getter_AddRefs(realFolder));
     NS_ENSURE_SUCCESS(rv, rv);
-    RefPtr<VirtualFolderChangeListener> dbListener = new VirtualFolderChangeListener();
+    RefPtr<VirtualFolderChangeListener> dbListener =
+        new VirtualFolderChangeListener();
     NS_ENSURE_TRUE(dbListener, NS_ERROR_OUT_OF_MEMORY);
     dbListener->m_virtualFolder = virtualFolder;
     dbListener->m_folderWatching = realFolder;
-    if (NS_FAILED(dbListener->Init()))
-    {
+    if (NS_FAILED(dbListener->Init())) {
       dbListener = nullptr;
       continue;
     }
     m_virtualFolderListeners.AppendElement(dbListener);
     msgDBService->RegisterPendingListener(realFolder, dbListener);
   }
   return NS_OK;
 }
 
 // This is called if a folder that's part of the scope of a saved search
 // has gone away.
 nsresult nsMsgAccountManager::RemoveVFListenerForVF(nsIMsgFolder *virtualFolder,
-                                                    nsIMsgFolder *folder)
-{
+                                                    nsIMsgFolder *folder) {
   nsresult rv;
-  nsCOMPtr<nsIMsgDBService> msgDBService(do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIMsgDBService> msgDBService(
+      do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(m_virtualFolderListeners);
+  nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(
+      m_virtualFolderListeners);
   RefPtr<VirtualFolderChangeListener> listener;
 
-  while (iter.HasMore())
-  {
+  while (iter.HasMore()) {
     listener = iter.GetNext();
     if (listener->m_folderWatching == folder &&
-        listener->m_virtualFolder == virtualFolder)
-    {
+        listener->m_virtualFolder == virtualFolder) {
       msgDBService->UnregisterPendingListener(listener);
       m_virtualFolderListeners.RemoveElement(listener);
       break;
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::GetAllFolders(nsIArray **aAllFolders)
-{
+NS_IMETHODIMP nsMsgAccountManager::GetAllFolders(nsIArray **aAllFolders) {
   NS_ENSURE_ARG_POINTER(aAllFolders);
 
   nsCOMPtr<nsIArray> servers;
   nsresult rv = GetAllServers(getter_AddRefs(servers));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t numServers = 0;
   rv = servers->GetLength(&numServers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMutableArray> allFolders(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+  nsCOMPtr<nsIMutableArray> allFolders(
+      do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t i;
-  for (i = 0; i < numServers; i++)
-  {
+  for (i = 0; i < numServers; i++) {
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(servers, i);
-    if (server)
-    {
+    if (server) {
       nsCOMPtr<nsIMsgFolder> rootFolder;
       server->GetRootFolder(getter_AddRefs(rootFolder));
-      if (rootFolder)
-        rootFolder->ListDescendants(allFolders);
+      if (rootFolder) rootFolder->ListDescendants(allFolders);
     }
   }
 
   allFolders.forget(aAllFolders);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIMsgFolder *parentItem, nsISupports *item)
-{
+NS_IMETHODIMP nsMsgAccountManager::OnItemAdded(nsIMsgFolder *parentItem,
+                                               nsISupports *item) {
   nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(item);
   // just kick out with a success code if the item in question is not a folder
-  if (!folder)
-    return NS_OK;
+  if (!folder) return NS_OK;
 
   uint32_t folderFlags;
   folder->GetFlags(&folderFlags);
   bool addToSmartFolders = false;
-  folder->IsSpecialFolder(nsMsgFolderFlags::Inbox |
-                          nsMsgFolderFlags::Templates |
-                          nsMsgFolderFlags::Trash |
-                          nsMsgFolderFlags::Drafts, false,
-                          &addToSmartFolders);
+  folder->IsSpecialFolder(
+      nsMsgFolderFlags::Inbox | nsMsgFolderFlags::Templates |
+          nsMsgFolderFlags::Trash | nsMsgFolderFlags::Drafts,
+      false, &addToSmartFolders);
   // For Sent/Archives/Trash, we treat sub-folders of those folders as
   // "special", and want to add them the smart folders search scope.
   // So we check if this is a sub-folder of one of those special folders
   // and set the corresponding folderFlag if so.
-  if (!addToSmartFolders)
-  {
+  if (!addToSmartFolders) {
     bool isSpecial = false;
     folder->IsSpecialFolder(nsMsgFolderFlags::SentMail, true, &isSpecial);
-    if (isSpecial)
-    {
+    if (isSpecial) {
       addToSmartFolders = true;
       folderFlags |= nsMsgFolderFlags::SentMail;
     }
     folder->IsSpecialFolder(nsMsgFolderFlags::Archive, true, &isSpecial);
-    if (isSpecial)
-    {
+    if (isSpecial) {
       addToSmartFolders = true;
       folderFlags |= nsMsgFolderFlags::Archive;
     }
     folder->IsSpecialFolder(nsMsgFolderFlags::Trash, true, &isSpecial);
-    if (isSpecial)
-    {
+    if (isSpecial) {
       addToSmartFolders = true;
       folderFlags |= nsMsgFolderFlags::Trash;
     }
   }
   nsresult rv = NS_OK;
   // if this is a special folder, check if we have a saved search over
   // folders with this flag, and if so, add this folder to the scope.
-  if (addToSmartFolders)
-  {
+  if (addToSmartFolders) {
     // quick way to enumerate the saved searches.
-    nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(m_virtualFolderListeners);
+    nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator
+        iter(m_virtualFolderListeners);
     RefPtr<VirtualFolderChangeListener> listener;
 
-    while (iter.HasMore())
-    {
+    while (iter.HasMore()) {
       listener = iter.GetNext();
-      nsCOMPtr <nsIMsgDatabase> db;
-      nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
-      listener->m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
-                                                      getter_AddRefs(db));
-      if (dbFolderInfo)
-      {
+      nsCOMPtr<nsIMsgDatabase> db;
+      nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
+      listener->m_virtualFolder->GetDBFolderInfoAndDB(
+          getter_AddRefs(dbFolderInfo), getter_AddRefs(db));
+      if (dbFolderInfo) {
         uint32_t vfFolderFlag;
-        dbFolderInfo->GetUint32Property("searchFolderFlag", 0, & vfFolderFlag);
+        dbFolderInfo->GetUint32Property("searchFolderFlag", 0, &vfFolderFlag);
         // found a saved search over folders w/ the same flag as the new folder.
-        if (vfFolderFlag & folderFlags)
-        {
+        if (vfFolderFlag & folderFlags) {
           nsCString searchURI;
           dbFolderInfo->GetCharProperty(kSearchFolderUriProp, searchURI);
 
           // "normalize" searchURI so we can search for |folderURI|.
-          if (!searchURI.IsEmpty())
-          {
+          if (!searchURI.IsEmpty()) {
             searchURI.Insert('|', 0);
             searchURI.Append('|');
           }
           nsCString folderURI;
           folder->GetURI(folderURI);
 
           int32_t index = searchURI.Find(folderURI);
-          if (index == kNotFound)
-          {
+          if (index == kNotFound) {
             searchURI.Cut(0, 1);
             searchURI.Append(folderURI);
             dbFolderInfo->SetCharProperty(kSearchFolderUriProp, searchURI);
             break;
           }
-          // New sent or archive folder, need to add sub-folders to smart folder.
-          if (vfFolderFlag & (nsMsgFolderFlags::Archive | nsMsgFolderFlags::SentMail))
-          {
+          // New sent or archive folder, need to add sub-folders to smart
+          // folder.
+          if (vfFolderFlag &
+              (nsMsgFolderFlags::Archive | nsMsgFolderFlags::SentMail)) {
             nsCOMPtr<nsIArray> allDescendants;
             rv = folder->GetDescendants(getter_AddRefs(allDescendants));
             NS_ENSURE_SUCCESS(rv, rv);
 
             uint32_t cnt = 0;
             rv = allDescendants->GetLength(&cnt);
             NS_ENSURE_SUCCESS(rv, rv);
 
             nsCOMPtr<nsIMsgFolder> parent;
-            for (uint32_t j = 0; j < cnt; j++)
-            {
-              nsCOMPtr<nsIMsgFolder> subFolder = do_QueryElementAt(allDescendants, j);
-              if (subFolder)
-              {
+            for (uint32_t j = 0; j < cnt; j++) {
+              nsCOMPtr<nsIMsgFolder> subFolder =
+                  do_QueryElementAt(allDescendants, j);
+              if (subFolder) {
                 subFolder->GetParent(getter_AddRefs(parent));
                 OnItemAdded(parent, subFolder);
               }
             }
           }
         }
       }
     }
   }
   // need to make sure this isn't happening during loading of virtualfolders.dat
-  if (folderFlags & nsMsgFolderFlags::Virtual && !m_loadingVirtualFolders)
-  {
+  if (folderFlags & nsMsgFolderFlags::Virtual && !m_loadingVirtualFolders) {
     // When a new virtual folder is added, need to create a db Listener for it.
-    nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
-    if (msgDBService)
-    {
-      nsCOMPtr <nsIMsgDatabase> virtDatabase;
-      nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
-      rv = folder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
+    nsCOMPtr<nsIMsgDBService> msgDBService =
+        do_GetService(NS_MSGDB_SERVICE_CONTRACTID, &rv);
+    if (msgDBService) {
+      nsCOMPtr<nsIMsgDatabase> virtDatabase;
+      nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
+      rv = folder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
+                                        getter_AddRefs(virtDatabase));
       NS_ENSURE_SUCCESS(rv, rv);
       nsCString srchFolderUri;
       dbFolderInfo->GetCharProperty(kSearchFolderUriProp, srchFolderUri);
       AddVFListenersForVF(folder, srchFolderUri, msgDBService);
     }
     rv = SaveVirtualFolders();
   }
   return rv;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::OnItemRemoved(nsIMsgFolder *parentItem, nsISupports *item)
-{
+NS_IMETHODIMP nsMsgAccountManager::OnItemRemoved(nsIMsgFolder *parentItem,
+                                                 nsISupports *item) {
   nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(item);
   // just kick out with a success code if the item in question is not a folder
-  if (!folder)
-    return NS_OK;
+  if (!folder) return NS_OK;
   nsresult rv = NS_OK;
   uint32_t folderFlags;
   folder->GetFlags(&folderFlags);
-  if (folderFlags & nsMsgFolderFlags::Virtual) // if we removed a VF, flush VF list to disk.
-  {
+  // if we removed a VF, flush VF list to disk.
+  if (folderFlags & nsMsgFolderFlags::Virtual) {
     rv = SaveVirtualFolders();
-    // clear flags on deleted folder if it's a virtual folder, so that creating a new folder
-    // with the same name doesn't cause confusion.
+    // clear flags on deleted folder if it's a virtual folder, so that creating
+    // a new folder with the same name doesn't cause confusion.
     folder->SetFlags(0);
     return rv;
   }
   // need to update the saved searches to check for a few things:
   // 1. Folder removed was in the scope of a saved search - if so, remove the
   //    uri from the scope of the saved search.
   // 2. If the scope is now empty, remove the saved search.
 
   // build a "normalized" uri that we can do a find on.
   nsCString removedFolderURI;
   folder->GetURI(removedFolderURI);
   removedFolderURI.Insert('|', 0);
   removedFolderURI.Append('|');
 
   // Enumerate the saved searches.
-  nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(m_virtualFolderListeners);
+  nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(
+      m_virtualFolderListeners);
   RefPtr<VirtualFolderChangeListener> listener;
 
-  while (iter.HasMore())
-  {
+  while (iter.HasMore()) {
     listener = iter.GetNext();
     nsCOMPtr<nsIMsgDatabase> db;
     nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
     nsCOMPtr<nsIMsgFolder> savedSearch = listener->m_virtualFolder;
     savedSearch->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
                                       getter_AddRefs(db));
-    if (dbFolderInfo)
-    {
+    if (dbFolderInfo) {
       nsCString searchURI;
       dbFolderInfo->GetCharProperty(kSearchFolderUriProp, searchURI);
       // "normalize" searchURI so we can search for |folderURI|.
       searchURI.Insert('|', 0);
       searchURI.Append('|');
       int32_t index = searchURI.Find(removedFolderURI);
-      if (index != kNotFound)
-      {
+      if (index != kNotFound) {
         RemoveVFListenerForVF(savedSearch, folder);
 
         // remove |folderURI
         searchURI.Cut(index, removedFolderURI.Length() - 1);
         // remove last '|' we added
         searchURI.SetLength(searchURI.Length() - 1);
 
         // if saved search is empty now, delete it.
-        if (searchURI.IsEmpty())
-        {
+        if (searchURI.IsEmpty()) {
           db = nullptr;
           dbFolderInfo = nullptr;
 
           nsCOMPtr<nsIMsgFolder> parent;
           rv = savedSearch->GetParent(getter_AddRefs(parent));
           NS_ENSURE_SUCCESS(rv, rv);
 
-          if (!parent)
-            continue;
+          if (!parent) continue;
           parent->PropagateDelete(savedSearch, true, nullptr);
-        }
-        else
-        {
-        // remove leading '|' we added (or one after |folderURI, if first URI)
+        } else {
+          // remove leading '|' we added (or one after |folderURI, if first URI)
           searchURI.Cut(0, 1);
           dbFolderInfo->SetCharProperty(kSearchFolderUriProp, searchURI);
         }
       }
     }
   }
 
   return rv;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::OnItemPropertyChanged(nsIMsgFolder *item, const nsACString &property, const char *oldValue, const char *newValue)
-{
+NS_IMETHODIMP nsMsgAccountManager::OnItemPropertyChanged(
+    nsIMsgFolder *item, const nsACString &property, const char *oldValue,
+    const char *newValue) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::OnItemIntPropertyChanged(nsIMsgFolder *aFolder,
                                               const nsACString &aProperty,
                                               int64_t oldValue,
-                                              int64_t newValue)
-{
-  if (aProperty.Equals(kFolderFlag))
-  {
-    uint32_t smartFlagsChanged = (oldValue ^ newValue) &
-      (nsMsgFolderFlags::SpecialUse & ~nsMsgFolderFlags::Queue);
-    if (smartFlagsChanged)
-    {
-      if (smartFlagsChanged & newValue)
-      {
+                                              int64_t newValue) {
+  if (aProperty.Equals(kFolderFlag)) {
+    uint32_t smartFlagsChanged =
+        (oldValue ^ newValue) &
+        (nsMsgFolderFlags::SpecialUse & ~nsMsgFolderFlags::Queue);
+    if (smartFlagsChanged) {
+      if (smartFlagsChanged & newValue) {
         // if the smart folder flag was set, calling OnItemAdded will
         // do the right thing.
         nsCOMPtr<nsIMsgFolder> parent;
         aFolder->GetParent(getter_AddRefs(parent));
         return OnItemAdded(parent, aFolder);
       }
       RemoveFolderFromSmartFolder(aFolder, smartFlagsChanged);
       // sent|archive flag removed, remove sub-folders from smart folder.
-      if (smartFlagsChanged & (nsMsgFolderFlags::Archive | nsMsgFolderFlags::SentMail))
-      {
+      if (smartFlagsChanged &
+          (nsMsgFolderFlags::Archive | nsMsgFolderFlags::SentMail)) {
         nsCOMPtr<nsIArray> allDescendants;
         nsresult rv = aFolder->GetDescendants(getter_AddRefs(allDescendants));
         NS_ENSURE_SUCCESS(rv, rv);
 
         uint32_t cnt = 0;
         rv = allDescendants->GetLength(&cnt);
         NS_ENSURE_SUCCESS(rv, rv);
 
         nsCOMPtr<nsIMsgFolder> parent;
-        for (uint32_t j = 0; j < cnt; j++)
-        {
-          nsCOMPtr<nsIMsgFolder> subFolder = do_QueryElementAt(allDescendants, j);
+        for (uint32_t j = 0; j < cnt; j++) {
+          nsCOMPtr<nsIMsgFolder> subFolder =
+              do_QueryElementAt(allDescendants, j);
           if (subFolder)
             RemoveFolderFromSmartFolder(subFolder, smartFlagsChanged);
         }
       }
     }
   }
   return NS_OK;
 }
 
-nsresult
-nsMsgAccountManager::RemoveFolderFromSmartFolder(nsIMsgFolder *aFolder,
-                                                 uint32_t flagsChanged)
-{
+nsresult nsMsgAccountManager::RemoveFolderFromSmartFolder(
+    nsIMsgFolder *aFolder, uint32_t flagsChanged) {
   nsCString removedFolderURI;
   aFolder->GetURI(removedFolderURI);
   removedFolderURI.Insert('|', 0);
   removedFolderURI.Append('|');
   uint32_t flags;
   aFolder->GetFlags(&flags);
   NS_ASSERTION(!(flags & flagsChanged), "smart folder flag should not be set");
   // Flag was removed. Look for smart folder based on that flag,
   // and remove this folder from its scope.
-  nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(m_virtualFolderListeners);
+  nsTObserverArray<RefPtr<VirtualFolderChangeListener> >::ForwardIterator iter(
+      m_virtualFolderListeners);
   RefPtr<VirtualFolderChangeListener> listener;
 
-  while (iter.HasMore())
-  {
+  while (iter.HasMore()) {
     listener = iter.GetNext();
-    nsCOMPtr <nsIMsgDatabase> db;
-    nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
-    listener->m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo),
-                                                    getter_AddRefs(db));
-    if (dbFolderInfo)
-    {
+    nsCOMPtr<nsIMsgDatabase> db;
+    nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
+    listener->m_virtualFolder->GetDBFolderInfoAndDB(
+        getter_AddRefs(dbFolderInfo), getter_AddRefs(db));
+    if (dbFolderInfo) {
       uint32_t vfFolderFlag;
-      dbFolderInfo->GetUint32Property("searchFolderFlag", 0, & vfFolderFlag);
+      dbFolderInfo->GetUint32Property("searchFolderFlag", 0, &vfFolderFlag);
       // found a smart folder over the removed flag
-      if (vfFolderFlag & flagsChanged)
-      {
+      if (vfFolderFlag & flagsChanged) {
         nsCString searchURI;
         dbFolderInfo->GetCharProperty(kSearchFolderUriProp, searchURI);
         // "normalize" searchURI so we can search for |folderURI|.
         searchURI.Insert('|', 0);
         searchURI.Append('|');
         int32_t index = searchURI.Find(removedFolderURI);
-        if (index != kNotFound)
-        {
+        if (index != kNotFound) {
           RemoveVFListenerForVF(listener->m_virtualFolder, aFolder);
 
           // remove |folderURI
           searchURI.Cut(index, removedFolderURI.Length() - 1);
           // remove last '|' we added
           searchURI.SetLength(searchURI.Length() - 1);
 
           // remove leading '|' we added (or one after |folderURI, if first URI)
@@ -3560,89 +3278,87 @@ nsMsgAccountManager::RemoveFolderFromSma
           dbFolderInfo->SetCharProperty(kSearchFolderUriProp, searchURI);
         }
       }
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::OnItemBoolPropertyChanged(nsIMsgFolder *item, const nsACString &property, bool oldValue, bool newValue)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP nsMsgAccountManager::OnItemUnicharPropertyChanged(nsIMsgFolder *item, const nsACString &property, const char16_t *oldValue, const char16_t *newValue)
-{
+NS_IMETHODIMP nsMsgAccountManager::OnItemBoolPropertyChanged(
+    nsIMsgFolder *item, const nsACString &property, bool oldValue,
+    bool newValue) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-
-NS_IMETHODIMP nsMsgAccountManager::OnItemPropertyFlagChanged(nsIMsgDBHdr *item, const nsACString &property, uint32_t oldFlag, uint32_t newFlag)
-{
+NS_IMETHODIMP nsMsgAccountManager::OnItemUnicharPropertyChanged(
+    nsIMsgFolder *item, const nsACString &property, const char16_t *oldValue,
+    const char16_t *newValue) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-NS_IMETHODIMP nsMsgAccountManager::OnItemEvent(nsIMsgFolder *aFolder, const nsACString &aEvent)
-{
+NS_IMETHODIMP nsMsgAccountManager::OnItemPropertyFlagChanged(
+    nsIMsgDBHdr *item, const nsACString &property, uint32_t oldFlag,
+    uint32_t newFlag) {
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP nsMsgAccountManager::OnItemEvent(nsIMsgFolder *aFolder,
+                                               const nsACString &aEvent) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsMsgAccountManager::FolderUriForPath(nsIFile *aLocalPath,
-                                               nsACString &aMailboxUri)
-{
+                                      nsACString &aMailboxUri) {
   NS_ENSURE_ARG_POINTER(aLocalPath);
   bool equals;
   if (m_lastPathLookedUp &&
-      NS_SUCCEEDED(aLocalPath->Equals(m_lastPathLookedUp, &equals)) && equals)
-  {
+      NS_SUCCEEDED(aLocalPath->Equals(m_lastPathLookedUp, &equals)) && equals) {
     aMailboxUri = m_lastFolderURIForPath;
     return NS_OK;
   }
   nsCOMPtr<nsIArray> folderArray;
   nsresult rv = GetAllFolders(getter_AddRefs(folderArray));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t count;
   rv = folderArray->GetLength(&count);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  for (uint32_t i = 0; i < count; i++)
-  {
+  for (uint32_t i = 0; i < count; i++) {
     nsCOMPtr<nsIMsgFolder> folder(do_QueryElementAt(folderArray, i, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIFile> folderPath;
     rv = folder->GetFilePath(getter_AddRefs(folderPath));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Check if we're equal
     rv = folderPath->Equals(aLocalPath, &equals);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    if (equals)
-    {
+    if (equals) {
       rv = folder->GetURI(aMailboxUri);
       m_lastFolderURIForPath = aMailboxUri;
       aLocalPath->Clone(getter_AddRefs(m_lastPathLookedUp));
       return rv;
     }
   }
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-nsMsgAccountManager::GetSortOrder(nsIMsgIncomingServer* aServer, int32_t* aSortOrder)
-{
+nsMsgAccountManager::GetSortOrder(nsIMsgIncomingServer *aServer,
+                                  int32_t *aSortOrder) {
   NS_ENSURE_ARG_POINTER(aServer);
   NS_ENSURE_ARG_POINTER(aSortOrder);
 
-  // If the passed in server is the default, return its sort order as 0 regardless
-  // of its server sort order.
+  // If the passed in server is the default, return its sort order as 0
+  // regardless of its server sort order.
 
   nsCOMPtr<nsIMsgAccount> defaultAccount;
   nsresult rv = GetDefaultAccount(getter_AddRefs(defaultAccount));
   if (NS_SUCCEEDED(rv) && defaultAccount) {
     nsCOMPtr<nsIMsgIncomingServer> defaultServer;
     rv = m_defaultAccount->GetIncomingServer(getter_AddRefs(defaultServer));
     if (NS_SUCCEEDED(rv) && (aServer == defaultServer)) {
       *aSortOrder = 0;
@@ -3656,18 +3372,17 @@ nsMsgAccountManager::GetSortOrder(nsIMsg
   // the accounts list. This ensures that even when several accounts have the
   // same sort order value, the returned value is not the same and keeps
   // their relative order in the account list when and unstable sort is run
   // on the returned sort order values.
   int32_t sortOrder;
   int32_t serverIndex;
 
   rv = aServer->GetSortOrder(&sortOrder);
-  if (NS_SUCCEEDED(rv))
-    rv = FindServerIndex(aServer, &serverIndex);
+  if (NS_SUCCEEDED(rv)) rv = FindServerIndex(aServer, &serverIndex);
 
   if (NS_FAILED(rv)) {
     *aSortOrder = 999999999;
   } else {
     *aSortOrder = sortOrder + serverIndex;
   }
 
   return NS_OK;
--- a/mailnews/base/src/nsMsgAccountManager.h
+++ b/mailnews/base/src/nsMsgAccountManager.h
@@ -1,16 +1,17 @@
 /* -*- 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/.
- * This Original Code has been modified by IBM Corporation. Modifications made by IBM
- * described herein are Copyright (c) International Business Machines Corporation, 2000.
- * Modifications to Mozilla code or documentation identified per MPL Section 3.3
+ * This Original Code has been modified by IBM Corporation. Modifications made
+ * by IBM described herein are Copyright (c) International Business Machines
+ * Corporation, 2000. Modifications to Mozilla code or documentation identified
+ * per MPL Section 3.3
  *
  * Date             Modified by     Description of modification
  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
  */
 
 #include "nscore.h"
 #include "nsIMsgAccountManager.h"
 #include "nsCOMPtr.h"
@@ -24,19 +25,18 @@
 #include "nsCOMArray.h"
 #include "nsIMsgSearchSession.h"
 #include "nsInterfaceHashtable.h"
 #include "nsIMsgDatabase.h"
 #include "nsIDBChangeListener.h"
 #include "nsAutoPtr.h"
 #include "nsTObserverArray.h"
 
-class VirtualFolderChangeListener final : public nsIDBChangeListener
-{
-public:
+class VirtualFolderChangeListener final : public nsIDBChangeListener {
+ public:
   VirtualFolderChangeListener();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDBCHANGELISTENER
 
   nsresult Init();
   /**
    * Posts an event to update the summary totals and commit the db.
@@ -44,61 +44,62 @@ public:
    * in a synchronous loop.
    */
   nsresult PostUpdateEvent(nsIMsgFolder *folder, nsIMsgDatabase *db);
   /// Handles event posted to event queue to batch notifications.
   void ProcessUpdateEvent(nsIMsgFolder *folder, nsIMsgDatabase *db);
 
   void DecrementNewMsgCount();
 
-  nsCOMPtr <nsIMsgFolder> m_virtualFolder; // folder we're listening to db changes on behalf of.
-  nsCOMPtr <nsIMsgFolder> m_folderWatching; // folder whose db we're listening to.
-  nsCOMPtr <nsIMsgSearchSession> m_searchSession;
+  // folder we're listening to db changes on behalf of.
+  nsCOMPtr<nsIMsgFolder> m_virtualFolder;
+  // folder whose db we're listening to.
+  nsCOMPtr<nsIMsgFolder> m_folderWatching;
+  nsCOMPtr<nsIMsgSearchSession> m_searchSession;
   bool m_searchOnMsgStatus;
   bool m_batchingEvents;
 
-private:
+ private:
   ~VirtualFolderChangeListener() {}
 };
 
-
-class nsMsgAccountManager: public nsIMsgAccountManager,
-    public nsIObserver,
-    public nsSupportsWeakReference,
-    public nsIUrlListener,
-    public nsIFolderListener
-{
-public:
-
+class nsMsgAccountManager : public nsIMsgAccountManager,
+                            public nsIObserver,
+                            public nsSupportsWeakReference,
+                            public nsIUrlListener,
+                            public nsIFolderListener {
+ public:
   nsMsgAccountManager();
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
   /* nsIMsgAccountManager methods */
 
   NS_DECL_NSIMSGACCOUNTMANAGER
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIURLLISTENER
   NS_DECL_NSIFOLDERLISTENER
 
   nsresult Init();
   nsresult Shutdown();
   void LogoutOfServer(nsIMsgIncomingServer *aServer);
 
-private:
+ private:
   virtual ~nsMsgAccountManager();
 
   bool m_accountsLoaded;
-  nsCOMPtr <nsIMsgFolderCache> m_msgFolderCache;
+  nsCOMPtr<nsIMsgFolderCache> m_msgFolderCache;
   nsTArray<nsCOMPtr<nsIMsgAccount> > m_accounts;
   nsInterfaceHashtable<nsCStringHashKey, nsIMsgIdentity> m_identities;
-  nsInterfaceHashtable<nsCStringHashKey, nsIMsgIncomingServer> m_incomingServers;
+  nsInterfaceHashtable<nsCStringHashKey, nsIMsgIncomingServer>
+      m_incomingServers;
   nsCOMPtr<nsIMsgAccount> m_defaultAccount;
   nsCOMArray<nsIIncomingServerListener> m_incomingServerListeners;
-  nsTObserverArray<RefPtr<VirtualFolderChangeListener> > m_virtualFolderListeners;
+  nsTObserverArray<RefPtr<VirtualFolderChangeListener> >
+      m_virtualFolderListeners;
   nsCOMPtr<nsIMsgFolder> m_folderDoingEmptyTrash;
   nsCOMPtr<nsIMsgFolder> m_folderDoingCleanupInbox;
   bool m_emptyTrashInProgress;
   bool m_cleanupInboxInProgress;
 
   nsCString mAccountKeyList;
 
   // These are static because the account manager may go away during
@@ -106,47 +107,45 @@ private:
   static bool m_haveShutdown;
   static bool m_shutdownInProgress;
 
   bool m_userAuthenticated;
   bool m_loadingVirtualFolders;
   bool m_virtualFoldersLoaded;
 
   /* we call FindServer() a lot.  so cache the last server found */
-  nsCOMPtr <nsIMsgIncomingServer> m_lastFindServerResult;
+  nsCOMPtr<nsIMsgIncomingServer> m_lastFindServerResult;
   nsCString m_lastFindServerHostName;
   nsCString m_lastFindServerUserName;
   int32_t m_lastFindServerPort;
   nsCString m_lastFindServerType;
 
-  void SetLastServerFound(nsIMsgIncomingServer *server, const nsACString& hostname,
-                          const nsACString& username, const int32_t port, const nsACString& type);
+  void SetLastServerFound(nsIMsgIncomingServer *server,
+                          const nsACString &hostname,
+                          const nsACString &username, const int32_t port,
+                          const nsACString &type);
 
   // Cache the results of the last call to FolderUriFromDirInProfile
   nsCOMPtr<nsIFile> m_lastPathLookedUp;
   nsCString m_lastFolderURIForPath;
 
   /* internal creation routines - updates m_identities and m_incomingServers */
-  nsresult createKeyedAccount(const nsCString& key,
-                              nsIMsgAccount **_retval);
-  nsresult createKeyedServer(const nsACString& key,
-                             const nsACString& username,
-                             const nsACString& password,
-                             const nsACString& type,
+  nsresult createKeyedAccount(const nsCString &key, nsIMsgAccount **_retval);
+  nsresult createKeyedServer(const nsACString &key, const nsACString &username,
+                             const nsACString &password, const nsACString &type,
                              nsIMsgIncomingServer **_retval);
 
-  nsresult createKeyedIdentity(const nsACString& key,
-                               nsIMsgIdentity **_retval);
+  nsresult createKeyedIdentity(const nsACString &key, nsIMsgIdentity **_retval);
 
   nsresult GetLocalFoldersPrettyName(nsString &localFoldersName);
 
   /**
    * Check if the given account can be the set as the default account.
    */
-  nsresult CheckDefaultAccount(nsIMsgAccount* aAccount, bool &aCanBeDefault);
+  nsresult CheckDefaultAccount(nsIMsgAccount *aAccount, bool &aCanBeDefault);
 
   /**
    * Find a new account that can serve as default.
    */
   nsresult AutosetDefaultAccount();
 
   // sets the pref for the default server
   nsresult setDefaultAccountPref(nsIMsgAccount *aDefaultAccount);
@@ -159,48 +158,46 @@ private:
                                      nsIMsgAccount *aNewAccount);
 
   //
   // account enumerators
   // ("element" is always an account)
   //
 
   // find the servers that correspond to the given identity
-  static bool findServersForIdentity (nsISupports *element, void *aData);
+  static bool findServersForIdentity(nsISupports *element, void *aData);
 
-  void findAccountByServerKey(const nsCString &aKey,
-                              nsIMsgAccount **aResult);
+  void findAccountByServerKey(const nsCString &aKey, nsIMsgAccount **aResult);
 
   //
   // server enumerators
   // ("element" is always a server)
   //
 
-  nsresult findServerInternal(const nsACString& username,
-                              const nsACString& hostname,
-                              const nsACString& type,
-                              int32_t port,
-                              bool aRealFlag,
-                              nsIMsgIncomingServer** aResult);
+  nsresult findServerInternal(const nsACString &username,
+                              const nsACString &hostname,
+                              const nsACString &type, int32_t port,
+                              bool aRealFlag, nsIMsgIncomingServer **aResult);
 
   // handle virtual folders
-  static nsresult GetVirtualFoldersFile(nsCOMPtr<nsIFile>& file);
-  static nsresult WriteLineToOutputStream(const char *prefix, const char * line, nsIOutputStream *outputStream);
+  static nsresult GetVirtualFoldersFile(nsCOMPtr<nsIFile> &file);
+  static nsresult WriteLineToOutputStream(const char *prefix, const char *line,
+                                          nsIOutputStream *outputStream);
   void ParseAndVerifyVirtualFolderScope(nsCString &buffer);
   nsresult AddVFListenersForVF(nsIMsgFolder *virtualFolder,
-                               const nsCString& srchFolderUris,
+                               const nsCString &srchFolderUris,
                                nsIMsgDBService *msgDBService);
 
   nsresult RemoveVFListenerForVF(nsIMsgFolder *virtualFolder,
                                  nsIMsgFolder *folder);
 
-  void getUniqueAccountKey(nsCString& aResult);
+  void getUniqueAccountKey(nsCString &aResult);
 
   // Scan the preferences to find a unique server key
-  void GetUniqueServerKey(nsACString& aResult);
+  void GetUniqueServerKey(nsACString &aResult);
 
   nsresult RemoveFolderFromSmartFolder(nsIMsgFolder *aFolder,
                                        uint32_t flagsChanged);
 
   nsresult SetSendLaterUriPref(nsIMsgIncomingServer *server);
 
   nsCOMPtr<nsIPrefBranch> m_prefs;
 
--- a/mailnews/base/src/nsMsgBiffManager.cpp
+++ b/mailnews/base/src/nsMsgBiffManager.cpp
@@ -20,307 +20,265 @@
 
 #define PREF_BIFF_JITTER "mail.biff.add_interval_jitter"
 
 static NS_DEFINE_CID(kStatusBarBiffManagerCID, NS_STATUSBARBIFFMANAGER_CID);
 
 static mozilla::LazyLogModule MsgBiffLogModule("MsgBiff");
 
 NS_IMPL_ISUPPORTS(nsMsgBiffManager, nsIMsgBiffManager,
-                   nsIIncomingServerListener, nsIObserver,
-                   nsISupportsWeakReference)
+                  nsIIncomingServerListener, nsIObserver,
+                  nsISupportsWeakReference)
 
-void OnBiffTimer(nsITimer *timer, void *aBiffManager)
-{
-  nsMsgBiffManager *biffManager = (nsMsgBiffManager*)aBiffManager;
+void OnBiffTimer(nsITimer *timer, void *aBiffManager) {
+  nsMsgBiffManager *biffManager = (nsMsgBiffManager *)aBiffManager;
   biffManager->PerformBiff();
 }
 
-nsMsgBiffManager::nsMsgBiffManager()
-{
+nsMsgBiffManager::nsMsgBiffManager() {
   mHaveShutdown = false;
   mInited = false;
 }
 
-nsMsgBiffManager::~nsMsgBiffManager()
-{
-  if (mBiffTimer)
-    mBiffTimer->Cancel();
+nsMsgBiffManager::~nsMsgBiffManager() {
+  if (mBiffTimer) mBiffTimer->Cancel();
 
-  if (!mHaveShutdown)
-    Shutdown();
+  if (!mHaveShutdown) Shutdown();
 
   nsCOMPtr<nsIObserverService> observerService =
-    mozilla::services::GetObserverService();
-  if (observerService)
-  {
+      mozilla::services::GetObserverService();
+  if (observerService) {
     observerService->RemoveObserver(this, "wake_notification");
     observerService->RemoveObserver(this, "sleep_notification");
   }
 }
 
-NS_IMETHODIMP nsMsgBiffManager::Init()
-{
-  if (mInited)
-    return NS_OK;
+NS_IMETHODIMP nsMsgBiffManager::Init() {
+  if (mInited) return NS_OK;
 
   mInited = true;
   nsresult rv;
 
   nsCOMPtr<nsIMsgAccountManager> accountManager =
-  do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv))
-    accountManager->AddIncomingServerListener(this);
+      do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) accountManager->AddIncomingServerListener(this);
 
   // in turbo mode on profile change we don't need to do anything below this
-  if (mHaveShutdown)
-  {
+  if (mHaveShutdown) {
     mHaveShutdown = false;
     return NS_OK;
   }
 
   // Ensure status bar biff service has started
   nsCOMPtr<nsIFolderListener> statusBarBiffService =
-    do_GetService(kStatusBarBiffManagerCID, &rv);
+      do_GetService(kStatusBarBiffManagerCID, &rv);
 
   nsCOMPtr<nsIObserverService> observerService =
-    mozilla::services::GetObserverService();
-  if (observerService)
-  {
+      mozilla::services::GetObserverService();
+  if (observerService) {
     observerService->AddObserver(this, "sleep_notification", true);
     observerService->AddObserver(this, "wake_notification", true);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgBiffManager::Shutdown()
-{
-  if (mBiffTimer)
-  {
+NS_IMETHODIMP nsMsgBiffManager::Shutdown() {
+  if (mBiffTimer) {
     mBiffTimer->Cancel();
     mBiffTimer = nullptr;
   }
 
   nsresult rv;
   nsCOMPtr<nsIMsgAccountManager> accountManager =
-    do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv))
-    accountManager->RemoveIncomingServerListener(this);
+      do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) accountManager->RemoveIncomingServerListener(this);
 
   mHaveShutdown = true;
   mInited = false;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgBiffManager::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData)
-{
-  if (!strcmp(aTopic, "sleep_notification") && mBiffTimer)
-  {
+NS_IMETHODIMP nsMsgBiffManager::Observe(nsISupports *aSubject,
+                                        const char *aTopic,
+                                        const char16_t *someData) {
+  if (!strcmp(aTopic, "sleep_notification") && mBiffTimer) {
     mBiffTimer->Cancel();
     mBiffTimer = nullptr;
-  }
-  else if (!strcmp(aTopic, "wake_notification"))
-  {
+  } else if (!strcmp(aTopic, "wake_notification")) {
     // wait 10 seconds after waking up to start biffing again.
     mBiffTimer = do_CreateInstance("@mozilla.org/timer;1");
-    mBiffTimer->InitWithNamedFuncCallback(OnBiffTimer, (void*)this, 10000,
+    mBiffTimer->InitWithNamedFuncCallback(OnBiffTimer, (void *)this, 10000,
                                           nsITimer::TYPE_ONE_SHOT,
                                           "nsMsgBiffManager::OnBiffTimer");
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgBiffManager::AddServerBiff(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgBiffManager::AddServerBiff(nsIMsgIncomingServer *server) {
   NS_ENSURE_ARG_POINTER(server);
 
   int32_t biffMinutes;
 
   nsresult rv = server->GetBiffMinutes(&biffMinutes);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Don't add if biffMinutes isn't > 0
-  if (biffMinutes > 0)
-  {
+  if (biffMinutes > 0) {
     int32_t serverIndex = FindServer(server);
     // Only add it if it hasn't been added already.
-    if (serverIndex == -1)
-    {
+    if (serverIndex == -1) {
       nsBiffEntry biffEntry;
       biffEntry.server = server;
       rv = SetNextBiffTime(biffEntry, PR_Now());
       NS_ENSURE_SUCCESS(rv, rv);
 
       AddBiffEntry(biffEntry);
       SetupNextBiff();
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgBiffManager::RemoveServerBiff(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgBiffManager::RemoveServerBiff(nsIMsgIncomingServer *server) {
   int32_t pos = FindServer(server);
-  if (pos != -1)
-    mBiffArray.RemoveElementAt(pos);
+  if (pos != -1) mBiffArray.RemoveElementAt(pos);
 
   // Should probably reset biff time if this was the server that gets biffed
   // next.
   return NS_OK;
 }
 
-
-NS_IMETHODIMP nsMsgBiffManager::ForceBiff(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgBiffManager::ForceBiff(nsIMsgIncomingServer *server) {
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgBiffManager::ForceBiffAll()
-{
-  return NS_OK;
-}
+NS_IMETHODIMP nsMsgBiffManager::ForceBiffAll() { return NS_OK; }
 
-NS_IMETHODIMP nsMsgBiffManager::OnServerLoaded(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgBiffManager::OnServerLoaded(nsIMsgIncomingServer *server) {
   NS_ENSURE_ARG_POINTER(server);
 
   bool doBiff = false;
   nsresult rv = server->GetDoBiff(&doBiff);
 
-  if (NS_SUCCEEDED(rv) && doBiff)
-    rv = AddServerBiff(server);
+  if (NS_SUCCEEDED(rv) && doBiff) rv = AddServerBiff(server);
 
   return rv;
 }
 
-NS_IMETHODIMP nsMsgBiffManager::OnServerUnloaded(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgBiffManager::OnServerUnloaded(nsIMsgIncomingServer *server) {
   return RemoveServerBiff(server);
 }
 
-NS_IMETHODIMP nsMsgBiffManager::OnServerChanged(nsIMsgIncomingServer *server)
-{
+NS_IMETHODIMP nsMsgBiffManager::OnServerChanged(nsIMsgIncomingServer *server) {
   // nothing required.  If the hostname or username changed
   // the next time biff fires, we'll ping the right server
   return NS_OK;
 }
 
-int32_t nsMsgBiffManager::FindServer(nsIMsgIncomingServer *server)
-{
+int32_t nsMsgBiffManager::FindServer(nsIMsgIncomingServer *server) {
   uint32_t count = mBiffArray.Length();
-  for (uint32_t i = 0; i < count; i++)
-  {
-    if (server == mBiffArray[i].server.get())
-      return i;
+  for (uint32_t i = 0; i < count; i++) {
+    if (server == mBiffArray[i].server.get()) return i;
   }
   return -1;
 }
 
-nsresult nsMsgBiffManager::AddBiffEntry(nsBiffEntry &biffEntry)
-{
+nsresult nsMsgBiffManager::AddBiffEntry(nsBiffEntry &biffEntry) {
   uint32_t i;
   uint32_t count = mBiffArray.Length();
-  for (i = 0; i < count; i++)
-  {
-    if (biffEntry.nextBiffTime < mBiffArray[i].nextBiffTime)
-      break;
+  for (i = 0; i < count; i++) {
+    if (biffEntry.nextBiffTime < mBiffArray[i].nextBiffTime) break;
   }
-  MOZ_LOG(MsgBiffLogModule, mozilla::LogLevel::Info, ("inserting biff entry at %d", i));
+  MOZ_LOG(MsgBiffLogModule, mozilla::LogLevel::Info,
+          ("inserting biff entry at %d", i));
   mBiffArray.InsertElementAt(i, biffEntry);
   return NS_OK;
 }
 
-nsresult nsMsgBiffManager::SetNextBiffTime(nsBiffEntry &biffEntry, PRTime currentTime)
-{
+nsresult nsMsgBiffManager::SetNextBiffTime(nsBiffEntry &biffEntry,
+                                           PRTime currentTime) {
   nsIMsgIncomingServer *server = biffEntry.server;
   NS_ENSURE_TRUE(server, NS_ERROR_FAILURE);
 
   int32_t biffInterval;
   nsresult rv = server->GetBiffMinutes(&biffInterval);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Add biffInterval, converted in microseconds, to current time.
   // Force 64-bit multiplication.
   PRTime chosenTimeInterval = biffInterval * 60000000LL;
   biffEntry.nextBiffTime = currentTime + chosenTimeInterval;
 
   // Check if we should jitter.
   nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
-  if (prefs)
-  {
+  if (prefs) {
     bool shouldUseBiffJitter = false;
     prefs->GetBoolPref(PREF_BIFF_JITTER, &shouldUseBiffJitter);
-    if (shouldUseBiffJitter)
-    {
+    if (shouldUseBiffJitter) {
       // Calculate a jitter of +/-5% on chosenTimeInterval
       // - minimum 1 second (to avoid a modulo with 0)
-      // - maximum 30 seconds (to avoid problems when biffInterval is very large)
+      // - maximum 30 seconds (to avoid problems when biffInterval is very
+      // large)
       int64_t jitter = (int64_t)(0.05 * (int64_t)chosenTimeInterval);
-      jitter = std::max<int64_t>(1000000LL, std::min<int64_t>(jitter, 30000000LL));
+      jitter =
+          std::max<int64_t>(1000000LL, std::min<int64_t>(jitter, 30000000LL));
       jitter = ((rand() % 2) ? 1 : -1) * (rand() % jitter);
 
       biffEntry.nextBiffTime += jitter;
     }
   }
 
   return NS_OK;
 }
 
-nsresult nsMsgBiffManager::SetupNextBiff()
-{
-  if (mBiffArray.Length() > 0)
-  {
+nsresult nsMsgBiffManager::SetupNextBiff() {
+  if (mBiffArray.Length() > 0) {
     // Get the next biff entry
     const nsBiffEntry &biffEntry = mBiffArray[0];
     PRTime currentTime = PR_Now();
     int64_t biffDelay;
     int64_t ms(1000);
 
-    if (currentTime > biffEntry.nextBiffTime)
-    {
+    if (currentTime > biffEntry.nextBiffTime) {
       // Let's wait 30 seconds before firing biff again
       biffDelay = 30 * PR_USEC_PER_SEC;
-    }
-    else
+    } else
       biffDelay = biffEntry.nextBiffTime - currentTime;
 
     // Convert biffDelay into milliseconds
     int64_t timeInMS = biffDelay / ms;
     uint32_t timeInMSUint32 = (uint32_t)timeInMS;
 
     // Can't currently reset a timer when it's in the process of
     // calling Notify. So, just release the timer here and create a new one.
-    if (mBiffTimer)
-      mBiffTimer->Cancel();
+    if (mBiffTimer) mBiffTimer->Cancel();
 
-    MOZ_LOG(MsgBiffLogModule, mozilla::LogLevel::Info, ("setting %d timer", timeInMSUint32));
+    MOZ_LOG(MsgBiffLogModule, mozilla::LogLevel::Info,
+            ("setting %d timer", timeInMSUint32));
     mBiffTimer = do_CreateInstance("@mozilla.org/timer;1");
-    mBiffTimer->InitWithNamedFuncCallback(OnBiffTimer, (void*)this, timeInMSUint32,
-                                          nsITimer::TYPE_ONE_SHOT,
-                                          "nsMsgBiffManager::OnBiffTimer");
-
+    mBiffTimer->InitWithNamedFuncCallback(
+        OnBiffTimer, (void *)this, timeInMSUint32, nsITimer::TYPE_ONE_SHOT,
+        "nsMsgBiffManager::OnBiffTimer");
   }
   return NS_OK;
 }
 
-//This is the function that does a biff on all of the servers whose time it is to biff.
-nsresult nsMsgBiffManager::PerformBiff()
-{
+// This is the function that does a biff on all of the servers whose time it is
+// to biff.
+nsresult nsMsgBiffManager::PerformBiff() {
   PRTime currentTime = PR_Now();
   nsCOMArray<nsIMsgFolder> targetFolders;
   MOZ_LOG(MsgBiffLogModule, mozilla::LogLevel::Info, ("performing biffs"));
 
   uint32_t count = mBiffArray.Length();
-  for (uint32_t i = 0; i < count; i++)
-  {
+  for (uint32_t i = 0; i < count; i++) {
     // Take a copy of the entry rather than the a reference so that we can
     // remove and add if necessary, but keep the references and memory alive.
     nsBiffEntry current = mBiffArray[i];
-    if (current.nextBiffTime < currentTime)
-    {
+    if (current.nextBiffTime < currentTime) {
       bool serverBusy = false;
       bool serverRequiresPassword = true;
       bool passwordPromptRequired;
 
       current.server->GetPasswordPromptRequired(&passwordPromptRequired);
       current.server->GetServerBusy(&serverBusy);
       current.server->GetServerRequiresPasswordForBiff(&serverRequiresPassword);
       // find the dest folder we're actually downloading to...
@@ -329,45 +287,44 @@ nsresult nsMsgBiffManager::PerformBiff()
       int32_t targetFolderIndex = targetFolders.IndexOfObject(rootMsgFolder);
       if (targetFolderIndex == kNotFound)
         targetFolders.AppendObject(rootMsgFolder);
 
       // so if we need to be authenticated to biff, check that we are
       // (since we don't want to prompt the user for password UI)
       // and make sure the server isn't already in the middle of downloading
       // new messages
-      if (!serverBusy &&
-          (!serverRequiresPassword || !passwordPromptRequired) &&
-          targetFolderIndex == kNotFound)
-      {
+      if (!serverBusy && (!serverRequiresPassword || !passwordPromptRequired) &&
+          targetFolderIndex == kNotFound) {
         nsCString serverKey;
         current.server->GetKey(serverKey);
         nsresult rv = current.server->PerformBiff(nullptr);
         MOZ_LOG(MsgBiffLogModule, mozilla::LogLevel::Info,
-          ("biffing server %s rv = %" PRIx32, serverKey.get(), static_cast<uint32_t>(rv)));
-      }
-      else
-      {
+                ("biffing server %s rv = %" PRIx32, serverKey.get(),
+                 static_cast<uint32_t>(rv)));
+      } else {
         MOZ_LOG(MsgBiffLogModule, mozilla::LogLevel::Info,
-          ("not biffing server serverBusy = %d requirespassword = %d password prompt required = %d targetFolderIndex = %d",
-           serverBusy, serverRequiresPassword, passwordPromptRequired, targetFolderIndex));
+                ("not biffing server serverBusy = %d requirespassword = %d "
+                 "password prompt required = %d targetFolderIndex = %d",
+                 serverBusy, serverRequiresPassword, passwordPromptRequired,
+                 targetFolderIndex));
       }
-      // if we didn't do this server because the destination server was already being
-      // biffed into, leave this server in the biff array so it will fire next.
-      if (targetFolderIndex == kNotFound)
-      {
+      // if we didn't do this server because the destination server was already
+      // being biffed into, leave this server in the biff array so it will fire
+      // next.
+      if (targetFolderIndex == kNotFound) {
         mBiffArray.RemoveElementAt(i);
-        i--; //Because we removed it we need to look at the one that just moved up.
+        i--;  // Because we removed it we need to look at the one that just
+              // moved up.
         SetNextBiffTime(current, currentTime);
         AddBiffEntry(current);
       }
 #ifdef DEBUG_David_Bienvenu
       else
         printf("dest account performing biff\n");
 #endif
-    }
-    else
-      //since we're in biff order, there's no reason to keep checking
+    } else
+      // since we're in biff order, there's no reason to keep checking
       break;
   }
   SetupNextBiff();
   return NS_OK;
 }
--- a/mailnews/base/src/nsMsgBiffManager.h
+++ b/mailnews/base/src/nsMsgBiffManager.h
@@ -15,41 +15,38 @@
 #include "nsWeakReference.h"
 #include "nsIObserver.h"
 
 typedef struct {
   nsCOMPtr<nsIMsgIncomingServer> server;
   PRTime nextBiffTime;
 } nsBiffEntry;
 
-
-class nsMsgBiffManager
-  : public nsIMsgBiffManager,
-    public nsIIncomingServerListener,
-    public nsIObserver,
-    public nsSupportsWeakReference
-{
-public:
+class nsMsgBiffManager : public nsIMsgBiffManager,
+                         public nsIIncomingServerListener,
+                         public nsIObserver,
+                         public nsSupportsWeakReference {
+ public:
   nsMsgBiffManager();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMSGBIFFMANAGER
   NS_DECL_NSIINCOMINGSERVERLISTENER
   NS_DECL_NSIOBSERVER
 
   nsresult PerformBiff();
 
-protected:
+ protected:
   virtual ~nsMsgBiffManager();
 
   int32_t FindServer(nsIMsgIncomingServer *server);
   nsresult SetNextBiffTime(nsBiffEntry &biffEntry, PRTime currentTime);
   nsresult SetupNextBiff();
   nsresult AddBiffEntry(nsBiffEntry &biffEntry);
 
-protected:
+ protected:
   nsCOMPtr<nsITimer> mBiffTimer;
   nsTArray<nsBiffEntry> mBiffArray;
   bool mHaveShutdown;
   bool mInited;
 };
 
-#endif // NSMSGBIFFMANAGER_H
+#endif  // NSMSGBIFFMANAGER_H
--- a/mailnews/base/src/nsMsgContentPolicy.cpp
+++ b/mailnews/base/src/nsMsgContentPolicy.cpp
@@ -27,58 +27,52 @@
 #include "nsThreadUtils.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
 #include "mozilla/dom/HTMLImageElement.h"
 #include "nsINntpUrl.h"
 #include "nsILoadInfo.h"
 #include "nsSandboxFlags.h"
 #include "nsQueryObject.h"
 
-static const char kBlockRemoteImages[] = "mailnews.message_display.disable_remote_image";
-static const char kTrustedDomains[] =  "mail.trusteddomains";
+static const char kBlockRemoteImages[] =
+    "mailnews.message_display.disable_remote_image";
+static const char kTrustedDomains[] = "mail.trusteddomains";
 
 using namespace mozilla::mailnews;
 
-// Per message headder flags to keep track of whether the user is allowing remote
-// content for a particular message.
-// if you change or add more values to these constants, be sure to modify
-// the corresponding definitions in mailWindowOverlay.js
+// Per message headder flags to keep track of whether the user is allowing
+// remote content for a particular message. if you change or add more values to
+// these constants, be sure to modify the corresponding definitions in
+// mailWindowOverlay.js
 #define kNoRemoteContentPolicy 0
 #define kBlockRemoteContent 1
 #define kAllowRemoteContent 2
 
-NS_IMPL_ISUPPORTS(nsMsgContentPolicy,
-                  nsIContentPolicy,
-                  nsIWebProgressListener,
-                  nsIMsgContentPolicy,
-                  nsIObserver,
-                  nsISupportsWeakReference)
+NS_IMPL_ISUPPORTS(nsMsgContentPolicy, nsIContentPolicy, nsIWebProgressListener,
+                  nsIMsgContentPolicy, nsIObserver, nsISupportsWeakReference)
 
-nsMsgContentPolicy::nsMsgContentPolicy()
-{
-  mBlockRemoteImages = true;
-}
+nsMsgContentPolicy::nsMsgContentPolicy() { mBlockRemoteImages = true; }
 
-nsMsgContentPolicy::~nsMsgContentPolicy()
-{
+nsMsgContentPolicy::~nsMsgContentPolicy() {
   // hey, we are going away...clean up after ourself....unregister our observer
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch> prefInternal = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv))
-  {
+  nsCOMPtr<nsIPrefBranch> prefInternal =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  if (NS_SUCCEEDED(rv)) {
     prefInternal->RemoveObserver(kBlockRemoteImages, this);
   }
 }
 
-nsresult nsMsgContentPolicy::Init()
-{
+nsresult nsMsgContentPolicy::Init() {
   nsresult rv;
 
-  // register ourself as an observer on the mail preference to block remote images
-  nsCOMPtr<nsIPrefBranch> prefInternal = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  // register ourself as an observer on the mail preference to block remote
+  // images
+  nsCOMPtr<nsIPrefBranch> prefInternal =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   prefInternal->AddObserver(kBlockRemoteImages, this, true);
 
   prefInternal->GetCharPref(kTrustedDomains, mTrustedMailDomains);
   prefInternal->GetBoolPref(kBlockRemoteImages, &mBlockRemoteImages);
 
   // Grab a handle on the PermissionManager service for managing allowed remote
@@ -88,71 +82,67 @@ nsresult nsMsgContentPolicy::Init()
 
   return NS_OK;
 }
 
 /**
  * @returns true if the sender referenced by aMsgHdr is explicitly allowed to
  *          load remote images according to the PermissionManager
  */
-bool
-nsMsgContentPolicy::ShouldAcceptRemoteContentForSender(nsIMsgDBHdr *aMsgHdr)
-{
-  if (!aMsgHdr)
-    return false;
+bool nsMsgContentPolicy::ShouldAcceptRemoteContentForSender(
+    nsIMsgDBHdr *aMsgHdr) {
+  if (!aMsgHdr) return false;
 
   // extract the e-mail address from the msg hdr
   nsCString author;
   nsresult rv = aMsgHdr->GetAuthor(getter_Copies(author));
   NS_ENSURE_SUCCESS(rv, false);
 
   nsCString emailAddress;
   ExtractEmail(EncodedHeader(author), emailAddress);
-  if (emailAddress.IsEmpty())
-    return false;
+  if (emailAddress.IsEmpty()) return false;
 
-  nsCOMPtr<nsIIOService> ios = do_GetService("@mozilla.org/network/io-service;1", &rv);
+  nsCOMPtr<nsIIOService> ios =
+      do_GetService("@mozilla.org/network/io-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, false);
   nsCOMPtr<nsIURI> mailURI;
   emailAddress.InsertLiteral("chrome://messenger/content/email=", 0);
   rv = ios->NewURI(emailAddress, nullptr, nullptr, getter_AddRefs(mailURI));
   NS_ENSURE_SUCCESS(rv, false);
 
   // check with permission manager
   uint32_t permission = 0;
-  rv = mPermissionManager->TestPermission(mailURI, NS_LITERAL_CSTRING("image"), &permission);
+  rv = mPermissionManager->TestPermission(mailURI, NS_LITERAL_CSTRING("image"),
+                                          &permission);
   NS_ENSURE_SUCCESS(rv, false);
 
   // Only return true if the permission manager has an explicit allow
   return (permission == nsIPermissionManager::ALLOW_ACTION);
 }
 
 /**
  * Extract the host name from aContentLocation, and look it up in our list
  * of trusted domains.
  */
-bool nsMsgContentPolicy::IsTrustedDomain(nsIURI * aContentLocation)
-{
+bool nsMsgContentPolicy::IsTrustedDomain(nsIURI *aContentLocation) {
   bool trustedDomain = false;
   // get the host name of the server hosting the remote image
   nsAutoCString host;
   nsresult rv = aContentLocation->GetHost(host);
 
   if (NS_SUCCEEDED(rv) && !mTrustedMailDomains.IsEmpty())
     trustedDomain = MsgHostDomainIsTrusted(host, mTrustedMailDomains);
 
   return trustedDomain;
 }
 
 NS_IMETHODIMP
-nsMsgContentPolicy::ShouldLoad(nsIURI           *aContentLocation,
-                               nsILoadInfo      *aLoadInfo,
+nsMsgContentPolicy::ShouldLoad(nsIURI *aContentLocation, nsILoadInfo *aLoadInfo,
                                const nsACString &aMimeGuess,
-                               int16_t          *aDecision)
-{
+                               int16_t *aDecision) {
   nsresult rv = NS_OK;
   uint32_t aContentType = aLoadInfo->GetExternalContentPolicyType();
   nsCOMPtr<nsISupports> aRequestingContext;
   if (aContentType == nsIContentPolicy::TYPE_DOCUMENT)
     aRequestingContext = aLoadInfo->ContextForTopLevelLoad();
   else
     aRequestingContext = aLoadInfo->LoadingNode();
   nsCOMPtr<nsIPrincipal> aRequestPrincipal = aLoadInfo->TriggeringPrincipal();
@@ -172,81 +162,80 @@ nsMsgContentPolicy::ShouldLoad(nsIURI   
   //
   // In most cases if an error occurs, its something we didn't expect so we
   // should be rejecting the document anyway.
   *aDecision = nsIContentPolicy::ACCEPT;
 
   NS_ENSURE_ARG_POINTER(aContentLocation);
 
 #ifdef DEBUG_MsgContentPolicy
-  fprintf(stderr, "aContentType: %d\naContentLocation = %s\n",
-          aContentType,
+  fprintf(stderr, "aContentType: %d\naContentLocation = %s\n", aContentType,
           aContentLocation->GetSpecOrDefault().get());
 #endif
 
 #ifndef MOZ_THUNDERBIRD
   // Go find out if we are dealing with mailnews. Anything else
   // isn't our concern and we accept content.
   nsCOMPtr<nsIDocShell> rootDocShell;
   rv = GetRootDocShellForContext(aRequestingContext,
                                  getter_AddRefs(rootDocShell));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // We only want to deal with mailnews
-  if (rootDocShell->GetAppType() != nsIDocShell::APP_TYPE_MAIL)
-    return NS_OK;
+  if (rootDocShell->GetAppType() != nsIDocShell::APP_TYPE_MAIL) return NS_OK;
 #endif
 
-  switch(aContentType) {
-    // Plugins (nsIContentPolicy::TYPE_OBJECT) are blocked on document load.
-  case nsIContentPolicy::TYPE_DOCUMENT:
-    // At this point, we have no intention of supporting a different JS
-    // setting on a subdocument, so we don't worry about TYPE_SUBDOCUMENT here.
+  switch (aContentType) {
+      // Plugins (nsIContentPolicy::TYPE_OBJECT) are blocked on document load.
+    case nsIContentPolicy::TYPE_DOCUMENT:
+      // At this point, we have no intention of supporting a different JS
+      // setting on a subdocument, so we don't worry about TYPE_SUBDOCUMENT
+      // here.
 
-    // If the timing were right, we'd enable JavaScript on the docshell
-    // for non mailnews URIs here.  However, at this point, the
-    // old document may still be around, so we can't do any enabling just yet.
-    // Instead, we apply the policy in nsIWebProgressListener::OnLocationChange.
-    // For now, we explicitly disable JavaScript in order to be safe rather than
-    // sorry, because OnLocationChange isn't guaranteed to necessarily be called
-    // soon enough to disable it in time (though bz says it _should_ be called
-    // soon enough "in all sane cases").
-    rv = SetDisableItemsOnMailNewsUrlDocshells(aContentLocation,
-                                               aRequestingContext);
-    // if something went wrong during the tweaking, reject this content
-    if (NS_FAILED(rv)) {
-      NS_WARNING("Failed to set disable items on docShells");
-      *aDecision = nsIContentPolicy::REJECT_TYPE;
+      // If the timing were right, we'd enable JavaScript on the docshell
+      // for non mailnews URIs here.  However, at this point, the
+      // old document may still be around, so we can't do any enabling just yet.
+      // Instead, we apply the policy in
+      // nsIWebProgressListener::OnLocationChange. For now, we explicitly
+      // disable JavaScript in order to be safe rather than sorry, because
+      // OnLocationChange isn't guaranteed to necessarily be called soon enough
+      // to disable it in time (though bz says it _should_ be called soon enough
+      // "in all sane cases").
+      rv = SetDisableItemsOnMailNewsUrlDocshells(aContentLocation,
+                                                 aRequestingContext);
+      // if something went wrong during the tweaking, reject this content
+      if (NS_FAILED(rv)) {
+        NS_WARNING("Failed to set disable items on docShells");
+        *aDecision = nsIContentPolicy::REJECT_TYPE;
+        return NS_OK;
+      }
+      break;
+
+    case nsIContentPolicy::TYPE_CSP_REPORT:
+      // We cannot block CSP reports.
+      *aDecision = nsIContentPolicy::ACCEPT;
       return NS_OK;
-    }
-    break;
+      break;
 
-  case nsIContentPolicy::TYPE_CSP_REPORT:
-    // We cannot block CSP reports.
-    *aDecision = nsIContentPolicy::ACCEPT;
-    return NS_OK;
-    break;
-
-  default:
-    break;
+    default:
+      break;
   }
 
   // NOTE: Not using NS_ENSURE_ARG_POINTER because this is a legitimate case
   // that can happen.  Also keep in mind that the default policy used for a
   // failure code is ACCEPT.
-  if (!aRequestingLocation)
-    return NS_ERROR_INVALID_POINTER;
+  if (!aRequestingLocation) return NS_ERROR_INVALID_POINTER;
 
 #ifdef DEBUG_MsgContentPolicy
-  fprintf(stderr, "aRequestingLocation = %s\n", aRequestingLocation->GetSpecOrDefault().get());
+  fprintf(stderr, "aRequestingLocation = %s\n",
+          aRequestingLocation->GetSpecOrDefault().get());
 #endif
 
   // If the requesting location is safe, accept the content location request.
-  if (IsSafeRequestingLocation(aRequestingLocation))
-    return rv;
+  if (IsSafeRequestingLocation(aRequestingLocation)) return rv;
 
   // Now default to reject so early returns via NS_ENSURE_SUCCESS
   // cause content to be rejected.
   *aDecision = nsIContentPolicy::REJECT_REQUEST;
 
   // We want to establish the following:
   // \--------\  requester    |               |              |
   // content   \------------\ |               |              |
@@ -258,163 +247,149 @@ nsMsgContentPolicy::ShouldLoad(nsIURI   
   // news message             | don't load (4)| load (5)     | load (6)
   // -------------------------+---------------+--------------+------------------
   // http(s)/data, etc.       | (default)     | (default)    | (default)
   // -------------------------+---------------+--------------+------------------
   nsCOMPtr<nsIMsgMessageUrl> contentURL(do_QueryInterface(aContentLocation));
   if (contentURL) {
     nsCOMPtr<nsINntpUrl> contentNntpURL(do_QueryInterface(aContentLocation));
     if (!contentNntpURL) {
-      // Mail message (mailbox, imap or JsAccount) content requested, for example
-      // a message part, like an image:
-      // To load mail message content the requester must have the same
-      // "normalized" principal. This is basically a "same origin" test, it
-      // protects against cross-loading of mail message content from
-      // other mail or news messages.
-      nsCOMPtr<nsIMsgMessageUrl> requestURL(do_QueryInterface(aRequestingLocation));
+      // Mail message (mailbox, imap or JsAccount) content requested, for
+      // example a message part, like an image: To load mail message content the
+      // requester must have the same "normalized" principal. This is basically
+      // a "same origin" test, it protects against cross-loading of mail message
+      // content from other mail or news messages.
+      nsCOMPtr<nsIMsgMessageUrl> requestURL(
+          do_QueryInterface(aRequestingLocation));
       // If the request URL is not also a message URL, then we don't accept.
       if (requestURL) {
         nsCString contentPrincipalSpec, requestPrincipalSpec;
         nsresult rv1 = contentURL->GetNormalizedSpec(contentPrincipalSpec);
         nsresult rv2 = requestURL->GetNormalizedSpec(requestPrincipalSpec);
         if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2) &&
             contentPrincipalSpec.Equals(requestPrincipalSpec))
-          *aDecision = nsIContentPolicy::ACCEPT; // (1)
+          *aDecision = nsIContentPolicy::ACCEPT;  // (1)
       }
-      return NS_OK; // (2) and (3)
+      return NS_OK;  // (2) and (3)
     }
 
     // News message content requested. Don't accept request coming
     // from a mail message since it would access the news server.
-    nsCOMPtr<nsIMsgMessageUrl> requestURL(do_QueryInterface(aRequestingLocation));
+    nsCOMPtr<nsIMsgMessageUrl> requestURL(
+        do_QueryInterface(aRequestingLocation));
     if (requestURL) {
-      nsCOMPtr<nsINntpUrl> requestNntpURL(do_QueryInterface(aRequestingLocation));
-      if (!requestNntpURL)
-        return NS_OK; // (4)
+      nsCOMPtr<nsINntpUrl> requestNntpURL(
+          do_QueryInterface(aRequestingLocation));
+      if (!requestNntpURL) return NS_OK;  // (4)
     }
-    *aDecision = nsIContentPolicy::ACCEPT; // (5) and (6)
+    *aDecision = nsIContentPolicy::ACCEPT;  // (5) and (6)
     return NS_OK;
   }
 
   // If exposed protocol not covered by the test above or protocol that has been
   // specifically exposed by an add-on, or is a chrome url, then allow the load.
-  if (IsExposedProtocol(aContentLocation))
-  {
+  if (IsExposedProtocol(aContentLocation)) {
     *aDecision = nsIContentPolicy::ACCEPT;
     return NS_OK;
   }
 
   // never load unexposed protocols except for http, https and file.
   // Protocols like ftp are always blocked.
-  if (ShouldBlockUnexposedProtocol(aContentLocation))
-    return NS_OK;
-
+  if (ShouldBlockUnexposedProtocol(aContentLocation)) return NS_OK;
 
   // Find out the URI that originally initiated the set of requests for this
   // context.
   nsCOMPtr<nsIURI> originatorLocation;
-  if (!aRequestingContext && aRequestPrincipal)
-  {
+  if (!aRequestingContext && aRequestPrincipal) {
     // Can get the URI directly from the principal.
     rv = aRequestPrincipal->GetURI(getter_AddRefs(originatorLocation));
-  }
-  else
-  {
+  } else {
     rv = GetOriginatingURIForContext(aRequestingContext,
                                      getter_AddRefs(originatorLocation));
-    if (NS_SUCCEEDED(rv) && !originatorLocation)
-      return NS_OK;
+    if (NS_SUCCEEDED(rv) && !originatorLocation) return NS_OK;
   }
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
 #ifdef DEBUG_MsgContentPolicy
-  fprintf(stderr, "originatorLocation = %s\n", originatorLocation->GetSpecOrDefault().get());
+  fprintf(stderr, "originatorLocation = %s\n",
+          originatorLocation->GetSpecOrDefault().get());
 #endif
 
   // Don't load remote content for encrypted messages.
-  nsCOMPtr<nsIEncryptedSMIMEURIsService> encryptedURIService =
-    do_GetService("@mozilla.org/messenger-smime/smime-encrypted-uris-service;1", &rv);
+  nsCOMPtr<nsIEncryptedSMIMEURIsService> encryptedURIService = do_GetService(
+      "@mozilla.org/messenger-smime/smime-encrypted-uris-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   bool isEncrypted;
-  rv = encryptedURIService->IsEncrypted(aRequestingLocation->GetSpecOrDefault(), &isEncrypted);
+  rv = encryptedURIService->IsEncrypted(aRequestingLocation->GetSpecOrDefault(),
+                                        &isEncrypted);
   NS_ENSURE_SUCCESS(rv, rv);
-  if (isEncrypted)
-  {
+  if (isEncrypted) {
     *aDecision = nsIContentPolicy::REJECT_REQUEST;
     NotifyContentWasBlocked(originatorLocation, aContentLocation, false);
     return NS_OK;
   }
 
   // If we are allowing all remote content...
-  if (!mBlockRemoteImages)
-  {
+  if (!mBlockRemoteImages) {
     *aDecision = nsIContentPolicy::ACCEPT;
     return NS_OK;
   }
 
   // Extract the windowtype to handle compose windows separately from mail
-  if (aRequestingContext)
-  {
+  if (aRequestingContext) {
     nsCOMPtr<nsIMsgCompose> msgCompose =
-      GetMsgComposeForContext(aRequestingContext);
+        GetMsgComposeForContext(aRequestingContext);
     // Work out if we're in a compose window or not.
-    if (msgCompose)
-    {
+    if (msgCompose) {
       ComposeShouldLoad(msgCompose, aRequestingContext, aContentLocation,
                         aDecision);
       return NS_OK;
     }
   }
 
   // Allow content when using a remote page.
   bool isHttp;
   bool isHttps;
   rv = originatorLocation->SchemeIs("http", &isHttp);
   nsresult rv2 = originatorLocation->SchemeIs("https", &isHttps);
-  if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2) && (isHttp || isHttps))
-  {
+  if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2) && (isHttp || isHttps)) {
     *aDecision = nsIContentPolicy::ACCEPT;
     return NS_OK;
   }
 
   uint32_t permission;
-  mPermissionManager->TestPermission(aContentLocation, NS_LITERAL_CSTRING("image"), &permission);
+  mPermissionManager->TestPermission(aContentLocation,
+                                     NS_LITERAL_CSTRING("image"), &permission);
   switch (permission) {
-    case nsIPermissionManager::UNKNOWN_ACTION:
-    {
+    case nsIPermissionManager::UNKNOWN_ACTION: {
       // No exception was found for this location.
       break;
     }
-    case nsIPermissionManager::ALLOW_ACTION:
-    {
+    case nsIPermissionManager::ALLOW_ACTION: {
       *aDecision = nsIContentPolicy::ACCEPT;
       return NS_OK;
     }
-    case nsIPermissionManager::DENY_ACTION:
-    {
+    case nsIPermissionManager::DENY_ACTION: {
       *aDecision = nsIContentPolicy::REJECT_REQUEST;
       return NS_OK;
     }
   }
 
   // The default decision is still to reject.
   ShouldAcceptContentForPotentialMsg(originatorLocation, aContentLocation,
                                      aDecision);
   return NS_OK;
 }
 
 /**
  * Determines if the requesting location is a safe one, i.e. its under the
  * app/user's control - so file, about, chrome etc.
  */
-bool
-nsMsgContentPolicy::IsSafeRequestingLocation(nsIURI *aRequestingLocation)
-{
-  if (!aRequestingLocation)
-    return false;
+bool nsMsgContentPolicy::IsSafeRequestingLocation(nsIURI *aRequestingLocation) {
+  if (!aRequestingLocation) return false;
 
   // If aRequestingLocation is one of chrome, resource, file or view-source,
   // allow aContentLocation to load.
   bool isChrome;
   bool isRes;
   bool isFile;
   bool isViewSource;
 
@@ -422,59 +397,54 @@ nsMsgContentPolicy::IsSafeRequestingLoca
   NS_ENSURE_SUCCESS(rv, false);
   rv = aRequestingLocation->SchemeIs("resource", &isRes);
   NS_ENSURE_SUCCESS(rv, false);
   rv = aRequestingLocation->SchemeIs("file", &isFile);
   NS_ENSURE_SUCCESS(rv, false);
   rv = aRequestingLocation->SchemeIs("view-source", &isViewSource);
   NS_ENSURE_SUCCESS(rv, false);
 
-  if (isChrome || isRes || isFile || isViewSource)
-    return true;
+  if (isChrome || isRes || isFile || isViewSource) return true;
 
   // Only allow about: to load anything if the requesting location is not the
   // special about:blank one.
   bool isAbout;
   rv = aRequestingLocation->SchemeIs("about", &isAbout);
   NS_ENSURE_SUCCESS(rv, false);
 
-  if (!isAbout)
-    return false;
+  if (!isAbout) return false;
 
   nsCString fullSpec;
   rv = aRequestingLocation->GetSpec(fullSpec);
   NS_ENSURE_SUCCESS(rv, false);
 
   return !fullSpec.EqualsLiteral("about:blank");
 }
 
 /**
  * Determines if the content location is a scheme that we're willing to expose
  * for unlimited loading of content.
  */
-bool
-nsMsgContentPolicy::IsExposedProtocol(nsIURI *aContentLocation)
-{
+bool nsMsgContentPolicy::IsExposedProtocol(nsIURI *aContentLocation) {
   nsAutoCString contentScheme;
   nsresult rv = aContentLocation->GetScheme(contentScheme);
   NS_ENSURE_SUCCESS(rv, false);
 
   // Check some exposed protocols. Not all protocols in the list of
   // network.protocol-handler.expose.* prefs in all-thunderbird.js are
   // admitted purely based on their scheme.
   // news, snews, nntp, imap and mailbox are checked before the call
   // to this function by matching content location and requesting location.
   if (MsgLowerCaseEqualsLiteral(contentScheme, "mailto") ||
       MsgLowerCaseEqualsLiteral(contentScheme, "addbook") ||
       MsgLowerCaseEqualsLiteral(contentScheme, "about"))
     return true;
 
   // check if customized exposed scheme
-  if (mCustomExposedProtocols.Contains(contentScheme))
-    return true;
+  if (mCustomExposedProtocols.Contains(contentScheme)) return true;
 
   bool isData;
   bool isChrome;
   bool isRes;
   bool isMozExtension;
   rv = aContentLocation->SchemeIs("chrome", &isChrome);
   NS_ENSURE_SUCCESS(rv, false);
   rv = aContentLocation->SchemeIs("resource", &isRes);
@@ -485,19 +455,18 @@ nsMsgContentPolicy::IsExposedProtocol(ns
   NS_ENSURE_SUCCESS(rv, false);
 
   return isChrome || isRes || isData || isMozExtension;
 }
 
 /**
  * We block most unexposed protocols - apart from http(s) and file.
  */
-bool
-nsMsgContentPolicy::ShouldBlockUnexposedProtocol(nsIURI *aContentLocation)
-{
+bool nsMsgContentPolicy::ShouldBlockUnexposedProtocol(
+    nsIURI *aContentLocation) {
   bool isHttp;
   bool isHttps;
   bool isFile;
   // Error condition - we must return true so that we block.
   nsresult rv = aContentLocation->SchemeIs("http", &isHttp);
   NS_ENSURE_SUCCESS(rv, true);
   rv = aContentLocation->SchemeIs("https", &isHttps);
   NS_ENSURE_SUCCESS(rv, true);
@@ -512,23 +481,20 @@ nsMsgContentPolicy::ShouldBlockUnexposed
  * When determining if to allow the request for a given msg hdr, the function
  * will go through the list of remote content blocking criteria:
  *
  * #1 Allow if there is a db header for a manual override.
  * #2 Allow if the message is in an RSS folder.
  * #3 Allow if the domain for the remote image in our white list.
  * #4 Allow if the author has been specifically white listed.
  */
-int16_t
-nsMsgContentPolicy::ShouldAcceptRemoteContentForMsgHdr(nsIMsgDBHdr *aMsgHdr,
-                                                       nsIURI *aRequestingLocation,
-                                                       nsIURI *aContentLocation)
-{
-  if (!aMsgHdr)
-    return static_cast<int16_t>(nsIContentPolicy::REJECT_REQUEST);
+int16_t nsMsgContentPolicy::ShouldAcceptRemoteContentForMsgHdr(
+    nsIMsgDBHdr *aMsgHdr, nsIURI *aRequestingLocation,
+    nsIURI *aContentLocation) {
+  if (!aMsgHdr) return static_cast<int16_t>(nsIContentPolicy::REJECT_REQUEST);
 
   // Case #1, check the db hdr for the remote content policy on this particular
   // message.
   uint32_t remoteContentPolicy = kNoRemoteContentPolicy;
   aMsgHdr->GetUint32Property("remoteContentPolicy", &remoteContentPolicy);
 
   // Case #2, check if the message is in an RSS folder
   bool isRSS = false;
@@ -540,279 +506,260 @@ nsMsgContentPolicy::ShouldAcceptRemoteCo
   // Case 4 means looking up items in the permissions database. So if
   // either of the two previous items means we load the data, just do it.
   if (isRSS || remoteContentPolicy == kAllowRemoteContent || trustedDomain)
     return nsIContentPolicy::ACCEPT;
 
   // Case #4, author is in our white list..
   bool allowForSender = ShouldAcceptRemoteContentForSender(aMsgHdr);
 
-  int16_t result = allowForSender ?
-    static_cast<int16_t>(nsIContentPolicy::ACCEPT) :
-    static_cast<int16_t>(nsIContentPolicy::REJECT_REQUEST);
+  int16_t result = allowForSender
+                       ? static_cast<int16_t>(nsIContentPolicy::ACCEPT)
+                       : static_cast<int16_t>(nsIContentPolicy::REJECT_REQUEST);
 
   // kNoRemoteContentPolicy means we have never set a value on the message
   if (result == nsIContentPolicy::REJECT_REQUEST && !remoteContentPolicy)
     aMsgHdr->SetUint32Property("remoteContentPolicy", kBlockRemoteContent);
 
   return result;
 }
 
-class RemoteContentNotifierEvent : public mozilla::Runnable
-{
-public:
+class RemoteContentNotifierEvent : public mozilla::Runnable {
+ public:
   RemoteContentNotifierEvent(nsIMsgWindow *aMsgWindow, nsIMsgDBHdr *aMsgHdr,
                              nsIURI *aContentURI, bool aCanOverride = true)
-    : mozilla::Runnable("RemoteContentNotifierEvent")
-    , mMsgWindow(aMsgWindow), mMsgHdr(aMsgHdr), mContentURI(aContentURI),
-    mCanOverride(aCanOverride)
-  {}
+      : mozilla::Runnable("RemoteContentNotifierEvent"),
+        mMsgWindow(aMsgWindow),
+        mMsgHdr(aMsgHdr),
+        mContentURI(aContentURI),
+        mCanOverride(aCanOverride) {}
 
-  NS_IMETHOD Run()
-  {
-    if (mMsgWindow)
-    {
+  NS_IMETHOD Run() {
+    if (mMsgWindow) {
       nsCOMPtr<nsIMsgHeaderSink> msgHdrSink;
       (void)mMsgWindow->GetMsgHeaderSink(getter_AddRefs(msgHdrSink));
       if (msgHdrSink)
         msgHdrSink->OnMsgHasRemoteContent(mMsgHdr, mContentURI, mCanOverride);
     }
     return NS_OK;
   }
 
-private:
+ private:
   nsCOMPtr<nsIMsgWindow> mMsgWindow;
   nsCOMPtr<nsIMsgDBHdr> mMsgHdr;
   nsCOMPtr<nsIURI> mContentURI;
   bool mCanOverride;
 };
 
 /**
  * This function is used to show a blocked remote content notification.
  */
-void
-nsMsgContentPolicy::NotifyContentWasBlocked(nsIURI *aOriginatorLocation,
-                                            nsIURI *aContentLocation,
-                                            bool aCanOverride)
-{
+void nsMsgContentPolicy::NotifyContentWasBlocked(nsIURI *aOriginatorLocation,
+                                                 nsIURI *aContentLocation,
+                                                 bool aCanOverride) {
   // Is it a mailnews url?
   nsresult rv;
-  nsCOMPtr<nsIMsgMessageUrl> msgUrl(do_QueryInterface(aOriginatorLocation,
-                                                      &rv));
-  if (NS_FAILED(rv))
-  {
+  nsCOMPtr<nsIMsgMessageUrl> msgUrl(
+      do_QueryInterface(aOriginatorLocation, &rv));
+  if (NS_FAILED(rv)) {
     return;
   }
 
   nsCString resourceURI;
   rv = msgUrl->GetUri(getter_Copies(resourceURI));
   NS_ENSURE_SUCCESS_VOID(rv);
 
-  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(do_QueryInterface(aOriginatorLocation, &rv));
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(
+      do_QueryInterface(aOriginatorLocation, &rv));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   nsCOMPtr<nsIMsgDBHdr> msgHdr;
   rv = GetMsgDBHdrFromURI(resourceURI.get(), getter_AddRefs(msgHdr));
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     // Maybe we can get a dummy header.
     nsCOMPtr<nsIMsgWindow> msgWindow;
     rv = mailnewsUrl->GetMsgWindow(getter_AddRefs(msgWindow));
-    if (msgWindow)
-    {
+    if (msgWindow) {
       nsCOMPtr<nsIMsgHeaderSink> msgHdrSink;
       rv = msgWindow->GetMsgHeaderSink(getter_AddRefs(msgHdrSink));
       if (msgHdrSink)
         rv = msgHdrSink->GetDummyMsgHeader(getter_AddRefs(msgHdr));
     }
   }
 
   nsCOMPtr<nsIMsgWindow> msgWindow;
   (void)mailnewsUrl->GetMsgWindow(getter_AddRefs(msgWindow));
-  if (msgWindow)
-  {
-    nsCOMPtr<nsIRunnable> event =
-      new RemoteContentNotifierEvent(msgWindow, msgHdr, aContentLocation, aCanOverride);
+  if (msgWindow) {
+    nsCOMPtr<nsIRunnable> event = new RemoteContentNotifierEvent(
+        msgWindow, msgHdr, aContentLocation, aCanOverride);
     // Post this as an event because it can cause dom mutations, and we
     // get called at a bad time to be causing dom mutations.
-    if (event)
-      NS_DispatchToCurrentThread(event);
+    if (event) NS_DispatchToCurrentThread(event);
   }
 }
 
 /**
  * This function is used to determine if we allow content for a remote message.
  * If we reject loading remote content, then we'll inform the message window
  * that this message has remote content (and hence we are not loading it).
  *
  * See ShouldAcceptRemoteContentForMsgHdr for the actual decisions that
  * determine if we are going to allow remote content.
  */
-void
-nsMsgContentPolicy::ShouldAcceptContentForPotentialMsg(nsIURI *aOriginatorLocation,
-                                                       nsIURI *aContentLocation,
-                                                       int16_t *aDecision)
-{
-  NS_ASSERTION(*aDecision == nsIContentPolicy::REJECT_REQUEST,
-               "AllowContentForPotentialMessage expects default decision to be reject!");
+void nsMsgContentPolicy::ShouldAcceptContentForPotentialMsg(
+    nsIURI *aOriginatorLocation, nsIURI *aContentLocation, int16_t *aDecision) {
+  NS_ASSERTION(
+      *aDecision == nsIContentPolicy::REJECT_REQUEST,
+      "AllowContentForPotentialMessage expects default decision to be reject!");
 
   // Is it a mailnews url?
   nsresult rv;
-  nsCOMPtr<nsIMsgMessageUrl> msgUrl(do_QueryInterface(aOriginatorLocation,
-                                                      &rv));
-  if (NS_FAILED(rv))
-  {
+  nsCOMPtr<nsIMsgMessageUrl> msgUrl(
+      do_QueryInterface(aOriginatorLocation, &rv));
+  if (NS_FAILED(rv)) {
     // It isn't a mailnews url - so we accept the load here, and let other
     // content policies make the decision if we should be loading it or not.
     *aDecision = nsIContentPolicy::ACCEPT;
     return;
   }
 
   nsCString resourceURI;
   rv = msgUrl->GetUri(getter_Copies(resourceURI));
   NS_ENSURE_SUCCESS_VOID(rv);
 
-  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(do_QueryInterface(aOriginatorLocation, &rv));
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl(
+      do_QueryInterface(aOriginatorLocation, &rv));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   nsCOMPtr<nsIMsgDBHdr> msgHdr;
   rv = GetMsgDBHdrFromURI(resourceURI.get(), getter_AddRefs(msgHdr));
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     // Maybe we can get a dummy header.
     nsCOMPtr<nsIMsgWindow> msgWindow;
     rv = mailnewsUrl->GetMsgWindow(getter_AddRefs(msgWindow));
-    if (msgWindow)
-    {
+    if (msgWindow) {
       nsCOMPtr<nsIMsgHeaderSink> msgHdrSink;
       rv = msgWindow->GetMsgHeaderSink(getter_AddRefs(msgHdrSink));
       if (msgHdrSink)
         rv = msgHdrSink->GetDummyMsgHeader(getter_AddRefs(msgHdr));
     }
   }
 
   // Get a decision on whether or not to allow remote content for this message
   // header.
   *aDecision = ShouldAcceptRemoteContentForMsgHdr(msgHdr, aOriginatorLocation,
                                                   aContentLocation);
 
   // If we're not allowing the remote content, tell the nsIMsgWindow loading
   // this url that this is the case, so that the UI knows to show the remote
   // content header bar, so the user can override if they wish.
-  if (*aDecision == nsIContentPolicy::REJECT_REQUEST)
-  {
+  if (*aDecision == nsIContentPolicy::REJECT_REQUEST) {
     nsCOMPtr<nsIMsgWindow> msgWindow;
     (void)mailnewsUrl->GetMsgWindow(getter_AddRefs(msgWindow));
-    if (msgWindow)
-    {
+    if (msgWindow) {
       nsCOMPtr<nsIRunnable> event =
-        new RemoteContentNotifierEvent(msgWindow, msgHdr, aContentLocation);
+          new RemoteContentNotifierEvent(msgWindow, msgHdr, aContentLocation);
       // Post this as an event because it can cause dom mutations, and we
       // get called at a bad time to be causing dom mutations.
-      if (event)
-        NS_DispatchToCurrentThread(event);
+      if (event) NS_DispatchToCurrentThread(event);
     }
   }
 }
 
 /**
  * Content policy logic for compose windows
  *
  */
 void nsMsgContentPolicy::ComposeShouldLoad(nsIMsgCompose *aMsgCompose,
                                            nsISupports *aRequestingContext,
                                            nsIURI *aContentLocation,
-                                           int16_t *aDecision)
-{
+                                           int16_t *aDecision) {
   NS_ASSERTION(*aDecision == nsIContentPolicy::REJECT_REQUEST,
                "ComposeShouldLoad expects default decision to be reject!");
 
   nsCString originalMsgURI;
   nsresult rv = aMsgCompose->GetOriginalMsgURI(getter_Copies(originalMsgURI));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   MSG_ComposeType composeType;
   rv = aMsgCompose->GetType(&composeType);
   NS_ENSURE_SUCCESS_VOID(rv);
 
   // Only allow remote content for new mail compositions or mailto
-  // Block remote content for all other types (drafts, templates, forwards, replies, etc)
-  // unless there is an associated msgHdr which allows the load, or unless the image is being
-  // added by the user and not the quoted message content...
+  // Block remote content for all other types (drafts, templates, forwards,
+  // replies, etc) unless there is an associated msgHdr which allows the load,
+  // or unless the image is being added by the user and not the quoted message
+  // content...
   if (composeType == nsIMsgCompType::New ||
       composeType == nsIMsgCompType::MailToUrl)
     *aDecision = nsIContentPolicy::ACCEPT;
-  else if (!originalMsgURI.IsEmpty())
-  {
+  else if (!originalMsgURI.IsEmpty()) {
     nsCOMPtr<nsIMsgDBHdr> msgHdr;
     rv = GetMsgDBHdrFromURI(originalMsgURI.get(), getter_AddRefs(msgHdr));
     NS_ENSURE_SUCCESS_VOID(rv);
-    *aDecision = ShouldAcceptRemoteContentForMsgHdr(msgHdr, nullptr,
-                                                    aContentLocation);
+    *aDecision =
+        ShouldAcceptRemoteContentForMsgHdr(msgHdr, nullptr, aContentLocation);
 
     // Special case image elements. When replying to a message, we want to allow
     // the user to add remote images to the message. But we don't want remote
     // images that are a part of the quoted content to load. Hence we block them
     // while the reply is created (insertingQuotedContent==true), but allow them
     // later when the user inserts them.
-    if (*aDecision == nsIContentPolicy::REJECT_REQUEST)
-    {
+    if (*aDecision == nsIContentPolicy::REJECT_REQUEST) {
       bool insertingQuotedContent = true;
       aMsgCompose->GetInsertingQuotedContent(&insertingQuotedContent);
       nsCOMPtr<Element> element = do_QueryInterface(aRequestingContext);
       RefPtr<mozilla::dom::HTMLImageElement> image =
-        mozilla::dom::HTMLImageElement::FromNodeOrNull(element);
-      if (image)
-      {
-        if (!insertingQuotedContent)
-        {
+          mozilla::dom::HTMLImageElement::FromNodeOrNull(element);
+      if (image) {
+        if (!insertingQuotedContent) {
           *aDecision = nsIContentPolicy::ACCEPT;
           return;
         }
 
         // Test whitelist.
         uint32_t permission;
-        mPermissionManager->TestPermission(aContentLocation, NS_LITERAL_CSTRING("image"), &permission);
+        mPermissionManager->TestPermission(
+            aContentLocation, NS_LITERAL_CSTRING("image"), &permission);
         if (permission == nsIPermissionManager::ALLOW_ACTION)
           *aDecision = nsIContentPolicy::ACCEPT;
       }
     }
   }
 }
 
-already_AddRefed<nsIMsgCompose> nsMsgContentPolicy::GetMsgComposeForContext(nsISupports *aRequestingContext)
-{
+already_AddRefed<nsIMsgCompose> nsMsgContentPolicy::GetMsgComposeForContext(
+    nsISupports *aRequestingContext) {
   nsresult rv;
 
   nsIDocShell *shell = NS_CP_GetDocShellFromContext(aRequestingContext);
-  if (!shell)
-    return nullptr;
+  if (!shell) return nullptr;
   nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem(shell);
 
   nsCOMPtr<nsIDocShellTreeItem> rootItem;
   rv = docShellTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(rootItem));
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(rootItem, &rv));
   NS_ENSURE_SUCCESS(rv, nullptr);
 
-  nsCOMPtr<nsIMsgComposeService> composeService(do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIMsgComposeService> composeService(
+      do_GetService(NS_MSGCOMPOSESERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   nsCOMPtr<nsIMsgCompose> msgCompose;
-  // Don't bother checking rv, as GetMsgComposeForDocShell returns NS_ERROR_FAILURE
-  // for not found.
+  // Don't bother checking rv, as GetMsgComposeForDocShell returns
+  // NS_ERROR_FAILURE for not found.
   composeService->GetMsgComposeForDocShell(docShell,
                                            getter_AddRefs(msgCompose));
   return msgCompose.forget();
 }
 
 nsresult nsMsgContentPolicy::SetDisableItemsOnMailNewsUrlDocshells(
-  nsIURI *aContentLocation, nsISupports *aRequestingContext)
-{
+    nsIURI *aContentLocation, nsISupports *aRequestingContext) {
   // XXX if this class changes so that this method can be called from
   // ShouldProcess, and if it's possible for this to be null when called from
   // ShouldLoad, but not in the corresponding ShouldProcess call,
   // we need to re-think the assumptions underlying this code.
 
   // If there's no docshell to get to, there's nowhere for the JavaScript to
   // run, so we're already safe and don't need to disable anything.
   if (!aRequestingContext) {
@@ -832,17 +779,18 @@ nsresult nsMsgContentPolicy::SetDisableI
   // since NS_CP_GetDocShellFromContext returns the containing docshell rather
   // than the contained one we need, we can't use that here, so...
   RefPtr<nsFrameLoaderOwner> flOwner = do_QueryObject(aRequestingContext);
   NS_ENSURE_TRUE(flOwner, NS_ERROR_INVALID_POINTER);
 
   RefPtr<nsFrameLoader> frameLoader = flOwner->GetFrameLoader();
   NS_ENSURE_TRUE(frameLoader, NS_ERROR_INVALID_POINTER);
 
-  nsCOMPtr<nsIDocShell> docShell = frameLoader->GetDocShell(mozilla::IgnoreErrors());
+  nsCOMPtr<nsIDocShell> docShell =
+      frameLoader->GetDocShell(mozilla::IgnoreErrors());
   NS_ENSURE_TRUE(docShell, NS_ERROR_INVALID_POINTER);
 
   nsCOMPtr<nsIDocShellTreeItem> docshellTreeItem(docShell);
 
   // what sort of docshell is this?
   int32_t itemType;
   rv = docshellTreeItem->GetItemType(&itemType);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -860,38 +808,35 @@ nsresult nsMsgContentPolicy::SetDisableI
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t sandboxFlags;
     rv = docShell->GetSandboxFlags(&sandboxFlags);
     sandboxFlags |= SANDBOXED_FORMS;
     NS_ENSURE_SUCCESS(rv, rv);
     rv = docShell->SetSandboxFlags(sandboxFlags);
     NS_ENSURE_SUCCESS(rv, rv);
-  }
-  else {
+  } else {
     // JavaScript is allowed on non-message URLs.
     rv = docShell->SetAllowJavascript(true);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = docShell->SetAllowContentRetargetingOnChildren(true);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   rv = docShell->SetAllowPlugins(false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 /**
  * Gets the root docshell from a requesting context.
  */
-nsresult
-nsMsgContentPolicy::GetRootDocShellForContext(nsISupports *aRequestingContext,
-                                              nsIDocShell **aDocShell)
-{
+nsresult nsMsgContentPolicy::GetRootDocShellForContext(
+    nsISupports *aRequestingContext, nsIDocShell **aDocShell) {
   NS_ENSURE_ARG_POINTER(aRequestingContext);
   nsresult rv;
 
   nsIDocShell *shell = NS_CP_GetDocShellFromContext(aRequestingContext);
   NS_ENSURE_TRUE(shell, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIDocShellTreeItem> docshellTreeItem(shell);
 
   nsCOMPtr<nsIDocShellTreeItem> rootItem;
@@ -904,20 +849,18 @@ nsMsgContentPolicy::GetRootDocShellForCo
 /**
  * Gets the originating URI that started off a set of requests, accounting
  * for multiple iframes.
  *
  * Navigates up the docshell tree from aRequestingContext and finds the
  * highest parent with the same type docshell as aRequestingContext, then
  * returns the URI associated with that docshell.
  */
-nsresult
-nsMsgContentPolicy::GetOriginatingURIForContext(nsISupports *aRequestingContext,
-                                                nsIURI **aURI)
-{
+nsresult nsMsgContentPolicy::GetOriginatingURIForContext(
+    nsISupports *aRequestingContext, nsIURI **aURI) {
   NS_ENSURE_ARG_POINTER(aRequestingContext);
   nsresult rv;
 
   nsIDocShell *shell = NS_CP_GetDocShellFromContext(aRequestingContext);
   if (!shell) {
     *aURI = nullptr;
     return NS_OK;
   }
@@ -929,34 +872,33 @@ nsMsgContentPolicy::GetOriginatingURIFor
 
   nsCOMPtr<nsIWebNavigation> webNavigation(do_QueryInterface(rootItem, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return webNavigation->GetCurrentURI(aURI);
 }
 
 NS_IMETHODIMP
-nsMsgContentPolicy::ShouldProcess(nsIURI           *aContentLocation,
-                                  nsILoadInfo      *aLoadInfo,
+nsMsgContentPolicy::ShouldProcess(nsIURI *aContentLocation,
+                                  nsILoadInfo *aLoadInfo,
                                   const nsACString &aMimeGuess,
-                                  int16_t          *aDecision)
-{
+                                  int16_t *aDecision) {
   // XXX Returning ACCEPT is presumably only a reasonable thing to do if we
   // think that ShouldLoad is going to catch all possible cases (i.e. that
   // everything we use to make decisions is going to be available at
   // ShouldLoad time, and not only become available in time for ShouldProcess).
   // Do we think that's actually the case?
   *aDecision = nsIContentPolicy::ACCEPT;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgContentPolicy::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData)
-{
-  if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic))
-  {
+NS_IMETHODIMP nsMsgContentPolicy::Observe(nsISupports *aSubject,
+                                          const char *aTopic,
+                                          const char16_t *aData) {
+  if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
     NS_LossyConvertUTF16toASCII pref(aData);
 
     nsresult rv;
 
     nsCOMPtr<nsIPrefBranch> prefBranchInt = do_QueryInterface(aSubject, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (pref.Equals(kBlockRemoteImages))
@@ -968,37 +910,34 @@ NS_IMETHODIMP nsMsgContentPolicy::Observ
 
 /**
  * We implement the nsIWebProgressListener interface in order to enforce
  * settings at onLocationChange time.
  */
 NS_IMETHODIMP
 nsMsgContentPolicy::OnStateChange(nsIWebProgress *aWebProgress,
                                   nsIRequest *aRequest, uint32_t aStateFlags,
-                                  nsresult aStatus)
-{
+                                  nsresult aStatus) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgContentPolicy::OnProgressChange(nsIWebProgress *aWebProgress,
                                      nsIRequest *aRequest,
                                      int32_t aCurSelfProgress,
                                      int32_t aMaxSelfProgress,
                                      int32_t aCurTotalProgress,
-                                     int32_t aMaxTotalProgress)
-{
+                                     int32_t aMaxTotalProgress) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgContentPolicy::OnLocationChange(nsIWebProgress *aWebProgress,
                                      nsIRequest *aRequest, nsIURI *aLocation,
-                                     uint32_t aFlags)
-{
+                                     uint32_t aFlags) {
   nsresult rv;
 
   // If anything goes wrong and/or there's no docshell associated with this
   // request, just give up.  The behavior ends up being "don't consider
   // re-enabling JS on the docshell", which is the safe thing to do (and if
   // the problem was that there's no docshell, that means that there was
   // nowhere for any JavaScript to run, so we're already safe
 
@@ -1007,80 +946,73 @@ nsMsgContentPolicy::OnLocationChange(nsI
     return NS_OK;
   }
 
 #ifdef DEBUG
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest, &rv);
   if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIDocShell> docShell2;
     NS_QueryNotificationCallbacks(channel, docShell2);
-    NS_ASSERTION(docShell == docShell2, "aWebProgress and channel callbacks"
-                                        " do not point to the same docshell");
+    NS_ASSERTION(docShell == docShell2,
+                 "aWebProgress and channel callbacks"
+                 " do not point to the same docshell");
   }
 #endif
 
   nsCOMPtr<nsIMsgMessageUrl> messageUrl = do_QueryInterface(aLocation, &rv);
   mozilla::Unused << messageUrl;
   if (NS_SUCCEEDED(rv)) {
     // Disable javascript on message URLs.
     rv = docShell->SetAllowJavascript(false);
     NS_ASSERTION(NS_SUCCEEDED(rv),
                  "Failed to set javascript disabled on docShell");
-  }
-  else {
+  } else {
     // Javascript is allowed on non-message URLs. Plugins are not.
     rv = docShell->SetAllowJavascript(true);
     NS_ASSERTION(NS_SUCCEEDED(rv),
                  "Failed to set javascript allowed on docShell");
   }
 
   rv = docShell->SetAllowPlugins(false);
-  NS_ASSERTION(NS_SUCCEEDED(rv),
-               "Failed to set plugins disabled on docShell");
+  NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to set plugins disabled on docShell");
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgContentPolicy::OnStatusChange(nsIWebProgress *aWebProgress,
                                    nsIRequest *aRequest, nsresult aStatus,
-                                   const char16_t *aMessage)
-{
+                                   const char16_t *aMessage) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgContentPolicy::OnSecurityChange(nsIWebProgress *aWebProgress,
-                                     nsIRequest *aRequest, uint32_t aState)
-{
+                                     nsIRequest *aRequest, uint32_t aState) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgContentPolicy::OnContentBlockingEvent(nsIWebProgress *aWebProgress,
-                                           nsIRequest *aRequest, uint32_t aEvent)
-{
+                                           nsIRequest *aRequest,
+                                           uint32_t aEvent) {
   return NS_OK;
 }
 
 /**
  * Implementation of nsIMsgContentPolicy
  *
  */
 NS_IMETHODIMP
-nsMsgContentPolicy::AddExposedProtocol(const nsACString &aScheme)
-{
-  if (mCustomExposedProtocols.Contains(nsCString(aScheme)))
-    return NS_OK;
+nsMsgContentPolicy::AddExposedProtocol(const nsACString &aScheme) {
+  if (mCustomExposedProtocols.Contains(nsCString(aScheme))) return NS_OK;
 
   mCustomExposedProtocols.AppendElement(aScheme);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgContentPolicy::RemoveExposedProtocol(const nsACString &aScheme)
-{
+nsMsgContentPolicy::RemoveExposedProtocol(const nsACString &aScheme) {
   mCustomExposedProtocols.RemoveElement(nsCString(aScheme));
 
   return NS_OK;
 }
-
--- a/mailnews/base/src/nsMsgContentPolicy.h
+++ b/mailnews/base/src/nsMsgContentPolicy.h
@@ -1,19 +1,20 @@
 /* -*- 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/. */
 
-/**********************************************************************************
- * nsMsgContentPolicy enforces the specified content policy on images, js, plugins, etc.
- * This is the class used to determine what elements in a message should be loaded.
+/******************************************************************************
+ * nsMsgContentPolicy enforces the specified content policy on images, js,
+ * plugins, etc. This is the class used to determine what elements in a message
+ * should be loaded.
  *
  * nsMsgCookiePolicy enforces our cookie policy for mail and RSS messages.
- ***********************************************************************************/
+ ******************************************************************************/
 
 #ifndef _nsMsgContentPolicy_H_
 #define _nsMsgContentPolicy_H_
 
 #include "nsIContentPolicy.h"
 #include "nsIObserver.h"
 #include "nsWeakReference.h"
 #include "nsString.h"
@@ -21,72 +22,75 @@
 #include "nsIWebProgressListener.h"
 #include "nsIMsgCompose.h"
 #include "nsIDocShell.h"
 #include "nsIPermissionManager.h"
 #include "nsIMsgContentPolicy.h"
 #include "nsTArray.h"
 
 /* DBFCFDF0-4489-4faa-8122-190FD1EFA16C */
-#define NS_MSGCONTENTPOLICY_CID \
-{ 0xdbfcfdf0, 0x4489, 0x4faa, { 0x81, 0x22, 0x19, 0xf, 0xd1, 0xef, 0xa1, 0x6c } }
+#define NS_MSGCONTENTPOLICY_CID                     \
+  {                                                 \
+    0xdbfcfdf0, 0x4489, 0x4faa, {                   \
+      0x81, 0x22, 0x19, 0xf, 0xd1, 0xef, 0xa1, 0x6c \
+    }                                               \
+  }
 
 #define NS_MSGCONTENTPOLICY_CONTRACTID "@mozilla.org/messenger/content-policy;1"
 
 class nsIMsgDBHdr;
 class nsIDocShell;
 
 class nsMsgContentPolicy : public nsIContentPolicy,
                            public nsIObserver,
                            public nsIWebProgressListener,
                            public nsIMsgContentPolicy,
-                           public nsSupportsWeakReference
-{
-public:
+                           public nsSupportsWeakReference {
+ public:
   nsMsgContentPolicy();
 
   nsresult Init();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSICONTENTPOLICY
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIWEBPROGRESSLISTENER
   NS_DECL_NSIMSGCONTENTPOLICY
 
-protected:
+ protected:
   virtual ~nsMsgContentPolicy();
 
-  bool     mBlockRemoteImages;
+  bool mBlockRemoteImages;
   nsCString mTrustedMailDomains;
   nsCOMPtr<nsIPermissionManager> mPermissionManager;
 
-  bool IsTrustedDomain(nsIURI * aContentLocation);
+  bool IsTrustedDomain(nsIURI *aContentLocation);
   bool IsSafeRequestingLocation(nsIURI *aRequestingLocation);
   bool IsExposedProtocol(nsIURI *aContentLocation);
   bool IsExposedChromeProtocol(nsIURI *aContentLocation);
   bool ShouldBlockUnexposedProtocol(nsIURI *aContentLocation);
 
   bool ShouldAcceptRemoteContentForSender(nsIMsgDBHdr *aMsgHdr);
   int16_t ShouldAcceptRemoteContentForMsgHdr(nsIMsgDBHdr *aMsgHdr,
                                              nsIURI *aRequestingLocation,
                                              nsIURI *aContentLocation);
   void NotifyContentWasBlocked(nsIURI *aOriginatorLocation,
-                               nsIURI *aContentLocation,
-                               bool aCanOverride);
+                               nsIURI *aContentLocation, bool aCanOverride);
   void ShouldAcceptContentForPotentialMsg(nsIURI *aOriginatorLocation,
                                           nsIURI *aContentLocation,
                                           int16_t *aDecision);
   void ComposeShouldLoad(nsIMsgCompose *aMsgCompose,
                          nsISupports *aRequestingContext,
                          nsIURI *aContentLocation, int16_t *aDecision);
-  already_AddRefed<nsIMsgCompose> GetMsgComposeForContext(nsISupports *aRequestingContext);
+  already_AddRefed<nsIMsgCompose> GetMsgComposeForContext(
+      nsISupports *aRequestingContext);
 
   nsresult GetRootDocShellForContext(nsISupports *aRequestingContext,
                                      nsIDocShell **aDocShell);
   nsresult GetOriginatingURIForContext(nsISupports *aRequestingContext,
                                        nsIURI **aURI);
-  nsresult SetDisableItemsOnMailNewsUrlDocshells(nsIURI *aContentLocation,
-                                                 nsISupports *aRequestingContext);
+  nsresult SetDisableItemsOnMailNewsUrlDocshells(
+      nsIURI *aContentLocation, nsISupports *aRequestingContext);
 
   nsTArray<nsCString> mCustomExposedProtocols;
 };
 
-#endif // _nsMsgContentPolicy_H_
+#endif  // _nsMsgContentPolicy_H_
--- a/mailnews/base/src/nsMsgCopyService.cpp
+++ b/mailnews/base/src/nsMsgCopyService.cpp
@@ -14,444 +14,370 @@
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Logging.h"
 
 static mozilla::LazyLogModule gCopyServiceLog("MsgCopyService");
 
 // ******************** nsCopySource ******************
-//
 
-nsCopySource::nsCopySource() : m_processed(false)
-{
+nsCopySource::nsCopySource() : m_processed(false) {
   MOZ_COUNT_CTOR(nsCopySource);
   m_messageArray = do_CreateInstance(NS_ARRAY_CONTRACTID);
 }
 
-nsCopySource::nsCopySource(nsIMsgFolder* srcFolder) :
-    m_processed(false)
-{
+nsCopySource::nsCopySource(nsIMsgFolder* srcFolder) : m_processed(false) {
   MOZ_COUNT_CTOR(nsCopySource);
   m_messageArray = do_CreateInstance(NS_ARRAY_CONTRACTID);
   m_msgFolder = srcFolder;
 }
 
-nsCopySource::~nsCopySource()
-{
-  MOZ_COUNT_DTOR(nsCopySource);
-}
+nsCopySource::~nsCopySource() { MOZ_COUNT_DTOR(nsCopySource); }
 
-void nsCopySource::AddMessage(nsIMsgDBHdr* aMsg)
-{
+void nsCopySource::AddMessage(nsIMsgDBHdr* aMsg) {
   m_messageArray->AppendElement(aMsg);
 }
 
 // ************ nsCopyRequest *****************
 //
 
-nsCopyRequest::nsCopyRequest() :
-    m_requestType(nsCopyMessagesType),
-    m_isMoveOrDraftOrTemplate(false),
-    m_processed(false),
-    m_newMsgFlags(0)
-{
+nsCopyRequest::nsCopyRequest()
+    : m_requestType(nsCopyMessagesType),
+      m_isMoveOrDraftOrTemplate(false),
+      m_processed(false),
+      m_newMsgFlags(0) {
   MOZ_COUNT_CTOR(nsCopyRequest);
 }
 
-nsCopyRequest::~nsCopyRequest()
-{
+nsCopyRequest::~nsCopyRequest() {
   MOZ_COUNT_DTOR(nsCopyRequest);
 
   int32_t j = m_copySourceArray.Length();
-  while(j-- > 0)
-    delete m_copySourceArray.ElementAt(j);
+  while (j-- > 0) delete m_copySourceArray.ElementAt(j);
 }
 
-nsresult
-nsCopyRequest::Init(nsCopyRequestType type, nsISupports* aSupport,
-                    nsIMsgFolder* dstFolder,
-                    bool bVal, uint32_t newMsgFlags,
-                    const nsACString &newMsgKeywords,
-                    nsIMsgCopyServiceListener* listener,
-                    nsIMsgWindow* msgWindow, bool allowUndo)
-{
+nsresult nsCopyRequest::Init(nsCopyRequestType type, nsISupports* aSupport,
+                             nsIMsgFolder* dstFolder, bool bVal,
+                             uint32_t newMsgFlags,
+                             const nsACString& newMsgKeywords,
+                             nsIMsgCopyServiceListener* listener,
+                             nsIMsgWindow* msgWindow, bool allowUndo) {
   nsresult rv = NS_OK;
   m_requestType = type;
   m_srcSupport = aSupport;
   m_dstFolder = dstFolder;
   m_isMoveOrDraftOrTemplate = bVal;
   m_allowUndo = allowUndo;
   m_newMsgFlags = newMsgFlags;
   m_newMsgKeywords = newMsgKeywords;
 
-  if (listener)
-      m_listener = listener;
-  if (msgWindow)
-  {
+  if (listener) m_listener = listener;
+  if (msgWindow) {
     m_msgWindow = msgWindow;
-    if (m_allowUndo)
-      msgWindow->GetTransactionManager(getter_AddRefs(m_txnMgr));
+    if (m_allowUndo) msgWindow->GetTransactionManager(getter_AddRefs(m_txnMgr));
   }
-  if (type == nsCopyFoldersType)
-  {
+  if (type == nsCopyFoldersType) {
     // To support multiple copy folder operations to the same destination, we
     // need to save the leaf name of the src file spec so that FindRequest() is
     // able to find the right request when copy finishes.
     nsCOMPtr<nsIMsgFolder> srcFolder = do_QueryInterface(aSupport, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     nsString folderName;
     rv = srcFolder->GetName(folderName);
     NS_ENSURE_SUCCESS(rv, rv);
     m_dstFolderName = folderName;
   }
 
   return rv;
 }
 
-nsCopySource*
-nsCopyRequest::AddNewCopySource(nsIMsgFolder* srcFolder)
-{
+nsCopySource* nsCopyRequest::AddNewCopySource(nsIMsgFolder* srcFolder) {
   nsCopySource* newSrc = new nsCopySource(srcFolder);
-  if (newSrc)
-  {
-      m_copySourceArray.AppendElement(newSrc);
-      if (srcFolder == m_dstFolder)
-        newSrc->m_processed = true;
+  if (newSrc) {
+    m_copySourceArray.AppendElement(newSrc);
+    if (srcFolder == m_dstFolder) newSrc->m_processed = true;
   }
   return newSrc;
 }
 
 // ************* nsMsgCopyService ****************
 //
 
+nsMsgCopyService::nsMsgCopyService() {}
 
-nsMsgCopyService::nsMsgCopyService()
-{
-}
-
-nsMsgCopyService::~nsMsgCopyService()
-{
+nsMsgCopyService::~nsMsgCopyService() {
   int32_t i = m_copyRequests.Length();
 
-  while (i-- > 0)
-    ClearRequest(m_copyRequests.ElementAt(i), NS_ERROR_FAILURE);
+  while (i-- > 0) ClearRequest(m_copyRequests.ElementAt(i), NS_ERROR_FAILURE);
 }
 
-void nsMsgCopyService::LogCopyCompletion(nsISupports *aSrc, nsIMsgFolder *aDest)
-{
+void nsMsgCopyService::LogCopyCompletion(nsISupports* aSrc,
+                                         nsIMsgFolder* aDest) {
   nsCString srcFolderUri, destFolderUri;
   nsCOMPtr<nsIMsgFolder> srcFolder(do_QueryInterface(aSrc));
-  if (srcFolder)
-    srcFolder->GetURI(srcFolderUri);
+  if (srcFolder) srcFolder->GetURI(srcFolderUri);
   aDest->GetURI(destFolderUri);
   MOZ_LOG(gCopyServiceLog, mozilla::LogLevel::Info,
-         ("NotifyCompletion - src %s dest %s\n",
-          srcFolderUri.get(), destFolderUri.get()));
+          ("NotifyCompletion - src %s dest %s\n", srcFolderUri.get(),
+           destFolderUri.get()));
 }
 
-void nsMsgCopyService::LogCopyRequest(const char *logMsg, nsCopyRequest* aRequest)
-{
+void nsMsgCopyService::LogCopyRequest(const char* logMsg,
+                                      nsCopyRequest* aRequest) {
   nsCString srcFolderUri, destFolderUri;
   nsCOMPtr<nsIMsgFolder> srcFolder(do_QueryInterface(aRequest->m_srcSupport));
-  if (srcFolder)
-    srcFolder->GetURI(srcFolderUri);
+  if (srcFolder) srcFolder->GetURI(srcFolderUri);
   aRequest->m_dstFolder->GetURI(destFolderUri);
   uint32_t numMsgs = 0;
   if (aRequest->m_requestType == nsCopyMessagesType &&
       aRequest->m_copySourceArray.Length() > 0 &&
       aRequest->m_copySourceArray[0]->m_messageArray)
     aRequest->m_copySourceArray[0]->m_messageArray->GetLength(&numMsgs);
   MOZ_LOG(gCopyServiceLog, mozilla::LogLevel::Info,
-         ("request %p %s - src %s dest %s numItems %d type=%d",
-         aRequest, logMsg, srcFolderUri.get(),
-         destFolderUri.get(), numMsgs, aRequest->m_requestType));
+          ("request %p %s - src %s dest %s numItems %d type=%d", aRequest,
+           logMsg, srcFolderUri.get(), destFolderUri.get(), numMsgs,
+           aRequest->m_requestType));
 }
 
-nsresult
-nsMsgCopyService::ClearRequest(nsCopyRequest* aRequest, nsresult rv)
-{
-  if (aRequest)
-  {
+nsresult nsMsgCopyService::ClearRequest(nsCopyRequest* aRequest, nsresult rv) {
+  if (aRequest) {
     if (MOZ_LOG_TEST(gCopyServiceLog, mozilla::LogLevel::Info))
-      LogCopyRequest(NS_SUCCEEDED(rv) ? "Clearing OK request"
-                                      : "Clearing failed request", aRequest);
+      LogCopyRequest(
+          NS_SUCCEEDED(rv) ? "Clearing OK request" : "Clearing failed request",
+          aRequest);
 
     // Send notifications to nsIMsgFolderListeners
-    if (NS_SUCCEEDED(rv) && aRequest->m_requestType == nsCopyFoldersType)
-    {
-      nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
-      if (notifier)
-      {
+    if (NS_SUCCEEDED(rv) && aRequest->m_requestType == nsCopyFoldersType) {
+      nsCOMPtr<nsIMsgFolderNotificationService> notifier(
+          do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
+      if (notifier) {
         bool hasListeners;
         notifier->GetHasListeners(&hasListeners);
-        if (hasListeners)
-        {
-          // Iterate over the copy sources and append their message arrays to this mutable array
-          // or in the case of folders, the source folder.
+        if (hasListeners) {
+          // Iterate over the copy sources and append their message arrays to
+          // this mutable array or in the case of folders, the source folder.
           int32_t cnt, i;
           cnt = aRequest->m_copySourceArray.Length();
-          for (i = 0; i < cnt; i++)
-          {
-            nsCopySource *copySource = aRequest->m_copySourceArray.ElementAt(i);
-            notifier->NotifyFolderMoveCopyCompleted(aRequest->m_isMoveOrDraftOrTemplate, copySource->m_msgFolder, aRequest->m_dstFolder);
+          for (i = 0; i < cnt; i++) {
+            nsCopySource* copySource = aRequest->m_copySourceArray.ElementAt(i);
+            notifier->NotifyFolderMoveCopyCompleted(
+                aRequest->m_isMoveOrDraftOrTemplate, copySource->m_msgFolder,
+                aRequest->m_dstFolder);
           }
         }
       }
     }
 
     // undo stuff
-    if (aRequest->m_allowUndo &&
-        aRequest->m_copySourceArray.Length() > 1 &&
+    if (aRequest->m_allowUndo && aRequest->m_copySourceArray.Length() > 1 &&
         aRequest->m_txnMgr)
-        aRequest->m_txnMgr->EndBatch(false);
+      aRequest->m_txnMgr->EndBatch(false);
 
     m_copyRequests.RemoveElement(aRequest);
-    if (aRequest->m_listener)
-        aRequest->m_listener->OnStopCopy(rv);
+    if (aRequest->m_listener) aRequest->m_listener->OnStopCopy(rv);
     delete aRequest;
   }
 
   return rv;
 }
 
-nsresult
-nsMsgCopyService::QueueRequest(nsCopyRequest* aRequest, bool *aCopyImmediately)
-{
+nsresult nsMsgCopyService::QueueRequest(nsCopyRequest* aRequest,
+                                        bool* aCopyImmediately) {
   NS_ENSURE_ARG_POINTER(aRequest);
   NS_ENSURE_ARG_POINTER(aCopyImmediately);
   *aCopyImmediately = true;
   nsCopyRequest* copyRequest;
 
   uint32_t cnt = m_copyRequests.Length();
-  for (uint32_t i = 0; i < cnt; i++)
-  {
+  for (uint32_t i = 0; i < cnt; i++) {
     copyRequest = m_copyRequests.ElementAt(i);
-    if (aRequest->m_requestType == nsCopyFoldersType)
-    {
+    if (aRequest->m_requestType == nsCopyFoldersType) {
       // For copy folder, see if both destination folder (root)
       // (ie, Local Folder) and folder name (ie, abc) are the same.
       if (copyRequest->m_dstFolderName == aRequest->m_dstFolderName &&
-          copyRequest->m_dstFolder.get() == aRequest->m_dstFolder.get())
-      {
+          copyRequest->m_dstFolder.get() == aRequest->m_dstFolder.get()) {
         *aCopyImmediately = false;
         break;
       }
-    }
-    else if (copyRequest->m_dstFolder.get() == aRequest->m_dstFolder.get())  //if dst are same and we already have a request, we cannot copy immediately
-    {
+    } else if (copyRequest->m_dstFolder.get() == aRequest->m_dstFolder.get()) {
+      // If dst are same and we already have a request, we cannot copy
+      // immediately.
       *aCopyImmediately = false;
       break;
     }
   }
   return NS_OK;
 }
 
-nsresult
-nsMsgCopyService::DoCopy(nsCopyRequest* aRequest)
-{
+nsresult nsMsgCopyService::DoCopy(nsCopyRequest* aRequest) {
   NS_ENSURE_ARG(aRequest);
   bool copyImmediately;
   QueueRequest(aRequest, &copyImmediately);
   m_copyRequests.AppendElement(aRequest);
   if (MOZ_LOG_TEST(gCopyServiceLog, mozilla::LogLevel::Info))
     LogCopyRequest(copyImmediately ? "DoCopy" : "QueueRequest", aRequest);
 
   // if no active request for this dest folder then we can copy immediately
-  if (copyImmediately)
-    return DoNextCopy();
+  if (copyImmediately) return DoNextCopy();
 
   return NS_OK;
 }
 
-nsresult
-nsMsgCopyService::DoNextCopy()
-{
+nsresult nsMsgCopyService::DoNextCopy() {
   nsresult rv = NS_OK;
   nsCopyRequest* copyRequest = nullptr;
   nsCopySource* copySource = nullptr;
   uint32_t i, j, scnt;
 
   uint32_t cnt = m_copyRequests.Length();
-  if (cnt > 0)
-  {
+  if (cnt > 0) {
     nsCOMArray<nsIMsgFolder> activeTargets;
 
     // ** jt -- always FIFO
-    for (i = 0; i < cnt; i++)
-    {
+    for (i = 0; i < cnt; i++) {
       copyRequest = m_copyRequests.ElementAt(i);
       copySource = nullptr;
       scnt = copyRequest->m_copySourceArray.Length();
-      if (!copyRequest->m_processed)
-      {
+      if (!copyRequest->m_processed) {
         // if the target folder of this request already has an active
         // copy request, skip this request for now.
-        if (activeTargets.ContainsObject(copyRequest->m_dstFolder))
-        {
+        if (activeTargets.ContainsObject(copyRequest->m_dstFolder)) {
           copyRequest = nullptr;
           continue;
         }
-        if (scnt <= 0)
-            goto found; // must be CopyFileMessage
-        for (j = 0; j < scnt; j++)
-        {
+        if (scnt <= 0) goto found;  // must be CopyFileMessage
+        for (j = 0; j < scnt; j++) {
           copySource = copyRequest->m_copySourceArray.ElementAt(j);
-          if (!copySource->m_processed)
-            goto found;
+          if (!copySource->m_processed) goto found;
         }
-        if (j >= scnt) // all processed set the value
+        if (j >= scnt)  // all processed set the value
           copyRequest->m_processed = true;
       }
-      if (copyRequest->m_processed) // keep track of folders actively getting copied to.
+      if (copyRequest->m_processed) {
+        // Keep track of folders actively getting copied to.
         activeTargets.AppendObject(copyRequest->m_dstFolder);
-    }
-    found:
-      if (copyRequest && !copyRequest->m_processed)
-      {
-          if (copyRequest->m_listener)
-              copyRequest->m_listener->OnStartCopy();
-          if (copyRequest->m_requestType == nsCopyMessagesType &&
-              copySource)
-          {
-              copySource->m_processed = true;
-              rv = copyRequest->m_dstFolder->CopyMessages
-                  (copySource->m_msgFolder, copySource->m_messageArray,
-                   copyRequest->m_isMoveOrDraftOrTemplate,
-                   copyRequest->m_msgWindow, copyRequest->m_listener, false, copyRequest->m_allowUndo);   //isFolder operation false
-
-          }
-          else if (copyRequest->m_requestType == nsCopyFoldersType)
-          {
-              NS_ENSURE_STATE(copySource);
-              copySource->m_processed = true;
-              rv = copyRequest->m_dstFolder->CopyFolder
-                  (copySource->m_msgFolder,
-                   copyRequest->m_isMoveOrDraftOrTemplate,
-                   copyRequest->m_msgWindow, copyRequest->m_listener);
-              // If it's a copy folder operation and the destination
-              // folder already exists, CopyFolder() returns an error w/o sending
-              // a completion notification, so clear it here.
-              if (NS_FAILED(rv))
-                ClearRequest(copyRequest, rv);
-
-          }
-          else if (copyRequest->m_requestType == nsCopyFileMessageType)
-          {
-            nsCOMPtr<nsIFile> aFile(do_QueryInterface(copyRequest->m_srcSupport, &rv));
-            if (NS_SUCCEEDED(rv))
-            {
-                // ** in case of saving draft/template; the very first
-                // time we may not have the original message to replace
-                // with; if we do we shall have an instance of copySource
-                nsCOMPtr<nsIMsgDBHdr> aMessage;
-                if (copySource)
-                {
-                    aMessage = do_QueryElementAt(copySource->m_messageArray,
-                                                 0, &rv);
-                    copySource->m_processed = true;
-                }
-                copyRequest->m_processed = true;
-                rv = copyRequest->m_dstFolder->CopyFileMessage
-                    (aFile, aMessage,
-                     copyRequest->m_isMoveOrDraftOrTemplate,
-                     copyRequest->m_newMsgFlags,
-                     copyRequest->m_newMsgKeywords,
-                     copyRequest->m_msgWindow,
-                     copyRequest->m_listener);
-            }
-          }
       }
     }
-    return rv;
+  found:
+    if (copyRequest && !copyRequest->m_processed) {
+      if (copyRequest->m_listener) copyRequest->m_listener->OnStartCopy();
+      if (copyRequest->m_requestType == nsCopyMessagesType && copySource) {
+        copySource->m_processed = true;
+        rv = copyRequest->m_dstFolder->CopyMessages(
+            copySource->m_msgFolder, copySource->m_messageArray,
+            copyRequest->m_isMoveOrDraftOrTemplate, copyRequest->m_msgWindow,
+            copyRequest->m_listener, false,
+            copyRequest->m_allowUndo);  // isFolder operation false
+
+      } else if (copyRequest->m_requestType == nsCopyFoldersType) {
+        NS_ENSURE_STATE(copySource);
+        copySource->m_processed = true;
+        rv = copyRequest->m_dstFolder->CopyFolder(
+            copySource->m_msgFolder, copyRequest->m_isMoveOrDraftOrTemplate,
+            copyRequest->m_msgWindow, copyRequest->m_listener);
+        // If it's a copy folder operation and the destination
+        // folder already exists, CopyFolder() returns an error w/o sending
+        // a completion notification, so clear it here.
+        if (NS_FAILED(rv)) ClearRequest(copyRequest, rv);
+
+      } else if (copyRequest->m_requestType == nsCopyFileMessageType) {
+        nsCOMPtr<nsIFile> aFile(
+            do_QueryInterface(copyRequest->m_srcSupport, &rv));
+        if (NS_SUCCEEDED(rv)) {
+          // ** in case of saving draft/template; the very first
+          // time we may not have the original message to replace
+          // with; if we do we shall have an instance of copySource
+          nsCOMPtr<nsIMsgDBHdr> aMessage;
+          if (copySource) {
+            aMessage = do_QueryElementAt(copySource->m_messageArray, 0, &rv);
+            copySource->m_processed = true;
+          }
+          copyRequest->m_processed = true;
+          rv = copyRequest->m_dstFolder->CopyFileMessage(
+              aFile, aMessage, copyRequest->m_isMoveOrDraftOrTemplate,
+              copyRequest->m_newMsgFlags, copyRequest->m_newMsgKeywords,
+              copyRequest->m_msgWindow, copyRequest->m_listener);
+        }
+      }
+    }
+  }
+  return rv;
 }
 
 /**
  * Find a request in m_copyRequests which matches the passed in source
  * and destination folders.
  *
  * @param aSupport the iSupports of the source folder.
  * @param dstFolder the destination folder of the copy request.
  */
-nsCopyRequest*
-nsMsgCopyService::FindRequest(nsISupports* aSupport,
-                              nsIMsgFolder* dstFolder)
-{
+nsCopyRequest* nsMsgCopyService::FindRequest(nsISupports* aSupport,
+                                             nsIMsgFolder* dstFolder) {
   nsCopyRequest* copyRequest = nullptr;
   uint32_t cnt = m_copyRequests.Length();
-  for (uint32_t i = 0; i < cnt; i++)
-  {
+  for (uint32_t i = 0; i < cnt; i++) {
     copyRequest = m_copyRequests.ElementAt(i);
     if (copyRequest->m_srcSupport.get() == aSupport &&
         copyRequest->m_dstFolder.get() == dstFolder)
       break;
 
     // When copying folders the notification of the message copy serves as a
     // proxy for the folder copy. Check for that here.
-    if (copyRequest->m_requestType == nsCopyFoldersType)
-    {
-        // If the src is different then check next request.
-        if (copyRequest->m_srcSupport.get() != aSupport)
-        {
-          copyRequest = nullptr;
-          continue;
-        }
+    if (copyRequest->m_requestType == nsCopyFoldersType) {
+      // If the src is different then check next request.
+      if (copyRequest->m_srcSupport.get() != aSupport) {
+        copyRequest = nullptr;
+        continue;
+      }
 
-        // See if the parent of the copied folder is the same as the one when the request was made.
-        // Note if the destination folder is already a server folder then no need to get parent.
-        nsCOMPtr <nsIMsgFolder> parentMsgFolder;
-        nsresult rv = NS_OK;
-        bool isServer=false;
-        dstFolder->GetIsServer(&isServer);
-        if (!isServer)
-          rv = dstFolder->GetParent(getter_AddRefs(parentMsgFolder));
-        if ((NS_FAILED(rv)) || (!parentMsgFolder && !isServer) || (copyRequest->m_dstFolder.get() != parentMsgFolder))
-        {
-          copyRequest = nullptr;
-          continue;
-        }
+      // See if the parent of the copied folder is the same as the one when the
+      // request was made. Note if the destination folder is already a server
+      // folder then no need to get parent.
+      nsCOMPtr<nsIMsgFolder> parentMsgFolder;
+      nsresult rv = NS_OK;
+      bool isServer = false;
+      dstFolder->GetIsServer(&isServer);
+      if (!isServer) rv = dstFolder->GetParent(getter_AddRefs(parentMsgFolder));
+      if ((NS_FAILED(rv)) || (!parentMsgFolder && !isServer) ||
+          (copyRequest->m_dstFolder.get() != parentMsgFolder)) {
+        copyRequest = nullptr;
+        continue;
+      }
 
-        // Now checks if the folder name is the same.
-        nsString folderName;
-        rv = dstFolder->GetName(folderName);
-        if (NS_FAILED(rv))
-        {
-          copyRequest = nullptr;
-          continue;
-        }
+      // Now checks if the folder name is the same.
+      nsString folderName;
+      rv = dstFolder->GetName(folderName);
+      if (NS_FAILED(rv)) {
+        copyRequest = nullptr;
+        continue;
+      }
 
-        if (copyRequest->m_dstFolderName == folderName)
-          break;
-    }
-    else
-        copyRequest = nullptr;
+      if (copyRequest->m_dstFolderName == folderName) break;
+    } else
+      copyRequest = nullptr;
   }
 
   return copyRequest;
 }
 
 NS_IMPL_ISUPPORTS(nsMsgCopyService, nsIMsgCopyService)
 
 NS_IMETHODIMP
 nsMsgCopyService::CopyMessages(nsIMsgFolder* srcFolder, /* UI src folder */
-                               nsIArray* messages,
-                               nsIMsgFolder* dstFolder,
-                               bool isMove,
-                               nsIMsgCopyServiceListener* listener,
-                               nsIMsgWindow* window,
-                               bool allowUndo)
-{
+                               nsIArray* messages, nsIMsgFolder* dstFolder,
+                               bool isMove, nsIMsgCopyServiceListener* listener,
+                               nsIMsgWindow* window, bool allowUndo) {
   NS_ENSURE_ARG_POINTER(srcFolder);
   NS_ENSURE_ARG_POINTER(messages);
   NS_ENSURE_ARG_POINTER(dstFolder);
 
   MOZ_LOG(gCopyServiceLog, mozilla::LogLevel::Debug, ("CopyMessages"));
 
-  if (srcFolder == dstFolder)
-  {
+  if (srcFolder == dstFolder) {
     NS_ERROR("src and dest folders for msg copy can't be the same");
     return NS_ERROR_FAILURE;
   }
   nsCopyRequest* copyRequest;
   nsCopySource* copySource = nullptr;
   nsCOMArray<nsIMsgDBHdr> msgArray;
   uint32_t cnt;
   nsCOMPtr<nsIMsgDBHdr> msg;
@@ -461,250 +387,216 @@ nsMsgCopyService::CopyMessages(nsIMsgFol
 
   // XXX TODO
   // JUNK MAIL RELATED
   // make sure dest folder exists
   // and has proper flags, before we start copying?
 
   // bail early if nothing to do
   messages->GetLength(&cnt);
-  if (!cnt)
-  {
-    if (listener)
-    {
+  if (!cnt) {
+    if (listener) {
       listener->OnStartCopy();
       listener->OnStopCopy(NS_OK);
     }
     return NS_OK;
   }
 
   copyRequest = new nsCopyRequest();
-  if (!copyRequest)
-    return NS_ERROR_OUT_OF_MEMORY;
+  if (!copyRequest) return NS_ERROR_OUT_OF_MEMORY;
 
   aSupport = do_QueryInterface(srcFolder, &rv);
 
   rv = copyRequest->Init(nsCopyMessagesType, aSupport, dstFolder, isMove,
-                        0 /* new msg flags, not used */, EmptyCString(),
-                        listener, window, allowUndo);
-  if (NS_FAILED(rv))
-    goto done;
+                         0 /* new msg flags, not used */, EmptyCString(),
+                         listener, window, allowUndo);
+  if (NS_FAILED(rv)) goto done;
 
   if (MOZ_LOG_TEST(gCopyServiceLog, mozilla::LogLevel::Info))
     LogCopyRequest("CopyMessages request", copyRequest);
 
   // duplicate the message array so we could sort the messages by it's
   // folder easily
-  for (uint32_t i = 0; i < cnt; i++)
-  {
+  for (uint32_t i = 0; i < cnt; i++) {
     nsCOMPtr<nsIMsgDBHdr> currMsg = do_QueryElementAt(messages, i);
     msgArray.AppendObject(currMsg);
   }
 
   cnt = msgArray.Count();
 
-  while (cnt-- > 0)
-  {
+  while (cnt-- > 0) {
     msg = msgArray[cnt];
     rv = msg->GetFolder(getter_AddRefs(curFolder));
 
-    if (NS_FAILED(rv))
-      goto done;
-    if (!copySource)
-    {
+    if (NS_FAILED(rv)) goto done;
+    if (!copySource) {
       copySource = copyRequest->AddNewCopySource(curFolder);
-      if (!copySource)
-      {
-         rv = NS_ERROR_OUT_OF_MEMORY;
-         goto done;
+      if (!copySource) {
+        rv = NS_ERROR_OUT_OF_MEMORY;
+        goto done;
       }
     }
 
-    if (curFolder == copySource->m_msgFolder)
-    {
+    if (curFolder == copySource->m_msgFolder) {
       copySource->AddMessage(msg);
       msgArray.RemoveObjectAt(cnt);
     }
 
-    if (cnt == 0)
-    {
+    if (cnt == 0) {
       cnt = msgArray.Count();
-      if (cnt > 0)
-        copySource = nullptr; // * force to create a new one and
-                             // * continue grouping the messages
+      if (cnt > 0) {
+        // Force to create a new one and continue grouping the messages.
+        copySource = nullptr;
+      }
     }
   }
 
   // undo stuff
-  if (NS_SUCCEEDED(rv) && copyRequest->m_allowUndo && copyRequest->m_copySourceArray.Length() > 1 &&
-      copyRequest->m_txnMgr)
+  if (NS_SUCCEEDED(rv) && copyRequest->m_allowUndo &&
+      copyRequest->m_copySourceArray.Length() > 1 && copyRequest->m_txnMgr)
     copyRequest->m_txnMgr->BeginBatch(nullptr);
 
 done:
 
-    if (NS_FAILED(rv))
-      delete copyRequest;
-    else
-      rv = DoCopy(copyRequest);
+  if (NS_FAILED(rv))
+    delete copyRequest;
+  else
+    rv = DoCopy(copyRequest);
 
-    return rv;
+  return rv;
 }
 
 NS_IMETHODIMP
-nsMsgCopyService::CopyFolders(nsIArray* folders,
-                              nsIMsgFolder* dstFolder,
-                              bool isMove,
-                              nsIMsgCopyServiceListener* listener,
-                              nsIMsgWindow* window)
-{
+nsMsgCopyService::CopyFolders(nsIArray* folders, nsIMsgFolder* dstFolder,
+                              bool isMove, nsIMsgCopyServiceListener* listener,
+                              nsIMsgWindow* window) {
   NS_ENSURE_ARG_POINTER(folders);
   NS_ENSURE_ARG_POINTER(dstFolder);
   nsCopyRequest* copyRequest;
   nsCopySource* copySource = nullptr;
   nsresult rv;
   uint32_t cnt;
   nsCOMPtr<nsIMsgFolder> curFolder;
   nsCOMPtr<nsISupports> support;
 
-  rv = folders->GetLength(&cnt);   //if cnt is zero it cannot to get this point, will be detected earlier
+  // If cnt is zero it cannot to get this point, will be detected earlier.
+  rv = folders->GetLength(&cnt);
   if (cnt > 1)
-    NS_ASSERTION((NS_SUCCEEDED(rv)),"More than one folders to copy");
+    NS_ASSERTION((NS_SUCCEEDED(rv)), "More than one folders to copy");
 
   support = do_QueryElementAt(folders, 0);
 
   copyRequest = new nsCopyRequest();
   if (!copyRequest) return NS_ERROR_OUT_OF_MEMORY;
 
-  rv = copyRequest->Init(nsCopyFoldersType, support, dstFolder,
-    isMove, 0 /* new msg flags, not used */ , EmptyCString(), listener, window, false);
+  rv = copyRequest->Init(nsCopyFoldersType, support, dstFolder, isMove,
+                         0 /* new msg flags, not used */, EmptyCString(),
+                         listener, window, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   curFolder = do_QueryInterface(support, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   copySource = copyRequest->AddNewCopySource(curFolder);
-  if (!copySource)
-    rv = NS_ERROR_OUT_OF_MEMORY;
+  if (!copySource) rv = NS_ERROR_OUT_OF_MEMORY;
 
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     delete copyRequest;
     NS_ENSURE_SUCCESS(rv, rv);
-  }
-  else
+  } else
     rv = DoCopy(copyRequest);
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgCopyService::CopyFileMessage(nsIFile* file,
-                                  nsIMsgFolder* dstFolder,
-                                  nsIMsgDBHdr* msgToReplace,
-                                  bool isDraft,
+nsMsgCopyService::CopyFileMessage(nsIFile* file, nsIMsgFolder* dstFolder,
+                                  nsIMsgDBHdr* msgToReplace, bool isDraft,
                                   uint32_t aMsgFlags,
-                                  const nsACString &aNewMsgKeywords,
+                                  const nsACString& aNewMsgKeywords,
                                   nsIMsgCopyServiceListener* listener,
-                                  nsIMsgWindow* window)
-{
+                                  nsIMsgWindow* window) {
   nsresult rv = NS_ERROR_NULL_POINTER;
   nsCopyRequest* copyRequest;
   nsCopySource* copySource = nullptr;
   nsCOMPtr<nsISupports> fileSupport;
   nsCOMPtr<nsITransactionManager> txnMgr;
 
   NS_ENSURE_ARG_POINTER(file);
   NS_ENSURE_ARG_POINTER(dstFolder);
 
-  if (window)
-    window->GetTransactionManager(getter_AddRefs(txnMgr));
+  if (window) window->GetTransactionManager(getter_AddRefs(txnMgr));
   copyRequest = new nsCopyRequest();
   if (!copyRequest) return rv;
   fileSupport = do_QueryInterface(file, &rv);
   if (NS_FAILED(rv)) goto done;
 
-  rv = copyRequest->Init(nsCopyFileMessageType, fileSupport, dstFolder,
-                         isDraft, aMsgFlags, aNewMsgKeywords, listener, window, false);
+  rv = copyRequest->Init(nsCopyFileMessageType, fileSupport, dstFolder, isDraft,
+                         aMsgFlags, aNewMsgKeywords, listener, window, false);
   if (NS_FAILED(rv)) goto done;
 
-  if (msgToReplace)
-  {
+  if (msgToReplace) {
     // The actual source of the message is a file not a folder, but
     // we still need an nsCopySource to reference the old message header
     // which will be used to recover message metadata.
     copySource = copyRequest->AddNewCopySource(nullptr);
-    if (!copySource)
-    {
-        rv = NS_ERROR_OUT_OF_MEMORY;
-        goto done;
+    if (!copySource) {
+      rv = NS_ERROR_OUT_OF_MEMORY;
+      goto done;
     }
     copySource->AddMessage(msgToReplace);
   }
 
 done:
-    if (NS_FAILED(rv))
-    {
-      delete copyRequest;
-    }
-    else
-    {
-      rv = DoCopy(copyRequest);
-    }
+  if (NS_FAILED(rv)) {
+    delete copyRequest;
+  } else {
+    rv = DoCopy(copyRequest);
+  }
 
-    return rv;
+  return rv;
 }
 
 NS_IMETHODIMP
 nsMsgCopyService::NotifyCompletion(nsISupports* aSupport,
-                                   nsIMsgFolder* dstFolder,
-                                   nsresult result)
-{
+                                   nsIMsgFolder* dstFolder, nsresult result) {
   if (MOZ_LOG_TEST(gCopyServiceLog, mozilla::LogLevel::Info))
     LogCopyCompletion(aSupport, dstFolder);
   nsCopyRequest* copyRequest = nullptr;
   uint32_t numOrigRequests = m_copyRequests.Length();
-  do
-  {
+  do {
     // loop for copy requests, because if we do a cross server folder copy,
     // we'll have a copy request for the folder copy, which will in turn
     // generate a copy request for the messages in the folder, which
     // will have the same src support.
     copyRequest = FindRequest(aSupport, dstFolder);
 
-    if (copyRequest)
-    {
+    if (copyRequest) {
       // ClearRequest can cause a new request to get added to m_copyRequests
       // with matching source and dest folders if the copy listener starts
       // a new copy. We want to ignore any such request here, because it wasn't
       // the one that was completed. So we keep track of how many original
       // requests there were.
-      if (m_copyRequests.IndexOf(copyRequest) >= numOrigRequests)
-        break;
+      if (m_copyRequests.IndexOf(copyRequest) >= numOrigRequests) break;
       // check if this copy request is done by making sure all the
       // sources have been processed.
       int32_t sourceIndex, sourceCount;
       sourceCount = copyRequest->m_copySourceArray.Length();
-      for (sourceIndex = 0; sourceIndex < sourceCount;)
-      {
-        if (!(copyRequest->m_copySourceArray.ElementAt(sourceIndex))->m_processed)
-            break;
-         sourceIndex++;
+      for (sourceIndex = 0; sourceIndex < sourceCount;) {
+        if (!(copyRequest->m_copySourceArray.ElementAt(sourceIndex))
+                 ->m_processed)
+          break;
+        sourceIndex++;
       }
       // if all sources processed, mark the request as processed
-      if (sourceIndex >= sourceCount)
-        copyRequest->m_processed = true;
+      if (sourceIndex >= sourceCount) copyRequest->m_processed = true;
       // if this request is done, or failed, clear it.
-      if (copyRequest->m_processed || NS_FAILED(result))
-      {
+      if (copyRequest->m_processed || NS_FAILED(result)) {
         ClearRequest(copyRequest, result);
         numOrigRequests--;
-      }
-      else
+      } else
         break;
-    }
-    else
+    } else
       break;
-  }
-  while (copyRequest);
+  } while (copyRequest);
 
   return DoNextCopy();
 }
-
--- a/mailnews/base/src/nsMsgCopyService.h
+++ b/mailnews/base/src/nsMsgCopyService.h
@@ -11,84 +11,78 @@
 #include "nsCOMPtr.h"
 #include "nsIMsgFolder.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgWindow.h"
 #include "nsIMutableArray.h"
 #include "nsITransactionManager.h"
 #include "nsTArray.h"
 
-typedef enum _nsCopyRequestType
-{
-    nsCopyMessagesType = 0x0,
-    nsCopyFileMessageType = 0x1,
-    nsCopyFoldersType = 0x2
+typedef enum _nsCopyRequestType {
+  nsCopyMessagesType = 0x0,
+  nsCopyFileMessageType = 0x1,
+  nsCopyFoldersType = 0x2
 } nsCopyRequestType;
 
 class nsCopyRequest;
 
-class nsCopySource
-{
-public:
-    nsCopySource();
-    explicit nsCopySource(nsIMsgFolder* srcFolder);
-    ~nsCopySource();
-    void AddMessage(nsIMsgDBHdr* aMsg);
+class nsCopySource {
+ public:
+  nsCopySource();
+  explicit nsCopySource(nsIMsgFolder* srcFolder);
+  ~nsCopySource();
+  void AddMessage(nsIMsgDBHdr* aMsg);
 
-    nsCOMPtr<nsIMsgFolder> m_msgFolder;
-    nsCOMPtr<nsIMutableArray> m_messageArray;
-    bool m_processed;
+  nsCOMPtr<nsIMsgFolder> m_msgFolder;
+  nsCOMPtr<nsIMutableArray> m_messageArray;
+  bool m_processed;
 };
 
-class nsCopyRequest
-{
-public:
-    nsCopyRequest();
-    ~nsCopyRequest();
+class nsCopyRequest {
+ public:
+  nsCopyRequest();
+  ~nsCopyRequest();
 
-    nsresult Init(nsCopyRequestType type, nsISupports* aSupport,
-                  nsIMsgFolder* dstFolder,
-                  bool bVal, uint32_t newMsgFlags,
-                  const nsACString &newMsgKeywords,
-                  nsIMsgCopyServiceListener* listener,
-                  nsIMsgWindow *msgWindow, bool allowUndo);
-    nsCopySource* AddNewCopySource(nsIMsgFolder* srcFolder);
+  nsresult Init(nsCopyRequestType type, nsISupports* aSupport,
+                nsIMsgFolder* dstFolder, bool bVal, uint32_t newMsgFlags,
+                const nsACString& newMsgKeywords,
+                nsIMsgCopyServiceListener* listener, nsIMsgWindow* msgWindow,
+                bool allowUndo);
+  nsCopySource* AddNewCopySource(nsIMsgFolder* srcFolder);
 
-    nsCOMPtr<nsISupports> m_srcSupport; // ui source folder or file spec
-    nsCOMPtr<nsIMsgFolder> m_dstFolder;
-    nsCOMPtr<nsIMsgWindow> m_msgWindow;
-    nsCOMPtr<nsIMsgCopyServiceListener> m_listener;
-    nsCOMPtr<nsITransactionManager> m_txnMgr;
-    nsCopyRequestType m_requestType;
-    bool m_isMoveOrDraftOrTemplate;
-    bool m_allowUndo;
-    bool m_processed;
-    uint32_t m_newMsgFlags;
-    nsCString m_newMsgKeywords;
-    nsString m_dstFolderName;      // used for copy folder.
-    nsTArray<nsCopySource*> m_copySourceArray; // array of nsCopySource
+  nsCOMPtr<nsISupports> m_srcSupport;  // ui source folder or file spec
+  nsCOMPtr<nsIMsgFolder> m_dstFolder;
+  nsCOMPtr<nsIMsgWindow> m_msgWindow;
+  nsCOMPtr<nsIMsgCopyServiceListener> m_listener;
+  nsCOMPtr<nsITransactionManager> m_txnMgr;
+  nsCopyRequestType m_requestType;
+  bool m_isMoveOrDraftOrTemplate;
+  bool m_allowUndo;
+  bool m_processed;
+  uint32_t m_newMsgFlags;
+  nsCString m_newMsgKeywords;
+  nsString m_dstFolderName;                   // used for copy folder.
+  nsTArray<nsCopySource*> m_copySourceArray;  // array of nsCopySource
 };
 
-class nsMsgCopyService : public nsIMsgCopyService
-{
-public:
+class nsMsgCopyService : public nsIMsgCopyService {
+ public:
   nsMsgCopyService();
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
   NS_DECL_NSIMSGCOPYSERVICE
 
-private:
+ private:
   virtual ~nsMsgCopyService();
 
   nsresult ClearRequest(nsCopyRequest* aRequest, nsresult rv);
   nsresult DoCopy(nsCopyRequest* aRequest);
   nsresult DoNextCopy();
   nsCopyRequest* FindRequest(nsISupports* aSupport, nsIMsgFolder* dstFolder);
-  nsresult QueueRequest(nsCopyRequest* aRequest, bool *aCopyImmediately);
-  void LogCopyCompletion(nsISupports *aSrc, nsIMsgFolder *aDest);
-  void LogCopyRequest(const char *logMsg, nsCopyRequest* aRequest);
+  nsresult QueueRequest(nsCopyRequest* aRequest, bool* aCopyImmediately);
+  void LogCopyCompletion(nsISupports* aSrc, nsIMsgFolder* aDest);
+  void LogCopyRequest(const char* logMsg, nsCopyRequest* aRequest);
 
   nsTArray<nsCopyRequest*> m_copyRequests;
 };
 
-
 #endif