Bug 1546364 - Reformat to Google coding style in mailnews/compose (part 2). rs=reformat
authorJorg K <jorgk@jorgk.com>
Sat, 11 May 2019 21:27:39 +0200
changeset 35335 6bd11ad2949dc7454e6b98f9613064621ee319f3
parent 35334 28c5478ca164a254392f3f7db745758739b1a549
child 35336 9606c2de08183a9f9dcb6fba20528f6c963c101e
push id391
push userclokep@gmail.com
push dateTue, 09 Jul 2019 00:57:56 +0000
reviewersreformat
bugs1546364
Bug 1546364 - Reformat to Google coding style in mailnews/compose (part 2). rs=reformat # ignore-this-changeset
mailnews/compose/src/nsSmtpProtocol.cpp
mailnews/compose/src/nsSmtpProtocol.h
mailnews/compose/src/nsSmtpServer.cpp
mailnews/compose/src/nsSmtpServer.h
mailnews/compose/src/nsSmtpService.cpp
mailnews/compose/src/nsSmtpService.h
mailnews/compose/src/nsSmtpUrl.cpp
mailnews/compose/src/nsSmtpUrl.h
mailnews/compose/src/nsURLFetcher.cpp
mailnews/compose/src/nsURLFetcher.h
--- a/mailnews/compose/src/nsSmtpProtocol.cpp
+++ b/mailnews/compose/src/nsSmtpProtocol.cpp
@@ -32,80 +32,78 @@
 #include "nsIPipe.h"
 #include "nsNetUtil.h"
 #include "nsIPrefService.h"
 #include "nsISSLSocketControl.h"
 #include "nsComposeStrings.h"
 #include "nsIStringBundle.h"
 #include "nsMsgCompUtils.h"
 #include "nsIMsgWindow.h"
-#include "MailNewsTypes2.h" // for nsMsgSocketType and nsMsgAuthMethod
+#include "MailNewsTypes2.h"  // for nsMsgSocketType and nsMsgAuthMethod
 #include "nsIIDNService.h"
 #include "nsICancelable.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
 #include "mozilla/Services.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Preferences.h"
 #include "nsINetAddr.h"
 #include "nsIProxyInfo.h"
 
 #ifndef XP_UNIX
-#include <stdarg.h>
+#  include <stdarg.h>
 #endif /* !XP_UNIX */
 
-#undef PostMessage // avoid to collision with WinUser.h
+#undef PostMessage  // avoid to collision with WinUser.h
 
 static mozilla::LazyLogModule SMTPLogModule("SMTP");
 
 using namespace mozilla::mailnews;
 
 /* the output_buffer_size must be larger than the largest possible line
  * 2000 seems good for news
  *
  * jwz: I increased this to 4k since it must be big enough to hold the
  * entire button-bar HTML, and with the new "mailto" format, that can
  * contain arbitrarily long header fields like "references".
  *
  * fortezza: proxy auth is huge, buffer increased to 8k (sigh).
  */
-#define OUTPUT_BUFFER_SIZE (4096*2)
+#define OUTPUT_BUFFER_SIZE (4096 * 2)
 
 ////////////////////////////////////////////////////////////////////////////////////////////
 // TEMPORARY HARD CODED FUNCTIONS
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 /* based on in NET_ExplainErrorDetails in mkmessag.c */
-nsresult nsExplainErrorDetails(nsISmtpUrl * aSmtpUrl, nsresult aCode,
-                               const char* arg1, const char* arg2)
-{
+nsresult nsExplainErrorDetails(nsISmtpUrl *aSmtpUrl, nsresult aCode,
+                               const char *arg1, const char *arg2) {
   NS_ENSURE_ARG(aSmtpUrl);
 
   nsCOMPtr<nsIPrompt> dialog;
   aSmtpUrl->GetPrompt(getter_AddRefs(dialog));
   NS_ENSURE_TRUE(dialog, NS_ERROR_FAILURE);
 
   nsString msg;
   nsString eMsg;
   nsCOMPtr<nsIStringBundleService> bundleService =
-    mozilla::services::GetStringBundleService();
+      mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   nsresult rv = bundleService->CreateBundle(
-    "chrome://messenger/locale/messengercompose/composeMsgs.properties",
-    getter_AddRefs(bundle));
+      "chrome://messenger/locale/messengercompose/composeMsgs.properties",
+      getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  const char* exitString;
+  const char *exitString;
 #ifdef __GNUC__
 // Temporary workaround until bug 783526 is fixed.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wswitch"
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wswitch"
 #endif
-  switch (aCode)
-  {
+  switch (aCode) {
     case NS_ERROR_ILLEGAL_LOCALPART:
       bundle->GetStringFromName("errorIllegalLocalPart", eMsg);
       nsTextFormatter::ssprintf(msg, eMsg.get(), arg1, arg2);
       break;
     case NS_ERROR_SMTP_SERVER_ERROR:
     case NS_ERROR_SMTP_SEND_NOT_ALLOWED:
     case NS_ERROR_SMTP_TEMP_SIZE_EXCEEDED:
     case NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_1:
@@ -131,502 +129,463 @@ nsresult nsExplainErrorDetails(nsISmtpUr
       break;
     default:
       NS_WARNING("falling to default error code");
       bundle->GetStringFromName("communicationsError", eMsg);
       nsTextFormatter::ssprintf(msg, eMsg.get(), static_cast<uint32_t>(aCode));
       break;
   }
 #ifdef __GNUC__
-#pragma GCC diagnostic pop
+#  pragma GCC diagnostic pop
 #endif
 
   rv = dialog->Alert(nullptr, msg.get());
 
   return rv;
 }
 
 /* RFC 1891 -- extended smtp value encoding scheme
 
   5. Additional parameters for RCPT and MAIL commands
 
-     The extended RCPT and MAIL commands are issued by a client when it wishes to request a DSN from the
-     server, under certain conditions, for a particular recipient. The extended RCPT and MAIL commands are
-     identical to the RCPT and MAIL commands defined in [1], except that one or more of the following parameters
-     appear after the sender or recipient address, respectively. The general syntax for extended SMTP commands is
-     defined in [4].
+  The extended RCPT and MAIL commands are issued by a client when it wishes
+  to request a DSN from the server, under certain conditions, for a particular
+  recipient. The extended RCPT and MAIL commands are identical to the RCPT and
+  MAIL commands defined in [1], except that one or more of the following
+  parameters appear after the sender or recipient address, respectively. The
+  general syntax for extended SMTP commands is defined in [4].
 
-     NOTE: Although RFC 822 ABNF is used to describe the syntax of these parameters, they are not, in the
-     language of that document, "structured field bodies". Therefore, while parentheses MAY appear within an
-     emstp-value, they are not recognized as comment delimiters.
-
-     The syntax for "esmtp-value" in [4] does not allow SP, "=", control characters, or characters outside the
-     traditional ASCII range of 1- 127 decimal to be transmitted in an esmtp-value. Because the ENVID and
-     ORCPT parameters may need to convey values outside this range, the esmtp-values for these parameters are
-     encoded as "xtext". "xtext" is formally defined as follows:
+  NOTE: Although RFC 822 ABNF is used to describe the syntax of these
+  parameters, they are not, in the language of that document, "structured field
+  bodies". Therefore, while parentheses MAY appear within an emstp-value, they
+  are not recognized as comment delimiters.
 
-     xtext = *( xchar / hexchar )
-
-     xchar = any ASCII CHAR between "!" (33) and "~" (126) inclusive, except for "+" and "=".
+  The syntax for "esmtp-value" in [4] does not allow SP, "=", control
+  characters, or characters outside the traditional ASCII range of 1- 127
+  decimal to be transmitted in an esmtp-value. Because the ENVID and ORCPT
+  parameters may need to convey values outside this range, the esmtp-values for
+  these parameters are encoded as "xtext". "xtext" is formally defined as
+  follows:
 
-    ; "hexchar"s are intended to encode octets that cannot appear
-    ; as ASCII characters within an esmtp-value.
+  xtext = *( xchar / hexchar )
 
-         hexchar = ASCII "+" immediately followed by two upper case hexadecimal digits
+  xchar = any ASCII CHAR between "!" (33) and "~" (126) inclusive, except for
+          "+" and "=".
 
-    When encoding an octet sequence as xtext:
+  ; "hexchar"s are intended to encode octets that cannot appear
+  ; as ASCII characters within an esmtp-value.
+
+  hexchar = ASCII "+" immediately followed by two upper case hexadecimal digits
 
-    + Any ASCII CHAR between "!" and "~" inclusive, except for "+" and "=",
-         MAY be encoded as itself. (A CHAR in this range MAY instead be encoded as a "hexchar", at the
-         implementor's discretion.)
+  When encoding an octet sequence as xtext:
 
-    + ASCII CHARs that fall outside the range above must be encoded as
-         "hexchar".
+  + Any ASCII CHAR between "!" and "~" inclusive, except for "+" and "=",
+    MAY be encoded as itself. (A CHAR in this range MAY instead be encoded
+    as a "hexchar", at the implementor's discretion.)
+
+  + ASCII CHARs that fall outside the range above must be encoded as "hexchar".
 
  */
 /* caller must free the return buffer */
-static char *
-esmtp_value_encode(const char *addr)
-{
-  char *buffer = (char *) PR_Malloc(512); /* esmtp ORCPT allow up to 500 chars encoded addresses */
-  char *bp = buffer, *bpEnd = buffer+500;
+static char *esmtp_value_encode(const char *addr) {
+  char *buffer = (char *)PR_Malloc(
+      512); /* esmtp ORCPT allow up to 500 chars encoded addresses */
+  char *bp = buffer, *bpEnd = buffer + 500;
   int len, i;
 
   if (!buffer) return NULL;
 
-  *bp=0;
-  if (! addr || *addr == 0) /* this will never happen */
+  *bp = 0;
+  if (!addr || *addr == 0) /* this will never happen */
     return buffer;
 
-  for (i=0, len=PL_strlen(addr); i < len && bp < bpEnd; i++)
-  {
-    if (*addr >= 0x21 &&
-      *addr <= 0x7E &&
-      *addr != '+' &&
-      *addr != '=')
-    {
+  for (i = 0, len = PL_strlen(addr); i < len && bp < bpEnd; i++) {
+    if (*addr >= 0x21 && *addr <= 0x7E && *addr != '+' && *addr != '=') {
       *bp++ = *addr++;
-    }
-    else
-    {
-      PR_snprintf(bp, bpEnd-bp, "+%.2X", ((int)*addr++));
+    } else {
+      PR_snprintf(bp, bpEnd - bp, "+%.2X", ((int)*addr++));
       bp += PL_strlen(bp);
     }
   }
-  *bp=0;
+  *bp = 0;
   return buffer;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////
 // END OF TEMPORARY HARD CODED FUNCTIONS
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED(nsSmtpProtocol, nsMsgAsyncWriteProtocol,
-                            msgIOAuth2ModuleListener,
-                            nsIProtocolProxyCallback)
+                            msgIOAuth2ModuleListener, nsIProtocolProxyCallback)
 
-nsSmtpProtocol::nsSmtpProtocol(nsIURI * aURL)
-    : nsMsgAsyncWriteProtocol(aURL)
-    , m_dataBuf(nullptr)
-{
-}
+nsSmtpProtocol::nsSmtpProtocol(nsIURI *aURL)
+    : nsMsgAsyncWriteProtocol(aURL), m_dataBuf(nullptr) {}
 
-nsSmtpProtocol::~nsSmtpProtocol()
-{
+nsSmtpProtocol::~nsSmtpProtocol() {
   // free our local state
   PR_FREEIF(m_dataBuf);
 }
 
-nsresult nsSmtpProtocol::Initialize(nsIURI * aURL)
-{
-    NS_ASSERTION(aURL, "invalid URL passed into Smtp Protocol");
-    nsresult rv = NS_OK;
+nsresult nsSmtpProtocol::Initialize(nsIURI *aURL) {
+  NS_ASSERTION(aURL, "invalid URL passed into Smtp Protocol");
+  nsresult rv = NS_OK;
+
+  m_flags = 0;
+  m_prefAuthMethods = 0;
+  m_failedAuthMethods = 0;
+  m_currentAuthMethod = 0;
+  m_usernamePrompted = false;
+  m_prefSocketType = nsMsgSocketType::trySTARTTLS;
+  m_tlsInitiated = false;
+  m_clientIDInitialized = false;
 
-    m_flags = 0;
-    m_prefAuthMethods = 0;
-    m_failedAuthMethods = 0;
-    m_currentAuthMethod = 0;
-    m_usernamePrompted = false;
-    m_prefSocketType = nsMsgSocketType::trySTARTTLS;
-    m_tlsInitiated = false;
-    m_clientIDInitialized = false;
+  m_url = aURL;  // Needed in nsMsgAsyncWriteProtocol::UpdateProgress().
+  m_urlErrorState = NS_ERROR_FAILURE;
+
+  if (aURL) m_runningURL = do_QueryInterface(aURL);
 
-    m_url = aURL; // Needed in nsMsgAsyncWriteProtocol::UpdateProgress().
-    m_urlErrorState = NS_ERROR_FAILURE;
+  // extract out message feedback if there is any.
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aURL);
+  if (mailnewsUrl)
+    mailnewsUrl->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
 
-    if (aURL)
-        m_runningURL = do_QueryInterface(aURL);
+  m_dataBuf = (char *)PR_Malloc(sizeof(char) * OUTPUT_BUFFER_SIZE);
+  m_dataBufSize = OUTPUT_BUFFER_SIZE;
 
-    // extract out message feedback if there is any.
-    nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aURL);
-    if (mailnewsUrl)
-        mailnewsUrl->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
+  m_nextState = SMTP_START_CONNECT;
+  m_nextStateAfterResponse = SMTP_START_CONNECT;
+  m_responseCode = 0;
+  m_responseCodeEnhanced = 0;
+  m_previousResponseCode = 0;
+  m_continuationResponse = -1;
+  m_tlsEnabled = false;
+  m_addressesLeft = 0;
 
-    m_dataBuf = (char *) PR_Malloc(sizeof(char) * OUTPUT_BUFFER_SIZE);
-    m_dataBufSize = OUTPUT_BUFFER_SIZE;
+  m_sendDone = false;
 
-    m_nextState = SMTP_START_CONNECT;
-    m_nextStateAfterResponse = SMTP_START_CONNECT;
-    m_responseCode = 0;
-    m_responseCodeEnhanced = 0;
-    m_previousResponseCode = 0;
-    m_continuationResponse = -1;
-    m_tlsEnabled = false;
-    m_addressesLeft = 0;
+  m_sizelimit = 0;
+  m_totalMessageSize = 0;
+  nsCOMPtr<nsIFile> file;
+  m_runningURL->GetPostMessageFile(getter_AddRefs(file));
+  if (file) file->GetFileSize(&m_totalMessageSize);
+
+  m_originalContentLength = 0;
+  m_totalAmountRead = 0;
 
-    m_sendDone = false;
-
-    m_sizelimit = 0;
-    m_totalMessageSize = 0;
-    nsCOMPtr<nsIFile> file;
-    m_runningURL->GetPostMessageFile(getter_AddRefs(file));
-    if (file)
-        file->GetFileSize(&m_totalMessageSize);
-
-    m_originalContentLength = 0;
-    m_totalAmountRead = 0;
+  m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, true);
+  // ** may want to consider caching the server capability to save lots of
+  // round trip communication between the client and server
+  int32_t authMethod = 0;
+  nsCOMPtr<nsISmtpServer> smtpServer;
+  m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
+  if (smtpServer) {
+    smtpServer->GetAuthMethod(&authMethod);
+    smtpServer->GetSocketType(&m_prefSocketType);
+    smtpServer->GetHelloArgument(m_helloArgument);
+    smtpServer->GetClientid(m_clientId);
 
-    m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, true);
-    // ** may want to consider caching the server capability to save lots of
-    // round trip communication between the client and server
-    int32_t authMethod = 0;
-    nsCOMPtr<nsISmtpServer> smtpServer;
-    m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
-    if (smtpServer) {
-        smtpServer->GetAuthMethod(&authMethod);
-        smtpServer->GetSocketType(&m_prefSocketType);
-        smtpServer->GetHelloArgument(m_helloArgument);
-        smtpServer->GetClientid(m_clientId);
+    // Query for OAuth2 support. If the SMTP server preferences don't allow
+    // for OAuth2, then don't carry around the OAuth2 module any longer
+    // since we won't need it.
+    mOAuth2Support = do_CreateInstance(MSGIOAUTH2MODULE_CONTRACTID);
+    if (mOAuth2Support) {
+      bool supportsOAuth = false;
+      mOAuth2Support->InitFromSmtp(smtpServer, &supportsOAuth);
+      if (!supportsOAuth) mOAuth2Support = nullptr;
+    }
+  }
+  InitPrefAuthMethods(authMethod);
 
-        // Query for OAuth2 support. If the SMTP server preferences don't allow
-        // for OAuth2, then don't carry around the OAuth2 module any longer
-        // since we won't need it.
-        mOAuth2Support = do_CreateInstance(MSGIOAUTH2MODULE_CONTRACTID);
-        if (mOAuth2Support)
-        {
-          bool supportsOAuth = false;
-          mOAuth2Support->InitFromSmtp(smtpServer, &supportsOAuth);
-          if (!supportsOAuth)
-            mOAuth2Support = nullptr;
-        }
-    }
-    InitPrefAuthMethods(authMethod);
+  nsAutoCString hostName;
+  int32_t port = 0;
+
+  aURL->GetPort(&port);
+  aURL->GetAsciiHost(hostName);
 
-    nsAutoCString hostName;
-    int32_t port = 0;
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info,
+          ("SMTP Connecting to: %s:%d", hostName.get(), port));
 
-    aURL->GetPort(&port);
-    aURL->GetAsciiHost(hostName);
+  bool postMessage = false;
+  m_runningURL->GetPostMessage(&postMessage);
 
-    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info, ("SMTP Connecting to: %s:%d", hostName.get(), port));
+  if (postMessage) {
+    m_nextState = SMTP_RESPONSE;
+    m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
 
-    bool postMessage = false;
-    m_runningURL->GetPostMessage(&postMessage);
-
-    if (postMessage)
-    {
-      m_nextState = SMTP_RESPONSE;
-      m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
+    // compile a minimal list of valid target addresses by
+    // - looking only at mailboxes
+    // - dropping addresses with invalid localparts (until we implement RFC
+    // 6532)
+    // - using ACE for IDN domainparts
+    // - stripping duplicates
+    nsCString addresses;
+    m_runningURL->GetRecipients(getter_Copies(addresses));
 
-      // compile a minimal list of valid target addresses by
-      // - looking only at mailboxes
-      // - dropping addresses with invalid localparts (until we implement RFC 6532)
-      // - using ACE for IDN domainparts
-      // - stripping duplicates
-      nsCString addresses;
-      m_runningURL->GetRecipients(getter_Copies(addresses));
-
-      ExtractEmails(EncodedHeader(addresses), UTF16ArrayAdapter<>(m_addresses));
+    ExtractEmails(EncodedHeader(addresses), UTF16ArrayAdapter<>(m_addresses));
 
-      nsCOMPtr<nsIIDNService> converter = do_GetService(NS_IDNSERVICE_CONTRACTID);
-      addresses.Truncate();
-      uint32_t count = m_addresses.Length();
-      for (uint32_t i = 0; i < count; i++)
-      {
-        const char *start = m_addresses[i].get();
-        // Location of the @ character
-        const char *lastAt = nullptr;
-        const char *ch = start;
-        for (; *ch; ch++)
-        {
-          if (*ch == '@')
-            lastAt = ch;
-          // Check for first illegal character (outside 0x09,0x20-0x7e)
-          else if ((*ch < ' ' || *ch > '~') && (*ch != '\t'))
-          {
-            break;
+    nsCOMPtr<nsIIDNService> converter = do_GetService(NS_IDNSERVICE_CONTRACTID);
+    addresses.Truncate();
+    uint32_t count = m_addresses.Length();
+    for (uint32_t i = 0; i < count; i++) {
+      const char *start = m_addresses[i].get();
+      // Location of the @ character
+      const char *lastAt = nullptr;
+      const char *ch = start;
+      for (; *ch; ch++) {
+        if (*ch == '@') lastAt = ch;
+        // Check for first illegal character (outside 0x09,0x20-0x7e)
+        else if ((*ch < ' ' || *ch > '~') && (*ch != '\t')) {
+          break;
+        }
+      }
+      // validate the just parsed address
+      if (*ch || m_addresses[i].IsEmpty()) {
+        // Fortunately, we will always have an @ in each mailbox address.
+        // We try to fix illegal character in the domain part by converting
+        // that to ACE. Illegal characters in the local part are not fixable
+        // (which charset would it be anyway?), hence we error out in that
+        // case as well.
+        nsresult rv = NS_ERROR_FAILURE;  // anything but NS_OK
+        if (lastAt) {
+          // Illegal char in the domain part, hence use ACE
+          nsAutoCString domain;
+          domain.Assign(lastAt + 1);
+          rv = converter->ConvertUTF8toACE(domain, domain);
+          if (NS_SUCCEEDED(rv)) {
+            m_addresses[i].SetLength(lastAt - start + 1);
+            m_addresses[i] += domain;
           }
         }
-        // validate the just parsed address
-        if (*ch || m_addresses[i].IsEmpty())
-        {
-          // Fortunately, we will always have an @ in each mailbox address.
-          // We try to fix illegal character in the domain part by converting
-          // that to ACE. Illegal characters in the local part are not fixable
-          // (which charset would it be anyway?), hence we error out in that
-          // case as well.
-          nsresult rv = NS_ERROR_FAILURE; // anything but NS_OK
-          if (lastAt)
-          {
-            // Illegal char in the domain part, hence use ACE
-            nsAutoCString domain;
-            domain.Assign(lastAt + 1);
-            rv = converter->ConvertUTF8toACE(domain, domain);
-            if (NS_SUCCEEDED(rv))
-            {
-              m_addresses[i].SetLength(lastAt - start + 1);
-              m_addresses[i] += domain;
-            }
-          }
-          if (NS_FAILED(rv))
-          {
-            // Throw an error, including the broken address
-            m_nextState = SMTP_ERROR_DONE;
-            ClearFlag(SMTP_PAUSE_FOR_READ);
-            // Unfortunately, nsExplainErrorDetails will show the error above
-            // the mailnews main window, because we don't necessarily get
-            // passed down a compose window - we might be sending in the
-            // background!
-            rv = nsExplainErrorDetails(m_runningURL,
-                                       NS_ERROR_ILLEGAL_LOCALPART, start, nullptr);
-            NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain illegal localpart");
-            m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
-            return NS_ERROR_BUT_DONT_SHOW_ALERT;
-          }
+        if (NS_FAILED(rv)) {
+          // Throw an error, including the broken address
+          m_nextState = SMTP_ERROR_DONE;
+          ClearFlag(SMTP_PAUSE_FOR_READ);
+          // Unfortunately, nsExplainErrorDetails will show the error above
+          // the mailnews main window, because we don't necessarily get
+          // passed down a compose window - we might be sending in the
+          // background!
+          rv = nsExplainErrorDetails(m_runningURL, NS_ERROR_ILLEGAL_LOCALPART,
+                                     start, nullptr);
+          NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain illegal localpart");
+          m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
+          return NS_ERROR_BUT_DONT_SHOW_ALERT;
         }
       }
-
-      // final cleanup
-      m_addressesLeft = m_addresses.Length();
-
-      // hmm no addresses to send message to...
-      if (m_addressesLeft == 0)
-      {
-        m_nextState = SMTP_ERROR_DONE;
-        ClearFlag(SMTP_PAUSE_FOR_READ);
-        m_urlErrorState = NS_MSG_NO_RECIPIENTS;
-        return NS_MSG_NO_RECIPIENTS;
-      }
-    } // if post message
-
-    rv = MsgExamineForProxyAsync(this, this, getter_AddRefs(m_proxyRequest));
-    if (NS_FAILED(rv))
-    {
-      rv = InitializeInternal(nullptr);
     }
 
-    return rv;
+    // final cleanup
+    m_addressesLeft = m_addresses.Length();
+
+    // hmm no addresses to send message to...
+    if (m_addressesLeft == 0) {
+      m_nextState = SMTP_ERROR_DONE;
+      ClearFlag(SMTP_PAUSE_FOR_READ);
+      m_urlErrorState = NS_MSG_NO_RECIPIENTS;
+      return NS_MSG_NO_RECIPIENTS;
+    }
+  }  // if post message
+
+  rv = MsgExamineForProxyAsync(this, this, getter_AddRefs(m_proxyRequest));
+  if (NS_FAILED(rv)) {
+    rv = InitializeInternal(nullptr);
+  }
+
+  return rv;
 }
 
 // nsIProtocolProxyCallback
 NS_IMETHODIMP
 nsSmtpProtocol::OnProxyAvailable(nsICancelable *aRequest, nsIChannel *aChannel,
-                                 nsIProxyInfo *aProxyInfo, nsresult aStatus)
-{
+                                 nsIProxyInfo *aProxyInfo, nsresult aStatus) {
   // No checking of 'aStatus' here, see nsHttpChannel::OnProxyAvailable().
   // Status is non-fatal and we just kick on.
   return InitializeInternal(aProxyInfo);
 }
 
-nsresult nsSmtpProtocol::InitializeInternal(nsIProxyInfo* proxyInfo)
-{
+nsresult nsSmtpProtocol::InitializeInternal(nsIProxyInfo *proxyInfo) {
   m_proxyRequest = nullptr;
 
   // When we are making a secure connection, we need to make sure that we
   // pass an interface requestor down to the socket transport so that PSM can
   // retrieve a nsIPrompt instance if needed.
   nsCOMPtr<nsIInterfaceRequestor> callbacks;
   nsCOMPtr<nsISmtpUrl> smtpUrl(do_QueryInterface(m_url));
-  if (smtpUrl)
-    smtpUrl->GetNotificationCallbacks(getter_AddRefs(callbacks));
+  if (smtpUrl) smtpUrl->GetNotificationCallbacks(getter_AddRefs(callbacks));
 
   int32_t port = 0;
   m_url->GetPort(&port);
 
   nsAutoCString hostName;
   m_url->GetAsciiHost(hostName);
 
   nsresult rv;
   if (m_prefSocketType == nsMsgSocketType::SSL)
-    rv = OpenNetworkSocketWithInfo(hostName.get(), port, "ssl", proxyInfo, callbacks);
-  else if (m_prefSocketType != nsMsgSocketType::plain)
-  {
-    rv = OpenNetworkSocketWithInfo(hostName.get(), port, "starttls",
-      proxyInfo, callbacks);
-    if (NS_FAILED(rv) && m_prefSocketType == nsMsgSocketType::trySTARTTLS)
-    {
+    rv = OpenNetworkSocketWithInfo(hostName.get(), port, "ssl", proxyInfo,
+                                   callbacks);
+  else if (m_prefSocketType != nsMsgSocketType::plain) {
+    rv = OpenNetworkSocketWithInfo(hostName.get(), port, "starttls", proxyInfo,
+                                   callbacks);
+    if (NS_FAILED(rv) && m_prefSocketType == nsMsgSocketType::trySTARTTLS) {
       m_prefSocketType = nsMsgSocketType::plain;
-      rv = OpenNetworkSocketWithInfo(hostName.get(), port, nullptr, proxyInfo, callbacks);
+      rv = OpenNetworkSocketWithInfo(hostName.get(), port, nullptr, proxyInfo,
+                                     callbacks);
     }
-  }
-  else
-    rv = OpenNetworkSocketWithInfo(hostName.get(), port, nullptr, proxyInfo, callbacks);
+  } else
+    rv = OpenNetworkSocketWithInfo(hostName.get(), port, nullptr, proxyInfo,
+                                   callbacks);
 
   return LoadUrlInternal(m_url, m_consumer);
 }
 
-void nsSmtpProtocol::AppendHelloArgument(nsACString& aResult)
-{
+void nsSmtpProtocol::AppendHelloArgument(nsACString &aResult) {
   nsresult rv;
 
   // is a custom EHLO/HELO argument configured for the transport to be used?
-  if (!m_helloArgument.IsEmpty())
-  {
-      aResult += m_helloArgument;
-  }
-  else
-  {
-      // is a FQDN known for this system?
-      char hostName[256];
-      PR_GetSystemInfo(PR_SI_HOSTNAME_UNTRUNCATED, hostName, sizeof hostName);
-      if ((hostName[0] != '\0') && (strchr(hostName, '.') != NULL))
-      {
-          nsDependentCString cleanedHostName(hostName);
-          // avoid problems with hostnames containing newlines/whitespace
-          cleanedHostName.StripWhitespace();
-          aResult += cleanedHostName;
-      }
-      else
-      {
-          nsCOMPtr<nsINetAddr> iaddr; // IP address for this connection
-          // our transport is always a nsISocketTransport
-          nsCOMPtr<nsISocketTransport> socketTransport = do_QueryInterface(m_transport);
-          // should return the interface ip of the SMTP connection
-          // minimum case - see bug 68877 and RFC 2821, chapter 4.1.1.1
-          rv = socketTransport->GetScriptableSelfAddr(getter_AddRefs(iaddr));
+  if (!m_helloArgument.IsEmpty()) {
+    aResult += m_helloArgument;
+  } else {
+    // is a FQDN known for this system?
+    char hostName[256];
+    PR_GetSystemInfo(PR_SI_HOSTNAME_UNTRUNCATED, hostName, sizeof hostName);
+    if ((hostName[0] != '\0') && (strchr(hostName, '.') != NULL)) {
+      nsDependentCString cleanedHostName(hostName);
+      // avoid problems with hostnames containing newlines/whitespace
+      cleanedHostName.StripWhitespace();
+      aResult += cleanedHostName;
+    } else {
+      nsCOMPtr<nsINetAddr> iaddr;  // IP address for this connection
+      // our transport is always a nsISocketTransport
+      nsCOMPtr<nsISocketTransport> socketTransport =
+          do_QueryInterface(m_transport);
+      // should return the interface ip of the SMTP connection
+      // minimum case - see bug 68877 and RFC 2821, chapter 4.1.1.1
+      rv = socketTransport->GetScriptableSelfAddr(getter_AddRefs(iaddr));
 
-          if (NS_SUCCEEDED(rv))
-          {
-              // turn it into a string
-              nsCString ipAddressString;
-              rv = iaddr->GetAddress(ipAddressString);
-              if (NS_SUCCEEDED(rv))
-              {
+      if (NS_SUCCEEDED(rv)) {
+        // turn it into a string
+        nsCString ipAddressString;
+        rv = iaddr->GetAddress(ipAddressString);
+        if (NS_SUCCEEDED(rv)) {
 #ifdef DEBUG
-                  bool v4mapped = false;
-                  iaddr->GetIsV4Mapped(&v4mapped);
-                  NS_ASSERTION(!v4mapped,
-                               "unexpected IPv4-mapped IPv6 address");
+          bool v4mapped = false;
+          iaddr->GetIsV4Mapped(&v4mapped);
+          NS_ASSERTION(!v4mapped, "unexpected IPv4-mapped IPv6 address");
 #endif
 
-                  uint16_t family = nsINetAddr::FAMILY_INET;
-                  iaddr->GetFamily(&family);
+          uint16_t family = nsINetAddr::FAMILY_INET;
+          iaddr->GetFamily(&family);
 
-                  if (family == nsINetAddr::FAMILY_INET6) // IPv6 style address?
-                      aResult.AppendLiteral("[IPv6:");
-                  else
-                      aResult.Append('[');
+          if (family == nsINetAddr::FAMILY_INET6)  // IPv6 style address?
+            aResult.AppendLiteral("[IPv6:");
+          else
+            aResult.Append('[');
 
-                  aResult.Append(ipAddressString);
-                  aResult.Append(']');
-              }
-          }
+          aResult.Append(ipAddressString);
+          aResult.Append(']');
+        }
       }
+    }
   }
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 // we support the nsIStreamListener interface
 ////////////////////////////////////////////////////////////////////////////////////////////
 
 // stop binding is a "notification" informing us that the stream
 // associated with aURL is going away.
 NS_IMETHODIMP nsSmtpProtocol::OnStopRequest(nsIRequest *request,
-                                            nsresult aStatus)
-{
-  bool connDroppedDuringAuth = NS_SUCCEEDED(aStatus) && !m_sendDone &&
+                                            nsresult aStatus) {
+  bool connDroppedDuringAuth =
+      NS_SUCCEEDED(aStatus) && !m_sendDone &&
       (m_nextStateAfterResponse == SMTP_AUTH_LOGIN_STEP0_RESPONSE ||
        m_nextStateAfterResponse == SMTP_AUTH_LOGIN_RESPONSE);
   // ignore errors handling the QUIT command so fcc can continue.
-  if (m_sendDone && NS_FAILED(aStatus))
-  {
+  if (m_sendDone && NS_FAILED(aStatus)) {
     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info,
-     ("SMTP connection error quitting %" PRIx32 ", ignoring ", static_cast<uint32_t>(aStatus)));
+            ("SMTP connection error quitting %" PRIx32 ", ignoring ",
+             static_cast<uint32_t>(aStatus)));
     aStatus = NS_OK;
   }
   if (NS_SUCCEEDED(aStatus) && !m_sendDone) {
     // if we are getting OnStopRequest() with NS_OK,
     // but we haven't finished clean, that's spells trouble.
-    // it means that the server has dropped us before we could send the whole mail
-    // for example, see bug #200647
+    // it means that the server has dropped us before we could send the whole
+    // mail for example, see bug #200647
     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info,
- ("SMTP connection dropped after %d total bytes read", m_totalAmountRead));
+            ("SMTP connection dropped after %d total bytes read",
+             m_totalAmountRead));
     if (!connDroppedDuringAuth)
       nsMsgAsyncWriteProtocol::OnStopRequest(nullptr, NS_ERROR_NET_INTERRUPT);
-  }
-  else
+  } else
     nsMsgAsyncWriteProtocol::OnStopRequest(nullptr, aStatus);
 
-  // okay, we've been told that the send is done and the connection is going away. So
-  // we need to release all of our state
+  // okay, we've been told that the send is done and the connection is going
+  // away. So we need to release all of our state
   nsresult rv = nsMsgAsyncWriteProtocol::CloseSocket();
   // If the server dropped the connection when we were expecting
   // a login response, reprompt for password, and if the user asks,
   // retry the url.
-  if (connDroppedDuringAuth)
-  {
+  if (connDroppedDuringAuth) {
     nsCOMPtr<nsIURI> runningURI = do_QueryInterface(m_runningURL);
     nsresult rv = AuthLoginResponse(nullptr, 0);
-    if (NS_FAILED(rv))
-      return rv;
+    if (NS_FAILED(rv)) return rv;
     return LoadUrl(runningURI, nullptr);
   }
 
   return rv;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 // End of nsIStreamListenerSupport
 //////////////////////////////////////////////////////////////////////////////////////////////
 
-void nsSmtpProtocol::UpdateStatus(const char* aStatusName)
-{
-  if (m_statusFeedback)
-  {
+void nsSmtpProtocol::UpdateStatus(const char *aStatusName) {
+  if (m_statusFeedback) {
     nsCOMPtr<nsIStringBundleService> bundleService =
-      mozilla::services::GetStringBundleService();
+        mozilla::services::GetStringBundleService();
     if (!bundleService) return;
     nsCOMPtr<nsIStringBundle> bundle;
-    nsresult rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
+    nsresult rv = bundleService->CreateBundle(
+        "chrome://messenger/locale/messengercompose/composeMsgs.properties",
+        getter_AddRefs(bundle));
     if (NS_FAILED(rv)) return;
     nsString msg;
     bundle->GetStringFromName(aStatusName, msg);
     UpdateStatusWithString(msg.get());
   }
 }
 
-void nsSmtpProtocol::UpdateStatusWithString(const char16_t * aStatusString)
-{
+void nsSmtpProtocol::UpdateStatusWithString(const char16_t *aStatusString) {
   if (m_statusFeedback && aStatusString)
     m_statusFeedback->ShowStatusString(nsDependentString(aStatusString));
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 // Begin protocol state machine functions...
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 /*
  * gets the response code from the SMTP server and the
  * response line
  */
-nsresult nsSmtpProtocol::SmtpResponse(nsIInputStream * inputStream, uint32_t length)
-{
-  char * line = nullptr;
+nsresult nsSmtpProtocol::SmtpResponse(nsIInputStream *inputStream,
+                                      uint32_t length) {
+  char *line = nullptr;
   char cont_char;
   uint32_t ln = 0;
   bool pauseForMoreData = false;
 
   if (!m_lineStreamBuffer)
     // this will force an error and at least we won't crash
     return NS_ERROR_NULL_POINTER;
 
   line = m_lineStreamBuffer->ReadNextLine(inputStream, ln, pauseForMoreData);
 
-  if (pauseForMoreData || !line)
-  {
+  if (pauseForMoreData || !line) {
     SetFlag(SMTP_PAUSE_FOR_READ); /* pause */
     PR_Free(line);
     return NS_OK;
   }
 
   m_totalAmountRead += ln;
 
   // The expected response is in the format:
@@ -635,517 +594,476 @@ nsresult nsSmtpProtocol::SmtpResponse(ns
   MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info, ("SMTP Response: %s", line));
   cont_char = ' '; /* default */
   int chars_read = 0;
   // sscanf() doesn't update m_responseCode if line doesn't start
   // with a number. That can be dangerous. So be sure to set
   // m_responseCode to 0 if no items read.
   if (PR_sscanf(line, "%d%c%n", &m_responseCode, &cont_char, &chars_read) <= 0)
     m_responseCode = 0;
-  else if (cont_char != '-' )
-  {
+  else if (cont_char != '-') {
     m_responseCodeEnhanced = 0;
     char codeClass, codeSubject, codeDetail;
-    if (PR_sscanf(line + chars_read, "%1u.%1u.%1u ", &codeClass, &codeSubject, &codeDetail) == 3)
+    if (PR_sscanf(line + chars_read, "%1u.%1u.%1u ", &codeClass, &codeSubject,
+                  &codeDetail) == 3)
       m_responseCodeEnhanced = codeClass * 100 + codeSubject * 10 + codeDetail;
   }
 
-  if (m_continuationResponse == -1)
-  {
-    if (cont_char == '-')  /* begin continuation */
+  if (m_continuationResponse == -1) {
+    if (cont_char == '-') /* begin continuation */
       m_continuationResponse = m_responseCode;
 
     // display the whole message if no valid response code or
     // message shorter than 4 chars (chars_read)
     // For now we intentionally leave the ESMTP code in the message text
     // as we do not handle that code so let it for the user to get some clue.
-    m_responseText = (m_responseCode >= 100 && PL_strlen(line) > 3) ? line + chars_read : line;
-  }
-  else
-  { /* have to continue */
+    m_responseText = (m_responseCode >= 100 && PL_strlen(line) > 3)
+                         ? line + chars_read
+                         : line;
+  } else { /* have to continue */
     if (m_continuationResponse == m_responseCode && cont_char == ' ')
-      m_continuationResponse = -1;    /* ended */
+      m_continuationResponse = -1; /* ended */
 
     if (m_responseText.IsEmpty() || m_responseText.Last() != '\n')
       m_responseText += "\n";
 
     m_responseText += (PL_strlen(line) > 3) ? line + chars_read : line;
   }
 
   if (m_responseCode == 220 && m_responseText.Length() && !m_tlsInitiated &&
-     !m_sendDone)
+      !m_sendDone)
     m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
 
-  if (m_continuationResponse == -1)  /* all done with this response? */
+  if (m_continuationResponse == -1) /* all done with this response? */
   {
     m_nextState = m_nextStateAfterResponse;
     ClearFlag(SMTP_PAUSE_FOR_READ); /* don't pause */
   }
 
   PR_Free(line);
   return NS_OK;
 }
 
-nsresult nsSmtpProtocol::ExtensionLoginResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsSmtpProtocol::ExtensionLoginResponse(nsIInputStream *inputStream,
+                                                uint32_t length) {
   nsresult status = NS_OK;
 
-  if (m_responseCode != 220)
-  {
+  if (m_responseCode != 220) {
 #ifdef DEBUG
     nsresult rv =
 #endif
-    nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_GREETING,
-                          m_responseText.get(), nullptr);
+        nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_GREETING,
+                              m_responseText.get(), nullptr);
     NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
 
     m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
     return NS_ERROR_SMTP_AUTH_FAILURE;
   }
 
   nsAutoCString buffer("EHLO ");
   AppendHelloArgument(buffer);
   buffer += CRLF;
 
   status = SendData(buffer.get());
 
   m_nextState = SMTP_RESPONSE;
   m_nextStateAfterResponse = SMTP_SEND_EHLO_RESPONSE;
   SetFlag(SMTP_PAUSE_FOR_READ);
 
-  return(status);
+  return (status);
 }
 
-nsresult nsSmtpProtocol::SendHeloResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsSmtpProtocol::SendHeloResponse(nsIInputStream *inputStream,
+                                          uint32_t length) {
   nsresult status = NS_OK;
   nsAutoCString buffer;
   nsresult rv;
 
-  if (m_responseCode != 250)
-  {
+  if (m_responseCode != 250) {
 #ifdef DEBUG
     rv =
 #endif
-    nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_SERVER_ERROR,
-                          m_responseText.get(), nullptr);
+        nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_SERVER_ERROR,
+                              m_responseText.get(), nullptr);
     NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
 
     m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
     return NS_ERROR_SMTP_AUTH_FAILURE;
   }
 
   // check if we're just verifying the ability to logon
   nsCOMPtr<nsISmtpUrl> smtpUrl = m_runningURL;
   bool verifyingLogon = false;
   smtpUrl->GetVerifyLogon(&verifyingLogon);
-  if (verifyingLogon)
-    return SendQuit();
+  if (verifyingLogon) return SendQuit();
 
-  nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  nsCOMPtr<nsIPrefService> prefs =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsIPrefBranch> prefBranch;
   rv = prefs->GetBranch(nullptr, getter_AddRefs(prefBranch));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool useSenderForSmtpMailFrom = false;
-  prefBranch->GetBoolPref("mail.smtp.useSenderForSmtpMailFrom", &useSenderForSmtpMailFrom);
+  prefBranch->GetBoolPref("mail.smtp.useSenderForSmtpMailFrom",
+                          &useSenderForSmtpMailFrom);
   nsCString fullAddress;
 
-  if (useSenderForSmtpMailFrom)
-  {
+  if (useSenderForSmtpMailFrom) {
     // Extract the email address from the mail headers.
     nsCString from;
     m_runningURL->GetSender(getter_Copies(from));
 
     ExtractEmail(EncodedHeader(from), fullAddress);
     if (fullAddress.IsEmpty()) {
       m_urlErrorState = NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS;
-      return(NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS);
+      return (NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS);
     }
-  }
-  else
-  {
+  } else {
     // Extract the email address from the identity.
     nsCString emailAddress;
-    nsCOMPtr <nsIMsgIdentity> senderIdentity;
+    nsCOMPtr<nsIMsgIdentity> senderIdentity;
     rv = m_runningURL->GetSenderIdentity(getter_AddRefs(senderIdentity));
-    if (NS_FAILED(rv) || !senderIdentity)
-    {
+    if (NS_FAILED(rv) || !senderIdentity) {
       m_urlErrorState = NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY;
-      return(NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY);
+      return (NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY);
     }
     senderIdentity->GetEmail(emailAddress);
-    if (emailAddress.IsEmpty())
-    {
+    if (emailAddress.IsEmpty()) {
       m_urlErrorState = NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS;
-      return(NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS);
+      return (NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS);
     }
 
     // Quote the email address before passing it to the SMTP server.
     MakeMimeAddress(EmptyCString(), emailAddress, fullAddress);
   }
   buffer = "MAIL FROM:<";
   buffer += fullAddress;
   buffer += ">";
 
-  if (TestFlag(SMTP_EHLO_DSN_ENABLED))
-  {
+  if (TestFlag(SMTP_EHLO_DSN_ENABLED)) {
     bool requestDSN = false;
     rv = m_runningURL->GetRequestDSN(&requestDSN);
 
-    if (requestDSN)
-    {
+    if (requestDSN) {
       bool requestRetFull = false;
       rv = prefBranch->GetBoolPref("mail.dsn.ret_full_on", &requestRetFull);
 
       buffer += requestRetFull ? " RET=FULL" : " RET=HDRS";
 
       nsCString dsnEnvid;
 
       // get the envid from the smtpUrl
       rv = m_runningURL->GetDsnEnvid(dsnEnvid);
 
       if (dsnEnvid.IsEmpty()) {
-          nsCOMPtr <nsIMsgIdentity> senderIdentity;
-          rv = m_runningURL->GetSenderIdentity(getter_AddRefs(senderIdentity));
-          if (NS_FAILED(rv) || !senderIdentity) {
-              m_urlErrorState = NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY;
-              return(NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY);
-          }
-          dsnEnvid.Adopt(msg_generate_message_id(senderIdentity));
+        nsCOMPtr<nsIMsgIdentity> senderIdentity;
+        rv = m_runningURL->GetSenderIdentity(getter_AddRefs(senderIdentity));
+        if (NS_FAILED(rv) || !senderIdentity) {
+          m_urlErrorState = NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY;
+          return (NS_ERROR_COULD_NOT_GET_SENDERS_IDENTITY);
+        }
+        dsnEnvid.Adopt(msg_generate_message_id(senderIdentity));
       }
       buffer += " ENVID=";
       buffer += dsnEnvid;
     }
   }
 
-  if (TestFlag(SMTP_EHLO_8BIT_ENABLED))
-  {
+  if (TestFlag(SMTP_EHLO_8BIT_ENABLED)) {
     bool strictlyMime = false;
     rv = prefBranch->GetBoolPref("mail.strictly_mime", &strictlyMime);
 
-    if (!strictlyMime)
-      buffer.AppendLiteral(" BODY=8BITMIME");
+    if (!strictlyMime) buffer.AppendLiteral(" BODY=8BITMIME");
   }
 
-  if (TestFlag(SMTP_EHLO_SIZE_ENABLED))
-  {
+  if (TestFlag(SMTP_EHLO_SIZE_ENABLED)) {
     buffer.AppendLiteral(" SIZE=");
     buffer.AppendInt(m_totalMessageSize);
   }
   buffer += CRLF;
 
   status = SendData(buffer.get());
 
   m_nextState = SMTP_RESPONSE;
 
-
   m_nextStateAfterResponse = SMTP_SEND_MAIL_RESPONSE;
   SetFlag(SMTP_PAUSE_FOR_READ);
 
-  return(status);
+  return (status);
 }
 
-nsresult nsSmtpProtocol::SendEhloResponse(nsIInputStream * inputStream, uint32_t length)
-{
-    nsresult status = NS_OK;
+nsresult nsSmtpProtocol::SendEhloResponse(nsIInputStream *inputStream,
+                                          uint32_t length) {
+  nsresult status = NS_OK;
+
+  if (m_responseCode != 250) {
+    /* EHLO must not be implemented by the server, so fall back to the HELO case
+     * if command is unrecognized or unimplemented.
+     */
+    if (m_responseCode == 500 || m_responseCode == 502) {
+      /* If STARTTLS is requested by the user, EHLO is required to advertise it.
+       * But only if TLS handshake is not already accomplished.
+       */
+      if (m_prefSocketType == nsMsgSocketType::alwaysSTARTTLS &&
+          !m_tlsEnabled) {
+        m_nextState = SMTP_ERROR_DONE;
+        m_urlErrorState = NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS;
+        return (NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS);
+      }
+
+      nsAutoCString buffer("HELO ");
+      AppendHelloArgument(buffer);
+      buffer += CRLF;
 
-    if (m_responseCode != 250)
-    {
-        /* EHLO must not be implemented by the server, so fall back to the HELO case
-         * if command is unrecognized or unimplemented.
-         */
-        if (m_responseCode == 500 || m_responseCode == 502)
-        {
-            /* If STARTTLS is requested by the user, EHLO is required to advertise it.
-             * But only if TLS handshake is not already accomplished.
-             */
-            if (m_prefSocketType == nsMsgSocketType::alwaysSTARTTLS &&
-                !m_tlsEnabled)
-            {
-                m_nextState = SMTP_ERROR_DONE;
-                m_urlErrorState = NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS;
-                return(NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS);
-            }
+      status = SendData(buffer.get());
+
+      m_nextState = SMTP_RESPONSE;
+      m_nextStateAfterResponse = SMTP_SEND_HELO_RESPONSE;
+      SetFlag(SMTP_PAUSE_FOR_READ);
+      return (status);
+    }
+    /* e.g. getting 421 "Server says unauthorized, bye" or
+     * 501 "Syntax error in EHLOs parameters or arguments"
+     */
+    else {
+#ifdef DEBUG
+      nsresult rv =
+#endif
+          nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_SERVER_ERROR,
+                                m_responseText.get(), nullptr);
+      NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
+
+      m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
+      return NS_ERROR_SMTP_AUTH_FAILURE;
+    }
+  }
 
-            nsAutoCString buffer("HELO ");
-            AppendHelloArgument(buffer);
-            buffer += CRLF;
+  int32_t responseLength = m_responseText.Length();
+  int32_t startPos = 0;
+  int32_t endPos;
+  do {
+    endPos = m_responseText.FindChar('\n', startPos + 1);
+    nsAutoCString responseLine;
+    responseLine.Assign(
+        Substring(m_responseText, startPos,
+                  (endPos >= 0 ? endPos : responseLength) - startPos));
 
-            status = SendData(buffer.get());
+    MsgCompressWhitespace(responseLine);
+    if (responseLine.LowerCaseEqualsLiteral("starttls")) {
+      SetFlag(SMTP_EHLO_STARTTLS_ENABLED);
+    } else if (responseLine.LowerCaseEqualsLiteral("dsn")) {
+      SetFlag(SMTP_EHLO_DSN_ENABLED);
+    } else if (responseLine.LowerCaseEqualsLiteral("clientid")) {
+      SetFlag(SMTP_EHLO_CLIENTID_ENABLED);
+      // If we have "clientid" in the ehlo response, then TLS must be present.
+      if (m_prefSocketType == nsMsgSocketType::SSL) m_tlsEnabled = true;
+    } else if (StringBeginsWith(responseLine, NS_LITERAL_CSTRING("AUTH"),
+                                nsCaseInsensitiveCStringComparator())) {
+      SetFlag(SMTP_AUTH);
+
+      if (responseLine.Find(NS_LITERAL_CSTRING("GSSAPI"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_GSSAPI_ENABLED);
+
+      if (responseLine.Find(NS_LITERAL_CSTRING("CRAM-MD5"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_CRAM_MD5_ENABLED);
 
-            m_nextState = SMTP_RESPONSE;
-            m_nextStateAfterResponse = SMTP_SEND_HELO_RESPONSE;
-            SetFlag(SMTP_PAUSE_FOR_READ);
-            return (status);
-        }
-        /* e.g. getting 421 "Server says unauthorized, bye" or
-         * 501 "Syntax error in EHLOs parameters or arguments"
-         */
-        else
-        {
-#ifdef DEBUG
-            nsresult rv =
-#endif
-            nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_SERVER_ERROR,
-                                  m_responseText.get(), nullptr);
-            NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
+      if (responseLine.Find(NS_LITERAL_CSTRING("NTLM"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_NTLM_ENABLED);
+
+      if (responseLine.Find(NS_LITERAL_CSTRING("MSN"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_MSN_ENABLED);
+
+      if (responseLine.Find(NS_LITERAL_CSTRING("PLAIN"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_PLAIN_ENABLED);
+
+      if (responseLine.Find(NS_LITERAL_CSTRING("LOGIN"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_LOGIN_ENABLED);
 
-            m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
-            return NS_ERROR_SMTP_AUTH_FAILURE;
-        }
+      if (responseLine.Find(NS_LITERAL_CSTRING("EXTERNAL"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_EXTERNAL_ENABLED);
+
+      if (responseLine.Find(NS_LITERAL_CSTRING("XOAUTH2"),
+                            /* ignoreCase = */ true) >= 0)
+        SetFlag(SMTP_AUTH_OAUTH2_ENABLED);
+    } else if (StringBeginsWith(responseLine, NS_LITERAL_CSTRING("SIZE"),
+                                nsCaseInsensitiveCStringComparator())) {
+      SetFlag(SMTP_EHLO_SIZE_ENABLED);
+
+      m_sizelimit = atol((responseLine.get()) + 4);
+    } else if (StringBeginsWith(responseLine, NS_LITERAL_CSTRING("8BITMIME"),
+                                nsCaseInsensitiveCStringComparator())) {
+      SetFlag(SMTP_EHLO_8BIT_ENABLED);
     }
 
-    int32_t responseLength = m_responseText.Length();
-    int32_t startPos = 0;
-    int32_t endPos;
-    do
-    {
-        endPos = m_responseText.FindChar('\n', startPos + 1);
-        nsAutoCString responseLine;
-        responseLine.Assign(Substring(m_responseText, startPos,
-            (endPos >= 0 ? endPos : responseLength) - startPos));
+    startPos = endPos + 1;
+  } while (endPos >= 0);
 
-        MsgCompressWhitespace(responseLine);
-        if (responseLine.LowerCaseEqualsLiteral("starttls"))
-        {
-            SetFlag(SMTP_EHLO_STARTTLS_ENABLED);
-        }
-        else if (responseLine.LowerCaseEqualsLiteral("dsn"))
-        {
-            SetFlag(SMTP_EHLO_DSN_ENABLED);
-        }
-        else if (responseLine.LowerCaseEqualsLiteral("clientid"))
-        {
-            SetFlag(SMTP_EHLO_CLIENTID_ENABLED);
-            // If we have "clientid" in the ehlo response, then TLS must be present.
-            if (m_prefSocketType == nsMsgSocketType::SSL)
-                m_tlsEnabled = true;
-        }
-        else if (StringBeginsWith(responseLine, NS_LITERAL_CSTRING("AUTH"), nsCaseInsensitiveCStringComparator()))
-        {
-          SetFlag(SMTP_AUTH);
+  if (TestFlag(SMTP_EHLO_SIZE_ENABLED) && m_sizelimit > 0 &&
+      (int32_t)m_totalMessageSize > m_sizelimit) {
+#ifdef DEBUG
+    nsresult rv =
+#endif
+        nsExplainErrorDetails(m_runningURL, NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_1,
+                              nsPrintfCString("%" PRId32, m_sizelimit).get(),
+                              nullptr);
+    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
 
-          if (responseLine.Find(NS_LITERAL_CSTRING("GSSAPI"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_GSSAPI_ENABLED);
-
-          if (responseLine.Find(NS_LITERAL_CSTRING("CRAM-MD5"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_CRAM_MD5_ENABLED);
-
-          if (responseLine.Find(NS_LITERAL_CSTRING("NTLM"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_NTLM_ENABLED);
+    m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
+    return (NS_ERROR_SENDING_FROM_COMMAND);
+  }
 
-          if (responseLine.Find(NS_LITERAL_CSTRING("MSN"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_MSN_ENABLED);
-
-          if (responseLine.Find(NS_LITERAL_CSTRING("PLAIN"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_PLAIN_ENABLED);
-
-          if (responseLine.Find(NS_LITERAL_CSTRING("LOGIN"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_LOGIN_ENABLED);
-
-          if (responseLine.Find(NS_LITERAL_CSTRING("EXTERNAL"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_EXTERNAL_ENABLED);
-
-          if (responseLine.Find(NS_LITERAL_CSTRING("XOAUTH2"),
-                                /* ignoreCase = */ true) >= 0)
-            SetFlag(SMTP_AUTH_OAUTH2_ENABLED);
-        }
-        else if (StringBeginsWith(responseLine, NS_LITERAL_CSTRING("SIZE"), nsCaseInsensitiveCStringComparator()))
-        {
-            SetFlag(SMTP_EHLO_SIZE_ENABLED);
+  m_nextState = SMTP_AUTH_PROCESS_STATE;
+  return status;
+}
 
-            m_sizelimit = atol((responseLine.get()) + 4);
-        }
-        else if (StringBeginsWith(responseLine, NS_LITERAL_CSTRING("8BITMIME"), nsCaseInsensitiveCStringComparator()))
-        {
-            SetFlag(SMTP_EHLO_8BIT_ENABLED);
-        }
-
-        startPos = endPos + 1;
-    } while (endPos >= 0);
+nsresult nsSmtpProtocol::SendTLSResponse() {
+  // only tear down our existing connection and open a new one if we received a
+  // 220 response from the smtp server after we issued the STARTTLS
+  nsresult rv = NS_OK;
+  if (m_responseCode == 220) {
+    nsCOMPtr<nsISupports> secInfo;
+    nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport, &rv);
+    if (NS_FAILED(rv)) return rv;
 
-    if (TestFlag(SMTP_EHLO_SIZE_ENABLED) &&
-       m_sizelimit > 0 && (int32_t)m_totalMessageSize > m_sizelimit)
-    {
-#ifdef DEBUG
-        nsresult rv =
-#endif
-        nsExplainErrorDetails(m_runningURL,
-                              NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_1,
-                              nsPrintfCString("%" PRId32, m_sizelimit).get(), nullptr);
-        NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
+    rv = strans->GetSecurityInfo(getter_AddRefs(secInfo));
 
-        m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
-        return(NS_ERROR_SENDING_FROM_COMMAND);
+    if (NS_SUCCEEDED(rv) && secInfo) {
+      nsCOMPtr<nsISSLSocketControl> sslControl =
+          do_QueryInterface(secInfo, &rv);
+
+      if (NS_SUCCEEDED(rv) && sslControl) rv = sslControl->StartTLS();
     }
 
-    m_nextState = SMTP_AUTH_PROCESS_STATE;
-    return status;
-}
-
-
-nsresult nsSmtpProtocol::SendTLSResponse()
-{
-  // only tear down our existing connection and open a new one if we received a 220 response
-  // from the smtp server after we issued the STARTTLS
-  nsresult rv = NS_OK;
-  if (m_responseCode == 220)
-  {
-      nsCOMPtr<nsISupports> secInfo;
-      nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport, &rv);
-      if (NS_FAILED(rv)) return rv;
-
-      rv = strans->GetSecurityInfo(getter_AddRefs(secInfo));
-
-      if (NS_SUCCEEDED(rv) && secInfo) {
-          nsCOMPtr<nsISSLSocketControl> sslControl = do_QueryInterface(secInfo, &rv);
-
-          if (NS_SUCCEEDED(rv) && sslControl)
-              rv = sslControl->StartTLS();
-      }
-
-      if (NS_SUCCEEDED(rv))
-      {
-          m_nextState = SMTP_EXTN_LOGIN_RESPONSE;
-          m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
-          m_tlsEnabled = true;
-          m_flags = 0; // resetting the flags
-          return rv;
-      }
+    if (NS_SUCCEEDED(rv)) {
+      m_nextState = SMTP_EXTN_LOGIN_RESPONSE;
+      m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
+      m_tlsEnabled = true;
+      m_flags = 0;  // resetting the flags
+      return rv;
+    }
   }
 
   ClearFlag(SMTP_EHLO_STARTTLS_ENABLED);
   m_tlsInitiated = false;
   m_nextState = SMTP_AUTH_PROCESS_STATE;
 
   return rv;
 }
 
-nsresult nsSmtpProtocol::SendClientIDResponse()
-{
-  if (m_responseCode/10 == 25)
-  {
+nsresult nsSmtpProtocol::SendClientIDResponse() {
+  if (m_responseCode / 10 == 25) {
     // ClientID success!
     m_clientIDInitialized = true;
     ClearFlag(SMTP_EHLO_CLIENTID_ENABLED);
     m_nextState = SMTP_AUTH_PROCESS_STATE;
     return NS_OK;
   }
   // ClientID failed
   nsresult errorCode;
-  if (m_responseCode == 550)
-  {
+  if (m_responseCode == 550) {
     // 'You are not permitted to access this'
     // 'Access Denied' + server response
     errorCode = NS_ERROR_CLIENTID_PERMISSION;
-  }
-  else
-  {
-    if (MOZ_LOG_TEST(SMTPLogModule, mozilla::LogLevel::Error))
-    {
+  } else {
+    if (MOZ_LOG_TEST(SMTPLogModule, mozilla::LogLevel::Error)) {
       if (m_responseCode != 501 && m_responseCode != 503 &&
-          m_responseCode != 504 && m_responseCode/100 != 4)
-      {
+          m_responseCode != 504 && m_responseCode / 100 != 4) {
         // If not 501, 503, 504 or 4xx, log an error.
         MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
-                ("SendClientIDResponse: Unexpected error occurred, server responded: %s\n",
-                m_responseText.get()));
+                ("SendClientIDResponse: Unexpected error occurred, server "
+                 "responded: %s\n",
+                 m_responseText.get()));
       }
     }
     errorCode = NS_ERROR_CLIENTID;
   }
   nsExplainErrorDetails(m_runningURL, errorCode, m_responseText.get(), nullptr);
   m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
   return NS_ERROR_SMTP_AUTH_FAILURE;
 }
 
-void nsSmtpProtocol::InitPrefAuthMethods(int32_t authMethodPrefValue)
-{
+void nsSmtpProtocol::InitPrefAuthMethods(int32_t authMethodPrefValue) {
   // for m_prefAuthMethods, using the same flags as server capabilities.
-  switch (authMethodPrefValue)
-  {
+  switch (authMethodPrefValue) {
     case nsMsgAuthMethod::none:
       m_prefAuthMethods = SMTP_AUTH_NONE_ENABLED;
       break;
-    //case nsMsgAuthMethod::old -- no such thing for SMTP
+    // case nsMsgAuthMethod::old -- no such thing for SMTP
     case nsMsgAuthMethod::passwordCleartext:
-      m_prefAuthMethods = SMTP_AUTH_LOGIN_ENABLED |
-        SMTP_AUTH_PLAIN_ENABLED;
+      m_prefAuthMethods = SMTP_AUTH_LOGIN_ENABLED | SMTP_AUTH_PLAIN_ENABLED;
       break;
     case nsMsgAuthMethod::passwordEncrypted:
       m_prefAuthMethods = SMTP_AUTH_CRAM_MD5_ENABLED;
       break;
     case nsMsgAuthMethod::NTLM:
-      m_prefAuthMethods = SMTP_AUTH_NTLM_ENABLED |
-          SMTP_AUTH_MSN_ENABLED;
+      m_prefAuthMethods = SMTP_AUTH_NTLM_ENABLED | SMTP_AUTH_MSN_ENABLED;
       break;
     case nsMsgAuthMethod::GSSAPI:
       m_prefAuthMethods = SMTP_AUTH_GSSAPI_ENABLED;
       break;
     case nsMsgAuthMethod::OAuth2:
       m_prefAuthMethods = SMTP_AUTH_OAUTH2_ENABLED;
       break;
     case nsMsgAuthMethod::secure:
-      m_prefAuthMethods = SMTP_AUTH_CRAM_MD5_ENABLED |
-          SMTP_AUTH_GSSAPI_ENABLED |
+      m_prefAuthMethods =
+          SMTP_AUTH_CRAM_MD5_ENABLED | SMTP_AUTH_GSSAPI_ENABLED |
           SMTP_AUTH_NTLM_ENABLED | SMTP_AUTH_MSN_ENABLED |
-          SMTP_AUTH_EXTERNAL_ENABLED; // TODO: Expose EXTERNAL? How?
+          SMTP_AUTH_EXTERNAL_ENABLED;  // TODO: Expose EXTERNAL? How?
       break;
     default:
       NS_ASSERTION(false, "SMTP: authMethod pref invalid");
       // TODO log to error console
       MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
-          ("SMTP: bad pref authMethod = %d\n", authMethodPrefValue));
+              ("SMTP: bad pref authMethod = %d\n", authMethodPrefValue));
       // fall to any
       MOZ_FALLTHROUGH;
     case nsMsgAuthMethod::anything:
-      m_prefAuthMethods =
-          SMTP_AUTH_LOGIN_ENABLED | SMTP_AUTH_PLAIN_ENABLED |
-          SMTP_AUTH_CRAM_MD5_ENABLED | SMTP_AUTH_GSSAPI_ENABLED |
-          SMTP_AUTH_NTLM_ENABLED | SMTP_AUTH_MSN_ENABLED |
-          SMTP_AUTH_OAUTH2_ENABLED |
-          SMTP_AUTH_EXTERNAL_ENABLED;
+      m_prefAuthMethods = SMTP_AUTH_LOGIN_ENABLED | SMTP_AUTH_PLAIN_ENABLED |
+                          SMTP_AUTH_CRAM_MD5_ENABLED |
+                          SMTP_AUTH_GSSAPI_ENABLED | SMTP_AUTH_NTLM_ENABLED |
+                          SMTP_AUTH_MSN_ENABLED | SMTP_AUTH_OAUTH2_ENABLED |
+                          SMTP_AUTH_EXTERNAL_ENABLED;
       break;
   }
 
   // Only enable OAuth2 support if we can do the lookup.
   if ((m_prefAuthMethods & SMTP_AUTH_OAUTH2_ENABLED) && !mOAuth2Support)
     m_prefAuthMethods &= ~SMTP_AUTH_OAUTH2_ENABLED;
 
   NS_ASSERTION(m_prefAuthMethods != 0, "SMTP:InitPrefAuthMethods() failed");
 }
 
 /**
  * Changes m_currentAuthMethod to pick the next-best one
  * which is allowed by server and prefs and not marked failed.
  * The order of preference and trying of auth methods is encoded here.
  */
-nsresult nsSmtpProtocol::ChooseAuthMethod()
-{
-  int32_t serverCaps = m_flags; // from nsMsgProtocol::TestFlag()
+nsresult nsSmtpProtocol::ChooseAuthMethod() {
+  int32_t serverCaps = m_flags;  // from nsMsgProtocol::TestFlag()
   int32_t availCaps = serverCaps & m_prefAuthMethods & ~m_failedAuthMethods;
 
+  // clang-format off
   MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
-        ("SMTP auth: server caps 0x%X, pref 0x%X, failed 0x%X, avail caps 0x%X",
-        serverCaps, m_prefAuthMethods, m_failedAuthMethods, availCaps));
-  MOZ_LOG(SMTPLogModule, mozilla::LogLevel:: Debug,
-        ("(GSSAPI = 0x%X, CRAM = 0x%X, NTLM = 0x%X, "
-        "MSN =  0x%X, PLAIN = 0x%X, LOGIN = 0x%X, EXTERNAL = 0x%X)",
-        SMTP_AUTH_GSSAPI_ENABLED, SMTP_AUTH_CRAM_MD5_ENABLED,
-        SMTP_AUTH_NTLM_ENABLED, SMTP_AUTH_MSN_ENABLED, SMTP_AUTH_PLAIN_ENABLED,
-        SMTP_AUTH_LOGIN_ENABLED, SMTP_AUTH_EXTERNAL_ENABLED));
+          ("SMTP auth: server caps 0x%X, pref 0x%X, failed 0x%X, avail caps 0x%X",
+           serverCaps, m_prefAuthMethods, m_failedAuthMethods, availCaps));
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("(GSSAPI = 0x%X, CRAM = 0x%X, NTLM = 0x%X, "
+           "MSN =  0x%X, PLAIN = 0x%X, LOGIN = 0x%X, EXTERNAL = 0x%X)",
+           SMTP_AUTH_GSSAPI_ENABLED, SMTP_AUTH_CRAM_MD5_ENABLED,
+           SMTP_AUTH_NTLM_ENABLED, SMTP_AUTH_MSN_ENABLED, SMTP_AUTH_PLAIN_ENABLED,
+           SMTP_AUTH_LOGIN_ENABLED, SMTP_AUTH_EXTERNAL_ENABLED));
+  // clang-format on
 
   if (SMTP_AUTH_GSSAPI_ENABLED & availCaps)
     m_currentAuthMethod = SMTP_AUTH_GSSAPI_ENABLED;
   else if (SMTP_AUTH_CRAM_MD5_ENABLED & availCaps)
     m_currentAuthMethod = SMTP_AUTH_CRAM_MD5_ENABLED;
   else if (SMTP_AUTH_NTLM_ENABLED & availCaps)
     m_currentAuthMethod = SMTP_AUTH_NTLM_ENABLED;
   else if (SMTP_AUTH_MSN_ENABLED & availCaps)
@@ -1153,227 +1071,198 @@ nsresult nsSmtpProtocol::ChooseAuthMetho
   else if (SMTP_AUTH_OAUTH2_ENABLED & availCaps)
     m_currentAuthMethod = SMTP_AUTH_OAUTH2_ENABLED;
   else if (SMTP_AUTH_PLAIN_ENABLED & availCaps)
     m_currentAuthMethod = SMTP_AUTH_PLAIN_ENABLED;
   else if (SMTP_AUTH_LOGIN_ENABLED & availCaps)
     m_currentAuthMethod = SMTP_AUTH_LOGIN_ENABLED;
   else if (SMTP_AUTH_EXTERNAL_ENABLED & availCaps)
     m_currentAuthMethod = SMTP_AUTH_EXTERNAL_ENABLED;
-  else
-  {
-    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error, ("no auth method remaining"));
+  else {
+    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
+            ("no auth method remaining"));
     m_currentAuthMethod = 0;
     return NS_ERROR_SMTP_AUTH_FAILURE;
   }
-  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("trying auth method 0x%X", m_currentAuthMethod));
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("trying auth method 0x%X", m_currentAuthMethod));
   return NS_OK;
 }
 
-void nsSmtpProtocol::MarkAuthMethodAsFailed(int32_t failedAuthMethod)
-{
+void nsSmtpProtocol::MarkAuthMethodAsFailed(int32_t failedAuthMethod) {
   MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
-      ("marking auth method 0x%X failed", failedAuthMethod));
+          ("marking auth method 0x%X failed", failedAuthMethod));
   m_failedAuthMethods |= failedAuthMethod;
 }
 
 /**
  * Start over, trying all auth methods again
  */
-void nsSmtpProtocol::ResetAuthMethods()
-{
+void nsSmtpProtocol::ResetAuthMethods() {
   m_currentAuthMethod = 0;
   m_failedAuthMethods = 0;
 }
 
-nsresult nsSmtpProtocol::ProcessAuth()
-{
-    nsresult status = NS_OK;
-    nsAutoCString buffer;
+nsresult nsSmtpProtocol::ProcessAuth() {
+  nsresult status = NS_OK;
+  nsAutoCString buffer;
+
+  if (!m_tlsEnabled) {
+    if (TestFlag(SMTP_EHLO_STARTTLS_ENABLED)) {
+      // Do not try to combine SMTPS with STARTTLS.
+      // If nsMsgSocketType::SSL is set,
+      // we are already using a secure connection.
+      // Do not attempt to do STARTTLS,
+      // even if server offers it.
+      if (m_prefSocketType == nsMsgSocketType::trySTARTTLS ||
+          m_prefSocketType == nsMsgSocketType::alwaysSTARTTLS) {
+        buffer = "STARTTLS";
+        buffer += CRLF;
 
-    if (!m_tlsEnabled)
-    {
-        if (TestFlag(SMTP_EHLO_STARTTLS_ENABLED))
-        {
-            // Do not try to combine SMTPS with STARTTLS.
-            // If nsMsgSocketType::SSL is set,
-            // we are already using a secure connection.
-            // Do not attempt to do STARTTLS,
-            // even if server offers it.
-            if (m_prefSocketType == nsMsgSocketType::trySTARTTLS ||
-                m_prefSocketType == nsMsgSocketType::alwaysSTARTTLS)
-            {
-                buffer = "STARTTLS";
-                buffer += CRLF;
+        status = SendData(buffer.get());
+
+        m_tlsInitiated = true;
 
-                status = SendData(buffer.get());
-
-                m_tlsInitiated = true;
-
-                m_nextState = SMTP_RESPONSE;
-                m_nextStateAfterResponse = SMTP_TLS_RESPONSE;
-                SetFlag(SMTP_PAUSE_FOR_READ);
-                return status;
-            }
-        }
-        else if (m_prefSocketType == nsMsgSocketType::alwaysSTARTTLS)
-        {
-            m_nextState = SMTP_ERROR_DONE;
-            m_urlErrorState = NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS;
-            return NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS;
-        }
+        m_nextState = SMTP_RESPONSE;
+        m_nextStateAfterResponse = SMTP_TLS_RESPONSE;
+        SetFlag(SMTP_PAUSE_FOR_READ);
+        return status;
+      }
+    } else if (m_prefSocketType == nsMsgSocketType::alwaysSTARTTLS) {
+      m_nextState = SMTP_ERROR_DONE;
+      m_urlErrorState = NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS;
+      return NS_ERROR_STARTTLS_FAILED_EHLO_STARTTLS;
     }
+  }
   // (wrong indentation until here)
 
-  if (!m_clientIDInitialized && m_tlsEnabled && !m_clientId.IsEmpty())
-  {
-    if (TestFlag(SMTP_EHLO_CLIENTID_ENABLED))
-    {
+  if (!m_clientIDInitialized && m_tlsEnabled && !m_clientId.IsEmpty()) {
+    if (TestFlag(SMTP_EHLO_CLIENTID_ENABLED)) {
       buffer = "CLIENTID TB-UUID ";
       buffer += m_clientId;
       buffer += CRLF;
 
       status = SendData(buffer.get());
 
       m_nextState = SMTP_RESPONSE;
       m_nextStateAfterResponse = SMTP_CLIENTID_RESPONSE;
       SetFlag(SMTP_PAUSE_FOR_READ);
       return status;
     }
   }
 
-  (void) ChooseAuthMethod(); // advance m_currentAuthMethod
+  (void)ChooseAuthMethod();  // advance m_currentAuthMethod
 
-   // We don't need to auth, per pref, or the server doesn't advertise AUTH,
+  // We don't need to auth, per pref, or the server doesn't advertise AUTH,
   // so skip auth and try to send message.
-  if (m_prefAuthMethods == SMTP_AUTH_NONE_ENABLED || !TestFlag(SMTP_AUTH))
-  {
+  if (m_prefAuthMethods == SMTP_AUTH_NONE_ENABLED || !TestFlag(SMTP_AUTH)) {
     m_nextState = SMTP_SEND_HELO_RESPONSE;
     // fake to 250 because SendHeloResponse() tests for this
     m_responseCode = 250;
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_EXTERNAL_ENABLED)
-  {
+  } else if (m_currentAuthMethod == SMTP_AUTH_EXTERNAL_ENABLED) {
     buffer = "AUTH EXTERNAL =";
     buffer += CRLF;
     SendData(buffer.get());
     m_nextState = SMTP_RESPONSE;
     m_nextStateAfterResponse = SMTP_AUTH_EXTERNAL_RESPONSE;
     SetFlag(SMTP_PAUSE_FOR_READ);
     return NS_OK;
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_GSSAPI_ENABLED)
-  {
+  } else if (m_currentAuthMethod == SMTP_AUTH_GSSAPI_ENABLED) {
     m_nextState = SMTP_SEND_AUTH_GSSAPI_FIRST;
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_CRAM_MD5_ENABLED ||
-           m_currentAuthMethod == SMTP_AUTH_PLAIN_ENABLED ||
-           m_currentAuthMethod == SMTP_AUTH_NTLM_ENABLED)
-  {
+  } else if (m_currentAuthMethod == SMTP_AUTH_CRAM_MD5_ENABLED ||
+             m_currentAuthMethod == SMTP_AUTH_PLAIN_ENABLED ||
+             m_currentAuthMethod == SMTP_AUTH_NTLM_ENABLED) {
     m_nextState = SMTP_SEND_AUTH_LOGIN_STEP1;
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED ||
-           m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED)
-  {
+  } else if (m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED ||
+             m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED) {
     m_nextState = SMTP_SEND_AUTH_LOGIN_STEP0;
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_OAUTH2_ENABLED)
-  {
+  } else if (m_currentAuthMethod == SMTP_AUTH_OAUTH2_ENABLED) {
     m_nextState = SMTP_AUTH_OAUTH2_STEP;
-  }
-  else // All auth methods failed
+  } else  // All auth methods failed
   {
     // show an appropriate error msg
-    if (m_failedAuthMethods == 0)
-    {
+    if (m_failedAuthMethods == 0) {
       // we didn't even try anything, so we had a non-working config:
       // pref doesn't match server
       MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
-          ("no working auth mech - pref doesn't match server capas"));
+              ("no working auth mech - pref doesn't match server capas"));
 
       // pref has encrypted pw & server claims to support plaintext pw
       if (m_prefAuthMethods == SMTP_AUTH_CRAM_MD5_ENABLED &&
-          m_flags & (SMTP_AUTH_LOGIN_ENABLED | SMTP_AUTH_PLAIN_ENABLED))
-      {
+          m_flags & (SMTP_AUTH_LOGIN_ENABLED | SMTP_AUTH_PLAIN_ENABLED)) {
         // have SSL
         if (m_prefSocketType == nsMsgSocketType::SSL ||
             m_prefSocketType == nsMsgSocketType::alwaysSTARTTLS)
           // tell user to change to plaintext pw
           m_urlErrorState = NS_ERROR_SMTP_AUTH_CHANGE_ENCRYPT_TO_PLAIN_SSL;
         else
           // tell user to change to plaintext pw, with big warning
           m_urlErrorState = NS_ERROR_SMTP_AUTH_CHANGE_ENCRYPT_TO_PLAIN_NO_SSL;
       }
       // pref has plaintext pw & server claims to support encrypted pw
-      else if (m_prefAuthMethods == (SMTP_AUTH_LOGIN_ENABLED |
-                   SMTP_AUTH_PLAIN_ENABLED) &&
+      else if (m_prefAuthMethods ==
+                   (SMTP_AUTH_LOGIN_ENABLED | SMTP_AUTH_PLAIN_ENABLED) &&
                m_flags & SMTP_AUTH_CRAM_MD5_ENABLED)
         // tell user to change to encrypted pw
         m_urlErrorState = NS_ERROR_SMTP_AUTH_CHANGE_PLAIN_TO_ENCRYPT;
-      else
-      {
+      else {
         // just "change auth method"
         m_urlErrorState = NS_ERROR_SMTP_AUTH_MECH_NOT_SUPPORTED;
       }
-    }
-    else if (m_failedAuthMethods == SMTP_AUTH_GSSAPI_ENABLED)
-    {
+    } else if (m_failedAuthMethods == SMTP_AUTH_GSSAPI_ENABLED) {
       // We have only GSSAPI, and it failed, so nothing left to do.
-      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error, ("GSSAPI only and it failed"));
+      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
+              ("GSSAPI only and it failed"));
       m_urlErrorState = NS_ERROR_SMTP_AUTH_GSSAPI;
-    }
-    else
-    {
+    } else {
       // we tried to login, but it all failed
-      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error, ("All auth attempts failed"));
+      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
+              ("All auth attempts failed"));
       m_urlErrorState = NS_ERROR_SMTP_AUTH_FAILURE;
     }
     m_nextState = SMTP_ERROR_DONE;
     return NS_ERROR_SMTP_AUTH_FAILURE;
   }
 
   return NS_OK;
 }
 
-
-
-nsresult nsSmtpProtocol::AuthLoginResponse(nsIInputStream * stream, uint32_t length)
-{
-  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("SMTP Login response, code %d", m_responseCode));
+nsresult nsSmtpProtocol::AuthLoginResponse(nsIInputStream *stream,
+                                           uint32_t length) {
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("SMTP Login response, code %d", m_responseCode));
   nsresult status = NS_OK;
 
-  switch (m_responseCode/100)
-  {
+  switch (m_responseCode / 100) {
     case 2:
       m_nextState = SMTP_SEND_HELO_RESPONSE;
       // fake to 250 because SendHeloResponse() tests for this
       m_responseCode = 250;
       break;
     case 3:
       m_nextState = SMTP_SEND_AUTH_LOGIN_STEP2;
       break;
     case 5:
     default:
       nsCOMPtr<nsISmtpServer> smtpServer;
       m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
-      if (smtpServer)
-      {
+      if (smtpServer) {
         // If one authentication failed, mark it failed, so that we're going to
         // fall back on a less secure login method.
         MarkAuthMethodAsFailed(m_currentAuthMethod);
 
         bool allFailed = NS_FAILED(ChooseAuthMethod());
         if (allFailed && m_failedAuthMethods > 0 &&
             m_failedAuthMethods != SMTP_AUTH_GSSAPI_ENABLED &&
-            m_failedAuthMethods != SMTP_AUTH_EXTERNAL_ENABLED)
-        {
-          // We've tried all avail. methods, and they all failed, and we have no mechanism left.
-          // Ask user to try with a new password.
+            m_failedAuthMethods != SMTP_AUTH_EXTERNAL_ENABLED) {
+          // We've tried all avail. methods, and they all failed, and we have no
+          // mechanism left. Ask user to try with a new password.
           MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Warning,
-              ("SMTP: ask user what to do (after login failed): new password, retry or cancel"));
+                  ("SMTP: ask user what to do (after login failed): new "
+                   "password, retry or cancel"));
 
           nsCOMPtr<nsISmtpServer> smtpServer;
           nsresult rv = m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
           NS_ENSURE_SUCCESS(rv, rv);
 
           nsCString hostname;
           rv = smtpServer->GetHostname(hostname);
           NS_ENSURE_SUCCESS(rv, rv);
@@ -1383,219 +1272,213 @@ nsresult nsSmtpProtocol::AuthLoginRespon
           NS_ENSURE_SUCCESS(rv, rv);
 
           nsCString accountname;
           rv = smtpServer->GetDescription(accountname);
           NS_ENSURE_SUCCESS(rv, rv);
           NS_ConvertUTF8toUTF16 accountNameUTF16(accountname);
 
           int32_t buttonPressed = 1;
-          if (NS_SUCCEEDED(MsgPromptLoginFailed(nullptr, hostname, username, accountNameUTF16,
-                                                &buttonPressed)))
-          {
-            if (buttonPressed == 1) // Cancel button
+          if (NS_SUCCEEDED(MsgPromptLoginFailed(nullptr, hostname, username,
+                                                accountNameUTF16,
+                                                &buttonPressed))) {
+            if (buttonPressed == 1)  // Cancel button
             {
-              MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Warning, ("cancel button pressed"));
+              MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Warning,
+                      ("cancel button pressed"));
               // abort and get out of here
               status = NS_ERROR_ABORT;
               break;
-            }
-            else if (buttonPressed == 2) // 'New password' button
+            } else if (buttonPressed == 2)  // 'New password' button
             {
-              MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Warning, ("new password button pressed"));
+              MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Warning,
+                      ("new password button pressed"));
               // Change password was pressed. For now, forget the stored
               // password and we'll prompt for a new one next time around.
               smtpServer->ForgetPassword();
-              if (m_usernamePrompted)
-                smtpServer->SetUsername(EmptyCString());
+              if (m_usernamePrompted) smtpServer->SetUsername(EmptyCString());
 
               // Let's restore the original auth flags from SendEhloResponse
               // so we can try them again with new password and username
               ResetAuthMethods();
-              // except for GSSAPI and EXTERNAL, which don't care about passwords.
+              // except for GSSAPI and EXTERNAL, which don't care about
+              // passwords.
               MarkAuthMethodAsFailed(SMTP_AUTH_GSSAPI_ENABLED);
               MarkAuthMethodAsFailed(SMTP_AUTH_EXTERNAL_ENABLED);
-            }
-            else if (buttonPressed == 0) // Retry button
+            } else if (buttonPressed == 0)  // Retry button
             {
-              MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Warning, ("retry button pressed"));
+              MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Warning,
+                      ("retry button pressed"));
               // try all again, including GSSAPI
               ResetAuthMethods();
             }
           }
         }
         MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
-            ("SMTP: login failed: failed %X, current %X", m_failedAuthMethods, m_currentAuthMethod));
+                ("SMTP: login failed: failed %X, current %X",
+                 m_failedAuthMethods, m_currentAuthMethod));
 
-        m_nextState = SMTP_AUTH_PROCESS_STATE; // try auth (ProcessAuth()) again, with other method
-      }
-      else
-          status = NS_ERROR_SMTP_PASSWORD_UNDEFINED;
+        m_nextState = SMTP_AUTH_PROCESS_STATE;  // try auth (ProcessAuth())
+                                                // again, with other method
+      } else
+        status = NS_ERROR_SMTP_PASSWORD_UNDEFINED;
       break;
   }
 
   return (status);
 }
 
-nsresult nsSmtpProtocol::AuthGSSAPIFirst()
-{
-  NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_GSSAPI_ENABLED, "called in invalid state");
+nsresult nsSmtpProtocol::AuthGSSAPIFirst() {
+  NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_GSSAPI_ENABLED,
+               "called in invalid state");
   nsAutoCString command("AUTH GSSAPI ");
   nsAutoCString resp;
   nsAutoCString service("smtp@");
   nsCString hostName;
   nsCString userName;
   nsresult rv;
   nsCOMPtr<nsISmtpServer> smtpServer;
   rv = m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
-  if (NS_FAILED(rv))
-    return NS_ERROR_FAILURE;
+  if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   rv = smtpServer->GetUsername(userName);
-  if (NS_FAILED(rv))
-    return NS_ERROR_FAILURE;
+  if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   rv = smtpServer->GetHostname(hostName);
-  if (NS_FAILED(rv))
-    return NS_ERROR_FAILURE;
+  if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
   service.Append(hostName);
-  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("SMTP: GSSAPI step 1 for user %s at server %s, service %s",
-      userName.get(), hostName.get(), service.get()));
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("SMTP: GSSAPI step 1 for user %s at server %s, service %s",
+           userName.get(), hostName.get(), service.get()));
 
   rv = DoGSSAPIStep1(service.get(), userName.get(), resp);
-  if (NS_FAILED(rv))
-  {
-    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error, ("SMTP: GSSAPI step 1 failed early"));
+  if (NS_FAILED(rv)) {
+    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
+            ("SMTP: GSSAPI step 1 failed early"));
     MarkAuthMethodAsFailed(SMTP_AUTH_GSSAPI_ENABLED);
     m_nextState = SMTP_AUTH_PROCESS_STATE;
     return NS_OK;
-  }
-  else
+  } else
     command.Append(resp);
   command.Append(CRLF);
   m_nextState = SMTP_RESPONSE;
   m_nextStateAfterResponse = SMTP_SEND_AUTH_GSSAPI_STEP;
   SetFlag(SMTP_PAUSE_FOR_READ);
   return SendData(command.get());
 }
 
 // GSSAPI may consist of multiple round trips
 
-nsresult nsSmtpProtocol::AuthGSSAPIStep()
-{
-  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("SMTP: GSSAPI auth step 2"));
-  NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_GSSAPI_ENABLED, "called in invalid state");
+nsresult nsSmtpProtocol::AuthGSSAPIStep() {
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("SMTP: GSSAPI auth step 2"));
+  NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_GSSAPI_ENABLED,
+               "called in invalid state");
   nsresult rv;
   nsAutoCString cmd;
 
   // Check to see what the server said
   if (m_responseCode / 100 != 3) {
     m_nextState = SMTP_AUTH_LOGIN_RESPONSE;
     return NS_OK;
   }
 
   rv = DoGSSAPIStep2(m_responseText, cmd);
-  if (NS_FAILED(rv))
-    cmd = "*";
+  if (NS_FAILED(rv)) cmd = "*";
   cmd += CRLF;
 
-  m_nextStateAfterResponse = (rv == NS_SUCCESS_AUTH_FINISHED)?SMTP_AUTH_LOGIN_RESPONSE:SMTP_SEND_AUTH_GSSAPI_STEP;
+  m_nextStateAfterResponse = (rv == NS_SUCCESS_AUTH_FINISHED)
+                                 ? SMTP_AUTH_LOGIN_RESPONSE
+                                 : SMTP_SEND_AUTH_GSSAPI_STEP;
   m_nextState = SMTP_RESPONSE;
   SetFlag(SMTP_PAUSE_FOR_READ);
 
   return SendData(cmd.get());
 }
 
-
 // LOGIN and MSN consist of three steps (MSN not through the mechanism
 // but by non-RFC2821 compliant implementation in MS servers) not two as
 // PLAIN or CRAM-MD5, so we've to start here and continue with AuthStep1
 // if the server responds with with a 3xx code to "AUTH LOGIN" or "AUTH MSN"
-nsresult nsSmtpProtocol::AuthLoginStep0()
-{
-    NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED ||
-        m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED,
-        "called in invalid state");
-    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("SMTP: MSN or LOGIN auth, step 0"));
-    nsAutoCString command(m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED
-        ? "AUTH MSN" CRLF : "AUTH LOGIN" CRLF);
-    m_nextState = SMTP_RESPONSE;
-    m_nextStateAfterResponse = SMTP_AUTH_LOGIN_STEP0_RESPONSE;
-    SetFlag(SMTP_PAUSE_FOR_READ);
+nsresult nsSmtpProtocol::AuthLoginStep0() {
+  NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED ||
+                   m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED,
+               "called in invalid state");
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("SMTP: MSN or LOGIN auth, step 0"));
+  nsAutoCString command(m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED
+                            ? "AUTH MSN" CRLF
+                            : "AUTH LOGIN" CRLF);
+  m_nextState = SMTP_RESPONSE;
+  m_nextStateAfterResponse = SMTP_AUTH_LOGIN_STEP0_RESPONSE;
+  SetFlag(SMTP_PAUSE_FOR_READ);
 
-    return SendData(command.get());
+  return SendData(command.get());
 }
 
-void nsSmtpProtocol::AuthLoginStep0Response()
-{
-    NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED ||
-        m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED,
-        "called in invalid state");
-    // need the test to be here instead in AuthLoginResponse() to
-    // continue with step 1 instead of 2 in case of a code 3xx
-    m_nextState = (m_responseCode/100 == 3) ?
-                  SMTP_SEND_AUTH_LOGIN_STEP1 : SMTP_AUTH_LOGIN_RESPONSE;
+void nsSmtpProtocol::AuthLoginStep0Response() {
+  NS_ASSERTION(m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED ||
+                   m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED,
+               "called in invalid state");
+  // need the test to be here instead in AuthLoginResponse() to
+  // continue with step 1 instead of 2 in case of a code 3xx
+  m_nextState = (m_responseCode / 100 == 3) ? SMTP_SEND_AUTH_LOGIN_STEP1
+                                            : SMTP_AUTH_LOGIN_RESPONSE;
 }
 
-nsresult nsSmtpProtocol::AuthLoginStep1()
-{
+nsresult nsSmtpProtocol::AuthLoginStep1() {
   // The longest message we are going to send is:
   // "AUTH PLAIN " followed by 684 bytes (base64 encoding of 512 bytes of
   // username/password) followed by CRLF: 11 + 684 + 2 + 1 = 698.
   char buffer[698];
   nsresult rv;
   nsresult status = NS_OK;
   nsCString username;
   char *base64Str = nullptr;
   nsAutoString password;
   nsCOMPtr<nsISmtpServer> smtpServer;
   rv = m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   rv = smtpServer->GetUsername(username);
-  if (username.IsEmpty())
-  {
+  if (username.IsEmpty()) {
     rv = GetUsernamePassword(username, password);
     m_usernamePrompted = true;
     if (username.IsEmpty() || password.IsEmpty())
       return NS_ERROR_SMTP_PASSWORD_UNDEFINED;
   }
 
   nsCString hostname;
   smtpServer->GetHostname(hostname);
 
-  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("SMTP AuthLoginStep1() for %s@%s",
-          username.get(), hostname.get()));
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("SMTP AuthLoginStep1() for %s@%s", username.get(), hostname.get()));
 
   GetPassword(password);
-  if (password.IsEmpty())
-  {
-    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error, ("SMTP: password undefined"));
+  if (password.IsEmpty()) {
+    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error,
+            ("SMTP: password undefined"));
     m_urlErrorState = NS_ERROR_SMTP_PASSWORD_UNDEFINED;
     return NS_ERROR_SMTP_PASSWORD_UNDEFINED;
   }
   NS_ConvertUTF16toUTF8 passwordUTF8(password);
 
-  if (m_currentAuthMethod == SMTP_AUTH_CRAM_MD5_ENABLED)
-  {
+  if (m_currentAuthMethod == SMTP_AUTH_CRAM_MD5_ENABLED) {
     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Error, ("CRAM auth, step 1"));
     PR_snprintf(buffer, sizeof(buffer), "AUTH CRAM-MD5" CRLF);
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_NTLM_ENABLED ||
-           m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED)
-  {
+  } else if (m_currentAuthMethod == SMTP_AUTH_NTLM_ENABLED ||
+             m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED) {
     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("NTLM/MSN auth, step 1"));
     nsAutoCString response;
     rv = DoNtlmStep1(username, password, response);
-    PR_snprintf(buffer, sizeof(buffer), TestFlag(SMTP_AUTH_NTLM_ENABLED) ?
-                                        "AUTH NTLM %.512s" CRLF :
-                                        "%.512s" CRLF, response.get());
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_PLAIN_ENABLED)
-  {
+    PR_snprintf(buffer, sizeof(buffer),
+                TestFlag(SMTP_AUTH_NTLM_ENABLED) ? "AUTH NTLM %.512s" CRLF
+                                                 : "%.512s" CRLF,
+                response.get());
+  } else if (m_currentAuthMethod == SMTP_AUTH_PLAIN_ENABLED) {
     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("PLAIN auth"));
     // Up to 255 octets.
     if (username.Length() > 255)  // RFC 4616: authcid; up to 255 octets
       username.Truncate(255);
     if (passwordUTF8.Length() > 255)  // RFC 4616: passwd; up to 255 octets
       passwordUTF8.Truncate(255);
 
     // RFC 4616: UTF8NUL authcid UTF8NUL passwd
@@ -1603,397 +1486,364 @@ nsresult nsSmtpProtocol::AuthLoginStep1(
     memset(plain_string, 0, 513);
     PR_snprintf(&plain_string[1], 256, "%s", username.get());
     int len = username.Length() + 2;  // We include two <NUL> characters.
     PR_snprintf(&plain_string[len], 256, "%s", passwordUTF8.get());
     len += passwordUTF8.Length();
 
     base64Str = PL_Base64Encode(plain_string, len, nullptr);
     PR_snprintf(buffer, sizeof(buffer), "AUTH PLAIN %s" CRLF, base64Str);
-  }
-  else if (m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED)
-  {
+  } else if (m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED) {
     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("LOGIN auth"));
-    if (username.Length() > 255)
-      username.Truncate(255);
+    if (username.Length() > 255) username.Truncate(255);
     base64Str = PL_Base64Encode(username.get(), username.Length(), nullptr);
     // Base64 encoding of 255 bytes gives 340 bytes.
     PR_snprintf(buffer, sizeof(buffer), "%s" CRLF, base64Str);
-  }
-  else
+  } else
     return (NS_ERROR_COMMUNICATIONS_ERROR);
 
   status = SendData(buffer, true);
   m_nextState = SMTP_RESPONSE;
   m_nextStateAfterResponse = SMTP_AUTH_LOGIN_RESPONSE;
   SetFlag(SMTP_PAUSE_FOR_READ);
   free(base64Str);
 
   return (status);
 }
 
-nsresult nsSmtpProtocol::AuthLoginStep2()
-{
+nsresult nsSmtpProtocol::AuthLoginStep2() {
   /* use cached smtp password first
-  * if not then use cached pop password
-  * if pop password undefined
-  * sync with smtp password
-  */
+   * if not then use cached pop password
+   * if pop password undefined
+   * sync with smtp password
+   */
   nsresult status = NS_OK;
   nsresult rv;
   nsAutoString password;
 
   GetPassword(password);
-  if (password.IsEmpty())
-  {
+  if (password.IsEmpty()) {
     m_urlErrorState = NS_ERROR_SMTP_PASSWORD_UNDEFINED;
     return NS_ERROR_SMTP_PASSWORD_UNDEFINED;
   }
   nsAutoCString passwordUTF8 = NS_ConvertUTF16toUTF8(password);
   MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("SMTP AuthLoginStep2"));
 
-  if (!passwordUTF8.IsEmpty())
-  {
-    // We use 515 characters here so we can transmit a 512 byte response followed by CRLF.
-    // User name and encoded digest, currently 255 + 1 + 2*16 bytes, will need
-    // 4 * (255 + 1 + 32) / 3 = 384 bytes when base64 encoded.
+  if (!passwordUTF8.IsEmpty()) {
+    // We use 515 characters here so we can transmit a 512 byte response
+    // followed by CRLF. User name and encoded digest, currently 255 + 1 + 2*16
+    // bytes, will need 4 * (255 + 1 + 32) / 3 = 384 bytes when base64 encoded.
     char buffer[515];
-    if (m_currentAuthMethod == SMTP_AUTH_CRAM_MD5_ENABLED)
-    {
+    if (m_currentAuthMethod == SMTP_AUTH_CRAM_MD5_ENABLED) {
       MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("CRAM auth, step 2"));
       unsigned char digest[DIGEST_LENGTH];
-      char * decodedChallenge = PL_Base64Decode(m_responseText.get(),
-        m_responseText.Length(), nullptr);
+      char *decodedChallenge = PL_Base64Decode(
+          m_responseText.get(), m_responseText.Length(), nullptr);
 
       if (decodedChallenge)
         rv = MSGCramMD5(decodedChallenge, strlen(decodedChallenge),
                         passwordUTF8.get(), passwordUTF8.Length(), digest);
       else
         rv = NS_ERROR_FAILURE;
 
       PR_Free(decodedChallenge);
-      if (NS_SUCCEEDED(rv))
-      {
+      if (NS_SUCCEEDED(rv)) {
         // The encoded digest is the hexadecimal representation of
         // DIGEST_LENGTH characters, so it will be twice that length.
         nsAutoCStringN<2 * DIGEST_LENGTH> encodedDigest;
 
-        for (uint32_t j = 0; j < DIGEST_LENGTH; j++)
-        {
+        for (uint32_t j = 0; j < DIGEST_LENGTH; j++) {
           char hexVal[3];
-          PR_snprintf (hexVal, 3, "%.2x", 0x0ff & (unsigned short)digest[j]);
+          PR_snprintf(hexVal, 3, "%.2x", 0x0ff & (unsigned short)digest[j]);
           encodedDigest.Append(hexVal);
         }
 
         nsCOMPtr<nsISmtpServer> smtpServer;
         rv = m_runningURL->GetSmtpServer(getter_AddRefs(smtpServer));
         if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
         nsCString userName;
         rv = smtpServer->GetUsername(userName);
 
-        if (userName.Length() > 255)
-          userName.Truncate(255);
-        PR_snprintf(buffer, sizeof(buffer), "%s %s", userName.get(), encodedDigest.get());
+        if (userName.Length() > 255) userName.Truncate(255);
+        PR_snprintf(buffer, sizeof(buffer), "%s %s", userName.get(),
+                    encodedDigest.get());
         char *base64Str = PL_Base64Encode(buffer, strlen(buffer), nullptr);
         PR_snprintf(buffer, sizeof(buffer), "%s" CRLF, base64Str);
         free(base64Str);
       }
-      if (NS_FAILED(rv))
-        PR_snprintf(buffer, sizeof(buffer), "*" CRLF);
-    }
-    else if (m_currentAuthMethod == SMTP_AUTH_NTLM_ENABLED ||
-             m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED)
-    {
-      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("NTLM/MSN auth, step 2"));
+      if (NS_FAILED(rv)) PR_snprintf(buffer, sizeof(buffer), "*" CRLF);
+    } else if (m_currentAuthMethod == SMTP_AUTH_NTLM_ENABLED ||
+               m_currentAuthMethod == SMTP_AUTH_MSN_ENABLED) {
+      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+              ("NTLM/MSN auth, step 2"));
       nsAutoCString response;
       rv = DoNtlmStep2(m_responseText, response);
       PR_snprintf(buffer, sizeof(buffer), "%.512s" CRLF, response.get());
-    }
-    else if (m_currentAuthMethod == SMTP_AUTH_PLAIN_ENABLED)
-    {
+    } else if (m_currentAuthMethod == SMTP_AUTH_PLAIN_ENABLED) {
       MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("PLAIN auth, step 2"));
-      if (passwordUTF8.Length() > 255)
-        passwordUTF8.Truncate(255);
-      char *base64Str = PL_Base64Encode(passwordUTF8.get(), passwordUTF8.Length(), nullptr);
+      if (passwordUTF8.Length() > 255) passwordUTF8.Truncate(255);
+      char *base64Str =
+          PL_Base64Encode(passwordUTF8.get(), passwordUTF8.Length(), nullptr);
       // Base64 encoding of 255 bytes gives 340 bytes.
       PR_snprintf(buffer, sizeof(buffer), "%s" CRLF, base64Str);
       free(base64Str);
-    }
-    else if (m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED)
-    {
+    } else if (m_currentAuthMethod == SMTP_AUTH_LOGIN_ENABLED) {
       MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("LOGIN auth, step 2"));
-      bool useLatin1 =
-        mozilla::Preferences::GetBool("mail.smtp_login_pop3_user_pass_auth_is_latin1", true);
+      bool useLatin1 = mozilla::Preferences::GetBool(
+          "mail.smtp_login_pop3_user_pass_auth_is_latin1", true);
       if (useLatin1)
-        passwordUTF8 = NS_LossyConvertUTF16toASCII(password);  // Don't use UTF-8 after all.
-      if (passwordUTF8.Length() > 255)
-        passwordUTF8.Truncate(255);
-      char *base64Str = PL_Base64Encode(passwordUTF8.get(), passwordUTF8.Length(), nullptr);
+        passwordUTF8 = NS_LossyConvertUTF16toASCII(
+            password);  // Don't use UTF-8 after all.
+      if (passwordUTF8.Length() > 255) passwordUTF8.Truncate(255);
+      char *base64Str =
+          PL_Base64Encode(passwordUTF8.get(), passwordUTF8.Length(), nullptr);
       // Base64 encoding of 255 bytes gives 340 bytes.
       PR_snprintf(buffer, sizeof(buffer), "%s" CRLF, base64Str);
       free(base64Str);
-    }
-    else
+    } else
       return NS_ERROR_COMMUNICATIONS_ERROR;
 
     status = SendData(buffer, true);
     m_nextState = SMTP_RESPONSE;
     m_nextStateAfterResponse = SMTP_AUTH_LOGIN_RESPONSE;
     SetFlag(SMTP_PAUSE_FOR_READ);
     return (status);
   }
 
   // XXX -1 is not a valid nsresult
   return static_cast<nsresult>(-1);
 }
 
-nsresult nsSmtpProtocol::AuthOAuth2Step1()
-{
+nsresult nsSmtpProtocol::AuthOAuth2Step1() {
   MOZ_ASSERT(mOAuth2Support, "Can't do anything without OAuth2 support");
 
   nsresult rv = mOAuth2Support->Connect(true, this);
   NS_ENSURE_SUCCESS(rv, rv);
 
   m_nextState = SMTP_SUSPENDED;
   return NS_OK;
 }
 
-nsresult nsSmtpProtocol::OnSuccess(const nsACString &aOAuth2String)
-{
+nsresult nsSmtpProtocol::OnSuccess(const nsACString &aOAuth2String) {
   MOZ_ASSERT(mOAuth2Support, "Can't do anything without OAuth2 support");
 
   // Send the AUTH XOAUTH2 command, and then siphon us back to the regular
   // authentication login stream.
   nsAutoCString buffer;
   buffer.AppendLiteral("AUTH XOAUTH2 ");
   buffer += aOAuth2String;
   buffer += CRLF;
   nsresult rv = SendData(buffer.get(), true);
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     m_nextState = SMTP_ERROR_DONE;
-  }
-  else
-  {
+  } else {
     m_nextState = SMTP_RESPONSE;
     m_nextStateAfterResponse = SMTP_AUTH_LOGIN_RESPONSE;
   }
 
   SetFlag(SMTP_PAUSE_FOR_READ);
 
   ProcessProtocolState(nullptr, nullptr, 0, 0);
   return NS_OK;
 }
 
-nsresult nsSmtpProtocol::OnFailure(nsresult aError)
-{
-  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug, ("OAuth2 login error %08x",
-    (uint32_t)aError));
+nsresult nsSmtpProtocol::OnFailure(nsresult aError) {
+  MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Debug,
+          ("OAuth2 login error %08x", (uint32_t)aError));
   m_urlErrorState = aError;
   m_nextState = SMTP_ERROR_DONE;
   return ProcessProtocolState(nullptr, nullptr, 0, 0);
 }
 
-
-nsresult nsSmtpProtocol::SendMailResponse()
-{
+nsresult nsSmtpProtocol::SendMailResponse() {
   nsresult status = NS_OK;
   nsAutoCString buffer;
   nsresult rv;
 
-  if (m_responseCode/10 != 25)
-  {
+  if (m_responseCode / 10 != 25) {
     nsresult errorcode;
     if ((m_responseCodeEnhanced == 570) || (m_responseCodeEnhanced == 571))
       errorcode = NS_ERROR_SMTP_SEND_NOT_ALLOWED;
     else if (TestFlag(SMTP_EHLO_SIZE_ENABLED))
-      errorcode = (m_responseCode == 452) ? NS_ERROR_SMTP_TEMP_SIZE_EXCEEDED :
-                  (m_responseCode == 552) ? NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_2 :
-                  NS_ERROR_SENDING_FROM_COMMAND;
+      errorcode = (m_responseCode == 452)
+                      ? NS_ERROR_SMTP_TEMP_SIZE_EXCEEDED
+                      : (m_responseCode == 552)
+                            ? NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_2
+                            : NS_ERROR_SENDING_FROM_COMMAND;
     else
       errorcode = NS_ERROR_SENDING_FROM_COMMAND;
 
-    rv = nsExplainErrorDetails(m_runningURL, errorcode, m_responseText.get(), nullptr);
+    rv = nsExplainErrorDetails(m_runningURL, errorcode, m_responseText.get(),
+                               nullptr);
     NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
 
     m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
-    return(NS_ERROR_SENDING_FROM_COMMAND);
+    return (NS_ERROR_SENDING_FROM_COMMAND);
   }
 
   /* Send the RCPT TO: command */
   bool requestDSN = false;
   rv = m_runningURL->GetRequestDSN(&requestDSN);
 
-  nsCOMPtr <nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIPrefService> prefs =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrefBranch> prefBranch;
   rv = prefs->GetBranch(nullptr, getter_AddRefs(prefBranch));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   bool requestOnSuccess = false;
-  rv = prefBranch->GetBoolPref("mail.dsn.request_on_success_on", &requestOnSuccess);
+  rv = prefBranch->GetBoolPref("mail.dsn.request_on_success_on",
+                               &requestOnSuccess);
 
   bool requestOnFailure = false;
-  rv = prefBranch->GetBoolPref("mail.dsn.request_on_failure_on", &requestOnFailure);
+  rv = prefBranch->GetBoolPref("mail.dsn.request_on_failure_on",
+                               &requestOnFailure);
 
   bool requestOnDelay = false;
   rv = prefBranch->GetBoolPref("mail.dsn.request_on_delay_on", &requestOnDelay);
 
   bool requestOnNever = false;
   rv = prefBranch->GetBoolPref("mail.dsn.request_never_on", &requestOnNever);
 
   nsCString &address = m_addresses[m_addressesLeft - 1];
-  if (TestFlag(SMTP_EHLO_DSN_ENABLED) && requestDSN && (requestOnSuccess || requestOnFailure || requestOnDelay || requestOnNever))
-    {
-      char *encodedAddress = esmtp_value_encode(address.get());
-      nsAutoCString dsnBuffer;
-
-      if (encodedAddress)
-      {
-        buffer = "RCPT TO:<";
-        buffer += address;
-        buffer += "> NOTIFY=";
-
-        if (requestOnNever)
-          dsnBuffer += "NEVER";
-        else
-        {
-          if (requestOnSuccess)
-            dsnBuffer += "SUCCESS";
+  if (TestFlag(SMTP_EHLO_DSN_ENABLED) && requestDSN &&
+      (requestOnSuccess || requestOnFailure || requestOnDelay ||
+       requestOnNever)) {
+    char *encodedAddress = esmtp_value_encode(address.get());
+    nsAutoCString dsnBuffer;
 
-          if (requestOnFailure)
-            dsnBuffer += dsnBuffer.IsEmpty() ? "FAILURE" : ",FAILURE";
-
-          if (requestOnDelay)
-            dsnBuffer += dsnBuffer.IsEmpty() ? "DELAY" : ",DELAY";
-        }
-
-        buffer += dsnBuffer;
-        buffer += " ORCPT=rfc822;";
-        buffer += encodedAddress;
-        buffer += CRLF;
-        PR_FREEIF(encodedAddress);
-      }
-      else
-      {
-        m_urlErrorState = NS_ERROR_OUT_OF_MEMORY;
-        return (NS_ERROR_OUT_OF_MEMORY);
-      }
-    }
-    else
-    {
+    if (encodedAddress) {
       buffer = "RCPT TO:<";
       buffer += address;
-      buffer += ">";
-      buffer += CRLF;
-    }
-    status = SendData(buffer.get());
+      buffer += "> NOTIFY=";
+
+      if (requestOnNever)
+        dsnBuffer += "NEVER";
+      else {
+        if (requestOnSuccess) dsnBuffer += "SUCCESS";
+
+        if (requestOnFailure)
+          dsnBuffer += dsnBuffer.IsEmpty() ? "FAILURE" : ",FAILURE";
+
+        if (requestOnDelay)
+          dsnBuffer += dsnBuffer.IsEmpty() ? "DELAY" : ",DELAY";
+      }
 
-    m_nextState = SMTP_RESPONSE;
-    m_nextStateAfterResponse = SMTP_SEND_RCPT_RESPONSE;
-    SetFlag(SMTP_PAUSE_FOR_READ);
+      buffer += dsnBuffer;
+      buffer += " ORCPT=rfc822;";
+      buffer += encodedAddress;
+      buffer += CRLF;
+      PR_FREEIF(encodedAddress);
+    } else {
+      m_urlErrorState = NS_ERROR_OUT_OF_MEMORY;
+      return (NS_ERROR_OUT_OF_MEMORY);
+    }
+  } else {
+    buffer = "RCPT TO:<";
+    buffer += address;
+    buffer += ">";
+    buffer += CRLF;
+  }
+  status = SendData(buffer.get());
 
-    return(status);
+  m_nextState = SMTP_RESPONSE;
+  m_nextStateAfterResponse = SMTP_SEND_RCPT_RESPONSE;
+  SetFlag(SMTP_PAUSE_FOR_READ);
+
+  return (status);
 }
 
-nsresult nsSmtpProtocol::SendRecipientResponse()
-{
+nsresult nsSmtpProtocol::SendRecipientResponse() {
   nsresult status = NS_OK;
   nsAutoCString buffer;
   nsresult rv;
 
-  if (m_responseCode / 10 != 25)
-  {
+  if (m_responseCode / 10 != 25) {
     nsresult errorcode;
     if ((m_responseCodeEnhanced == 570) || (m_responseCodeEnhanced == 571))
       errorcode = NS_ERROR_SMTP_SEND_NOT_ALLOWED;
     else if (TestFlag(SMTP_EHLO_SIZE_ENABLED))
-      errorcode = (m_responseCode == 452) ? NS_ERROR_SMTP_TEMP_SIZE_EXCEEDED :
-                  (m_responseCode == 552) ? NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_2 :
-                  NS_ERROR_SENDING_RCPT_COMMAND;
+      errorcode = (m_responseCode == 452)
+                      ? NS_ERROR_SMTP_TEMP_SIZE_EXCEEDED
+                      : (m_responseCode == 552)
+                            ? NS_ERROR_SMTP_PERM_SIZE_EXCEEDED_2
+                            : NS_ERROR_SENDING_RCPT_COMMAND;
     else
       errorcode = NS_ERROR_SENDING_RCPT_COMMAND;
 
-    rv = nsExplainErrorDetails(m_runningURL, errorcode,
-                               m_responseText.get(),
+    rv = nsExplainErrorDetails(m_runningURL, errorcode, m_responseText.get(),
                                m_addresses[m_addressesLeft - 1].get());
 
-    if (!NS_SUCCEEDED(rv))
-      NS_ASSERTION(false, "failed to explain SMTP error");
+    if (!NS_SUCCEEDED(rv)) NS_ASSERTION(false, "failed to explain SMTP error");
 
     m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
-    return(NS_ERROR_SENDING_RCPT_COMMAND);
+    return (NS_ERROR_SENDING_RCPT_COMMAND);
   }
 
-  if (--m_addressesLeft > 0)
-  {
+  if (--m_addressesLeft > 0) {
     // more senders to RCPT to
     // fake to 250 because SendMailResponse() can't handle 251
     m_responseCode = 250;
     m_nextState = SMTP_SEND_MAIL_RESPONSE;
     return NS_OK;
   }
 
   /* else send the DATA command */
   buffer = "DATA";
   buffer += CRLF;
   status = SendData(buffer.get());
 
   m_nextState = SMTP_RESPONSE;
   m_nextStateAfterResponse = SMTP_SEND_DATA_RESPONSE;
   SetFlag(SMTP_PAUSE_FOR_READ);
 
-  return(status);
+  return (status);
 }
 
-
-nsresult nsSmtpProtocol::SendData(const char *dataBuffer, bool aSuppressLogging)
-{
+nsresult nsSmtpProtocol::SendData(const char *dataBuffer,
+                                  bool aSuppressLogging) {
   // XXX -1 is not a valid nsresult
   if (!dataBuffer) return static_cast<nsresult>(-1);
 
   if (!aSuppressLogging) {
-      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info, ("SMTP Send: %s", dataBuffer));
+    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info,
+            ("SMTP Send: %s", dataBuffer));
   } else {
-      MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info, ("Logging suppressed for this command (it probably contained authentication information)"));
+    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info,
+            ("Logging suppressed for this command (it probably contained "
+             "authentication information)"));
   }
   return nsMsgAsyncWriteProtocol::SendData(dataBuffer);
 }
 
-
-nsresult nsSmtpProtocol::SendDataResponse()
-{
+nsresult nsSmtpProtocol::SendDataResponse() {
   nsresult status = NS_OK;
 
-  if (m_responseCode != 354)
-  {
-    mozilla::DebugOnly<nsresult> rv = nsExplainErrorDetails(m_runningURL,
-                                                            NS_ERROR_SENDING_DATA_COMMAND,
-                                                            m_responseText.get(), nullptr);
+  if (m_responseCode != 354) {
+    mozilla::DebugOnly<nsresult> rv =
+        nsExplainErrorDetails(m_runningURL, NS_ERROR_SENDING_DATA_COMMAND,
+                              m_responseText.get(), nullptr);
     NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
 
     m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
-    return(NS_ERROR_SENDING_DATA_COMMAND);
+    return (NS_ERROR_SENDING_DATA_COMMAND);
   }
 
   m_nextState = SMTP_SEND_POST_DATA;
-  ClearFlag(SMTP_PAUSE_FOR_READ);   /* send data directly */
+  ClearFlag(SMTP_PAUSE_FOR_READ); /* send data directly */
 
   UpdateStatus("smtpDeliveringMail");
-
-  {
-//      m_runningURL->GetBodySize(&m_totalMessageSize);
-  }
-  return(status);
+  //  m_runningURL->GetBodySize(&m_totalMessageSize);
+  return (status);
 }
 
-void nsSmtpProtocol::SendMessageInFile()
-{
+void nsSmtpProtocol::SendMessageInFile() {
   nsCOMPtr<nsIFile> file;
   nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningURL);
   m_runningURL->GetPostMessageFile(getter_AddRefs(file));
   if (url && file)
     // need to fully qualify to avoid getting overwritten by a #define
     // in some windows header file
     nsMsgAsyncWriteProtocol::PostMessage(url, file);
 
@@ -2002,173 +1852,161 @@ void nsSmtpProtocol::SendMessageInFile()
   // for now, we are always done at this point..we aren't making multiple calls
   // to post data...
 
   UpdateStatus("smtpDeliveringMail");
   m_nextState = SMTP_RESPONSE;
   m_nextStateAfterResponse = SMTP_SEND_MESSAGE_RESPONSE;
 }
 
-void nsSmtpProtocol::SendPostData()
-{
+void nsSmtpProtocol::SendPostData() {
   // mscott: as a first pass, I'm writing everything at once and am not
   // doing it in chunks...
 
   /* returns 0 on done and negative on error
    * positive if it needs to continue.
    */
 
   // check to see if url is a file..if it is...call our file handler...
   bool postMessageInFile = true;
   m_runningURL->GetPostMessage(&postMessageInFile);
-  if (postMessageInFile)
-  {
+  if (postMessageInFile) {
     SendMessageInFile();
   }
 
   /* Update the thermo and the status bar.  This is done by hand, rather
      than using the FE_GraphProgress* functions, because there seems to be
      no way to make FE_GraphProgress shut up and not display anything more
      when all the data has arrived.  At the end, we want to show the
      "message sent; waiting for reply" status; FE_GraphProgress gets in
      the way of that.  See bug #23414. */
 }
 
-nsresult nsSmtpProtocol::SendMessageResponse()
-{
-  if((m_responseCode/10 != 25))
-  {
-    mozilla::DebugOnly<nsresult> rv = nsExplainErrorDetails(m_runningURL,
-                                                            NS_ERROR_SENDING_MESSAGE,
-                                                            m_responseText.get(), nullptr);
+nsresult nsSmtpProtocol::SendMessageResponse() {
+  if ((m_responseCode / 10 != 25)) {
+    mozilla::DebugOnly<nsresult> rv = nsExplainErrorDetails(
+        m_runningURL, NS_ERROR_SENDING_MESSAGE, m_responseText.get(), nullptr);
     NS_ASSERTION(NS_SUCCEEDED(rv), "failed to explain SMTP error");
 
     m_urlErrorState = NS_ERROR_BUT_DONT_SHOW_ALERT;
-    return(NS_ERROR_SENDING_MESSAGE);
+    return (NS_ERROR_SENDING_MESSAGE);
   }
 
   UpdateStatus("smtpMailSent");
 
   /* else */
   return SendQuit();
 }
 
-nsresult nsSmtpProtocol::SendQuit(SmtpState aNextStateAfterResponse)
-{
+nsresult nsSmtpProtocol::SendQuit(SmtpState aNextStateAfterResponse) {
   m_sendDone = true;
   m_nextState = SMTP_RESPONSE;
   m_nextStateAfterResponse = aNextStateAfterResponse;
 
-  return SendData("QUIT" CRLF); // send a quit command to close the connection with the server.
+  return SendData("QUIT" CRLF);  // send a quit command to close the connection
+                                 // with the server.
 }
 
-nsresult nsSmtpProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
-{
-  if (!aURL)
-    return NS_OK;
+nsresult nsSmtpProtocol::LoadUrl(nsIURI *aURL, nsISupports *aConsumer) {
+  if (!aURL) return NS_OK;
 
   m_consumer = aConsumer;
   return Initialize(aURL);
 }
 
-nsresult nsSmtpProtocol::LoadUrlInternal(nsIURI *aURL, nsISupports *aConsumer)
-{
-  m_continuationResponse = -1;  /* init */
+nsresult nsSmtpProtocol::LoadUrlInternal(nsIURI *aURL, nsISupports *aConsumer) {
+  m_continuationResponse = -1; /* init */
   m_runningURL = do_QueryInterface(aURL);
-  if (!m_runningURL)
-    return NS_ERROR_FAILURE;
+  if (!m_runningURL) return NS_ERROR_FAILURE;
 
   // we had a bug where we failed to bring up an alert if the host
   // name was empty....so throw up an alert saying we don't have
   // a host name and inform the caller that we are not going to
   // run the url...
   nsAutoCString hostName;
   aURL->GetHost(hostName);
-  if (hostName.IsEmpty())
-  {
-    nsCOMPtr <nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL);
-    if (aMsgUrl)
-    {
+  if (hostName.IsEmpty()) {
+    nsCOMPtr<nsIMsgMailNewsUrl> aMsgUrl = do_QueryInterface(aURL);
+    if (aMsgUrl) {
       aMsgUrl->SetUrlState(true, NS_OK);
       // set the url as a url currently being run...
       aMsgUrl->SetUrlState(false /* we aren't running the url */,
                            NS_ERROR_SMTP_AUTH_FAILURE);
     }
     return NS_ERROR_BUT_DONT_SHOW_ALERT;
   }
 
   return nsMsgProtocol::LoadUrl(aURL, aConsumer);
 }
 
 /*
  * returns negative if the transfer is finished or error'd out
  *
  * returns zero or more if the transfer needs to be continued.
  */
-nsresult nsSmtpProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
-                                              uint64_t sourceOffset, uint32_t length)
- {
-   nsresult status = NS_OK;
-   ClearFlag(SMTP_PAUSE_FOR_READ); /* already paused; reset */
+nsresult nsSmtpProtocol::ProcessProtocolState(nsIURI *url,
+                                              nsIInputStream *inputStream,
+                                              uint64_t sourceOffset,
+                                              uint32_t length) {
+  nsresult status = NS_OK;
+  ClearFlag(SMTP_PAUSE_FOR_READ); /* already paused; reset */
 
-   while(!TestFlag(SMTP_PAUSE_FOR_READ))
-   {
-     MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info, ("SMTP entering state: %d",
-       m_nextState));
-     switch(m_nextState)
-     {
-     case SMTP_RESPONSE:
-       if (inputStream == nullptr)
-         SetFlag(SMTP_PAUSE_FOR_READ);
-       else
-         status = SmtpResponse(inputStream, length);
-       break;
+  while (!TestFlag(SMTP_PAUSE_FOR_READ)) {
+    MOZ_LOG(SMTPLogModule, mozilla::LogLevel::Info,
+            ("SMTP entering state: %d", m_nextState));
+    switch (m_nextState) {
+      case SMTP_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(SMTP_PAUSE_FOR_READ);
+        else
+          status = SmtpResponse(inputStream, length);
+        break;
 
-     case SMTP_START_CONNECT:
-       SetFlag(SMTP_PAUSE_FOR_READ);
-       m_nextState = SMTP_RESPONSE;
-       m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
-       break;
-     case SMTP_FINISH_CONNECT:
-       SetFlag(SMTP_PAUSE_FOR_READ);
-       break;
-     case SMTP_TLS_RESPONSE:
-       if (inputStream == nullptr)
-         SetFlag(SMTP_PAUSE_FOR_READ);
-       else
-         status = SendTLSResponse();
-       break;
-     case SMTP_EXTN_LOGIN_RESPONSE:
-       if (inputStream == nullptr)
-         SetFlag(SMTP_PAUSE_FOR_READ);
-       else
-         status = ExtensionLoginResponse(inputStream, length);
-       break;
+      case SMTP_START_CONNECT:
+        SetFlag(SMTP_PAUSE_FOR_READ);
+        m_nextState = SMTP_RESPONSE;
+        m_nextStateAfterResponse = SMTP_EXTN_LOGIN_RESPONSE;
+        break;
+      case SMTP_FINISH_CONNECT:
+        SetFlag(SMTP_PAUSE_FOR_READ);
+        break;
+      case SMTP_TLS_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(SMTP_PAUSE_FOR_READ);
+        else
+          status = SendTLSResponse();
+        break;
+      case SMTP_EXTN_LOGIN_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(SMTP_PAUSE_FOR_READ);
+        else
+          status = ExtensionLoginResponse(inputStream, length);
+        break;
 
-     case SMTP_SEND_HELO_RESPONSE:
-       if (inputStream == nullptr)
-         SetFlag(SMTP_PAUSE_FOR_READ);
-       else
-         status = SendHeloResponse(inputStream, length);
-       break;
-     case SMTP_SEND_EHLO_RESPONSE:
-       if (inputStream == nullptr)
-         SetFlag(SMTP_PAUSE_FOR_READ);
-       else
-         status = SendEhloResponse(inputStream, length);
-       break;
-     case SMTP_CLIENTID_RESPONSE:
-       if (inputStream == nullptr)
-         SetFlag(SMTP_PAUSE_FOR_READ);
-       else
-         status = SendClientIDResponse();
-       break;
-     case SMTP_AUTH_PROCESS_STATE:
-       status = ProcessAuth();
-       break;
+      case SMTP_SEND_HELO_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(SMTP_PAUSE_FOR_READ);
+        else
+          status = SendHeloResponse(inputStream, length);
+        break;
+      case SMTP_SEND_EHLO_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(SMTP_PAUSE_FOR_READ);
+        else
+          status = SendEhloResponse(inputStream, length);
+        break;
+      case SMTP_CLIENTID_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(SMTP_PAUSE_FOR_READ);
+        else
+          status = SendClientIDResponse();
+        break;
+      case SMTP_AUTH_PROCESS_STATE:
+        status = ProcessAuth();
+        break;
 
       case SMTP_SEND_AUTH_GSSAPI_FIRST:
         status = AuthGSSAPIFirst();
         break;
 
       case SMTP_SEND_AUTH_GSSAPI_STEP:
         status = AuthGSSAPIStep();
         break;
@@ -2197,17 +2035,16 @@ nsresult nsSmtpProtocol::ProcessProtocol
       case SMTP_SEND_AUTH_LOGIN_STEP2:
         status = AuthLoginStep2();
         break;
 
       case SMTP_AUTH_OAUTH2_STEP:
         status = AuthOAuth2Step1();
         break;
 
-
       case SMTP_SEND_MAIL_RESPONSE:
         if (inputStream == nullptr)
           SetFlag(SMTP_PAUSE_FOR_READ);
         else
           status = SendMailResponse();
         break;
 
       case SMTP_SEND_RCPT_RESPONSE:
@@ -2230,31 +2067,31 @@ nsresult nsSmtpProtocol::ProcessProtocol
         break;
 
       case SMTP_SEND_MESSAGE_RESPONSE:
         if (inputStream == nullptr)
           SetFlag(SMTP_PAUSE_FOR_READ);
         else
           status = SendMessageResponse();
         break;
-      case SMTP_DONE:
-        {
-          nsCOMPtr <nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(m_runningURL);
-          mailNewsUrl->SetUrlState(false, NS_OK);
-        }
+      case SMTP_DONE: {
+        nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl =
+            do_QueryInterface(m_runningURL);
+        mailNewsUrl->SetUrlState(false, NS_OK);
+      }
 
         m_nextState = SMTP_FREE;
         break;
 
-      case SMTP_ERROR_DONE:
-        {
-          nsCOMPtr <nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(m_runningURL);
-          // propagate the right error code
-          mailNewsUrl->SetUrlState(false, m_urlErrorState);
-        }
+      case SMTP_ERROR_DONE: {
+        nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl =
+            do_QueryInterface(m_runningURL);
+        // propagate the right error code
+        mailNewsUrl->SetUrlState(false, m_urlErrorState);
+      }
 
         m_nextState = SMTP_FREE;
         break;
 
       case SMTP_FREE:
         // smtp is a one time use connection so kill it if we get here...
         nsMsgAsyncWriteProtocol::CloseSocket();
         return NS_OK; /* final end */
@@ -2266,158 +2103,142 @@ nsresult nsSmtpProtocol::ProcessProtocol
         return NS_OK;
 
       default: /* should never happen !!! */
         m_nextState = SMTP_ERROR_DONE;
         break;
     }
 
     /* check for errors during load and call error
-    * state if found
-    */
+     * state if found
+     */
     if (NS_FAILED(status) && m_nextState != SMTP_FREE) {
       // send a quit command to close the connection with the server.
-      if (NS_FAILED(SendQuit(SMTP_ERROR_DONE)))
-      {
+      if (NS_FAILED(SendQuit(SMTP_ERROR_DONE))) {
         m_nextState = SMTP_ERROR_DONE;
         // Don't exit - loop around again and do the free case
         ClearFlag(SMTP_PAUSE_FOR_READ);
       }
     }
   } /* while(!SMTP_PAUSE_FOR_READ) */
 
   return NS_OK;
 }
 
-nsresult
-nsSmtpProtocol::GetPassword(nsString &aPassword)
-{
-    nsresult rv;
-    nsCOMPtr<nsISmtpUrl> smtpUrl = m_runningURL;
+nsresult nsSmtpProtocol::GetPassword(nsString &aPassword) {
+  nsresult rv;
+  nsCOMPtr<nsISmtpUrl> smtpUrl = m_runningURL;
 
-    nsCOMPtr<nsISmtpServer> smtpServer;
-    rv = smtpUrl->GetSmtpServer(getter_AddRefs(smtpServer));
-    NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsISmtpServer> smtpServer;
+  rv = smtpUrl->GetSmtpServer(getter_AddRefs(smtpServer));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = smtpServer->GetPassword(aPassword);
-    NS_ENSURE_SUCCESS(rv,rv);
+  rv = smtpServer->GetPassword(aPassword);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    if (!aPassword.IsEmpty())
-        return rv;
-    // empty password
+  if (!aPassword.IsEmpty()) return rv;
+  // empty password
 
-    nsCOMPtr <nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIPrefService> prefs =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsIPrefBranch> prefBranch;
-    rv = prefs->GetBranch(nullptr, getter_AddRefs(prefBranch));
-    NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIPrefBranch> prefBranch;
+  rv = prefs->GetBranch(nullptr, getter_AddRefs(prefBranch));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCString username;
-    rv = smtpServer->GetUsername(username);
-    NS_ENSURE_SUCCESS(rv, rv);
+  nsCString username;
+  rv = smtpServer->GetUsername(username);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    NS_ConvertASCIItoUTF16 usernameUTF16(username);
+  NS_ConvertASCIItoUTF16 usernameUTF16(username);
 
-    nsCString hostname;
-    rv = smtpServer->GetHostname(hostname);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsAutoString hostnameUTF16;
-    CopyASCIItoUTF16(hostname, hostnameUTF16);
+  nsCString hostname;
+  rv = smtpServer->GetHostname(hostname);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    const char16_t *formatStrings[] =
-    {
-      hostnameUTF16.get(),
-      usernameUTF16.get()
-    };
+  nsAutoString hostnameUTF16;
+  CopyASCIItoUTF16(hostname, hostnameUTF16);
 
-    rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword);
-    NS_ENSURE_SUCCESS(rv,rv);
-    return rv;
+  const char16_t *formatStrings[] = {hostnameUTF16.get(), usernameUTF16.get()};
+
+  rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword);
+  NS_ENSURE_SUCCESS(rv, rv);
+  return rv;
 }
 
 /**
  * formatStrings is an array for the prompts, item 0 is the hostname, item 1
  * is the username.
  */
-nsresult
-nsSmtpProtocol::PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl,
-                                  const char16_t **formatStrings, nsAString &aPassword)
-{
+nsresult nsSmtpProtocol::PromptForPassword(nsISmtpServer *aSmtpServer,
+                                           nsISmtpUrl *aSmtpUrl,
+                                           const char16_t **formatStrings,
+                                           nsAString &aPassword) {
   nsCOMPtr<nsIStringBundleService> stringService =
-    mozilla::services::GetStringBundleService();
+      mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(stringService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> composeStringBundle;
-  nsresult rv = stringService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(composeStringBundle));
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsresult rv = stringService->CreateBundle(
+      "chrome://messenger/locale/messengercompose/composeMsgs.properties",
+      getter_AddRefs(composeStringBundle));
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsString passwordPromptString;
-  if(formatStrings[1])
+  if (formatStrings[1])
     rv = composeStringBundle->FormatStringFromName(
-      "smtpEnterPasswordPromptWithUsername",
-      formatStrings, 2, passwordPromptString);
+        "smtpEnterPasswordPromptWithUsername", formatStrings, 2,
+        passwordPromptString);
   else
     rv = composeStringBundle->FormatStringFromName(
-      "smtpEnterPasswordPrompt",
-      formatStrings, 1, passwordPromptString);
+        "smtpEnterPasswordPrompt", formatStrings, 1, passwordPromptString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIAuthPrompt> netPrompt;
   rv = aSmtpUrl->GetAuthPrompt(getter_AddRefs(netPrompt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString passwordTitle;
-  rv = composeStringBundle->GetStringFromName(
-    "smtpEnterPasswordPromptTitle",
-    passwordTitle);
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = composeStringBundle->GetStringFromName("smtpEnterPasswordPromptTitle",
+                                              passwordTitle);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = aSmtpServer->GetPasswordWithUI(passwordPromptString.get(), passwordTitle.get(),
-    netPrompt, aPassword);
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = aSmtpServer->GetPasswordWithUI(
+      passwordPromptString.get(), passwordTitle.get(), netPrompt, aPassword);
+  NS_ENSURE_SUCCESS(rv, rv);
   return rv;
 }
 
-nsresult
-nsSmtpProtocol::GetUsernamePassword(nsACString &aUsername,
-                                    nsAString &aPassword)
-{
-    nsresult rv;
-    nsCOMPtr<nsISmtpUrl> smtpUrl = m_runningURL;
+nsresult nsSmtpProtocol::GetUsernamePassword(nsACString &aUsername,
+                                             nsAString &aPassword) {
+  nsresult rv;
+  nsCOMPtr<nsISmtpUrl> smtpUrl = m_runningURL;
 
-    nsCOMPtr<nsISmtpServer> smtpServer;
-    rv = smtpUrl->GetSmtpServer(getter_AddRefs(smtpServer));
-    NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsISmtpServer> smtpServer;
+  rv = smtpUrl->GetSmtpServer(getter_AddRefs(smtpServer));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = smtpServer->GetPassword(aPassword);
-    NS_ENSURE_SUCCESS(rv,rv);
+  rv = smtpServer->GetPassword(aPassword);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    if (!aPassword.IsEmpty())
-    {
-        rv = smtpServer->GetUsername(aUsername);
-        NS_ENSURE_SUCCESS(rv,rv);
+  if (!aPassword.IsEmpty()) {
+    rv = smtpServer->GetUsername(aUsername);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-        if (!aUsername.IsEmpty())
-          return rv;
-    }
-    // empty password
+    if (!aUsername.IsEmpty()) return rv;
+  }
+  // empty password
 
-    aPassword.Truncate();
+  aPassword.Truncate();
 
-    nsCString hostname;
-    rv = smtpServer->GetHostname(hostname);
-    NS_ENSURE_SUCCESS(rv, rv);
-    nsAutoString hostnameUTF16;
-    CopyASCIItoUTF16(hostname, hostnameUTF16);
+  nsCString hostname;
+  rv = smtpServer->GetHostname(hostname);
+  NS_ENSURE_SUCCESS(rv, rv);
+  nsAutoString hostnameUTF16;
+  CopyASCIItoUTF16(hostname, hostnameUTF16);
 
-    const char16_t *formatStrings[] =
-    {
-      hostnameUTF16.get(),
-      nullptr
-    };
+  const char16_t *formatStrings[] = {hostnameUTF16.get(), nullptr};
 
-    rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword);
-    NS_ENSURE_SUCCESS(rv,rv);
-    return rv;
+  rv = PromptForPassword(smtpServer, smtpUrl, formatStrings, aPassword);
+  NS_ENSURE_SUCCESS(rv, rv);
+  return rv;
 }
-
--- a/mailnews/compose/src/nsSmtpProtocol.h
+++ b/mailnews/compose/src/nsSmtpProtocol.h
@@ -9,228 +9,235 @@
 #include "mozilla/Attributes.h"
 #include "msgIOAuth2Module.h"
 #include "nsMsgProtocol.h"
 #include "nsIStreamListener.h"
 #include "nsISmtpUrl.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsMsgLineBuffer.h"
 #include "nsIProtocolProxyCallback.h"
-#include "MailNewsTypes2.h" // for nsMsgSocketType
+#include "MailNewsTypes2.h"  // for nsMsgSocketType
 
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 
 class nsIVariant;
 class nsIWritableVariant;
 
- /* states of the machine
+/* states of the machine
  */
 typedef enum _SmtpState {
-SMTP_RESPONSE = 0,                                  // 0
-SMTP_START_CONNECT,                                 // 1
-SMTP_FINISH_CONNECT,                                // 2
-SMTP_SEND_HELO_RESPONSE,                            // 3
-SMTP_SEND_EHLO_RESPONSE,                            // 4
-SMTP_SEND_MAIL_RESPONSE,                            // 5
-SMTP_SEND_RCPT_RESPONSE,                            // 6
-SMTP_SEND_DATA_RESPONSE,                            // 7
-SMTP_SEND_POST_DATA,                                // 8
-SMTP_SEND_MESSAGE_RESPONSE,                         // 9
-SMTP_DONE,                                          // 10
-SMTP_ERROR_DONE,                                    // 11
-SMTP_FREE,                                          // 12
-SMTP_AUTH_LOGIN_STEP0_RESPONSE,                     // 13
-SMTP_EXTN_LOGIN_RESPONSE,                           // 14
-SMTP_SEND_AUTH_LOGIN_STEP0,                         // 15
-SMTP_SEND_AUTH_LOGIN_STEP1,                         // 16
-SMTP_SEND_AUTH_LOGIN_STEP2,                         // 17
-SMTP_AUTH_LOGIN_RESPONSE,                           // 18
-SMTP_TLS_RESPONSE,                                  // 19
-SMTP_AUTH_EXTERNAL_RESPONSE,                        // 20
-SMTP_AUTH_PROCESS_STATE,                            // 21
-SMTP_AUTH_CRAM_MD5_CHALLENGE_RESPONSE,              // 22
-SMTP_SEND_AUTH_GSSAPI_FIRST,                        // 23
-SMTP_SEND_AUTH_GSSAPI_STEP,                         // 24
-SMTP_SUSPENDED,                                     // 25
-SMTP_AUTH_OAUTH2_STEP,                              // 26
-SMTP_AUTH_OAUTH2_RESPONSE,                          // 27
-SMTP_CLIENTID_RESPONSE,                             // 28
+  SMTP_RESPONSE = 0,                      // 0
+  SMTP_START_CONNECT,                     // 1
+  SMTP_FINISH_CONNECT,                    // 2
+  SMTP_SEND_HELO_RESPONSE,                // 3
+  SMTP_SEND_EHLO_RESPONSE,                // 4
+  SMTP_SEND_MAIL_RESPONSE,                // 5
+  SMTP_SEND_RCPT_RESPONSE,                // 6
+  SMTP_SEND_DATA_RESPONSE,                // 7
+  SMTP_SEND_POST_DATA,                    // 8
+  SMTP_SEND_MESSAGE_RESPONSE,             // 9
+  SMTP_DONE,                              // 10
+  SMTP_ERROR_DONE,                        // 11
+  SMTP_FREE,                              // 12
+  SMTP_AUTH_LOGIN_STEP0_RESPONSE,         // 13
+  SMTP_EXTN_LOGIN_RESPONSE,               // 14
+  SMTP_SEND_AUTH_LOGIN_STEP0,             // 15
+  SMTP_SEND_AUTH_LOGIN_STEP1,             // 16
+  SMTP_SEND_AUTH_LOGIN_STEP2,             // 17
+  SMTP_AUTH_LOGIN_RESPONSE,               // 18
+  SMTP_TLS_RESPONSE,                      // 19
+  SMTP_AUTH_EXTERNAL_RESPONSE,            // 20
+  SMTP_AUTH_PROCESS_STATE,                // 21
+  SMTP_AUTH_CRAM_MD5_CHALLENGE_RESPONSE,  // 22
+  SMTP_SEND_AUTH_GSSAPI_FIRST,            // 23
+  SMTP_SEND_AUTH_GSSAPI_STEP,             // 24
+  SMTP_SUSPENDED,                         // 25
+  SMTP_AUTH_OAUTH2_STEP,                  // 26
+  SMTP_AUTH_OAUTH2_RESPONSE,              // 27
+  SMTP_CLIENTID_RESPONSE,                 // 28
 } SmtpState;
 
 // State Flags (Note, I use the word state in terms of storing
 // state information about the connection (authentication, have we sent
 // commands, etc. I do not intend it to refer to protocol state)
-#define SMTP_PAUSE_FOR_READ             0x00000001  /* should we pause for the next read */
-#define SMTP_ESMTP_SERVER               0x00000002
-#define SMTP_EHLO_DSN_ENABLED           0x00000004
-#define SMTP_EHLO_STARTTLS_ENABLED      0x00000008
-#define SMTP_EHLO_SIZE_ENABLED          0x00000010
-#define SMTP_EHLO_8BIT_ENABLED          0x00000020
-#define SMTP_EHLO_CLIENTID_ENABLED      0x00000040
+#define SMTP_PAUSE_FOR_READ 0x00000001 /* should we pause for the next read */
+#define SMTP_ESMTP_SERVER 0x00000002
+#define SMTP_EHLO_DSN_ENABLED 0x00000004
+#define SMTP_EHLO_STARTTLS_ENABLED 0x00000008
+#define SMTP_EHLO_SIZE_ENABLED 0x00000010
+#define SMTP_EHLO_8BIT_ENABLED 0x00000020
+#define SMTP_EHLO_CLIENTID_ENABLED 0x00000040
 
 // insecure mechanisms follow
-#define SMTP_AUTH_LOGIN_ENABLED         0x00000100
-#define SMTP_AUTH_PLAIN_ENABLED         0x00000200
-#define SMTP_AUTH_EXTERNAL_ENABLED      0x00000400
+#define SMTP_AUTH_LOGIN_ENABLED 0x00000100
+#define SMTP_AUTH_PLAIN_ENABLED 0x00000200
+#define SMTP_AUTH_EXTERNAL_ENABLED 0x00000400
 // secure mechanisms follow
-#define SMTP_AUTH_GSSAPI_ENABLED        0x00000800
-#define SMTP_AUTH_DIGEST_MD5_ENABLED    0x00001000
-#define SMTP_AUTH_CRAM_MD5_ENABLED      0x00002000
-#define SMTP_AUTH_NTLM_ENABLED          0x00004000
-#define SMTP_AUTH_MSN_ENABLED           0x00008000
-#define SMTP_AUTH_OAUTH2_ENABLED        0x00010000
+#define SMTP_AUTH_GSSAPI_ENABLED 0x00000800
+#define SMTP_AUTH_DIGEST_MD5_ENABLED 0x00001000
+#define SMTP_AUTH_CRAM_MD5_ENABLED 0x00002000
+#define SMTP_AUTH_NTLM_ENABLED 0x00004000
+#define SMTP_AUTH_MSN_ENABLED 0x00008000
+#define SMTP_AUTH_OAUTH2_ENABLED 0x00010000
 // sum of all above auth mechanisms
-#define SMTP_AUTH_ANY                   0x0001FF00
+#define SMTP_AUTH_ANY 0x0001FF00
 // indicates that AUTH has been advertised
-#define SMTP_AUTH                       0x00020000
+#define SMTP_AUTH 0x00020000
 // No login necessary (pref)
-#define SMTP_AUTH_NONE_ENABLED          0x00040000
+#define SMTP_AUTH_NONE_ENABLED 0x00040000
 
 class nsSmtpProtocol : public nsMsgAsyncWriteProtocol,
                        public msgIOAuth2ModuleListener,
-                       public nsIProtocolProxyCallback
-{
-public:
-    NS_DECL_ISUPPORTS_INHERITED
-    NS_DECL_MSGIOAUTH2MODULELISTENER
-    NS_DECL_NSIPROTOCOLPROXYCALLBACK
+                       public nsIProtocolProxyCallback {
+ public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_MSGIOAUTH2MODULELISTENER
+  NS_DECL_NSIPROTOCOLPROXYCALLBACK
+
+  // Creating a protocol instance requires the URL which needs to be run.
+  explicit nsSmtpProtocol(nsIURI *aURL);
 
-    // Creating a protocol instance requires the URL which needs to be run.
-    explicit nsSmtpProtocol(nsIURI * aURL);
+  virtual nsresult LoadUrl(nsIURI *aURL,
+                           nsISupports *aConsumer = nullptr) override;
+  virtual nsresult SendData(const char *dataBuffer,
+                            bool aSuppressLogging = false) override;
 
-    virtual nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer = nullptr) override;
-    virtual nsresult SendData(const char * dataBuffer, bool aSuppressLogging = false) override;
-
-    ////////////////////////////////////////////////////////////////////////////////////////
-    // we support the nsIStreamListener interface
-    ////////////////////////////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////////////////////////////
+  // we support the nsIStreamListener interface
+  ////////////////////////////////////////////////////////////////////////////////////////
 
-    // stop binding is a "notification" informing us that the stream associated with aURL is going away.
-    NS_IMETHOD OnStopRequest(nsIRequest *request, nsresult status) override;
+  // stop binding is a "notification" informing us that the stream associated
+  // with aURL is going away.
+  NS_IMETHOD OnStopRequest(nsIRequest *request, nsresult status) override;
 
-private:
-    virtual ~nsSmtpProtocol();
-    // if we are asked to load a url while we are blocked waiting for redirection information,
-    // then we'll store the url consumer in mPendingConsumer until we can actually load
-    // the url.
-    nsCOMPtr<nsISupports> mPendingConsumer;
+ private:
+  virtual ~nsSmtpProtocol();
+  // if we are asked to load a url while we are blocked waiting for redirection
+  // information, then we'll store the url consumer in mPendingConsumer until we
+  // can actually load the url.
+  nsCOMPtr<nsISupports> mPendingConsumer;
 
-    // the nsISmtpURL that is currently running
-    nsCOMPtr<nsISmtpUrl> m_runningURL;
+  // the nsISmtpURL that is currently running
+  nsCOMPtr<nsISmtpUrl> m_runningURL;
 
-    // the error state we want to set on the url
-    nsresult m_urlErrorState;
-    nsCOMPtr<nsIMsgStatusFeedback> m_statusFeedback;
+  // the error state we want to set on the url
+  nsresult m_urlErrorState;
+  nsCOMPtr<nsIMsgStatusFeedback> m_statusFeedback;
 
-    // Generic state information -- What state are we in? What state do we want to go to
-    // after the next response? What was the last response code? etc.
-    SmtpState m_nextState;
-    SmtpState m_nextStateAfterResponse;
-    int32_t m_responseCode;    /* code returned from Smtp server */
-    int32_t m_responseCodeEnhanced;    /* ESMTP code returned from SMTP server (RFC1893) */
-    int32_t m_previousResponseCode;
-    int32_t m_continuationResponse;
-    nsCString m_responseText;   /* text returned from Smtp server */
-    RefPtr<nsMsgLineStreamBuffer> m_lineStreamBuffer; // used to efficiently extract lines from the incoming data stream
-
-    nsTArray<nsCString> m_addresses;
-    uint32_t       m_addressesLeft;
-    nsCString m_mailAddr;
-    nsCString m_helloArgument;
-    nsCString m_clientId;
-    int32_t        m_sizelimit;
+  // Generic state information -- What state are we in? What state do we want to
+  // go to after the next response? What was the last response code? etc.
+  SmtpState m_nextState;
+  SmtpState m_nextStateAfterResponse;
+  int32_t m_responseCode;         /* code returned from Smtp server */
+  int32_t m_responseCodeEnhanced; /* ESMTP code returned from SMTP server
+                                     (RFC1893) */
+  int32_t m_previousResponseCode;
+  int32_t m_continuationResponse;
+  nsCString m_responseText; /* text returned from Smtp server */
+  RefPtr<nsMsgLineStreamBuffer>
+      m_lineStreamBuffer;  // used to efficiently extract lines from the
+                           // incoming data stream
 
-    // *** the following should move to the smtp server when we support
-    // multiple smtp servers
-    bool m_usernamePrompted;
-    int32_t m_prefSocketType;
-    bool m_tlsEnabled;
-
-    bool m_tlsInitiated;
-
-    bool m_clientIDInitialized;
+  nsTArray<nsCString> m_addresses;
+  uint32_t m_addressesLeft;
+  nsCString m_mailAddr;
+  nsCString m_helloArgument;
+  nsCString m_clientId;
+  int32_t m_sizelimit;
 
-    bool m_sendDone;
+  // *** the following should move to the smtp server when we support
+  // multiple smtp servers
+  bool m_usernamePrompted;
+  int32_t m_prefSocketType;
+  bool m_tlsEnabled;
 
-    int32_t m_totalAmountRead;
-    int64_t m_totalMessageSize;
+  bool m_tlsInitiated;
 
-    char *m_dataBuf;
-    uint32_t m_dataBufSize;
+  bool m_clientIDInitialized;
+
+  bool m_sendDone;
 
-    int32_t   m_originalContentLength; /* the content length at the time of calling graph progress */
+  int32_t m_totalAmountRead;
+  int64_t m_totalMessageSize;
+
+  char *m_dataBuf;
+  uint32_t m_dataBufSize;
 
-    // initialization function given a new url and transport layer
-    nsresult Initialize(nsIURI * aURL);
-    nsresult InitializeInternal(nsIProxyInfo* proxyInfo);
-    nsresult LoadUrlInternal(nsIURI *aURL, nsISupports *aConsumer);
-    virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
-                                          uint64_t sourceOffset, uint32_t length) override;
+  int32_t m_originalContentLength; /* the content length at the time of calling
+                                      graph progress */
 
-    ////////////////////////////////////////////////////////////////////////////////////////
-    // Communication methods --> Reading and writing protocol
-    ////////////////////////////////////////////////////////////////////////////////////////
-
-    void UpdateStatus(const char* aStatusName);
-    void UpdateStatusWithString(const char16_t * aStatusString);
+  // initialization function given a new url and transport layer
+  nsresult Initialize(nsIURI *aURL);
+  nsresult InitializeInternal(nsIProxyInfo *proxyInfo);
+  nsresult LoadUrlInternal(nsIURI *aURL, nsISupports *aConsumer);
+  virtual nsresult ProcessProtocolState(nsIURI *url,
+                                        nsIInputStream *inputStream,
+                                        uint64_t sourceOffset,
+                                        uint32_t length) override;
 
-    ////////////////////////////////////////////////////////////////////////////////////////
-    // Protocol Methods --> This protocol is state driven so each protocol method is
-    //                      designed to re-act to the current "state". I've attempted to
-    //                      group them together based on functionality.
-    ////////////////////////////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////////////////////////////
+  // Communication methods --> Reading and writing protocol
+  ////////////////////////////////////////////////////////////////////////////////////////
+
+  void UpdateStatus(const char *aStatusName);
+  void UpdateStatusWithString(const char16_t *aStatusString);
 
-    nsresult SmtpResponse(nsIInputStream * inputStream, uint32_t length);
-    nsresult ExtensionLoginResponse(nsIInputStream * inputStream, uint32_t length);
-    nsresult SendHeloResponse(nsIInputStream * inputStream, uint32_t length);
-    nsresult SendEhloResponse(nsIInputStream * inputStream, uint32_t length);
-    nsresult SendQuit(SmtpState aNextStateAfterResponse = SMTP_DONE);
+  ////////////////////////////////////////////////////////////////////////////////////////
+  // Protocol Methods --> This protocol is state driven so each protocol method
+  //            is designed to re-act to the current "state". I've attempted to
+  //            group them together based on functionality.
+  ////////////////////////////////////////////////////////////////////////////////////////
 
-    nsresult AuthGSSAPIFirst();
-    nsresult AuthGSSAPIStep();
-    nsresult AuthLoginStep0();
-    void     AuthLoginStep0Response();
-    nsresult AuthLoginStep1();
-    nsresult AuthLoginStep2();
-    nsresult AuthLoginResponse(nsIInputStream * stream, uint32_t length);
-    nsresult AuthOAuth2Step1();
+  nsresult SmtpResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult ExtensionLoginResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult SendHeloResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult SendEhloResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult SendQuit(SmtpState aNextStateAfterResponse = SMTP_DONE);
 
-    nsresult SendTLSResponse();
-    nsresult SendClientIDResponse();
-    nsresult SendMailResponse();
-    nsresult SendRecipientResponse();
-    nsresult SendDataResponse();
-    void     SendPostData();
-    nsresult SendMessageResponse();
-    nsresult ProcessAuth();
+  nsresult AuthGSSAPIFirst();
+  nsresult AuthGSSAPIStep();
+  nsresult AuthLoginStep0();
+  void AuthLoginStep0Response();
+  nsresult AuthLoginStep1();
+  nsresult AuthLoginStep2();
+  nsresult AuthLoginResponse(nsIInputStream *stream, uint32_t length);
+  nsresult AuthOAuth2Step1();
 
+  nsresult SendTLSResponse();
+  nsresult SendClientIDResponse();
+  nsresult SendMailResponse();
+  nsresult SendRecipientResponse();
+  nsresult SendDataResponse();
+  void SendPostData();
+  nsresult SendMessageResponse();
+  nsresult ProcessAuth();
 
-    ////////////////////////////////////////////////////////////////////////////////////////
-    // End of Protocol Methods
-    ////////////////////////////////////////////////////////////////////////////////////////
-
-    void SendMessageInFile();
+  ////////////////////////////////////////////////////////////////////////////////////////
+  // End of Protocol Methods
+  ////////////////////////////////////////////////////////////////////////////////////////
 
-    void AppendHelloArgument(nsACString& aResult);
-    nsresult GetPassword(nsString &aPassword);
-    nsresult GetUsernamePassword(nsACString &aUsername, nsAString &aPassword);
-    nsresult PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl,
-                               const char16_t **formatStrings,
-                               nsAString &aPassword);
+  void SendMessageInFile();
+
+  void AppendHelloArgument(nsACString &aResult);
+  nsresult GetPassword(nsString &aPassword);
+  nsresult GetUsernamePassword(nsACString &aUsername, nsAString &aPassword);
+  nsresult PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl,
+                             const char16_t **formatStrings,
+                             nsAString &aPassword);
 
-    void    InitPrefAuthMethods(int32_t authMethodPrefValue);
-    nsresult ChooseAuthMethod();
-    void    MarkAuthMethodAsFailed(int32_t failedAuthMethod);
-    void    ResetAuthMethods();
+  void InitPrefAuthMethods(int32_t authMethodPrefValue);
+  nsresult ChooseAuthMethod();
+  void MarkAuthMethodAsFailed(int32_t failedAuthMethod);
+  void ResetAuthMethods();
 
-    virtual const char* GetType() override {return "smtp";}
+  virtual const char *GetType() override { return "smtp"; }
 
-    int32_t m_prefAuthMethods; // set of capability flags for auth methods
-    int32_t m_failedAuthMethods; // ditto
-    int32_t m_currentAuthMethod; // exactly one capability flag, or 0
+  int32_t m_prefAuthMethods;    // set of capability flags for auth methods
+  int32_t m_failedAuthMethods;  // ditto
+  int32_t m_currentAuthMethod;  // exactly one capability flag, or 0
 
-    // The support module for OAuth2 logon, only present if OAuth2 is enabled
-    // and working.
-    nsCOMPtr<msgIOAuth2Module> mOAuth2Support;
+  // The support module for OAuth2 logon, only present if OAuth2 is enabled
+  // and working.
+  nsCOMPtr<msgIOAuth2Module> mOAuth2Support;
 };
 
 #endif  // nsSmtpProtocol_h___
--- a/mailnews/compose/src/nsSmtpServer.cpp
+++ b/mailnews/compose/src/nsSmtpServer.cpp
@@ -18,493 +18,432 @@
 #include "nsIArray.h"
 #include "nsArrayUtils.h"
 #include "nsMemory.h"
 #include "nsIObserverService.h"
 
 NS_IMPL_ADDREF(nsSmtpServer)
 NS_IMPL_RELEASE(nsSmtpServer)
 NS_INTERFACE_MAP_BEGIN(nsSmtpServer)
-    NS_INTERFACE_MAP_ENTRY(nsISmtpServer)
-    NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-    NS_INTERFACE_MAP_ENTRY(nsIObserver)
-    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISmtpServer)
+  NS_INTERFACE_MAP_ENTRY(nsISmtpServer)
+  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
+  NS_INTERFACE_MAP_ENTRY(nsIObserver)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISmtpServer)
 NS_INTERFACE_MAP_END
 
-nsSmtpServer::nsSmtpServer():
-    mKey("")
-{
-    m_logonFailed = false;
-    getPrefs();
+nsSmtpServer::nsSmtpServer() : mKey("") {
+  m_logonFailed = false;
+  getPrefs();
 }
 
-nsSmtpServer::~nsSmtpServer()
-{
-}
+nsSmtpServer::~nsSmtpServer() {}
 
-nsresult nsSmtpServer::Init()
-{
+nsresult nsSmtpServer::Init() {
   // We need to know when the password manager changes.
   nsCOMPtr<nsIObserverService> observerService =
-           mozilla::services::GetObserverService();
+      mozilla::services::GetObserverService();
   NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
 
   observerService->AddObserver(this, "passwordmgr-storage-changed", false);
   observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::Observe(nsISupports *aSubject, const char* aTopic,
-                             const char16_t *aData)
-{
+nsSmtpServer::Observe(nsISupports *aSubject, const char *aTopic,
+                      const char16_t *aData) {
   // When the state of the password manager changes we need to clear the
   // password from the cache in case the user just removed it.
-  if (strcmp(aTopic, "passwordmgr-storage-changed") == 0)
-  {
+  if (strcmp(aTopic, "passwordmgr-storage-changed") == 0) {
     m_password.Truncate();
-  }
-  else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0)
-  {
+  } else if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
     // Now remove ourselves from the observer service as well.
     nsCOMPtr<nsIObserverService> observerService =
-      mozilla::services::GetObserverService();
+        mozilla::services::GetObserverService();
     NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
 
     observerService->RemoveObserver(this, "passwordmgr-storage-changed");
     observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
   }
 
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsSmtpServer::GetKey(char * *aKey)
-{
-    if (!aKey) return NS_ERROR_NULL_POINTER;
-    if (mKey.IsEmpty())
-        *aKey = nullptr;
-    else
-        *aKey = ToNewCString(mKey);
-    return NS_OK;
+nsSmtpServer::GetKey(char **aKey) {
+  if (!aKey) return NS_ERROR_NULL_POINTER;
+  if (mKey.IsEmpty())
+    *aKey = nullptr;
+  else
+    *aKey = ToNewCString(mKey);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetKey(const char * aKey)
-{
-    NS_ASSERTION(aKey, "Bad key pointer");
-    mKey = aKey;
-    return getPrefs();
+nsSmtpServer::SetKey(const char *aKey) {
+  NS_ASSERTION(aKey, "Bad key pointer");
+  mKey = aKey;
+  return getPrefs();
 }
 
-nsresult nsSmtpServer::getPrefs()
-{
-    nsresult rv;
-    nsCOMPtr<nsIPrefService> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-    if (NS_FAILED(rv))
-        return rv;
+nsresult nsSmtpServer::getPrefs() {
+  nsresult rv;
+  nsCOMPtr<nsIPrefService> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) return rv;
 
-    nsAutoCString branchName;
-    branchName.AssignLiteral("mail.smtpserver.");
-    branchName += mKey;
-    branchName.Append('.');
-    rv = prefs->GetBranch(branchName.get(), getter_AddRefs(mPrefBranch));
-    if (NS_FAILED(rv))
-        return rv;
+  nsAutoCString branchName;
+  branchName.AssignLiteral("mail.smtpserver.");
+  branchName += mKey;
+  branchName.Append('.');
+  rv = prefs->GetBranch(branchName.get(), getter_AddRefs(mPrefBranch));
+  if (NS_FAILED(rv)) return rv;
 
-    if(!mDefPrefBranch) {
-        branchName.AssignLiteral("mail.smtpserver.default.");
-        rv = prefs->GetBranch(branchName.get(), getter_AddRefs(mDefPrefBranch));
-        if (NS_FAILED(rv))
-            return rv;
-    }
+  if (!mDefPrefBranch) {
+    branchName.AssignLiteral("mail.smtpserver.default.");
+    rv = prefs->GetBranch(branchName.get(), getter_AddRefs(mDefPrefBranch));
+    if (NS_FAILED(rv)) return rv;
+  }
 
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetHostname(nsACString &aHostname)
-{
+nsSmtpServer::GetHostname(nsACString &aHostname) {
   nsCString result;
   nsresult rv = mPrefBranch->GetCharPref("hostname", result);
   if (NS_FAILED(rv))
     aHostname.Truncate();
   else
     aHostname = result;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetHostname(const nsACString &aHostname)
-{
+nsSmtpServer::SetHostname(const nsACString &aHostname) {
   if (!aHostname.IsEmpty())
     return mPrefBranch->SetCharPref("hostname", aHostname);
 
   // If the pref value is already empty, ClearUserPref will return
   // NS_ERROR_UNEXPECTED, so don't check the rv here.
   mPrefBranch->ClearUserPref("hostname");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetDescription(nsACString &aDescription)
-{
-    nsCString temp;
-    mPrefBranch->GetCharPref("description", temp);
-    aDescription.Assign(temp);
-    return NS_OK;
+nsSmtpServer::GetDescription(nsACString &aDescription) {
+  nsCString temp;
+  mPrefBranch->GetCharPref("description", temp);
+  aDescription.Assign(temp);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetDescription(const nsACString &aDescription)
-{
-    if (!aDescription.IsEmpty())
-        return mPrefBranch->SetCharPref("description", aDescription);
-    else
-        mPrefBranch->ClearUserPref("description");
-    return NS_OK;
+nsSmtpServer::SetDescription(const nsACString &aDescription) {
+  if (!aDescription.IsEmpty())
+    return mPrefBranch->SetCharPref("description", aDescription);
+  else
+    mPrefBranch->ClearUserPref("description");
+  return NS_OK;
 }
 
 // if GetPort returns 0, it means default port
 NS_IMETHODIMP
-nsSmtpServer::GetPort(int32_t *aPort)
-{
+nsSmtpServer::GetPort(int32_t *aPort) {
   NS_ENSURE_ARG_POINTER(aPort);
-  if (NS_FAILED(mPrefBranch->GetIntPref("port", aPort)))
-    *aPort = 0;
+  if (NS_FAILED(mPrefBranch->GetIntPref("port", aPort))) *aPort = 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetPort(int32_t aPort)
-{
-  if (aPort)
-    return mPrefBranch->SetIntPref("port", aPort);
+nsSmtpServer::SetPort(int32_t aPort) {
+  if (aPort) return mPrefBranch->SetIntPref("port", aPort);
 
   mPrefBranch->ClearUserPref("port");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetDisplayname(char * *aDisplayname)
-{
-    nsresult rv;
-    NS_ENSURE_ARG_POINTER(aDisplayname);
+nsSmtpServer::GetDisplayname(char **aDisplayname) {
+  nsresult rv;
+  NS_ENSURE_ARG_POINTER(aDisplayname);
 
-    nsCString hostname;
-    rv = mPrefBranch->GetCharPref("hostname", hostname);
-    if (NS_FAILED(rv)) {
-        *aDisplayname=nullptr;
-        return NS_OK;
-    }
-    int32_t port;
-    rv = mPrefBranch->GetIntPref("port", &port);
-    if (NS_FAILED(rv))
-        port = 0;
+  nsCString hostname;
+  rv = mPrefBranch->GetCharPref("hostname", hostname);
+  if (NS_FAILED(rv)) {
+    *aDisplayname = nullptr;
+    return NS_OK;
+  }
+  int32_t port;
+  rv = mPrefBranch->GetIntPref("port", &port);
+  if (NS_FAILED(rv)) port = 0;
 
-    if (port) {
-        hostname.Append(':');
-        hostname.AppendInt(port);
-    }
+  if (port) {
+    hostname.Append(':');
+    hostname.AppendInt(port);
+  }
 
-    *aDisplayname = ToNewCString(hostname);
-    return NS_OK;
+  *aDisplayname = ToNewCString(hostname);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetSocketType(int32_t *socketType)
-{
+nsSmtpServer::GetSocketType(int32_t *socketType) {
   NS_ENSURE_ARG_POINTER(socketType);
   getIntPrefWithDefault("try_ssl", socketType, 0);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetSocketType(int32_t socketType)
-{
-    return mPrefBranch->SetIntPref("try_ssl", socketType);
+nsSmtpServer::SetSocketType(int32_t socketType) {
+  return mPrefBranch->SetIntPref("try_ssl", socketType);
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetHelloArgument(nsACString& aHelloArgument)
-{
-    nsresult rv;
-    rv = mPrefBranch->GetCharPref("hello_argument", aHelloArgument);
-    if (NS_FAILED(rv))
-    {
-        rv = mDefPrefBranch->GetCharPref("hello_argument", aHelloArgument);
-        if (NS_FAILED(rv))
-            aHelloArgument.Truncate();
-    }
-    return NS_OK;
+nsSmtpServer::GetHelloArgument(nsACString &aHelloArgument) {
+  nsresult rv;
+  rv = mPrefBranch->GetCharPref("hello_argument", aHelloArgument);
+  if (NS_FAILED(rv)) {
+    rv = mDefPrefBranch->GetCharPref("hello_argument", aHelloArgument);
+    if (NS_FAILED(rv)) aHelloArgument.Truncate();
+  }
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetAuthMethod(int32_t *authMethod)
-{
+nsSmtpServer::GetAuthMethod(int32_t *authMethod) {
   NS_ENSURE_ARG_POINTER(authMethod);
   getIntPrefWithDefault("authMethod", authMethod, 3);
   return NS_OK;
 }
 
-void
-nsSmtpServer::getIntPrefWithDefault(const char *prefName,
-                                    int32_t *val,
-                                    int32_t defVal)
-{
+void nsSmtpServer::getIntPrefWithDefault(const char *prefName, int32_t *val,
+                                         int32_t defVal) {
   nsresult rv = mPrefBranch->GetIntPref(prefName, val);
-  if (NS_SUCCEEDED(rv))
-    return;
+  if (NS_SUCCEEDED(rv)) return;
 
   rv = mDefPrefBranch->GetIntPref(prefName, val);
   if (NS_FAILED(rv))
     // last resort
     *val = defVal;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetAuthMethod(int32_t authMethod)
-{
-    return mPrefBranch->SetIntPref("authMethod", authMethod);
+nsSmtpServer::SetAuthMethod(int32_t authMethod) {
+  return mPrefBranch->SetIntPref("authMethod", authMethod);
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetUsername(nsACString &aUsername)
-{
+nsSmtpServer::GetUsername(nsACString &aUsername) {
   nsCString result;
   nsresult rv = mPrefBranch->GetCharPref("username", result);
   if (NS_FAILED(rv))
     aUsername.Truncate();
   else
     aUsername = result;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetUsername(const nsACString &aUsername)
-{
+nsSmtpServer::SetUsername(const nsACString &aUsername) {
   if (!aUsername.IsEmpty())
     return mPrefBranch->SetCharPref("username", aUsername);
 
   // If the pref value is already empty, ClearUserPref will return
   // NS_ERROR_UNEXPECTED, so don't check the rv here.
   mPrefBranch->ClearUserPref("username");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetClientid(nsACString &aClientid)
-{
+nsSmtpServer::GetClientid(nsACString &aClientid) {
   nsresult rv;
   rv = mPrefBranch->GetCharPref("clientid", aClientid);
-  if (NS_FAILED(rv))
-  {
+  if (NS_FAILED(rv)) {
     rv = mDefPrefBranch->GetCharPref("clientid", aClientid);
-    if (NS_FAILED(rv))
-      aClientid.Truncate();
+    if (NS_FAILED(rv)) aClientid.Truncate();
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::SetClientid(const nsACString &aClientid)
-{
+nsSmtpServer::SetClientid(const nsACString &aClientid) {
   if (!aClientid.IsEmpty())
     return mPrefBranch->SetCharPref("clientid", aClientid);
 
   // If the pref value is already empty, ClearUserPref will return
   // NS_ERROR_UNEXPECTED, so don't check the rv here.
   mPrefBranch->ClearUserPref("clientid");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetPassword(nsAString& aPassword)
-{
-    if (m_password.IsEmpty() && !m_logonFailed)
-    {
-      // try to avoid prompting the user for another password. If the user has set
-      // the appropriate pref, we'll use the password from an incoming server, if
-      // the user has already logged onto that server.
+nsSmtpServer::GetPassword(nsAString &aPassword) {
+  if (m_password.IsEmpty() && !m_logonFailed) {
+    // try to avoid prompting the user for another password. If the user has set
+    // the appropriate pref, we'll use the password from an incoming server, if
+    // the user has already logged onto that server.
 
-      // if this is set, we'll only use this, and not the other prefs
-      // user_pref("mail.smtpserver.smtp1.incomingAccount", "server1");
+    // if this is set, we'll only use this, and not the other prefs
+    // user_pref("mail.smtpserver.smtp1.incomingAccount", "server1");
 
-      // if this is set, we'll accept an exact match of user name and server
-      // user_pref("mail.smtp.useMatchingHostNameServer", true);
+    // if this is set, we'll accept an exact match of user name and server
+    // user_pref("mail.smtp.useMatchingHostNameServer", true);
 
-      // if this is set, and we don't find an exact match of user and host name,
-      // we'll accept a match of username and domain, where domain
-      // is everything after the first '.'
-      // user_pref("mail.smtp.useMatchingDomainServer", true);
+    // if this is set, and we don't find an exact match of user and host name,
+    // we'll accept a match of username and domain, where domain
+    // is everything after the first '.'
+    // user_pref("mail.smtp.useMatchingDomainServer", true);
 
-      nsCString accountKey;
-      bool useMatchingHostNameServer = false;
-      bool useMatchingDomainServer = false;
-      mPrefBranch->GetCharPref("incomingAccount", accountKey);
+    nsCString accountKey;
+    bool useMatchingHostNameServer = false;
+    bool useMatchingDomainServer = false;
+    mPrefBranch->GetCharPref("incomingAccount", accountKey);
 
-      nsCOMPtr<nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID);
-      nsCOMPtr<nsIMsgIncomingServer> incomingServerToUse;
-      if (accountManager)
-      {
-        if (!accountKey.IsEmpty())
-          accountManager->GetIncomingServer(accountKey, getter_AddRefs(incomingServerToUse));
-        else
-        {
-          nsresult rv;
-          nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-          NS_ENSURE_SUCCESS(rv,rv);
-          prefBranch->GetBoolPref("mail.smtp.useMatchingHostNameServer", &useMatchingHostNameServer);
-          prefBranch->GetBoolPref("mail.smtp.useMatchingDomainServer", &useMatchingDomainServer);
-          if (useMatchingHostNameServer || useMatchingDomainServer)
-          {
-            nsCString userName;
-            nsCString hostName;
-            GetHostname(hostName);
-            GetUsername(userName);
-            if (useMatchingHostNameServer)
-              // pass in empty type and port=0, to match imap and pop3.
-              accountManager->FindRealServer(userName, hostName, EmptyCString(), 0, getter_AddRefs(incomingServerToUse));
-            int32_t dotPos = -1;
-            if (!incomingServerToUse && useMatchingDomainServer
-              && (dotPos = hostName.FindChar('.')) != kNotFound)
-            {
-              hostName.Cut(0, dotPos);
-              nsCOMPtr<nsIArray> allServers;
-              accountManager->GetAllServers(getter_AddRefs(allServers));
-              if (allServers)
-              {
-                uint32_t count = 0;
-                allServers->GetLength(&count);
-                uint32_t i;
-                for (i = 0; i < count; i++)
-                {
-                  nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(allServers, i);
-                  if (server)
-                  {
-                    nsCString serverUserName;
-                    nsCString serverHostName;
-                    server->GetRealUsername(serverUserName);
-                    server->GetRealHostName(serverHostName);
-                    if (serverUserName.Equals(userName))
-                    {
-                      int32_t serverDotPos = serverHostName.FindChar('.');
-                      if (serverDotPos != kNotFound)
-                      {
-                        serverHostName.Cut(0, serverDotPos);
-                        if (serverHostName.Equals(hostName))
-                        {
-                          incomingServerToUse = server;
-                          break;
-                        }
+    nsCOMPtr<nsIMsgAccountManager> accountManager =
+        do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID);
+    nsCOMPtr<nsIMsgIncomingServer> incomingServerToUse;
+    if (accountManager) {
+      if (!accountKey.IsEmpty())
+        accountManager->GetIncomingServer(accountKey,
+                                          getter_AddRefs(incomingServerToUse));
+      else {
+        nsresult rv;
+        nsCOMPtr<nsIPrefBranch> prefBranch(
+            do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+        NS_ENSURE_SUCCESS(rv, rv);
+        prefBranch->GetBoolPref("mail.smtp.useMatchingHostNameServer",
+                                &useMatchingHostNameServer);
+        prefBranch->GetBoolPref("mail.smtp.useMatchingDomainServer",
+                                &useMatchingDomainServer);
+        if (useMatchingHostNameServer || useMatchingDomainServer) {
+          nsCString userName;
+          nsCString hostName;
+          GetHostname(hostName);
+          GetUsername(userName);
+          if (useMatchingHostNameServer)
+            // pass in empty type and port=0, to match imap and pop3.
+            accountManager->FindRealServer(userName, hostName, EmptyCString(),
+                                           0,
+                                           getter_AddRefs(incomingServerToUse));
+          int32_t dotPos = -1;
+          if (!incomingServerToUse && useMatchingDomainServer &&
+              (dotPos = hostName.FindChar('.')) != kNotFound) {
+            hostName.Cut(0, dotPos);
+            nsCOMPtr<nsIArray> allServers;
+            accountManager->GetAllServers(getter_AddRefs(allServers));
+            if (allServers) {
+              uint32_t count = 0;
+              allServers->GetLength(&count);
+              uint32_t i;
+              for (i = 0; i < count; i++) {
+                nsCOMPtr<nsIMsgIncomingServer> server =
+                    do_QueryElementAt(allServers, i);
+                if (server) {
+                  nsCString serverUserName;
+                  nsCString serverHostName;
+                  server->GetRealUsername(serverUserName);
+                  server->GetRealHostName(serverHostName);
+                  if (serverUserName.Equals(userName)) {
+                    int32_t serverDotPos = serverHostName.FindChar('.');
+                    if (serverDotPos != kNotFound) {
+                      serverHostName.Cut(0, serverDotPos);
+                      if (serverHostName.Equals(hostName)) {
+                        incomingServerToUse = server;
+                        break;
                       }
                     }
                   }
                 }
               }
             }
           }
         }
       }
-      if (incomingServerToUse)
-        return incomingServerToUse->GetPassword(aPassword);
     }
-    aPassword = m_password;
-    return NS_OK;
+    if (incomingServerToUse) return incomingServerToUse->GetPassword(aPassword);
+  }
+  aPassword = m_password;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::VerifyLogon(nsIUrlListener *aUrlListener, nsIMsgWindow *aMsgWindow,
-                          nsIURI **aURL)
-{
+nsSmtpServer::VerifyLogon(nsIUrlListener *aUrlListener,
+                          nsIMsgWindow *aMsgWindow, nsIURI **aURL) {
   nsresult rv;
-  nsCOMPtr<nsISmtpService> smtpService(do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsISmtpService> smtpService(
+      do_GetService(NS_SMTPSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   return smtpService->VerifyLogon(this, aUrlListener, aMsgWindow, aURL);
 }
 
-
 NS_IMETHODIMP
-nsSmtpServer::SetPassword(const nsAString& aPassword)
-{
+nsSmtpServer::SetPassword(const nsAString &aPassword) {
   m_password = aPassword;
   return NS_OK;
 }
 
-nsresult
-nsSmtpServer::GetPasswordWithoutUI()
-{
+nsresult nsSmtpServer::GetPasswordWithoutUI() {
   nsresult rv;
-  nsCOMPtr<nsILoginManager> loginMgr(do_GetService(NS_LOGINMANAGER_CONTRACTID,
-                                                   &rv));
+  nsCOMPtr<nsILoginManager> loginMgr(
+      do_GetService(NS_LOGINMANAGER_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ConvertASCIItoUTF16 serverUri(GetServerURIInternal(false));
 
   uint32_t numLogins = 0;
-  nsILoginInfo** logins = nullptr;
-  rv = loginMgr->FindLogins(&numLogins, serverUri, EmptyString(),
-                            serverUri, &logins);
+  nsILoginInfo **logins = nullptr;
+  rv = loginMgr->FindLogins(&numLogins, serverUri, EmptyString(), serverUri,
+                            &logins);
   // Login manager can produce valid fails, e.g. NS_ERROR_ABORT when a user
   // cancels the master password dialog. Therefore handle that here, but don't
   // warn about it.
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
   // Don't abort here, if we didn't find any or failed, then we'll just have
   // to prompt.
-  if (numLogins > 0)
-  {
+  if (numLogins > 0) {
     nsCString serverCUsername;
     rv = GetUsername(serverCUsername);
     NS_ConvertASCIItoUTF16 serverUsername(serverCUsername);
 
     nsString username;
-    for (uint32_t i = 0; i < numLogins; ++i)
-    {
+    for (uint32_t i = 0; i < numLogins; ++i) {
       rv = logins[i]->GetUsername(username);
       NS_ENSURE_SUCCESS(rv, rv);
 
-      if (username.Equals(serverUsername))
-      {
+      if (username.Equals(serverUsername)) {
         nsString password;
         rv = logins[i]->GetPassword(password);
         NS_ENSURE_SUCCESS(rv, rv);
 
         m_password = password;
         break;
       }
     }
   }
   NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(numLogins, logins);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSmtpServer::GetPasswordWithUI(const char16_t *aPromptMessage,
                                 const char16_t *aPromptTitle,
-                                nsIAuthPrompt* aDialog,
-                                nsAString &aPassword)
-{
-  if (!m_password.IsEmpty())
-    return GetPassword(aPassword);
+                                nsIAuthPrompt *aDialog, nsAString &aPassword) {
+  if (!m_password.IsEmpty()) return GetPassword(aPassword);
 
   // We need to get a password, but see if we can get it from the password
   // manager without requiring a prompt.
   nsresult rv = GetPasswordWithoutUI();
-  if (rv == NS_ERROR_ABORT)
-    return NS_MSG_PASSWORD_PROMPT_CANCELLED;
+  if (rv == NS_ERROR_ABORT) return NS_MSG_PASSWORD_PROMPT_CANCELLED;
 
   // Now re-check if we've got a password or not, if we have, then we
   // don't need to prompt the user.
-  if (!m_password.IsEmpty())
-  {
+  if (!m_password.IsEmpty()) {
     aPassword = m_password;
     return NS_OK;
   }
 
   NS_ENSURE_ARG_POINTER(aDialog);
 
   // PromptPassword needs the username as well.
   nsCString serverUri(GetServerURIInternal(true));
@@ -513,63 +452,57 @@ nsSmtpServer::GetPasswordWithUI(const ch
 
   rv = aDialog->PromptPassword(aPromptTitle, aPromptMessage,
                                NS_ConvertASCIItoUTF16(serverUri).get(),
                                nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
                                getter_Copies(aPassword), &okayValue);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If the user pressed cancel, just return an empty string.
-  if (!okayValue)
-  {
+  if (!okayValue) {
     aPassword.Truncate();
     return NS_MSG_PASSWORD_PROMPT_CANCELLED;
   }
   rv = SetPassword(aPassword);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetUsernamePasswordWithUI(const char16_t * aPromptMessage, const
-                                char16_t *aPromptTitle,
-                                nsIAuthPrompt* aDialog,
-                                nsACString &aUsername,
-                                nsAString &aPassword)
-{
+nsSmtpServer::GetUsernamePasswordWithUI(const char16_t *aPromptMessage,
+                                        const char16_t *aPromptTitle,
+                                        nsIAuthPrompt *aDialog,
+                                        nsACString &aUsername,
+                                        nsAString &aPassword) {
   nsresult rv;
-  if (!m_password.IsEmpty())
-  {
+  if (!m_password.IsEmpty()) {
     rv = GetUsername(aUsername);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return GetPassword(aPassword);
   }
 
   NS_ENSURE_ARG_POINTER(aDialog);
 
   nsCString serverUri;
   rv = GetServerURI(serverUri);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString uniUsername;
   bool okayValue = true;
 
-  rv = aDialog->PromptUsernameAndPassword(aPromptTitle, aPromptMessage,
-                                          NS_ConvertASCIItoUTF16(serverUri).get(),
-                                          nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
-                                          getter_Copies(uniUsername),
-                                          getter_Copies(aPassword),
-                                          &okayValue);
+  rv = aDialog->PromptUsernameAndPassword(
+      aPromptTitle, aPromptMessage, NS_ConvertASCIItoUTF16(serverUri).get(),
+      nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY, getter_Copies(uniUsername),
+      getter_Copies(aPassword), &okayValue);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If the user pressed cancel, just return empty strings.
-  if (!okayValue)
-  {
+  if (!okayValue) {
     aUsername.Truncate();
     aPassword.Truncate();
     return rv;
   }
 
   // We got a username and password back...so remember them.
   NS_LossyConvertUTF16toASCII username(uniUsername);
 
@@ -579,86 +512,79 @@ nsSmtpServer::GetUsernamePasswordWithUI(
   rv = SetPassword(aPassword);
   NS_ENSURE_SUCCESS(rv, rv);
 
   aUsername = username;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::ForgetPassword()
-{
+nsSmtpServer::ForgetPassword() {
   nsresult rv;
   nsCOMPtr<nsILoginManager> loginMgr =
-    do_GetService(NS_LOGINMANAGER_CONTRACTID, &rv);
+      do_GetService(NS_LOGINMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the current server URI without the username
   nsAutoCString serverUri(NS_LITERAL_CSTRING("smtp://"));
 
   nsCString hostname;
   rv = GetHostname(hostname);
 
   if (NS_SUCCEEDED(rv) && !hostname.IsEmpty()) {
     nsCString escapedHostname;
     MsgEscapeString(hostname, nsINetUtil::ESCAPE_URL_PATH, escapedHostname);
     // not all servers have a hostname
     serverUri.Append(escapedHostname);
   }
 
   uint32_t count;
-  nsILoginInfo** logins;
+  nsILoginInfo **logins;
 
   NS_ConvertUTF8toUTF16 currServer(serverUri);
 
   nsCString serverCUsername;
   rv = GetUsername(serverCUsername);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ConvertUTF8toUTF16 serverUsername(serverCUsername);
 
-  rv = loginMgr->FindLogins(&count, currServer, EmptyString(),
-                            currServer, &logins);
+  rv = loginMgr->FindLogins(&count, currServer, EmptyString(), currServer,
+                            &logins);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // There should only be one-login stored for this url, however just in case
   // there isn't.
   nsString username;
-  for (uint32_t i = 0; i < count; ++i)
-  {
+  for (uint32_t i = 0; i < count; ++i) {
     if (NS_SUCCEEDED(logins[i]->GetUsername(username)) &&
-        username.Equals(serverUsername))
-    {
+        username.Equals(serverUsername)) {
       // If this fails, just continue, we'll still want to remove the password
       // from our local cache.
       loginMgr->RemoveLogin(logins[i]);
     }
   }
   NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins);
 
   rv = SetPassword(EmptyString());
   m_logonFailed = true;
   return rv;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::GetServerURI(nsACString &aResult)
-{
+nsSmtpServer::GetServerURI(nsACString &aResult) {
   aResult = GetServerURIInternal(true);
   return NS_OK;
 }
 
-nsCString
-nsSmtpServer::GetServerURIInternal(const bool aIncludeUsername)
-{
+nsCString nsSmtpServer::GetServerURIInternal(const bool aIncludeUsername) {
   nsCString uri(NS_LITERAL_CSTRING("smtp://"));
   nsresult rv;
 
-  if (aIncludeUsername)
-  {
+  if (aIncludeUsername) {
     nsCString username;
     rv = GetUsername(username);
 
     if (NS_SUCCEEDED(rv) && !username.IsEmpty()) {
       nsCString escapedUsername;
       MsgEscapeString(username, nsINetUtil::ESCAPE_XALPHAS, escapedUsername);
       // not all servers have a username
       uri.Append(escapedUsername);
@@ -675,12 +601,9 @@ nsSmtpServer::GetServerURIInternal(const
     // not all servers have a hostname
     uri.Append(escapedHostname);
   }
 
   return uri;
 }
 
 NS_IMETHODIMP
-nsSmtpServer::ClearAllValues()
-{
-  return mPrefBranch->DeleteBranch("");
-}
+nsSmtpServer::ClearAllValues() { return mPrefBranch->DeleteBranch(""); }
--- a/mailnews/compose/src/nsSmtpServer.h
+++ b/mailnews/compose/src/nsSmtpServer.h
@@ -1,44 +1,42 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef __nsSmtpServer_h_
 #define __nsSmtpServer_h_
 
-
 #include "nsString.h"
 #include "nsISmtpServer.h"
 #include "nsIPrefBranch.h"
 #include "nsWeakReference.h"
 #include "nsIObserver.h"
 
 class nsSmtpServer : public nsISmtpServer,
                      public nsSupportsWeakReference,
-                     public nsIObserver
-{
-public:
-    nsSmtpServer();
-    nsresult Init();
+                     public nsIObserver {
+ public:
+  nsSmtpServer();
+  nsresult Init();
 
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSISMTPSERVER
-    NS_DECL_NSIOBSERVER
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISMTPSERVER
+  NS_DECL_NSIOBSERVER
 
-private:
-    virtual ~nsSmtpServer();
-    nsCString mKey;
-    nsCOMPtr<nsIPrefBranch> mPrefBranch;
-    nsCOMPtr<nsIPrefBranch> mDefPrefBranch;
+ private:
+  virtual ~nsSmtpServer();
+  nsCString mKey;
+  nsCOMPtr<nsIPrefBranch> mPrefBranch;
+  nsCOMPtr<nsIPrefBranch> mDefPrefBranch;
 
-    nsresult getPrefs();
-    void getIntPrefWithDefault(const char *prefName, int32_t *val,
-                               int32_t defval);
-    nsresult GetPasswordWithoutUI();
-    nsCString GetServerURIInternal(const bool aIncludeUsername);
+  nsresult getPrefs();
+  void getIntPrefWithDefault(const char *prefName, int32_t *val,
+                             int32_t defval);
+  nsresult GetPasswordWithoutUI();
+  nsCString GetServerURIInternal(const bool aIncludeUsername);
 
-    nsString m_password;
-    bool m_logonFailed;
+  nsString m_password;
+  bool m_logonFailed;
 };
 
 #endif
--- a/mailnews/compose/src/nsSmtpService.cpp
+++ b/mailnews/compose/src/nsSmtpService.cpp
@@ -1,14 +1,14 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "msgCore.h"    // precompiled header...
+#include "msgCore.h"  // precompiled header...
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIIOService.h"
 #include "nsIPipe.h"
 #include "nsNetCID.h"
 #include "nsMsgUtils.h"
 #include "nsNetUtil.h"
 #include "nsSmtpService.h"
@@ -25,152 +25,131 @@
 #include "nsComposeStrings.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIPrincipal.h"
 
 #define SERVER_DELIMITER ','
 #define APPEND_SERVERS_VERSION_PREF_NAME "append_preconfig_smtpservers.version"
 #define MAIL_ROOT_PREF "mail."
 #define PREF_MAIL_SMTPSERVERS "mail.smtpservers"
-#define PREF_MAIL_SMTPSERVERS_APPEND_SERVERS "mail.smtpservers.appendsmtpservers"
+#define PREF_MAIL_SMTPSERVERS_APPEND_SERVERS \
+  "mail.smtpservers.appendsmtpservers"
 #define PREF_MAIL_SMTP_DEFAULTSERVER "mail.smtp.defaultserver"
 
 typedef struct _findServerByKeyEntry {
-    const char *key;
-    nsISmtpServer *server;
+  const char *key;
+  nsISmtpServer *server;
 } findServerByKeyEntry;
 
 typedef struct _findServerByHostnameEntry {
-    nsCString hostname;
-    nsCString username;
-    nsISmtpServer *server;
+  nsCString hostname;
+  nsCString username;
+  nsISmtpServer *server;
 } findServerByHostnameEntry;
 
 static NS_DEFINE_CID(kCSmtpUrlCID, NS_SMTPURL_CID);
 
 // forward declarations...
-nsresult
-NS_MsgBuildSmtpUrl(nsIFile * aFilePath,
-                   nsISmtpServer *aServer,
-                   const char* aRecipients,
-                   nsIMsgIdentity * aSenderIdentity,
-                   const char * aSender,
-                   nsIUrlListener * aUrlListener,
-                   nsIMsgStatusFeedback *aStatusFeedback,
-                   nsIInterfaceRequestor* aNotificationCallbacks,
-                   nsIURI ** aUrl,
-                   bool aRequestDSN);
+nsresult NS_MsgBuildSmtpUrl(nsIFile *aFilePath, nsISmtpServer *aServer,
+                            const char *aRecipients,
+                            nsIMsgIdentity *aSenderIdentity,
+                            const char *aSender, nsIUrlListener *aUrlListener,
+                            nsIMsgStatusFeedback *aStatusFeedback,
+                            nsIInterfaceRequestor *aNotificationCallbacks,
+                            nsIURI **aUrl, bool aRequestDSN);
 
-nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer, nsIRequest ** aRequest);
+nsresult NS_MsgLoadSmtpUrl(nsIURI *aUrl, nsISupports *aConsumer,
+                           nsIRequest **aRequest);
 
-nsSmtpService::nsSmtpService() :
-    mSmtpServersLoaded(false)
-{
-}
+nsSmtpService::nsSmtpService() : mSmtpServersLoaded(false) {}
 
-nsSmtpService::~nsSmtpService()
-{
-    // save the SMTP servers to disk
-
+nsSmtpService::~nsSmtpService() {
+  // save the SMTP servers to disk
 }
 
 NS_IMPL_ISUPPORTS(nsSmtpService, nsISmtpService, nsIProtocolHandler)
 
-
-NS_IMETHODIMP nsSmtpService::SendMailMessage(nsIFile * aFilePath,
-                                        const char * aRecipients,
-                                        nsIMsgIdentity * aSenderIdentity,
-                                        const char * aSender,
-                                        const nsAString & aPassword,
-                                        nsIUrlListener * aUrlListener,
-                                        nsIMsgStatusFeedback *aStatusFeedback,
-                                        nsIInterfaceRequestor* aNotificationCallbacks,
-                                        bool aRequestDSN,
-                                        nsIURI ** aURL,
-                                        nsIRequest ** aRequest)
-{
-  nsIURI * urlToRun = nullptr;
+NS_IMETHODIMP nsSmtpService::SendMailMessage(
+    nsIFile *aFilePath, const char *aRecipients,
+    nsIMsgIdentity *aSenderIdentity, const char *aSender,
+    const nsAString &aPassword, nsIUrlListener *aUrlListener,
+    nsIMsgStatusFeedback *aStatusFeedback,
+    nsIInterfaceRequestor *aNotificationCallbacks, bool aRequestDSN,
+    nsIURI **aURL, nsIRequest **aRequest) {
+  nsIURI *urlToRun = nullptr;
   nsresult rv = NS_OK;
 
   nsCOMPtr<nsISmtpServer> smtpServer;
   rv = GetServerByIdentity(aSenderIdentity, getter_AddRefs(smtpServer));
 
-  if (NS_SUCCEEDED(rv) && smtpServer)
-  {
-    if (!aPassword.IsEmpty())
-      smtpServer->SetPassword(aPassword);
+  if (NS_SUCCEEDED(rv) && smtpServer) {
+    if (!aPassword.IsEmpty()) smtpServer->SetPassword(aPassword);
 
     // this ref counts urlToRun
-    rv = NS_MsgBuildSmtpUrl(aFilePath, smtpServer, aRecipients, aSenderIdentity, aSender,
-                            aUrlListener, aStatusFeedback,
+    rv = NS_MsgBuildSmtpUrl(aFilePath, smtpServer, aRecipients, aSenderIdentity,
+                            aSender, aUrlListener, aStatusFeedback,
                             aNotificationCallbacks, &urlToRun, aRequestDSN);
     if (NS_SUCCEEDED(rv) && urlToRun)
       rv = NS_MsgLoadSmtpUrl(urlToRun, nullptr, aRequest);
 
-    if (aURL) // does the caller want a handle on the url?
-      *aURL = urlToRun; // transfer our ref count to the caller....
+    if (aURL)            // does the caller want a handle on the url?
+      *aURL = urlToRun;  // transfer our ref count to the caller....
     else
       NS_IF_RELEASE(urlToRun);
   }
 
   return rv;
 }
 
-
-// The following are two convenience functions I'm using to help expedite building and running a mail to url...
+// The following are two convenience functions I'm using to help expedite
+// building and running a mail to url...
 
 // short cut function for creating a mailto url...
-nsresult NS_MsgBuildSmtpUrl(nsIFile * aFilePath,
-                            nsISmtpServer *aSmtpServer,
-                            const char * aRecipients,
-                            nsIMsgIdentity * aSenderIdentity,
-                            const char * aSender,
-                            nsIUrlListener * aUrlListener,
+nsresult NS_MsgBuildSmtpUrl(nsIFile *aFilePath, nsISmtpServer *aSmtpServer,
+                            const char *aRecipients,
+                            nsIMsgIdentity *aSenderIdentity,
+                            const char *aSender, nsIUrlListener *aUrlListener,
                             nsIMsgStatusFeedback *aStatusFeedback,
-                            nsIInterfaceRequestor* aNotificationCallbacks,
-                            nsIURI ** aUrl,
-                            bool aRequestDSN)
-{
-  // mscott: this function is a convenience hack until netlib actually dispatches
-  // smtp urls. in addition until we have a session to get a password, host and
-  // other stuff from, we need to use default values....
+                            nsIInterfaceRequestor *aNotificationCallbacks,
+                            nsIURI **aUrl, bool aRequestDSN) {
+  // mscott: this function is a convenience hack until netlib actually
+  // dispatches smtp urls. in addition until we have a session to get a
+  // password, host and other stuff from, we need to use default values....
   // ..for testing purposes....
 
-    nsCString smtpHostName;
-    nsCString smtpUserName;
-    int32_t smtpPort;
-    int32_t socketType;
+  nsCString smtpHostName;
+  nsCString smtpUserName;
+  int32_t smtpPort;
+  int32_t socketType;
 
-    aSmtpServer->GetHostname(smtpHostName);
-    aSmtpServer->GetUsername(smtpUserName);
-    aSmtpServer->GetPort(&smtpPort);
-    aSmtpServer->GetSocketType(&socketType);
+  aSmtpServer->GetHostname(smtpHostName);
+  aSmtpServer->GetUsername(smtpUserName);
+  aSmtpServer->GetPort(&smtpPort);
+  aSmtpServer->GetSocketType(&socketType);
 
-    if (!smtpPort)
-      smtpPort = (socketType == nsMsgSocketType::SSL) ?
-        nsISmtpUrl::DEFAULT_SMTPS_PORT :  nsISmtpUrl::DEFAULT_SMTP_PORT;
+  if (!smtpPort)
+    smtpPort = (socketType == nsMsgSocketType::SSL)
+                   ? nsISmtpUrl::DEFAULT_SMTPS_PORT
+                   : nsISmtpUrl::DEFAULT_SMTP_PORT;
 
   nsresult rv;
   nsCOMPtr<nsISmtpUrl> smtpUrl(do_CreateInstance(kCSmtpUrlCID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString urlSpec("smtp://");
 
-  if (!smtpUserName.IsEmpty())
-  {
+  if (!smtpUserName.IsEmpty()) {
     nsCString escapedUsername;
-    MsgEscapeString(smtpUserName, nsINetUtil::ESCAPE_XALPHAS,
-                    escapedUsername);
+    MsgEscapeString(smtpUserName, nsINetUtil::ESCAPE_XALPHAS, escapedUsername);
     urlSpec.Append(escapedUsername);
     urlSpec.Append('@');
   }
 
   urlSpec.Append(smtpHostName);
-  if (smtpHostName.FindChar(':') == -1)
-  {
+  if (smtpHostName.FindChar(':') == -1) {
     urlSpec.Append(':');
     urlSpec.AppendInt(smtpPort);
   }
 
   nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl(do_QueryInterface(smtpUrl, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mailnewsurl->SetSpecInternal(urlSpec);
@@ -181,258 +160,241 @@ nsresult NS_MsgBuildSmtpUrl(nsIFile * aF
   smtpUrl->SetRequestDSN(aRequestDSN);
   smtpUrl->SetPostMessageFile(aFilePath);
   smtpUrl->SetSenderIdentity(aSenderIdentity);
   if (aNotificationCallbacks)
     smtpUrl->SetNotificationCallbacks(aNotificationCallbacks);
   smtpUrl->SetSmtpServer(aSmtpServer);
 
   nsCOMPtr<nsIPrompt> smtpPrompt(do_GetInterface(aNotificationCallbacks));
-  nsCOMPtr<nsIAuthPrompt> smtpAuthPrompt(do_GetInterface(aNotificationCallbacks));
-  if (!smtpPrompt || !smtpAuthPrompt)
-  {
-    nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
+  nsCOMPtr<nsIAuthPrompt> smtpAuthPrompt(
+      do_GetInterface(aNotificationCallbacks));
+  if (!smtpPrompt || !smtpAuthPrompt) {
+    nsCOMPtr<nsIWindowWatcher> wwatch(
+        do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    if (!smtpPrompt)
-      wwatch->GetNewPrompter(0, getter_AddRefs(smtpPrompt));
+    if (!smtpPrompt) wwatch->GetNewPrompter(0, getter_AddRefs(smtpPrompt));
     if (!smtpAuthPrompt)
       wwatch->GetNewAuthPrompter(0, getter_AddRefs(smtpAuthPrompt));
   }
 
   smtpUrl->SetPrompt(smtpPrompt);
   smtpUrl->SetAuthPrompt(smtpAuthPrompt);
 
-  if (aUrlListener)
-    mailnewsurl->RegisterListener(aUrlListener);
-  if (aStatusFeedback)
-    mailnewsurl->SetStatusFeedback(aStatusFeedback);
+  if (aUrlListener) mailnewsurl->RegisterListener(aUrlListener);
+  if (aStatusFeedback) mailnewsurl->SetStatusFeedback(aStatusFeedback);
 
   return CallQueryInterface(smtpUrl, aUrl);
 }
 
-nsresult NS_MsgLoadSmtpUrl(nsIURI * aUrl, nsISupports * aConsumer, nsIRequest ** aRequest)
-{
+nsresult NS_MsgLoadSmtpUrl(nsIURI *aUrl, nsISupports *aConsumer,
+                           nsIRequest **aRequest) {
   NS_ENSURE_ARG_POINTER(aUrl);
 
   // For now, assume the url is an smtp url and load it.
   nsresult rv;
   nsCOMPtr<nsISmtpUrl> smtpUrl(do_QueryInterface(aUrl, &rv));
   mozilla::Unused << smtpUrl;
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Create a smtp protocol instance to run the url in.
   RefPtr<nsSmtpProtocol> smtpProtocol = new nsSmtpProtocol(aUrl);
-  if (!smtpProtocol)
-    return NS_ERROR_OUT_OF_MEMORY;
+  if (!smtpProtocol) return NS_ERROR_OUT_OF_MEMORY;
 
   // Protocol will get destroyed when url is completed.
   rv = smtpProtocol->LoadUrl(aUrl, aConsumer);
   NS_ENSURE_SUCCESS(rv, rv);
 
   smtpProtocol.forget(aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsSmtpService::VerifyLogon(nsISmtpServer *aServer,
                                          nsIUrlListener *aUrlListener,
                                          nsIMsgWindow *aMsgWindow,
-                                         nsIURI **aURL)
-{
+                                         nsIURI **aURL) {
   NS_ENSURE_ARG_POINTER(aServer);
   nsCString popHost;
   nsCString popUser;
-  nsCOMPtr <nsIURI> urlToRun;
+  nsCOMPtr<nsIURI> urlToRun;
 
-  nsresult rv = NS_MsgBuildSmtpUrl(nullptr, aServer,
-                          nullptr, nullptr, nullptr, aUrlListener, nullptr,
-                          nullptr , getter_AddRefs(urlToRun), false);
-  if (NS_SUCCEEDED(rv) && urlToRun)
-  {
+  nsresult rv = NS_MsgBuildSmtpUrl(nullptr, aServer, nullptr, nullptr, nullptr,
+                                   aUrlListener, nullptr, nullptr,
+                                   getter_AddRefs(urlToRun), false);
+  if (NS_SUCCEEDED(rv) && urlToRun) {
     nsCOMPtr<nsIMsgMailNewsUrl> url(do_QueryInterface(urlToRun, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     url->SetMsgWindow(aMsgWindow);
     rv = NS_MsgLoadSmtpUrl(urlToRun, nullptr, nullptr /* aRequest */);
-    if (aURL)
-      urlToRun.forget(aURL);
+    if (aURL) urlToRun.forget(aURL);
   }
   return rv;
 }
 
-NS_IMETHODIMP nsSmtpService::GetScheme(nsACString &aScheme)
-{
-    aScheme = "mailto";
-    return NS_OK;
+NS_IMETHODIMP nsSmtpService::GetScheme(nsACString &aScheme) {
+  aScheme = "mailto";
+  return NS_OK;
 }
 
-NS_IMETHODIMP nsSmtpService::GetDefaultPort(int32_t *aDefaultPort)
-{
-    nsresult rv = NS_OK;
-    if (aDefaultPort)
-        *aDefaultPort = nsISmtpUrl::DEFAULT_SMTP_PORT;
-    else
-        rv = NS_ERROR_NULL_POINTER;
-    return rv;
+NS_IMETHODIMP nsSmtpService::GetDefaultPort(int32_t *aDefaultPort) {
+  nsresult rv = NS_OK;
+  if (aDefaultPort)
+    *aDefaultPort = nsISmtpUrl::DEFAULT_SMTP_PORT;
+  else
+    rv = NS_ERROR_NULL_POINTER;
+  return rv;
 }
 
 NS_IMETHODIMP
-nsSmtpService::AllowPort(int32_t port, const char *scheme, bool *_retval)
-{
-    // allow smtp to run on any port
-    *_retval = true;
-    return NS_OK;
+nsSmtpService::AllowPort(int32_t port, const char *scheme, bool *_retval) {
+  // allow smtp to run on any port
+  *_retval = true;
+  return NS_OK;
 }
 
-NS_IMETHODIMP nsSmtpService::GetProtocolFlags(uint32_t *result)
-{
-    *result = URI_NORELATIVE | ALLOWS_PROXY | URI_LOADABLE_BY_ANYONE |
-      URI_NON_PERSISTABLE | URI_DOES_NOT_RETURN_DATA |
-      URI_FORBIDS_COOKIE_ACCESS;
-    return NS_OK;
+NS_IMETHODIMP nsSmtpService::GetProtocolFlags(uint32_t *result) {
+  *result = URI_NORELATIVE | ALLOWS_PROXY | URI_LOADABLE_BY_ANYONE |
+            URI_NON_PERSISTABLE | URI_DOES_NOT_RETURN_DATA |
+            URI_FORBIDS_COOKIE_ACCESS;
+  return NS_OK;
 }
 
 // the smtp service is also the protocol handler for mailto urls....
 
-NS_IMETHODIMP nsSmtpService::NewURI(const nsACString &aSpec,
-                                    const char *aOriginCharset,  // ignored, always UTF-8.
-                                    nsIURI *aBaseURI,
-                                    nsIURI **_retval)
-{
+NS_IMETHODIMP nsSmtpService::NewURI(
+    const nsACString &aSpec,
+    const char *aOriginCharset,  // ignored, always UTF-8.
+    nsIURI *aBaseURI, nsIURI **_retval) {
   // get a new smtp url
   nsresult rv;
 
   nsCOMPtr<nsIURI> mailtoUrl;
   rv = NS_MutateURI(new nsMailtoUrl::Mutator())
-         .SetSpec(aSpec)
-         .Finalize(mailtoUrl);
+           .SetSpec(aSpec)
+           .Finalize(mailtoUrl);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mailtoUrl.forget(_retval);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSmtpService::NewChannel(nsIURI *aURI,
-                                        nsILoadInfo* aLoadInfo,
-                                        nsIChannel **_retval)
-{
+NS_IMETHODIMP nsSmtpService::NewChannel(nsIURI *aURI, nsILoadInfo *aLoadInfo,
+                                        nsIChannel **_retval) {
   NS_ENSURE_ARG_POINTER(aURI);
   // create an empty pipe for use with the input stream channel.
   nsCOMPtr<nsIAsyncInputStream> pipeIn;
   nsCOMPtr<nsIAsyncOutputStream> pipeOut;
   nsCOMPtr<nsIPipe> pipe = do_CreateInstance("@mozilla.org/pipe;1");
   nsresult rv = pipe->Init(false, false, 0, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // These always succeed because the pipe is initialized above.
   MOZ_ALWAYS_SUCCEEDS(pipe->GetInputStream(getter_AddRefs(pipeIn)));
   MOZ_ALWAYS_SUCCEEDS(pipe->GetOutputStream(getter_AddRefs(pipeOut)));
 
   pipeOut->Close();
 
   if (aLoadInfo) {
-    return NS_NewInputStreamChannelInternal(_retval,
-                                            aURI,
-                                            pipeIn.forget(),
-                                            NS_LITERAL_CSTRING("application/x-mailto"),
-                                            EmptyCString(),
-                                            aLoadInfo);
+    return NS_NewInputStreamChannelInternal(
+        _retval, aURI, pipeIn.forget(),
+        NS_LITERAL_CSTRING("application/x-mailto"), EmptyCString(), aLoadInfo);
   }
 
   nsCOMPtr<nsIPrincipal> nullPrincipal =
-    do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
+      do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
   NS_ASSERTION(NS_SUCCEEDED(rv), "CreateInstance of nullprincipal failed.");
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
-  return NS_NewInputStreamChannel(_retval,
-                                  aURI,
-                                  pipeIn.forget(),
-                                  nullPrincipal,
-                                  nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                                  nsIContentPolicy::TYPE_OTHER,
-                                  NS_LITERAL_CSTRING("application/x-mailto"));
+  return NS_NewInputStreamChannel(
+      _retval, aURI, pipeIn.forget(), nullPrincipal,
+      nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+      nsIContentPolicy::TYPE_OTHER, NS_LITERAL_CSTRING("application/x-mailto"));
 }
 
 NS_IMETHODIMP
-nsSmtpService::GetServers(nsISimpleEnumerator **aResult)
-{
+nsSmtpService::GetServers(nsISimpleEnumerator **aResult) {
   NS_ENSURE_ARG_POINTER(aResult);
 
   // now read in the servers from prefs if necessary
   uint32_t serverCount = mSmtpServers.Count();
 
-  if (serverCount <= 0)
-    loadSmtpServers();
+  if (serverCount <= 0) loadSmtpServers();
 
-  return NS_NewArrayEnumerator(aResult, mSmtpServers, NS_GET_IID(nsISmtpServer));
+  return NS_NewArrayEnumerator(aResult, mSmtpServers,
+                               NS_GET_IID(nsISmtpServer));
 }
 
-nsresult
-nsSmtpService::loadSmtpServers()
-{
-  if (mSmtpServersLoaded)
-    return NS_OK;
+nsresult nsSmtpService::loadSmtpServers() {
+  if (mSmtpServersLoaded) return NS_OK;
 
   nsresult rv;
-  nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-  if (NS_FAILED(rv))
-    return rv;
+  nsCOMPtr<nsIPrefService> prefService(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) return rv;
   nsCOMPtr<nsIPrefBranch> prefRootBranch;
   prefService->GetBranch(nullptr, getter_AddRefs(prefRootBranch));
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
   nsCString serverList;
   rv = prefRootBranch->GetCharPref(PREF_MAIL_SMTPSERVERS, serverList);
   serverList.StripWhitespace();
 
   nsTArray<nsCString> servers;
   ParseString(serverList, SERVER_DELIMITER, servers);
 
   /**
    * Check to see if we need to add pre-configured smtp servers.
    * Following prefs are important to note in understanding the procedure here.
    *
    * 1. pref("mailnews.append_preconfig_smtpservers.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
-   * smtp servers, 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 smtp servers 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 smtp servers, 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 smtp servers and any other version level
+   * changes that need to be done.
    *
-   * 2. pref("mail.smtpservers.appendsmtpservers", <comma separated servers list>);
-   * This pref contains the list of pre-configured smp servers that ISP/Vendor wants to
-   * to add to the existing servers list.
+   * 2. pref("mail.smtpservers.appendsmtpservers",
+   *         <comma separated servers list>);
+   * This pref contains the list of pre-configured smp servers that
+   * ISP/Vendor wants to to add to the existing servers list.
    */
   nsCOMPtr<nsIPrefBranch> defaultsPrefBranch;
-  rv = prefService->GetDefaultBranch(MAIL_ROOT_PREF, getter_AddRefs(defaultsPrefBranch));
+  rv = prefService->GetDefaultBranch(MAIL_ROOT_PREF,
+                                     getter_AddRefs(defaultsPrefBranch));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrefBranch> prefBranch;
   rv = prefService->GetBranch(MAIL_ROOT_PREF, getter_AddRefs(prefBranch));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   int32_t appendSmtpServersCurrentVersion = 0;
   int32_t appendSmtpServersDefaultVersion = 0;
-  rv = prefBranch->GetIntPref(APPEND_SERVERS_VERSION_PREF_NAME, &appendSmtpServersCurrentVersion);
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = prefBranch->GetIntPref(APPEND_SERVERS_VERSION_PREF_NAME,
+                              &appendSmtpServersCurrentVersion);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = defaultsPrefBranch->GetIntPref(APPEND_SERVERS_VERSION_PREF_NAME, &appendSmtpServersDefaultVersion);
-  NS_ENSURE_SUCCESS(rv,rv);
+  rv = defaultsPrefBranch->GetIntPref(APPEND_SERVERS_VERSION_PREF_NAME,
+                                      &appendSmtpServersDefaultVersion);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // Update the smtp server list if needed
   if (appendSmtpServersCurrentVersion <= appendSmtpServersDefaultVersion) {
     // If there are pre-configured servers, add them to the existing server list
     nsCString appendServerList;
-    rv = prefRootBranch->GetCharPref(PREF_MAIL_SMTPSERVERS_APPEND_SERVERS, appendServerList);
+    rv = prefRootBranch->GetCharPref(PREF_MAIL_SMTPSERVERS_APPEND_SERVERS,
+                                     appendServerList);
     appendServerList.StripWhitespace();
     ParseString(appendServerList, SERVER_DELIMITER, servers);
 
-    // Increase the version number so that updates will happen as and when needed
-    prefBranch->SetIntPref(APPEND_SERVERS_VERSION_PREF_NAME, appendSmtpServersCurrentVersion + 1);
+    // Increase the version number so that updates will happen as and when
+    // needed
+    prefBranch->SetIntPref(APPEND_SERVERS_VERSION_PREF_NAME,
+                           appendSmtpServersCurrentVersion + 1);
   }
 
   // use GetServerByKey to check if the key (pref) is already in
   // in the list. If not it calls createKeyedServer directly.
 
   for (uint32_t i = 0; i < servers.Length(); i++) {
     nsCOMPtr<nsISmtpServer> server;
     GetServerByKey(servers[i].get(), getter_AddRefs(server));
@@ -440,324 +402,295 @@ nsSmtpService::loadSmtpServers()
 
   saveKeyList();
 
   mSmtpServersLoaded = true;
   return NS_OK;
 }
 
 // save the list of keys
-nsresult
-nsSmtpService::saveKeyList()
-{
-    nsresult rv;
-    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-    if (NS_FAILED(rv)) return rv;
+nsresult nsSmtpService::saveKeyList() {
+  nsresult rv;
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  if (NS_FAILED(rv)) return rv;
 
-    return prefBranch->SetCharPref(PREF_MAIL_SMTPSERVERS, mServerKeyList);
+  return prefBranch->SetCharPref(PREF_MAIL_SMTPSERVERS, mServerKeyList);
 }
 
-nsresult
-nsSmtpService::createKeyedServer(const char *key, nsISmtpServer** aResult)
-{
-    if (!key) return NS_ERROR_NULL_POINTER;
+nsresult nsSmtpService::createKeyedServer(const char *key,
+                                          nsISmtpServer **aResult) {
+  if (!key) return NS_ERROR_NULL_POINTER;
 
-    nsresult rv;
-    nsCOMPtr<nsISmtpServer> server = do_CreateInstance(NS_SMTPSERVER_CONTRACTID, &rv);
-    if (NS_FAILED(rv)) return rv;
-
-    server->SetKey(key);
-    mSmtpServers.AppendObject(server);
+  nsresult rv;
+  nsCOMPtr<nsISmtpServer> server =
+      do_CreateInstance(NS_SMTPSERVER_CONTRACTID, &rv);
+  if (NS_FAILED(rv)) return rv;
 
-    if (mServerKeyList.IsEmpty())
-        mServerKeyList = key;
-    else {
-        mServerKeyList.Append(',');
-        mServerKeyList += key;
-    }
+  server->SetKey(key);
+  mSmtpServers.AppendObject(server);
 
-    if (aResult)
-       server.forget(aResult);
+  if (mServerKeyList.IsEmpty())
+    mServerKeyList = key;
+  else {
+    mServerKeyList.Append(',');
+    mServerKeyList += key;
+  }
 
-    return NS_OK;
+  if (aResult) server.forget(aResult);
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpService::GetSessionDefaultServer(nsISmtpServer **aServer)
-{
-    NS_ENSURE_ARG_POINTER(aServer);
+nsSmtpService::GetSessionDefaultServer(nsISmtpServer **aServer) {
+  NS_ENSURE_ARG_POINTER(aServer);
 
-    if (!mSessionDefaultServer)
-        return GetDefaultServer(aServer);
+  if (!mSessionDefaultServer) return GetDefaultServer(aServer);
 
-    NS_ADDREF(*aServer = mSessionDefaultServer);
-    return NS_OK;
+  NS_ADDREF(*aServer = mSessionDefaultServer);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpService::SetSessionDefaultServer(nsISmtpServer *aServer)
-{
-    mSessionDefaultServer = aServer;
-    return NS_OK;
+nsSmtpService::SetSessionDefaultServer(nsISmtpServer *aServer) {
+  mSessionDefaultServer = aServer;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpService::GetDefaultServer(nsISmtpServer **aServer)
-{
+nsSmtpService::GetDefaultServer(nsISmtpServer **aServer) {
   NS_ENSURE_ARG_POINTER(aServer);
 
   loadSmtpServers();
 
   *aServer = nullptr;
   // always returns NS_OK, just leaving *aServer at nullptr
   if (!mDefaultSmtpServer) {
-      nsresult rv;
-      nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-      if (NS_FAILED(rv)) return rv;
+    nsresult rv;
+    nsCOMPtr<nsIPrefBranch> prefBranch(
+        do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+    if (NS_FAILED(rv)) return rv;
 
-      // try to get it from the prefs
-      nsCString defaultServerKey;
-      rv = prefBranch->GetCharPref(PREF_MAIL_SMTP_DEFAULTSERVER, defaultServerKey);
-      if (NS_SUCCEEDED(rv) &&
-          !defaultServerKey.IsEmpty()) {
-
-          nsCOMPtr<nsISmtpServer> server;
-          rv = GetServerByKey(defaultServerKey.get(),
-                              getter_AddRefs(mDefaultSmtpServer));
-      } else {
-        // no pref set, so just return the first one, and set the pref
+    // try to get it from the prefs
+    nsCString defaultServerKey;
+    rv =
+        prefBranch->GetCharPref(PREF_MAIL_SMTP_DEFAULTSERVER, defaultServerKey);
+    if (NS_SUCCEEDED(rv) && !defaultServerKey.IsEmpty()) {
+      nsCOMPtr<nsISmtpServer> server;
+      rv = GetServerByKey(defaultServerKey.get(),
+                          getter_AddRefs(mDefaultSmtpServer));
+    } else {
+      // no pref set, so just return the first one, and set the pref
 
-        // Ensure the list of servers is loaded
-        loadSmtpServers();
+      // Ensure the list of servers is loaded
+      loadSmtpServers();
 
-        // nothing in the array, we had better create a new server
-        // (which will add it to the array & prefs anyway)
-        if (mSmtpServers.Count() == 0)
-          // if there are no smtp servers then don't create one for the default.
-          return NS_OK;
+      // nothing in the array, we had better create a new server
+      // (which will add it to the array & prefs anyway)
+      if (mSmtpServers.Count() == 0)
+        // if there are no smtp servers then don't create one for the default.
+        return NS_OK;
 
-        mDefaultSmtpServer = mSmtpServers[0];
-        NS_ENSURE_TRUE(mDefaultSmtpServer, NS_ERROR_NULL_POINTER);
+      mDefaultSmtpServer = mSmtpServers[0];
+      NS_ENSURE_TRUE(mDefaultSmtpServer, NS_ERROR_NULL_POINTER);
 
-        // now we have a default server, set the prefs correctly
-        nsCString serverKey;
-        mDefaultSmtpServer->GetKey(getter_Copies(serverKey));
-        if (NS_SUCCEEDED(rv))
-          prefBranch->SetCharPref(PREF_MAIL_SMTP_DEFAULTSERVER, serverKey);
-      }
+      // now we have a default server, set the prefs correctly
+      nsCString serverKey;
+      mDefaultSmtpServer->GetKey(getter_Copies(serverKey));
+      if (NS_SUCCEEDED(rv))
+        prefBranch->SetCharPref(PREF_MAIL_SMTP_DEFAULTSERVER, serverKey);
+    }
   }
 
   // at this point:
   // * mDefaultSmtpServer has a valid server
   // * the key has been set in the prefs
 
   NS_IF_ADDREF(*aServer = mDefaultSmtpServer);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpService::SetDefaultServer(nsISmtpServer *aServer)
-{
-    NS_ENSURE_ARG_POINTER(aServer);
+nsSmtpService::SetDefaultServer(nsISmtpServer *aServer) {
+  NS_ENSURE_ARG_POINTER(aServer);
 
-    mDefaultSmtpServer = aServer;
+  mDefaultSmtpServer = aServer;
 
-    nsCString serverKey;
-    nsresult rv = aServer->GetKey(getter_Copies(serverKey));
-    NS_ENSURE_SUCCESS(rv,rv);
+  nsCString serverKey;
+  nsresult rv = aServer->GetKey(getter_Copies(serverKey));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
-    NS_ENSURE_SUCCESS(rv,rv);
-    prefBranch->SetCharPref(PREF_MAIL_SMTP_DEFAULTSERVER, serverKey);
-    return NS_OK;
+  nsCOMPtr<nsIPrefBranch> prefBranch(
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  NS_ENSURE_SUCCESS(rv, rv);
+  prefBranch->SetCharPref(PREF_MAIL_SMTP_DEFAULTSERVER, serverKey);
+  return NS_OK;
 }
 
-bool
-nsSmtpService::findServerByKey(nsISmtpServer *aServer, void *aData)
-{
-  findServerByKeyEntry *entry = (findServerByKeyEntry*) aData;
+bool nsSmtpService::findServerByKey(nsISmtpServer *aServer, void *aData) {
+  findServerByKeyEntry *entry = (findServerByKeyEntry *)aData;
 
   nsCString key;
   nsresult rv = aServer->GetKey(getter_Copies(key));
-  if (NS_FAILED(rv))
-    return true;
+  if (NS_FAILED(rv)) return true;
 
-  if (key.Equals(entry->key))
-  {
+  if (key.Equals(entry->key)) {
     entry->server = aServer;
     return false;
   }
 
   return true;
 }
 
 NS_IMETHODIMP
-nsSmtpService::CreateServer(nsISmtpServer **aResult)
-{
-    if (!aResult) return NS_ERROR_NULL_POINTER;
+nsSmtpService::CreateServer(nsISmtpServer **aResult) {
+  if (!aResult) return NS_ERROR_NULL_POINTER;
 
-    loadSmtpServers();
-    nsresult rv;
-    int32_t i = 0;
-    bool unique = false;
+  loadSmtpServers();
+  nsresult rv;
+  int32_t i = 0;
+  bool unique = false;
 
-    findServerByKeyEntry entry;
-    nsAutoCString key;
+  findServerByKeyEntry entry;
+  nsAutoCString key;
 
-    do {
-        key = "smtp";
-        key.AppendInt(++i);
-        entry.key = key.get();
-        entry.server = nullptr;
+  do {
+    key = "smtp";
+    key.AppendInt(++i);
+    entry.key = key.get();
+    entry.server = nullptr;
 
-        for (nsISmtpServer* s : mSmtpServers)
-          findServerByKey(s, (void *)&entry);
-        if (!entry.server) unique=true;
+    for (nsISmtpServer *s : mSmtpServers) findServerByKey(s, (void *)&entry);
+    if (!entry.server) unique = true;
 
-    } while (!unique);
+  } while (!unique);
 
-    rv = createKeyedServer(key.get(), aResult);
-    NS_ENSURE_SUCCESS(rv, rv);
-    return saveKeyList();
+  rv = createKeyedServer(key.get(), aResult);
+  NS_ENSURE_SUCCESS(rv, rv);
+  return saveKeyList();
 }
 
-
-nsresult
-nsSmtpService::GetServerByKey(const char* aKey, nsISmtpServer **aResult)
-{
-    NS_ENSURE_ARG_POINTER(aResult);
+nsresult nsSmtpService::GetServerByKey(const char *aKey,
+                                       nsISmtpServer **aResult) {
+  NS_ENSURE_ARG_POINTER(aResult);
 
-    if (!aKey || !*aKey)
-    {
-      NS_ASSERTION(false, "bad key");
-      return NS_ERROR_FAILURE;
-    }
-    findServerByKeyEntry entry;
-    entry.key = aKey;
-    entry.server = nullptr;
-    for (nsISmtpServer* s : mSmtpServers)
-      findServerByKey(s, (void *)&entry);
+  if (!aKey || !*aKey) {
+    NS_ASSERTION(false, "bad key");
+    return NS_ERROR_FAILURE;
+  }
+  findServerByKeyEntry entry;
+  entry.key = aKey;
+  entry.server = nullptr;
+  for (nsISmtpServer *s : mSmtpServers) findServerByKey(s, (void *)&entry);
 
-    if (entry.server) {
-        NS_ADDREF(*aResult = entry.server);
-        return NS_OK;
-    }
+  if (entry.server) {
+    NS_ADDREF(*aResult = entry.server);
+    return NS_OK;
+  }
 
-    // not found in array, I guess we load it
-    return createKeyedServer(aKey, aResult);
+  // not found in array, I guess we load it
+  return createKeyedServer(aKey, aResult);
 }
 
 NS_IMETHODIMP
-nsSmtpService::DeleteServer(nsISmtpServer *aServer)
-{
-    if (!aServer) return NS_OK;
+nsSmtpService::DeleteServer(nsISmtpServer *aServer) {
+  if (!aServer) return NS_OK;
 
-    int32_t idx = mSmtpServers.IndexOf(aServer);
-    if (idx == -1)
-      return NS_OK;
+  int32_t idx = mSmtpServers.IndexOf(aServer);
+  if (idx == -1) return NS_OK;
 
-    nsCString serverKey;
-    aServer->GetKey(getter_Copies(serverKey));
-
-    mSmtpServers.RemoveObjectAt(idx);
+  nsCString serverKey;
+  aServer->GetKey(getter_Copies(serverKey));
 
-    if (mDefaultSmtpServer.get() == aServer)
-        mDefaultSmtpServer = nullptr;
-    if (mSessionDefaultServer.get() == aServer)
-        mSessionDefaultServer = nullptr;
+  mSmtpServers.RemoveObjectAt(idx);
+
+  if (mDefaultSmtpServer.get() == aServer) mDefaultSmtpServer = nullptr;
+  if (mSessionDefaultServer.get() == aServer) mSessionDefaultServer = nullptr;
 
-    nsAutoCString newServerList;
-    nsCString tmpStr = mServerKeyList;
-    char *newStr = tmpStr.BeginWriting();
-    char *token = NS_strtok(",", &newStr);
-    while (token) {
-      // only re-add the string if it's not the key
-      if (strcmp(token, serverKey.get()) != 0) {
-          if (newServerList.IsEmpty())
-              newServerList = token;
-          else {
-            newServerList += ',';
-            newServerList += token;
-          }
+  nsAutoCString newServerList;
+  nsCString tmpStr = mServerKeyList;
+  char *newStr = tmpStr.BeginWriting();
+  char *token = NS_strtok(",", &newStr);
+  while (token) {
+    // only re-add the string if it's not the key
+    if (strcmp(token, serverKey.get()) != 0) {
+      if (newServerList.IsEmpty())
+        newServerList = token;
+      else {
+        newServerList += ',';
+        newServerList += token;
       }
-      token = NS_strtok(",", &newStr);
     }
+    token = NS_strtok(",", &newStr);
+  }
 
-    // make sure the server clears out it's values....
-    aServer->ClearAllValues();
+  // make sure the server clears out it's values....
+  aServer->ClearAllValues();
 
-    mServerKeyList = newServerList;
-    saveKeyList();
-    return NS_OK;
+  mServerKeyList = newServerList;
+  saveKeyList();
+  return NS_OK;
 }
 
-bool
-nsSmtpService::findServerByHostname(nsISmtpServer *aServer, void *aData)
-{
-  findServerByHostnameEntry *entry = (findServerByHostnameEntry*)aData;
+bool nsSmtpService::findServerByHostname(nsISmtpServer *aServer, void *aData) {
+  findServerByHostnameEntry *entry = (findServerByHostnameEntry *)aData;
 
   nsCString hostname;
   nsresult rv = aServer->GetHostname(hostname);
-  if (NS_FAILED(rv))
-    return true;
+  if (NS_FAILED(rv)) return true;
 
   nsCString username;
   rv = aServer->GetUsername(username);
-  if (NS_FAILED(rv))
-    return true;
+  if (NS_FAILED(rv)) return true;
 
   bool checkHostname = !entry->hostname.IsEmpty();
   bool checkUsername = !entry->username.IsEmpty();
 
   if ((!checkHostname ||
-       (entry->hostname.Equals(hostname, nsCaseInsensitiveCStringComparator()))) &&
-       (!checkUsername ||
-        entry->username.Equals(username, nsCaseInsensitiveCStringComparator())))
-  {
+       (entry->hostname.Equals(hostname,
+                               nsCaseInsensitiveCStringComparator()))) &&
+      (!checkUsername || entry->username.Equals(
+                             username, nsCaseInsensitiveCStringComparator()))) {
     entry->server = aServer;
-    return false;        // stop when found
+    return false;  // stop when found
   }
   return true;
 }
 
 NS_IMETHODIMP
-nsSmtpService::FindServer(const char *aUsername,
-                          const char *aHostname, nsISmtpServer ** aResult)
-{
-    NS_ENSURE_ARG_POINTER(aResult);
+nsSmtpService::FindServer(const char *aUsername, const char *aHostname,
+                          nsISmtpServer **aResult) {
+  NS_ENSURE_ARG_POINTER(aResult);
 
-    findServerByHostnameEntry entry;
-    entry.server = nullptr;
-    entry.hostname = aHostname;
-    entry.username = aUsername;
+  findServerByHostnameEntry entry;
+  entry.server = nullptr;
+  entry.hostname = aHostname;
+  entry.username = aUsername;
 
-    for (nsISmtpServer* s : mSmtpServers)
-      findServerByHostname(s, (void *)&entry);
+  for (nsISmtpServer *s : mSmtpServers) findServerByHostname(s, (void *)&entry);
 
-    // entry.server may be null, but that's ok.
-    // just return null if no server is found
-    NS_IF_ADDREF(*aResult = entry.server);
+  // entry.server may be null, but that's ok.
+  // just return null if no server is found
+  NS_IF_ADDREF(*aResult = entry.server);
 
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSmtpService::GetServerByIdentity(nsIMsgIdentity *aSenderIdentity,
-                                   nsISmtpServer **aSmtpServer)
-{
+                                   nsISmtpServer **aSmtpServer) {
   NS_ENSURE_ARG_POINTER(aSmtpServer);
   nsresult rv = NS_ERROR_FAILURE;
 
   // First try the identity's preferred server
-  if (aSenderIdentity)
-  {
-      nsCString smtpServerKey;
-      rv = aSenderIdentity->GetSmtpServerKey(smtpServerKey);
-      if (NS_SUCCEEDED(rv) && !(smtpServerKey.IsEmpty()))
-          rv = GetServerByKey(smtpServerKey.get(), aSmtpServer);
+  if (aSenderIdentity) {
+    nsCString smtpServerKey;
+    rv = aSenderIdentity->GetSmtpServerKey(smtpServerKey);
+    if (NS_SUCCEEDED(rv) && !(smtpServerKey.IsEmpty()))
+      rv = GetServerByKey(smtpServerKey.get(), aSmtpServer);
   }
 
   // Fallback to the default
-  if (NS_FAILED(rv) || !(*aSmtpServer))
-      rv = GetDefaultServer(aSmtpServer);
+  if (NS_FAILED(rv) || !(*aSmtpServer)) rv = GetDefaultServer(aSmtpServer);
   return rv;
 }
--- a/mailnews/compose/src/nsSmtpService.h
+++ b/mailnews/compose/src/nsSmtpService.h
@@ -9,55 +9,52 @@
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsISmtpService.h"
 #include "nsISmtpServer.h"
 #include "nsIProtocolHandler.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////
-// The Smtp Service is an interfaced designed to make building and running mail to urls
-// easier. I'm not sure if this service will go away when the new networking model comes
-// on line (as part of the N2 project). So I reserve the right to change my mind and take
-// this service away =).
+// The Smtp Service is an interfaced designed to make building and running mail
+// to urls easier. I'm not sure if this service will go away when the new
+// networking model comes on line (as part of the N2 project). So I reserve the
+// right to change my mind and take this service away =).
 ////////////////////////////////////////////////////////////////////////////////////////
 
-class nsSmtpService : public nsISmtpService, public nsIProtocolHandler
-{
-public:
-
+class nsSmtpService : public nsISmtpService, public nsIProtocolHandler {
+ public:
   nsSmtpService();
 
   NS_DECL_ISUPPORTS
 
   ////////////////////////////////////////////////////////////////////////
   // we support the nsISmtpService interface
   ////////////////////////////////////////////////////////////////////////
   NS_DECL_NSISMTPSERVICE
 
   //////////////////////////////////////////////////////////////////////////
   // we support the nsIProtocolHandler interface
   //////////////////////////////////////////////////////////////////////////
   NS_DECL_NSIPROTOCOLHANDLER
 
-protected:
-    nsresult loadSmtpServers();
-
+ protected:
+  nsresult loadSmtpServers();
 
-private:
+ private:
   virtual ~nsSmtpService();
-    static bool findServerByKey(nsISmtpServer *aServer, void *aData);
-    static bool findServerByHostname(nsISmtpServer *aServer, void *aData);
+  static bool findServerByKey(nsISmtpServer *aServer, void *aData);
+  static bool findServerByHostname(nsISmtpServer *aServer, void *aData);
 
-    nsresult createKeyedServer(const char* key,
-                               nsISmtpServer **aResult = nullptr);
-    nsresult saveKeyList();
+  nsresult createKeyedServer(const char *key,
+                             nsISmtpServer **aResult = nullptr);
+  nsresult saveKeyList();
 
-    nsCOMArray<nsISmtpServer> mSmtpServers;
-    nsCOMPtr<nsISmtpServer> mDefaultSmtpServer;
-    nsCOMPtr<nsISmtpServer> mSessionDefaultServer;
+  nsCOMArray<nsISmtpServer> mSmtpServers;
+  nsCOMPtr<nsISmtpServer> mDefaultSmtpServer;
+  nsCOMPtr<nsISmtpServer> mSessionDefaultServer;
 
-    nsCString mServerKeyList;
+  nsCString mServerKeyList;
 
-    bool mSmtpServersLoaded;
+  bool mSmtpServersLoaded;
 };
 
 #endif /* nsSmtpService_h___ */
--- a/mailnews/compose/src/nsSmtpUrl.cpp
+++ b/mailnews/compose/src/nsSmtpUrl.cpp
@@ -16,45 +16,36 @@
 #include "nsServiceManagerUtils.h"
 #include "nsCRT.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Encoding.h"
 
 /////////////////////////////////////////////////////////////////////////////////////
 // mailto url definition
 /////////////////////////////////////////////////////////////////////////////////////
-nsMailtoUrl::nsMailtoUrl()
-{
-  mFormat = nsIMsgCompFormat::Default;
-}
+nsMailtoUrl::nsMailtoUrl() { mFormat = nsIMsgCompFormat::Default; }
 
-nsMailtoUrl::~nsMailtoUrl()
-{
-}
+nsMailtoUrl::~nsMailtoUrl() {}
 
 NS_IMPL_ISUPPORTS(nsMailtoUrl, nsIMailtoUrl, nsIURI)
 
 static void UnescapeAndConvert(nsIMimeConverter *mimeConverter,
-                               const nsACString &escaped, nsACString &out)
-{
+                               const nsACString &escaped, nsACString &out) {
   NS_ASSERTION(mimeConverter, "Set mimeConverter before calling!");
   // If the string is empty, do absolutely nothing.
-  if (escaped.IsEmpty())
-    return;
+  if (escaped.IsEmpty()) return;
 
   MsgUnescapeString(escaped, 0, out);
   nsAutoCString decodedString;
-  nsresult rv = mimeConverter->DecodeMimeHeaderToUTF8(out, "UTF_8", false,
-    true, decodedString);
-  if (NS_SUCCEEDED(rv) && !decodedString.IsEmpty())
-    out = decodedString;
+  nsresult rv = mimeConverter->DecodeMimeHeaderToUTF8(out, "UTF_8", false, true,
+                                                      decodedString);
+  if (NS_SUCCEEDED(rv) && !decodedString.IsEmpty()) out = decodedString;
 }
 
-nsresult nsMailtoUrl::ParseMailtoUrl(char * searchPart)
-{
+nsresult nsMailtoUrl::ParseMailtoUrl(char *searchPart) {
   char *rest = searchPart;
   nsCString escapedInReplyToPart;
   nsCString escapedToPart;
   nsCString escapedCcPart;
   nsCString escapedSubjectPart;
   nsCString escapedNewsgroupPart;
   nsCString escapedNewsHostPart;
   nsCString escapedReferencePart;
@@ -68,773 +59,669 @@ nsresult nsMailtoUrl::ParseMailtoUrl(cha
   nsCString escapedPriorityPart;
 
   // okay, first, free up all of our old search part state.....
   CleanupMailtoState();
   // m_toPart has the escaped address from before the query string, copy it
   // over so we can add on any additional to= addresses and unescape them all.
   escapedToPart = m_toPart;
 
-  if (rest && *rest == '?')
-  {
+  if (rest && *rest == '?') {
     /* start past the '?' */
     rest++;
   }
 
-  if (rest)
-  {
+  if (rest) {
     char *token = NS_strtok("&", &rest);
-    while (token && *token)
-    {
+    while (token && *token) {
       char *value = 0;
       char *eq = PL_strchr(token, '=');
-      if (eq)
-      {
-        value = eq+1;
+      if (eq) {
+        value = eq + 1;
         *eq = 0;
       }
 
       nsCString decodedName;
       MsgUnescapeString(nsDependentCString(token), 0, decodedName);
 
-      if (decodedName.IsEmpty())
-        break;
+      if (decodedName.IsEmpty()) break;
 
-      switch (NS_ToUpper(decodedName.First()))
-      {
-        /* DO NOT support attachment= in mailto urls. This poses a security fire hole!!!
-                          case 'A':
-                          if (!PL_strcasecmp (token, "attachment"))
-                          m_attachmentPart = value;
-                          break;
-                     */
-      case 'B':
-        if (decodedName.LowerCaseEqualsLiteral("bcc"))
-        {
-          if (!escapedBccPart.IsEmpty())
-          {
-            escapedBccPart += ", ";
-            escapedBccPart += value;
+      switch (NS_ToUpper(decodedName.First())) {
+          /* DO NOT support attachment= in mailto urls. This poses a security
+             fire hole!!! case 'A': if (!PL_strcasecmp (token, "attachment"))
+                            m_attachmentPart = value;
+                            break;
+                       */
+        case 'B':
+          if (decodedName.LowerCaseEqualsLiteral("bcc")) {
+            if (!escapedBccPart.IsEmpty()) {
+              escapedBccPart += ", ";
+              escapedBccPart += value;
+            } else
+              escapedBccPart = value;
+          } else if (decodedName.LowerCaseEqualsLiteral("body")) {
+            if (!escapedBodyPart.IsEmpty()) {
+              escapedBodyPart += "\n";
+              escapedBodyPart += value;
+            } else
+              escapedBodyPart = value;
           }
-          else
-            escapedBccPart = value;
-        }
-        else if (decodedName.LowerCaseEqualsLiteral("body"))
-        {
-          if (!escapedBodyPart.IsEmpty())
-          {
-            escapedBodyPart +="\n";
-            escapedBodyPart += value;
+          break;
+        case 'C':
+          if (decodedName.LowerCaseEqualsLiteral("cc")) {
+            if (!escapedCcPart.IsEmpty()) {
+              escapedCcPart += ", ";
+              escapedCcPart += value;
+            } else
+              escapedCcPart = value;
           }
-          else
-            escapedBodyPart = value;
-        }
-        break;
-      case 'C':
-        if (decodedName.LowerCaseEqualsLiteral("cc"))
-        {
-          if (!escapedCcPart.IsEmpty())
-          {
-            escapedCcPart += ", ";
-            escapedCcPart += value;
+          break;
+        case 'F':
+          if (decodedName.LowerCaseEqualsLiteral("followup-to"))
+            escapedFollowUpToPart = value;
+          else if (decodedName.LowerCaseEqualsLiteral("from"))
+            escapedFromPart = value;
+          break;
+        case 'H':
+          if (decodedName.LowerCaseEqualsLiteral("html-part") ||
+              decodedName.LowerCaseEqualsLiteral("html-body")) {
+            // escapedHtmlPart holds the body for both html-part and html-body.
+            escapedHtmlPart = value;
+            mFormat = nsIMsgCompFormat::HTML;
           }
-          else
-            escapedCcPart = value;
-        }
-        break;
-      case 'F':
-        if (decodedName.LowerCaseEqualsLiteral("followup-to"))
-          escapedFollowUpToPart = value;
-        else if (decodedName.LowerCaseEqualsLiteral("from"))
-          escapedFromPart = value;
-        break;
-      case 'H':
-        if (decodedName.LowerCaseEqualsLiteral("html-part") ||
-            decodedName.LowerCaseEqualsLiteral("html-body"))
-        {
-          // escapedHtmlPart holds the body for both html-part and html-body.
-          escapedHtmlPart = value;
-          mFormat = nsIMsgCompFormat::HTML;
-        }
-        break;
-      case 'I':
-        if (decodedName.LowerCaseEqualsLiteral("in-reply-to"))
-          escapedInReplyToPart = value;
-        break;
+          break;
+        case 'I':
+          if (decodedName.LowerCaseEqualsLiteral("in-reply-to"))
+            escapedInReplyToPart = value;
+          break;
 
-      case 'N':
-        if (decodedName.LowerCaseEqualsLiteral("newsgroups"))
-          escapedNewsgroupPart = value;
-        else if (decodedName.LowerCaseEqualsLiteral("newshost"))
-          escapedNewsHostPart = value;
-        break;
-      case 'O':
-        if (decodedName.LowerCaseEqualsLiteral("organization"))
-          escapedOrganizationPart = value;
-        break;
-      case 'R':
-        if (decodedName.LowerCaseEqualsLiteral("references"))
-          escapedReferencePart = value;
-        else if (decodedName.LowerCaseEqualsLiteral("reply-to"))
-          escapedReplyToPart = value;
-        break;
-      case 'S':
-        if(decodedName.LowerCaseEqualsLiteral("subject"))
-          escapedSubjectPart = value;
-        break;
-      case 'P':
-        if (decodedName.LowerCaseEqualsLiteral("priority"))
-          escapedPriorityPart = PL_strdup(value);
-        break;
-      case 'T':
-        if (decodedName.LowerCaseEqualsLiteral("to"))
-        {
-          if (!escapedToPart.IsEmpty())
-          {
-            escapedToPart += ", ";
-            escapedToPart += value;
+        case 'N':
+          if (decodedName.LowerCaseEqualsLiteral("newsgroups"))
+            escapedNewsgroupPart = value;
+          else if (decodedName.LowerCaseEqualsLiteral("newshost"))
+            escapedNewsHostPart = value;
+          break;
+        case 'O':
+          if (decodedName.LowerCaseEqualsLiteral("organization"))
+            escapedOrganizationPart = value;
+          break;
+        case 'R':
+          if (decodedName.LowerCaseEqualsLiteral("references"))
+            escapedReferencePart = value;
+          else if (decodedName.LowerCaseEqualsLiteral("reply-to"))
+            escapedReplyToPart = value;
+          break;
+        case 'S':
+          if (decodedName.LowerCaseEqualsLiteral("subject"))
+            escapedSubjectPart = value;
+          break;
+        case 'P':
+          if (decodedName.LowerCaseEqualsLiteral("priority"))
+            escapedPriorityPart = PL_strdup(value);
+          break;
+        case 'T':
+          if (decodedName.LowerCaseEqualsLiteral("to")) {
+            if (!escapedToPart.IsEmpty()) {
+              escapedToPart += ", ";
+              escapedToPart += value;
+            } else
+              escapedToPart = value;
           }
-          else
-            escapedToPart = value;
-        }
-        break;
-      default:
-        break;
-      } // end of switch statement...
+          break;
+        default:
+          break;
+      }  // end of switch statement...
 
-      if (eq)
-        *eq = '='; /* put it back */
+      if (eq) *eq = '='; /* put it back */
       token = NS_strtok("&", &rest);
-    } // while we still have part of the url to parse...
-  } // if rest && *rest
+    }  // while we still have part of the url to parse...
+  }    // if rest && *rest
 
   nsresult rv;
   // Get a global converter
   nsCOMPtr<nsIMimeConverter> mimeConverter =
-    do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
+      do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now unescape everything, and mime-decode the things that can be encoded.
   UnescapeAndConvert(mimeConverter, escapedToPart, m_toPart);
   UnescapeAndConvert(mimeConverter, escapedCcPart, m_ccPart);
   UnescapeAndConvert(mimeConverter, escapedBccPart, m_bccPart);
   UnescapeAndConvert(mimeConverter, escapedSubjectPart, m_subjectPart);
   UnescapeAndConvert(mimeConverter, escapedNewsgroupPart, m_newsgroupPart);
   UnescapeAndConvert(mimeConverter, escapedReferencePart, m_referencePart);
   if (!escapedBodyPart.IsEmpty())
     MsgUnescapeString(escapedBodyPart, 0, m_bodyPart);
   if (!escapedHtmlPart.IsEmpty())
     MsgUnescapeString(escapedHtmlPart, 0, m_htmlPart);
   UnescapeAndConvert(mimeConverter, escapedNewsHostPart, m_newsHostPart);
   UnescapeAndConvert(mimeConverter, escapedFollowUpToPart, m_followUpToPart);
   UnescapeAndConvert(mimeConverter, escapedFromPart, m_fromPart);
-  UnescapeAndConvert(mimeConverter, escapedOrganizationPart, m_organizationPart);
+  UnescapeAndConvert(mimeConverter, escapedOrganizationPart,
+                     m_organizationPart);
   UnescapeAndConvert(mimeConverter, escapedReplyToPart, m_replyToPart);
   UnescapeAndConvert(mimeConverter, escapedPriorityPart, m_priorityPart);
 
-  nsCString inReplyToPart; // Not a member like the others...
+  nsCString inReplyToPart;  // Not a member like the others...
   UnescapeAndConvert(mimeConverter, escapedInReplyToPart, inReplyToPart);
 
-  if (!inReplyToPart.IsEmpty())
-  {
+  if (!inReplyToPart.IsEmpty()) {
     // Ensure that References and In-Reply-To are consistent... The last
     // reference will be used as In-Reply-To header.
-    if (m_referencePart.IsEmpty())
-    {
+    if (m_referencePart.IsEmpty()) {
       // If References is not set, set it to be the In-Reply-To.
       m_referencePart = inReplyToPart;
-    }
-    else
-    {
+    } else {
       // References is set. Add the In-Reply-To as last header unless it's
       // set as last reference already.
       int32_t lastRefStart = m_referencePart.RFindChar('<');
       nsAutoCString lastReference;
       if (lastRefStart != -1)
         lastReference = StringTail(m_referencePart, lastRefStart);
       else
         lastReference = m_referencePart;
 
-      if (lastReference != inReplyToPart)
-      {
+      if (lastReference != inReplyToPart) {
         m_referencePart += " ";
         m_referencePart += inReplyToPart;
       }
     }
   }
 
   return NS_OK;
 }
 
-nsresult nsMailtoUrl::SetSpecInternal(const nsACString &aSpec)
-{
-  nsresult rv = NS_MutateURI(NS_SIMPLEURIMUTATOR_CONTRACTID).SetSpec(aSpec).Finalize(m_baseURL);
+nsresult nsMailtoUrl::SetSpecInternal(const nsACString &aSpec) {
+  nsresult rv = NS_MutateURI(NS_SIMPLEURIMUTATOR_CONTRACTID)
+                    .SetSpec(aSpec)
+                    .Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-nsresult nsMailtoUrl::CleanupMailtoState()
-{
-    m_ccPart = "";
-    m_subjectPart = "";
-    m_newsgroupPart = "";
-    m_newsHostPart = "";
-    m_referencePart = "";
-    m_bodyPart = "";
-    m_bccPart = "";
-    m_followUpToPart = "";
-    m_fromPart = "";
-    m_htmlPart = "";
-    m_organizationPart = "";
-    m_replyToPart = "";
-    m_priorityPart = "";
-    return NS_OK;
+nsresult nsMailtoUrl::CleanupMailtoState() {
+  m_ccPart = "";
+  m_subjectPart = "";
+  m_newsgroupPart = "";
+  m_newsHostPart = "";
+  m_referencePart = "";
+  m_bodyPart = "";
+  m_bccPart = "";
+  m_followUpToPart = "";
+  m_fromPart = "";
+  m_htmlPart = "";
+  m_organizationPart = "";
+  m_replyToPart = "";
+  m_priorityPart = "";
+  return NS_OK;
 }
 
-nsresult nsMailtoUrl::ParseUrl()
-{
+nsresult nsMailtoUrl::ParseUrl() {
   // we can get the path from the simple url.....
   nsCString escapedPath;
   m_baseURL->GetPathQueryRef(escapedPath);
 
   int32_t startOfSearchPart = escapedPath.FindChar('?');
-  if (startOfSearchPart >= 0)
-  {
+  if (startOfSearchPart >= 0) {
     // now parse out the search field...
     nsAutoCString searchPart(Substring(escapedPath, startOfSearchPart));
 
-    if (!searchPart.IsEmpty())
-    {
+    if (!searchPart.IsEmpty()) {
       // now we need to strip off the search part from the
       // to part....
       escapedPath.SetLength(startOfSearchPart);
       MsgUnescapeString(escapedPath, 0, m_toPart);
       ParseMailtoUrl(searchPart.BeginWriting());
     }
-  }
-  else if (!escapedPath.IsEmpty())
-  {
+  } else if (!escapedPath.IsEmpty()) {
     MsgUnescapeString(escapedPath, 0, m_toPart);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMailtoUrl::GetMessageContents(nsACString &aToPart, nsACString &aCcPart,
                                 nsACString &aBccPart, nsACString &aSubjectPart,
                                 nsACString &aBodyPart, nsACString &aHtmlPart,
                                 nsACString &aReferencePart,
                                 nsACString &aNewsgroupPart,
-                                MSG_ComposeFormat *aFormat)
-{
+                                MSG_ComposeFormat *aFormat) {
   NS_ENSURE_ARG_POINTER(aFormat);
 
   aToPart = m_toPart;
   aCcPart = m_ccPart;
   aBccPart = m_bccPart;
   aSubjectPart = m_subjectPart;
   aBodyPart = m_bodyPart;
   aHtmlPart = m_htmlPart;
   aReferencePart = m_referencePart;
   aNewsgroupPart = m_newsgroupPart;
   *aFormat = mFormat;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetFromPart(nsACString &aResult)
-{
+nsMailtoUrl::GetFromPart(nsACString &aResult) {
   aResult = m_fromPart;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetFollowUpToPart(nsACString &aResult)
-{
+nsMailtoUrl::GetFollowUpToPart(nsACString &aResult) {
   aResult = m_followUpToPart;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetOrganizationPart(nsACString &aResult)
-{
+nsMailtoUrl::GetOrganizationPart(nsACString &aResult) {
   aResult = m_organizationPart;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetReplyToPart(nsACString &aResult)
-{
+nsMailtoUrl::GetReplyToPart(nsACString &aResult) {
   aResult = m_replyToPart;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetPriorityPart(nsACString &aResult)
-{
+nsMailtoUrl::GetPriorityPart(nsACString &aResult) {
   aResult = m_priorityPart;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetNewsHostPart(nsACString &aResult)
-{
+nsMailtoUrl::GetNewsHostPart(nsACString &aResult) {
   aResult = m_newsHostPart;
   return NS_OK;
 }
 
 //////////////////////////////////////////////////////////////////////////////
 // Begin nsIURI support
 //////////////////////////////////////////////////////////////////////////////
 
-NS_IMETHODIMP nsMailtoUrl::GetSpec(nsACString &aSpec)
-{
+NS_IMETHODIMP nsMailtoUrl::GetSpec(nsACString &aSpec) {
   return m_baseURL->GetSpec(aSpec);
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetPrePath(nsACString &aPrePath)
-{
+NS_IMETHODIMP nsMailtoUrl::GetPrePath(nsACString &aPrePath) {
   return m_baseURL->GetPrePath(aPrePath);
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetScheme(nsACString &aScheme)
-{
+NS_IMETHODIMP nsMailtoUrl::GetScheme(nsACString &aScheme) {
   return m_baseURL->GetScheme(aScheme);
 }
 
-nsresult nsMailtoUrl::SetScheme(const nsACString &aScheme)
-{
+nsresult nsMailtoUrl::SetScheme(const nsACString &aScheme) {
   nsresult rv = NS_MutateURI(m_baseURL).SetScheme(aScheme).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetUserPass(nsACString &aUserPass)
-{
+NS_IMETHODIMP nsMailtoUrl::GetUserPass(nsACString &aUserPass) {
   return m_baseURL->GetUserPass(aUserPass);
 }
 
-nsresult nsMailtoUrl::SetUserPass(const nsACString &aUserPass)
-{
-  nsresult rv = NS_MutateURI(m_baseURL).SetUserPass(aUserPass).Finalize(m_baseURL);
+nsresult nsMailtoUrl::SetUserPass(const nsACString &aUserPass) {
+  nsresult rv =
+      NS_MutateURI(m_baseURL).SetUserPass(aUserPass).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetUsername(nsACString &aUsername)
-{
+NS_IMETHODIMP nsMailtoUrl::GetUsername(nsACString &aUsername) {
   return m_baseURL->GetUsername(aUsername);
 }
 
-nsresult nsMailtoUrl::SetUsername(const nsACString &aUsername)
-{
-  nsresult rv = NS_MutateURI(m_baseURL).SetUsername(aUsername).Finalize(m_baseURL);
+nsresult nsMailtoUrl::SetUsername(const nsACString &aUsername) {
+  nsresult rv =
+      NS_MutateURI(m_baseURL).SetUsername(aUsername).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetPassword(nsACString &aPassword)
-{
+NS_IMETHODIMP nsMailtoUrl::GetPassword(nsACString &aPassword) {
   return m_baseURL->GetPassword(aPassword);
 }
 
-nsresult nsMailtoUrl::SetPassword(const nsACString &aPassword)
-{
-  nsresult rv = NS_MutateURI(m_baseURL).SetPassword(aPassword).Finalize(m_baseURL);
+nsresult nsMailtoUrl::SetPassword(const nsACString &aPassword) {
+  nsresult rv =
+      NS_MutateURI(m_baseURL).SetPassword(aPassword).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetHostPort(nsACString &aHostPort)
-{
+NS_IMETHODIMP nsMailtoUrl::GetHostPort(nsACString &aHostPort) {
   return m_baseURL->GetHost(aHostPort);
 }
 
-nsresult nsMailtoUrl::SetHostPort(const nsACString &aHostPort)
-{
-  nsresult rv = NS_MutateURI(m_baseURL).SetHostPort(aHostPort).Finalize(m_baseURL);
+nsresult nsMailtoUrl::SetHostPort(const nsACString &aHostPort) {
+  nsresult rv =
+      NS_MutateURI(m_baseURL).SetHostPort(aHostPort).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetHost(nsACString &aHost)
-{
+NS_IMETHODIMP nsMailtoUrl::GetHost(nsACString &aHost) {
   return m_baseURL->GetHost(aHost);
 }
 
-nsresult nsMailtoUrl::SetHost(const nsACString &aHost)
-{
+nsresult nsMailtoUrl::SetHost(const nsACString &aHost) {
   nsresult rv = NS_MutateURI(m_baseURL).SetHost(aHost).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetPort(int32_t *aPort)
-{
+NS_IMETHODIMP nsMailtoUrl::GetPort(int32_t *aPort) {
   return m_baseURL->GetPort(aPort);
 }
 
-nsresult nsMailtoUrl::SetPort(int32_t aPort)
-{
+nsresult nsMailtoUrl::SetPort(int32_t aPort) {
   nsresult rv = NS_MutateURI(m_baseURL).SetPort(aPort).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetPathQueryRef(nsACString &aPath)
-{
+NS_IMETHODIMP nsMailtoUrl::GetPathQueryRef(nsACString &aPath) {
   return m_baseURL->GetPathQueryRef(aPath);
 }
 
-nsresult nsMailtoUrl::SetPathQueryRef(const nsACString &aPath)
-{
-  nsresult rv = NS_MutateURI(m_baseURL).SetPathQueryRef(aPath).Finalize(m_baseURL);
+nsresult nsMailtoUrl::SetPathQueryRef(const nsACString &aPath) {
+  nsresult rv =
+      NS_MutateURI(m_baseURL).SetPathQueryRef(aPath).Finalize(m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   return ParseUrl();
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetAsciiHost(nsACString &aHostA)
-{
+NS_IMETHODIMP nsMailtoUrl::GetAsciiHost(nsACString &aHostA) {
   return m_baseURL->GetAsciiHost(aHostA);
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetAsciiHostPort(nsACString &aHostPortA)
-{
+NS_IMETHODIMP nsMailtoUrl::GetAsciiHostPort(nsACString &aHostPortA) {
   return m_baseURL->GetAsciiHostPort(aHostPortA);
 }
 
-NS_IMETHODIMP nsMailtoUrl::GetAsciiSpec(nsACString &aSpecA)
-{
+NS_IMETHODIMP nsMailtoUrl::GetAsciiSpec(nsACString &aSpecA) {
   return m_baseURL->GetAsciiSpec(aSpecA);
 }
 
-NS_IMETHODIMP nsMailtoUrl::SchemeIs(const char *aScheme, bool *_retval)
-{
+NS_IMETHODIMP nsMailtoUrl::SchemeIs(const char *aScheme, bool *_retval) {
   return m_baseURL->SchemeIs(aScheme, _retval);
 }
 
-NS_IMETHODIMP nsMailtoUrl::Equals(nsIURI *other, bool *_retval)
-{
+NS_IMETHODIMP nsMailtoUrl::Equals(nsIURI *other, bool *_retval) {
   // The passed-in URI might be an nsMailtoUrl. Pass our inner URL to its
   // Equals method. The other nsMailtoUrl will then pass its inner URL to
   // to the Equals method of our inner URL. Other URIs will return false.
-  if (other)
-    return other->Equals(m_baseURL, _retval);
+  if (other) return other->Equals(m_baseURL, _retval);
 
   return m_baseURL->Equals(other, _retval);
 }
 
-nsresult
-nsMailtoUrl::Clone(nsIURI** _retval)
-{
+nsresult nsMailtoUrl::Clone(nsIURI **_retval) {
   NS_ENSURE_ARG_POINTER(_retval);
 
   RefPtr<nsMailtoUrl> clone = new nsMailtoUrl();
 
   NS_ENSURE_TRUE(clone, NS_ERROR_OUT_OF_MEMORY);
 
   nsresult rv = NS_MutateURI(m_baseURL).Finalize(clone->m_baseURL);
   NS_ENSURE_SUCCESS(rv, rv);
   clone->ParseUrl();
   clone.forget(_retval);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMailtoUrl::Resolve(const nsACString &relativePath, nsACString &result)
-{
+NS_IMETHODIMP nsMailtoUrl::Resolve(const nsACString &relativePath,
+                                   nsACString &result) {
   return m_baseURL->Resolve(relativePath, result);
 }
 
-nsresult nsMailtoUrl::SetRef(const nsACString &aRef)
-{
+nsresult nsMailtoUrl::SetRef(const nsACString &aRef) {
   return NS_MutateURI(m_baseURL).SetRef(aRef).Finalize(m_baseURL);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetRef(nsACString &result)
-{
-  return m_baseURL->GetRef(result);
-}
+nsMailtoUrl::GetRef(nsACString &result) { return m_baseURL->GetRef(result); }
 
-NS_IMETHODIMP nsMailtoUrl::EqualsExceptRef(nsIURI *other, bool *result)
-{
+NS_IMETHODIMP nsMailtoUrl::EqualsExceptRef(nsIURI *other, bool *result) {
   // The passed-in URI might be an nsMailtoUrl. Pass our inner URL to its
   // Equals method. The other nsMailtoUrl will then pass its inner URL to
   // to the Equals method of our inner URL. Other URIs will return false.
-  if (other)
-    return other->EqualsExceptRef(m_baseURL, result);
+  if (other) return other->EqualsExceptRef(m_baseURL, result);
 
   return m_baseURL->EqualsExceptRef(other, result);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetSpecIgnoringRef(nsACString &result)
-{
+nsMailtoUrl::GetSpecIgnoringRef(nsACString &result) {
   return m_baseURL->GetSpecIgnoringRef(result);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetDisplaySpec(nsACString& aUnicodeSpec)
-{
+nsMailtoUrl::GetDisplaySpec(nsACString &aUnicodeSpec) {
   return GetSpec(aUnicodeSpec);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetDisplayHostPort(nsACString& aUnicodeHostPort)
-{
+nsMailtoUrl::GetDisplayHostPort(nsACString &aUnicodeHostPort) {
   return GetHostPort(aUnicodeHostPort);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetDisplayHost(nsACString& aUnicodeHost)
-{
+nsMailtoUrl::GetDisplayHost(nsACString &aUnicodeHost) {
   return GetHost(aUnicodeHost);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetDisplayPrePath(nsACString& aPrePath)
-{
+nsMailtoUrl::GetDisplayPrePath(nsACString &aPrePath) {
   return GetPrePath(aPrePath);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetHasRef(bool *result)
-{
-  return m_baseURL->GetHasRef(result);
-}
+nsMailtoUrl::GetHasRef(bool *result) { return m_baseURL->GetHasRef(result); }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetFilePath(nsACString &aFilePath)
-{
+nsMailtoUrl::GetFilePath(nsACString &aFilePath) {
   return m_baseURL->GetFilePath(aFilePath);
 }
 
-nsresult nsMailtoUrl::SetFilePath(const nsACString &aFilePath)
-{
+nsresult nsMailtoUrl::SetFilePath(const nsACString &aFilePath) {
   return NS_MutateURI(m_baseURL).SetFilePath(aFilePath).Finalize(m_baseURL);
 }
 
 NS_IMETHODIMP
-nsMailtoUrl::GetQuery(nsACString &aQuery)
-{
+nsMailtoUrl::GetQuery(nsACString &aQuery) {
   return m_baseURL->GetQuery(aQuery);
 }
 
-nsresult nsMailtoUrl::SetQuery(const nsACString &aQuery)
-{
+nsresult nsMailtoUrl::SetQuery(const nsACString &aQuery) {
   return NS_MutateURI(m_baseURL).SetQuery(aQuery).Finalize(m_baseURL);
 }
 
-nsresult nsMailtoUrl::SetQueryWithEncoding(const nsACString &aQuery, const mozilla::Encoding* aEncoding)
-{
-  return NS_MutateURI(m_baseURL).SetQueryWithEncoding(aQuery, aEncoding).Finalize(m_baseURL);
+nsresult nsMailtoUrl::SetQueryWithEncoding(const nsACString &aQuery,
+                                           const mozilla::Encoding *aEncoding) {
+  return NS_MutateURI(m_baseURL)
+      .SetQueryWithEncoding(aQuery, aEncoding)
+      .Finalize(m_baseURL);
 }
 
 NS_IMETHODIMP_(void)
-nsMailtoUrl::Serialize(mozilla::ipc::URIParams &aParams)
-{
+nsMailtoUrl::Serialize(mozilla::ipc::URIParams &aParams) {
   m_baseURL->Serialize(aParams);
 }
 
 NS_IMPL_ISUPPORTS(nsMailtoUrl::Mutator, nsIURISetters, nsIURIMutator)
 
 NS_IMETHODIMP
-nsMailtoUrl::Mutate(nsIURIMutator** aMutator)
-{
+nsMailtoUrl::Mutate(nsIURIMutator **aMutator) {
   RefPtr<nsMailtoUrl::Mutator> mutator = new nsMailtoUrl::Mutator();
   nsresult rv = mutator->InitFromURI(this);
   if (NS_FAILED(rv)) {
     return rv;
   }
   mutator.forget(aMutator);
   return NS_OK;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
 // smtp url definition
 /////////////////////////////////////////////////////////////////////////////////////
 
-nsSmtpUrl::nsSmtpUrl() : nsMsgMailNewsUrl()
-{
+nsSmtpUrl::nsSmtpUrl() : nsMsgMailNewsUrl() {
   // nsISmtpUrl specific state...
 
   m_isPostMessage = true;
   m_requestDSN = false;
   m_verifyLogon = false;
 }
 
-nsSmtpUrl::~nsSmtpUrl()
-{
-}
+nsSmtpUrl::~nsSmtpUrl() {}
 
 NS_IMETHODIMP
-nsSmtpUrl::Init(const nsACString &aSpec)
-{
-  return SetSpecInternal(aSpec);
-}
+nsSmtpUrl::Init(const nsACString &aSpec) { return SetSpecInternal(aSpec); }
 
 NS_IMPL_ISUPPORTS_INHERITED(nsSmtpUrl, nsMsgMailNewsUrl, nsISmtpUrl)
 
 ////////////////////////////////////////////////////////////////////////////////////
 // Begin nsISmtpUrl specific support
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 NS_IMETHODIMP
-nsSmtpUrl::SetRecipients(const char * aRecipientsList)
-{
+nsSmtpUrl::SetRecipients(const char *aRecipientsList) {
   NS_ENSURE_ARG(aRecipientsList);
   MsgUnescapeString(nsDependentCString(aRecipientsList), 0, m_toPart);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetRecipients(char ** aRecipientsList)
-{
+nsSmtpUrl::GetRecipients(char **aRecipientsList) {
   NS_ENSURE_ARG_POINTER(aRecipientsList);
-  if (aRecipientsList)
-    *aRecipientsList = ToNewCString(m_toPart);
+  if (aRecipientsList) *aRecipientsList = ToNewCString(m_toPart);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::SetSender(const char * aSender)
-{
+nsSmtpUrl::SetSender(const char *aSender) {
   NS_ENSURE_ARG(aSender);
   MsgUnescapeString(nsDependentCString(aSender), 0, m_fromPart);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetSender(char ** aSender)
-{
+nsSmtpUrl::GetSender(char **aSender) {
   NS_ENSURE_ARG_POINTER(aSender);
-  if (aSender)
-    *aSender = ToNewCString(m_fromPart);
+  if (aSender) *aSender = ToNewCString(m_fromPart);
   return NS_OK;
 }
 
 NS_IMPL_GETSET(nsSmtpUrl, PostMessage, bool, m_isPostMessage)
 
 NS_IMPL_GETSET(nsSmtpUrl, VerifyLogon, bool, m_verifyLogon)
 
-// the message can be stored in a file....allow accessors for getting and setting
-// the file name to post...
-NS_IMETHODIMP nsSmtpUrl::SetPostMessageFile(nsIFile * aFile)
-{
+// the message can be stored in a file....allow accessors for getting and
+// setting the file name to post...
+NS_IMETHODIMP nsSmtpUrl::SetPostMessageFile(nsIFile *aFile) {
   NS_ENSURE_ARG_POINTER(aFile);
   m_fileName = aFile;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSmtpUrl::GetPostMessageFile(nsIFile ** aFile)
-{
+NS_IMETHODIMP nsSmtpUrl::GetPostMessageFile(nsIFile **aFile) {
   NS_ENSURE_ARG_POINTER(aFile);
-  if (m_fileName)
-  {
+  if (m_fileName) {
     // Clone the file so nsLocalFile stat caching doesn't make the caller get
     // the wrong file size.
     m_fileName->Clone(aFile);
     return *aFile ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
   }
   return NS_ERROR_NULL_POINTER;
 }
 
 NS_IMPL_GETSET(nsSmtpUrl, RequestDSN, bool, m_requestDSN)
 
 NS_IMETHODIMP
-nsSmtpUrl::SetDsnEnvid(const nsACString &aDsnEnvid)
-{
-    m_dsnEnvid = aDsnEnvid;
-    return NS_OK;
+nsSmtpUrl::SetDsnEnvid(const nsACString &aDsnEnvid) {
+  m_dsnEnvid = aDsnEnvid;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetDsnEnvid(nsACString &aDsnEnvid)
-{
-    aDsnEnvid = m_dsnEnvid;
-    return NS_OK;
+nsSmtpUrl::GetDsnEnvid(nsACString &aDsnEnvid) {
+  aDsnEnvid = m_dsnEnvid;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetSenderIdentity(nsIMsgIdentity **aSenderIdentity)
-{
+nsSmtpUrl::GetSenderIdentity(nsIMsgIdentity **aSenderIdentity) {
   NS_ENSURE_ARG_POINTER(aSenderIdentity);
   NS_ADDREF(*aSenderIdentity = m_senderIdentity);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::SetSenderIdentity(nsIMsgIdentity *aSenderIdentity)
-{
+nsSmtpUrl::SetSenderIdentity(nsIMsgIdentity *aSenderIdentity) {
   NS_ENSURE_ARG_POINTER(aSenderIdentity);
   m_senderIdentity = aSenderIdentity;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::SetPrompt(nsIPrompt *aNetPrompt)
-{
-    NS_ENSURE_ARG_POINTER(aNetPrompt);
-    m_netPrompt = aNetPrompt;
-    return NS_OK;
+nsSmtpUrl::SetPrompt(nsIPrompt *aNetPrompt) {
+  NS_ENSURE_ARG_POINTER(aNetPrompt);
+  m_netPrompt = aNetPrompt;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetPrompt(nsIPrompt **aNetPrompt)
-{
-    NS_ENSURE_ARG_POINTER(aNetPrompt);
-    NS_ENSURE_TRUE(m_netPrompt, NS_ERROR_NULL_POINTER);
-    NS_ADDREF(*aNetPrompt = m_netPrompt);
-    return NS_OK;
+nsSmtpUrl::GetPrompt(nsIPrompt **aNetPrompt) {
+  NS_ENSURE_ARG_POINTER(aNetPrompt);
+  NS_ENSURE_TRUE(m_netPrompt, NS_ERROR_NULL_POINTER);
+  NS_ADDREF(*aNetPrompt = m_netPrompt);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::SetAuthPrompt(nsIAuthPrompt *aNetAuthPrompt)
-{
-    NS_ENSURE_ARG_POINTER(aNetAuthPrompt);
-    m_netAuthPrompt = aNetAuthPrompt;
-    return NS_OK;
+nsSmtpUrl::SetAuthPrompt(nsIAuthPrompt *aNetAuthPrompt) {
+  NS_ENSURE_ARG_POINTER(aNetAuthPrompt);
+  m_netAuthPrompt = aNetAuthPrompt;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetAuthPrompt(nsIAuthPrompt **aNetAuthPrompt)
-{
-    NS_ENSURE_ARG_POINTER(aNetAuthPrompt);
-    NS_ENSURE_TRUE(m_netAuthPrompt, NS_ERROR_NULL_POINTER);
-    NS_ADDREF(*aNetAuthPrompt = m_netAuthPrompt);
-    return NS_OK;
+nsSmtpUrl::GetAuthPrompt(nsIAuthPrompt **aNetAuthPrompt) {
+  NS_ENSURE_ARG_POINTER(aNetAuthPrompt);
+  NS_ENSURE_TRUE(m_netAuthPrompt, NS_ERROR_NULL_POINTER);
+  NS_ADDREF(*aNetAuthPrompt = m_netAuthPrompt);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks)
-{
-    NS_ENSURE_ARG_POINTER(aCallbacks);
-    m_callbacks = aCallbacks;
-    return NS_OK;
+nsSmtpUrl::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks) {
+  NS_ENSURE_ARG_POINTER(aCallbacks);
+  m_callbacks = aCallbacks;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetNotificationCallbacks(nsIInterfaceRequestor** aCallbacks)
-{
-    NS_ENSURE_ARG_POINTER(aCallbacks);
-    NS_ENSURE_TRUE(m_callbacks, NS_ERROR_NULL_POINTER);
-    NS_ADDREF(*aCallbacks = m_callbacks);
-    return NS_OK;
+nsSmtpUrl::GetNotificationCallbacks(nsIInterfaceRequestor **aCallbacks) {
+  NS_ENSURE_ARG_POINTER(aCallbacks);
+  NS_ENSURE_TRUE(m_callbacks, NS_ERROR_NULL_POINTER);
+  NS_ADDREF(*aCallbacks = m_callbacks);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::SetSmtpServer(nsISmtpServer * aSmtpServer)
-{
-    NS_ENSURE_ARG_POINTER(aSmtpServer);
-    m_smtpServer = aSmtpServer;
-    return NS_OK;
+nsSmtpUrl::SetSmtpServer(nsISmtpServer *aSmtpServer) {
+  NS_ENSURE_ARG_POINTER(aSmtpServer);
+  m_smtpServer = aSmtpServer;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSmtpUrl::GetSmtpServer(nsISmtpServer ** aSmtpServer)
-{
-    NS_ENSURE_ARG_POINTER(aSmtpServer);
-    NS_ENSURE_TRUE(m_smtpServer, NS_ERROR_NULL_POINTER);
-    NS_ADDREF(*aSmtpServer = m_smtpServer);
-    return NS_OK;
+nsSmtpUrl::GetSmtpServer(nsISmtpServer **aSmtpServer) {
+  NS_ENSURE_ARG_POINTER(aSmtpServer);
+  NS_ENSURE_TRUE(m_smtpServer, NS_ERROR_NULL_POINTER);
+  NS_ADDREF(*aSmtpServer = m_smtpServer);
+  return NS_OK;
 }
--- a/mailnews/compose/src/nsSmtpUrl.h
+++ b/mailnews/compose/src/nsSmtpUrl.h
@@ -13,84 +13,80 @@
 #include "nsCOMPtr.h"
 #include "nsIPrompt.h"
 #include "nsIAuthPrompt.h"
 #include "nsISmtpServer.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIURIMutator.h"
 
-class nsMailtoUrl : public nsIMailtoUrl, public nsIURI
-{
-public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIURI
-    NS_DECL_NSIMAILTOURL
+class nsMailtoUrl : public nsIMailtoUrl, public nsIURI {
+ public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIURI
+  NS_DECL_NSIMAILTOURL
 
-    nsMailtoUrl();
+  nsMailtoUrl();
 
-protected:
+ protected:
   virtual nsresult Clone(nsIURI **_retval);
   virtual nsresult SetSpecInternal(const nsACString &aSpec);
   virtual nsresult SetScheme(const nsACString &aScheme);
   virtual nsresult SetUserPass(const nsACString &aUserPass);
   virtual nsresult SetUsername(const nsACString &aUsername);
   virtual nsresult SetPassword(const nsACString &aPassword);
   virtual nsresult SetHostPort(const nsACString &aHostPort);
   virtual nsresult SetHost(const nsACString &aHost);
   virtual nsresult SetPort(int32_t aPort);
   virtual nsresult SetPathQueryRef(const nsACString &aPath);
   virtual nsresult SetRef(const nsACString &aRef);
   virtual nsresult SetFilePath(const nsACString &aFilePath);
   virtual nsresult SetQuery(const nsACString &aQuery);
-  virtual nsresult SetQueryWithEncoding(const nsACString &aQuery, const mozilla::Encoding* aEncoding);
+  virtual nsresult SetQueryWithEncoding(const nsACString &aQuery,
+                                        const mozilla::Encoding *aEncoding);
 
-public:
-  class Mutator
-      : public nsIURIMutator
-      , public BaseURIMutator<nsMailtoUrl>
-  {
+ public:
+  class Mutator : public nsIURIMutator, public BaseURIMutator<nsMailtoUrl> {
     NS_DECL_ISUPPORTS
     NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
 
-    NS_IMETHOD Deserialize(const mozilla::ipc::URIParams& aParams) override
-    {
+    NS_IMETHOD Deserialize(const mozilla::ipc::URIParams &aParams) override {
       return NS_ERROR_NOT_IMPLEMENTED;
     }
 
-    NS_IMETHOD Finalize(nsIURI** aURI) override
-    {
+    NS_IMETHOD Finalize(nsIURI **aURI) override {
       mURI.forget(aURI);
       return NS_OK;
     }
 
-    NS_IMETHOD SetSpec(const nsACString & aSpec, nsIURIMutator** aMutator) override
-    {
-      if (aMutator)
-        NS_ADDREF(*aMutator = this);
+    NS_IMETHOD SetSpec(const nsACString &aSpec,
+                       nsIURIMutator **aMutator) override {
+      if (aMutator) NS_ADDREF(*aMutator = this);
       return InitFromSpec(aSpec);
     }
 
-    explicit Mutator() { }
-  private:
-    virtual ~Mutator() { }
+    explicit Mutator() {}
+
+   private:
+    virtual ~Mutator() {}
 
     friend class nsMailtoUrl;
   };
   friend BaseURIMutator<nsMailtoUrl>;
 
-protected:
+ protected:
   virtual ~nsMailtoUrl();
   nsresult ParseUrl();
   nsresult CleanupMailtoState();
-  nsresult ParseMailtoUrl(char * searchPart);
+  nsresult ParseMailtoUrl(char *searchPart);
 
   nsCOMPtr<nsIURI> m_baseURL;
 
-  // data retrieved from parsing the url: (Note the url could be a post from file or it could be in the url)
+  // data retrieved from parsing the url: (Note the url could be a post from
+  // file or it could be in the url)
   nsCString m_toPart;
   nsCString m_ccPart;
   nsCString m_subjectPart;
   nsCString m_newsgroupPart;
   nsCString m_newsHostPart;
   nsCString m_referencePart;
   nsCString m_bodyPart;
   nsCString m_bccPart;
@@ -99,28 +95,27 @@ protected:
   nsCString m_htmlPart;
   nsCString m_organizationPart;
   nsCString m_replyToPart;
   nsCString m_priorityPart;
 
   MSG_ComposeFormat mFormat;
 };
 
-class nsSmtpUrl : public nsISmtpUrl, public nsMsgMailNewsUrl
-{
-public:
+class nsSmtpUrl : public nsISmtpUrl, public nsMsgMailNewsUrl {
+ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // From nsISmtpUrl
   NS_DECL_NSISMTPURL
 
   // nsSmtpUrl
   nsSmtpUrl();
 
-protected:
+ protected:
   virtual ~nsSmtpUrl();
 
   // data retrieved from parsing the url: (Note the url could be a post from
   // file or it could be in the url)
   nsCString m_toPart;
   nsCString m_fromPart;
 
   bool m_isPostMessage;
@@ -134,12 +129,12 @@ protected:
   nsCOMPtr<nsIPrompt> m_netPrompt;
   nsCOMPtr<nsIAuthPrompt> m_netAuthPrompt;
   nsCOMPtr<nsIInterfaceRequestor> m_callbacks;
   nsCOMPtr<nsISmtpServer> m_smtpServer;
 
   // it is possible to encode the message to parse in the form of a url.
   // This function is used to decompose the search and path part into the bare
   // message components (to, fcc, bcc, etc.)
-  nsresult ParseMessageToPost(char * searchPart);
+  nsresult ParseMessageToPost(char *searchPart);
 };
 
-#endif // nsSmtpUrl_h__
+#endif  // nsSmtpUrl_h__
--- a/mailnews/compose/src/nsURLFetcher.cpp
+++ b/mailnews/compose/src/nsURLFetcher.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsURLFetcher.h"
 
-#include "msgCore.h" // for pre-compiled headers
+#include "msgCore.h"  // for pre-compiled headers
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include <stdio.h>
 #include "nscore.h"
 #include "nsIFactory.h"
 #include "nsISupports.h"
 #include "prmem.h"
 #include "plstr.h"
@@ -25,507 +25,446 @@
 #include "nsMsgAttachmentHandler.h"
 #include "nsMsgSend.h"
 #include "nsISeekableStream.h"
 #include "nsIStreamConverterService.h"
 #include "nsIMsgProgress.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Components.h"
 
-NS_IMPL_ISUPPORTS(nsURLFetcher,
-                   nsIURLFetcher,
-                   nsIStreamListener,
-                   nsIRequestObserver,
-                   nsIURIContentListener,
-                   nsIInterfaceRequestor,
-                   nsIWebProgressListener,
-                   nsISupportsWeakReference)
-
+NS_IMPL_ISUPPORTS(nsURLFetcher, nsIURLFetcher, nsIStreamListener,
+                  nsIRequestObserver, nsIURIContentListener,
+                  nsIInterfaceRequestor, nsIWebProgressListener,
+                  nsISupportsWeakReference)
 
 /*
  * Inherited methods for nsMimeConverter
  */
-nsURLFetcher::nsURLFetcher()
-{
+nsURLFetcher::nsURLFetcher() {
   // Init member variables...
   mTotalWritten = 0;
   mBuffer = nullptr;
   mBufferSize = 0;
   mStillRunning = true;
   mCallback = nullptr;
   mOnStopRequestProcessed = false;
-  mIsFile=false;
+  mIsFile = false;
   nsURLFetcherStreamConsumer *consumer = new nsURLFetcherStreamConsumer(this);
   mConverter = consumer;
 }
 
-nsURLFetcher::~nsURLFetcher()
-{
+nsURLFetcher::~nsURLFetcher() {
   mStillRunning = false;
 
   PR_FREEIF(mBuffer);
   // Remove the DocShell as a listener of the old WebProgress...
-  if (mLoadCookie)
-  {
+  if (mLoadCookie) {
     nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
 
-    if (webProgress)
-      webProgress->RemoveProgressListener(this);
+    if (webProgress) webProgress->RemoveProgressListener(this);
   }
 }
 
-NS_IMETHODIMP nsURLFetcher::GetInterface(const nsIID & aIID, void * *aInstancePtr)
-{
-   NS_ENSURE_ARG_POINTER(aInstancePtr);
-   return QueryInterface(aIID, aInstancePtr);
+NS_IMETHODIMP nsURLFetcher::GetInterface(const nsIID &aIID,
+                                         void **aInstancePtr) {
+  NS_ENSURE_ARG_POINTER(aInstancePtr);
+  return QueryInterface(aIID, aInstancePtr);
 }
 
 // nsIURIContentListener support
 NS_IMETHODIMP
-nsURLFetcher::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
-{
-   return NS_OK;
-}
+nsURLFetcher::OnStartURIOpen(nsIURI *aURI, bool *aAbortOpen) { return NS_OK; }
 
 NS_IMETHODIMP
-nsURLFetcher::IsPreferred(const char * aContentType,
-                                char ** aDesiredContentType,
-                                bool * aCanHandleContent)
+nsURLFetcher::IsPreferred(const char *aContentType, char **aDesiredContentType,
+                          bool *aCanHandleContent)
 
 {
   return CanHandleContent(aContentType, true, aDesiredContentType,
                           aCanHandleContent);
 }
 
 NS_IMETHODIMP
-nsURLFetcher::CanHandleContent(const char * aContentType,
-                                bool aIsContentPreferred,
-                                char ** aDesiredContentType,
-                                bool * aCanHandleContent)
+nsURLFetcher::CanHandleContent(const char *aContentType,
+                               bool aIsContentPreferred,
+                               char **aDesiredContentType,
+                               bool *aCanHandleContent)
 
 {
-    if (!mIsFile && PL_strcasecmp(aContentType, MESSAGE_RFC822) == 0)
-      *aDesiredContentType = strdup("text/html");
+  if (!mIsFile && PL_strcasecmp(aContentType, MESSAGE_RFC822) == 0)
+    *aDesiredContentType = strdup("text/html");
 
-    // since we explicitly loaded the url, we always want to handle it!
-    *aCanHandleContent = true;
+  // since we explicitly loaded the url, we always want to handle it!
+  *aCanHandleContent = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::DoContent(const nsACString& aContentType,
-                      bool aIsContentPreferred,
-                      nsIRequest *request,
-                      nsIStreamListener ** aContentHandler,
-                      bool * aAbortProcess)
-{
+nsURLFetcher::DoContent(const nsACString &aContentType,
+                        bool aIsContentPreferred, nsIRequest *request,
+                        nsIStreamListener **aContentHandler,
+                        bool *aAbortProcess) {
   nsresult rv = NS_OK;
 
-  if (aAbortProcess)
-    *aAbortProcess = false;
-  QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
+  if (aAbortProcess) *aAbortProcess = false;
+  QueryInterface(NS_GET_IID(nsIStreamListener), (void **)aContentHandler);
 
   /*
     Check the content-type to see if we need to insert a converter
   */
-  if (PL_strcasecmp(PromiseFlatCString(aContentType).get(), UNKNOWN_CONTENT_TYPE) == 0 ||
-      PL_strcasecmp(PromiseFlatCString(aContentType).get(), MULTIPART_MIXED_REPLACE) == 0 ||
-      PL_strcasecmp(PromiseFlatCString(aContentType).get(), MULTIPART_MIXED) == 0 ||
-      PL_strcasecmp(PromiseFlatCString(aContentType).get(), MULTIPART_BYTERANGES) == 0)
-  {
+  if (PL_strcasecmp(PromiseFlatCString(aContentType).get(),
+                    UNKNOWN_CONTENT_TYPE) == 0 ||
+      PL_strcasecmp(PromiseFlatCString(aContentType).get(),
+                    MULTIPART_MIXED_REPLACE) == 0 ||
+      PL_strcasecmp(PromiseFlatCString(aContentType).get(), MULTIPART_MIXED) ==
+          0 ||
+      PL_strcasecmp(PromiseFlatCString(aContentType).get(),
+                    MULTIPART_BYTERANGES) == 0) {
     rv = InsertConverter(PromiseFlatCString(aContentType).get());
     if (NS_SUCCEEDED(rv))
       mConverterContentType = PromiseFlatCString(aContentType).get();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::GetParentContentListener(nsIURIContentListener** aParent)
-{
+nsURLFetcher::GetParentContentListener(nsIURIContentListener **aParent) {
   *aParent = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::SetParentContentListener(nsIURIContentListener* aParent)
-{
+nsURLFetcher::SetParentContentListener(nsIURIContentListener *aParent) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::GetLoadCookie(nsISupports ** aLoadCookie)
-{
+nsURLFetcher::GetLoadCookie(nsISupports **aLoadCookie) {
   NS_IF_ADDREF(*aLoadCookie = mLoadCookie);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::SetLoadCookie(nsISupports * aLoadCookie)
-{
+nsURLFetcher::SetLoadCookie(nsISupports *aLoadCookie) {
   // Remove the DocShell as a listener of the old WebProgress...
-  if (mLoadCookie)
-  {
+  if (mLoadCookie) {
     nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
 
-    if (webProgress)
-      webProgress->RemoveProgressListener(this);
+    if (webProgress) webProgress->RemoveProgressListener(this);
   }
 
   mLoadCookie = aLoadCookie;
 
   // Add the DocShell as a listener to the new WebProgress...
-  if (mLoadCookie)
-  {
+  if (mLoadCookie) {
     nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
 
     if (webProgress)
       webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_ALL);
   }
   return NS_OK;
-
 }
 
-nsresult
-nsURLFetcher::StillRunning(bool *running)
-{
+nsresult nsURLFetcher::StillRunning(bool *running) {
   *running = mStillRunning;
   return NS_OK;
 }
 
-
 // Methods for nsIStreamListener...
-nsresult
-nsURLFetcher::OnDataAvailable(nsIRequest *request, nsIInputStream *aIStream,
-                              uint64_t sourceOffset, uint32_t aLength)
-{
+nsresult nsURLFetcher::OnDataAvailable(nsIRequest *request,
+                                       nsIInputStream *aIStream,
+                                       uint64_t sourceOffset,
+                                       uint32_t aLength) {
   /* let our converter or consumer process the data */
-  if (!mConverter)
-    return NS_ERROR_FAILURE;
+  if (!mConverter) return NS_ERROR_FAILURE;
 
   return mConverter->OnDataAvailable(request, aIStream, sourceOffset, aLength);
 }
 
-
 // Methods for nsIStreamObserver
-nsresult
-nsURLFetcher::OnStartRequest(nsIRequest *request)
-{
+nsresult nsURLFetcher::OnStartRequest(nsIRequest *request) {
   /* check if the user has canceld the operation */
-  if (mTagData)
-  {
+  if (mTagData) {
     nsCOMPtr<nsIMsgSend> sendPtr;
     mTagData->GetMimeDeliveryState(getter_AddRefs(sendPtr));
-    if (sendPtr)
-    {
+    if (sendPtr) {
       nsCOMPtr<nsIMsgProgress> progress;
       sendPtr->GetProgress(getter_AddRefs(progress));
-      if (progress)
-      {
+      if (progress) {
         bool cancel = false;
         progress->GetProcessCanceledByUser(&cancel);
-        if (cancel)
-          return request->Cancel(NS_ERROR_ABORT);
+        if (cancel) return request->Cancel(NS_ERROR_ABORT);
       }
     }
     mTagData->mRequest = request;
   }
 
   /* call our converter or consumer */
-  if (mConverter)
-    return mConverter->OnStartRequest(request);
+  if (mConverter) return mConverter->OnStartRequest(request);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::OnStopRequest(nsIRequest *request, nsresult aStatus)
-{
-  // it's possible we could get in here from the channel calling us with an OnStopRequest and from our
-  // onStatusChange method (in the case of an error). So we should protect against this to make sure we
-  // don't process the on stop request twice...
+nsURLFetcher::OnStopRequest(nsIRequest *request, nsresult aStatus) {
+  // it's possible we could get in here from the channel calling us with an
+  // OnStopRequest and from our onStatusChange method (in the case of an error).
+  // So we should protect against this to make sure we don't process the on stop
+  // request twice...
 
-  if (mOnStopRequestProcessed)
-    return NS_OK;
+  if (mOnStopRequestProcessed) return NS_OK;
 
   mOnStopRequestProcessed = true;
 
   /* first, call our converter or consumer */
-  if (mConverter)
-    (void) mConverter->OnStopRequest(request, aStatus);
+  if (mConverter) (void)mConverter->OnStopRequest(request, aStatus);
 
-  if (mTagData)
-    mTagData->mRequest = nullptr;
+  if (mTagData) mTagData->mRequest = nullptr;
 
   //
   // Now complete the stream!
   //
   mStillRunning = false;
 
   // time to close the output stream...
-  if (mOutStream)
-  {
+  if (mOutStream) {
     mOutStream->Close();
     mOutStream = nullptr;
 
-    /* In case of multipart/x-mixed-replace, we need to truncate the file to the current part size */
-    if (MsgLowerCaseEqualsLiteral(mConverterContentType, MULTIPART_MIXED_REPLACE))
-    {
+    /* In case of multipart/x-mixed-replace, we need to truncate the file to the
+     * current part size */
+    if (MsgLowerCaseEqualsLiteral(mConverterContentType,
+                                  MULTIPART_MIXED_REPLACE)) {
       mLocalFile->SetFileSize(mTotalWritten);
     }
   }
 
   // Now if there is a callback, we need to call it...
   if (mCallback)
-    mCallback (aStatus, mContentType, mCharset, mTotalWritten, nullptr, mTagData);
+    mCallback(aStatus, mContentType, mCharset, mTotalWritten, nullptr,
+              mTagData);
 
   // Time to return...
   return NS_OK;
 }
 
-nsresult
-nsURLFetcher::Initialize(nsIFile *localFile,
-                         nsIOutputStream *outputStream,
-                         nsAttachSaveCompletionCallback cb,
-                         nsMsgAttachmentHandler *tagData)
-{
-  if (!outputStream || !localFile)
-    return NS_ERROR_INVALID_ARG;
+nsresult nsURLFetcher::Initialize(nsIFile *localFile,
+                                  nsIOutputStream *outputStream,
+                                  nsAttachSaveCompletionCallback cb,
+                                  nsMsgAttachmentHandler *tagData) {
+  if (!outputStream || !localFile) return NS_ERROR_INVALID_ARG;
 
   mOutStream = outputStream;
   mLocalFile = localFile;
-  mCallback = cb;     //JFD: Please, no more callback, use a listener...
+  mCallback = cb;  // JFD: Please, no more callback, use a listener...
   mTagData = tagData;
   return NS_OK;
 }
 
-nsresult
-nsURLFetcher::FireURLRequest(nsIURI *aURL, nsIFile *localFile, nsIOutputStream *outputStream,
-                             nsAttachSaveCompletionCallback cb, nsMsgAttachmentHandler *tagData)
-{
+nsresult nsURLFetcher::FireURLRequest(nsIURI *aURL, nsIFile *localFile,
+                                      nsIOutputStream *outputStream,
+                                      nsAttachSaveCompletionCallback cb,
+                                      nsMsgAttachmentHandler *tagData) {
   nsresult rv;
 
   rv = Initialize(localFile, outputStream, cb, tagData);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  //check to see if aURL is a local file or not
+  // check to see if aURL is a local file or not
   aURL->SchemeIs("file", &mIsFile);
 
-  // we're about to fire a new url request so make sure the on stop request flag is cleared...
+  // we're about to fire a new url request so make sure the on stop request flag
+  // is cleared...
   mOnStopRequestProcessed = false;
 
   // let's try uri dispatching...
   nsCOMPtr<nsIURILoader> pURILoader = mozilla::components::URILoader::Service();
   NS_ENSURE_TRUE(pURILoader, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIChannel> channel;
-  rv = NS_NewChannel(getter_AddRefs(channel),
-                     aURL,
+  rv = NS_NewChannel(getter_AddRefs(channel), aURL,
                      nsContentUtils::GetSystemPrincipal(),
                      nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                      nsIContentPolicy::TYPE_OTHER,
-                     nullptr, // aCookieSettings
-                     nullptr, // aPerformanceStorage
-                     nullptr, // aLoadGroup
-                     this); // aCallbacks
+                     nullptr,  // aCookieSettings
+                     nullptr,  // aPerformanceStorage
+                     nullptr,  // aLoadGroup
+                     this);    // aCallbacks
   NS_ENSURE_SUCCESS(rv, rv);
 
   return pURILoader->OpenURI(channel, false, this);
 }
 
-nsresult
-nsURLFetcher::InsertConverter(const char * aContentType)
-{
+nsresult nsURLFetcher::InsertConverter(const char *aContentType) {
   nsresult rv;
 
-  nsCOMPtr<nsIStreamConverterService> convServ(do_GetService("@mozilla.org/streamConverters;1", &rv));
-  if (NS_SUCCEEDED(rv))
-  {
+  nsCOMPtr<nsIStreamConverterService> convServ(
+      do_GetService("@mozilla.org/streamConverters;1", &rv));
+  if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIStreamListener> toListener(mConverter);
     nsCOMPtr<nsIStreamListener> fromListener;
 
-    rv = convServ->AsyncConvertData(aContentType,
-                                    "*/*",
-                                    toListener,
-                                    nullptr,
+    rv = convServ->AsyncConvertData(aContentType, "*/*", toListener, nullptr,
                                     getter_AddRefs(fromListener));
-    if (NS_SUCCEEDED(rv))
-      mConverter = fromListener;
+    if (NS_SUCCEEDED(rv)) mConverter = fromListener;
   }
 
   return rv;
 }
 
 // web progress listener implementation
 
 NS_IMETHODIMP
 nsURLFetcher::OnProgressChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
-                             int32_t aCurSelfProgress, int32_t aMaxSelfProgress,
-                             int32_t aCurTotalProgress, int32_t aMaxTotalProgress)
-{
+                               int32_t aCurSelfProgress,
+                               int32_t aMaxSelfProgress,
+                               int32_t aCurTotalProgress,
+                               int32_t aMaxTotalProgress) {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsURLFetcher::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
-                          uint32_t aStateFlags, nsresult aStatus)
-{
-  // all we care about is the case where an error occurred (as in we were unable to locate the
-  // the url....
+                            uint32_t aStateFlags, nsresult aStatus) {
+  // all we care about is the case where an error occurred (as in we were unable
+  // to locate the the url....
 
-  if (NS_FAILED(aStatus))
-    OnStopRequest(aRequest, aStatus);
+  if (NS_FAILED(aStatus)) OnStopRequest(aRequest, aStatus);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::OnLocationChange(nsIWebProgress* aWebProgress,
-                               nsIRequest* aRequest,
-                               nsIURI *aURI,
-                               uint32_t aFlags)
-{
+nsURLFetcher::OnLocationChange(nsIWebProgress *aWebProgress,
+                               nsIRequest *aRequest, nsIURI *aURI,
+                               uint32_t aFlags) {
   MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsURLFetcher::OnStatusChange(nsIWebProgress* aWebProgress,
-                             nsIRequest* aRequest,
-                             nsresult aStatus,
-                             const char16_t* aMessage)
-{
+nsURLFetcher::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest,
+                             nsresult aStatus, const char16_t *aMessage) {
   MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsURLFetcher::OnSecurityChange(nsIWebProgress *aWebProgress,
-                               nsIRequest *aRequest,
-                               uint32_t state)
-{
+                               nsIRequest *aRequest, uint32_t state) {
   MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsURLFetcher::OnContentBlockingEvent(nsIWebProgress *aWebProgress,
-                                     nsIRequest *aRequest, uint32_t aEvent)
-{
+                                     nsIRequest *aRequest, uint32_t aEvent) {
   MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)");
   return NS_OK;
 }
 
 /**
- * Stream consumer used for handling special content type like multipart/x-mixed-replace
+ * Stream consumer used for handling special content type like
+ * multipart/x-mixed-replace
  */
 
-NS_IMPL_ISUPPORTS(nsURLFetcherStreamConsumer, nsIStreamListener, nsIRequestObserver)
+NS_IMPL_ISUPPORTS(nsURLFetcherStreamConsumer, nsIStreamListener,
+                  nsIRequestObserver)
 
-nsURLFetcherStreamConsumer::nsURLFetcherStreamConsumer(nsURLFetcher* urlFetcher) :
-  mURLFetcher(urlFetcher)
-{
-}
+nsURLFetcherStreamConsumer::nsURLFetcherStreamConsumer(nsURLFetcher *urlFetcher)
+    : mURLFetcher(urlFetcher) {}
 
-nsURLFetcherStreamConsumer::~nsURLFetcherStreamConsumer()
-{
-}
+nsURLFetcherStreamConsumer::~nsURLFetcherStreamConsumer() {}
 
 /** nsIRequestObserver methods **/
 
 /* void onStartRequest (in nsIRequest request); */
-NS_IMETHODIMP nsURLFetcherStreamConsumer::OnStartRequest(nsIRequest *aRequest)
-{
-  if (!mURLFetcher || !mURLFetcher->mOutStream)
-    return NS_ERROR_FAILURE;
+NS_IMETHODIMP nsURLFetcherStreamConsumer::OnStartRequest(nsIRequest *aRequest) {
+  if (!mURLFetcher || !mURLFetcher->mOutStream) return NS_ERROR_FAILURE;
 
-  /* In case of multipart/x-mixed-replace, we need to erase the output file content */
-  if (MsgLowerCaseEqualsLiteral(mURLFetcher->mConverterContentType, MULTIPART_MIXED_REPLACE))
-  {
-    nsCOMPtr<nsISeekableStream> seekStream = do_QueryInterface(mURLFetcher->mOutStream);
-    if (seekStream)
-      seekStream->Seek(nsISeekableStream::NS_SEEK_SET, 0);
+  /* In case of multipart/x-mixed-replace, we need to erase the output file
+   * content */
+  if (MsgLowerCaseEqualsLiteral(mURLFetcher->mConverterContentType,
+                                MULTIPART_MIXED_REPLACE)) {
+    nsCOMPtr<nsISeekableStream> seekStream =
+        do_QueryInterface(mURLFetcher->mOutStream);
+    if (seekStream) seekStream->Seek(nsISeekableStream::NS_SEEK_SET, 0);
     mURLFetcher->mTotalWritten = 0;
   }
 
   return NS_OK;
 }
 
 /* void onStopRequest (in nsIRequest request, in nsresult status); */
-NS_IMETHODIMP nsURLFetcherStreamConsumer::OnStopRequest(nsIRequest *aRequest, nsresult status)
-{
-  if (!mURLFetcher)
-    return NS_ERROR_FAILURE;
+NS_IMETHODIMP nsURLFetcherStreamConsumer::OnStopRequest(nsIRequest *aRequest,
+                                                        nsresult status) {
+  if (!mURLFetcher) return NS_ERROR_FAILURE;
 
   // Check the content type!
   nsAutoCString contentType;
   nsAutoCString charset;
 
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
-  if(!channel) return NS_ERROR_FAILURE;
+  if (!channel) return NS_ERROR_FAILURE;
 
   if (NS_SUCCEEDED(channel->GetContentType(contentType)) &&
-      !contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE))
-  {
+      !contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
     nsAutoCString uriSpec;
-    nsCOMPtr <nsIURI> channelURI;
+    nsCOMPtr<nsIURI> channelURI;
     channel->GetURI(getter_AddRefs(channelURI));
     nsresult rv = channelURI->GetSpec(uriSpec);
     NS_ENSURE_SUCCESS(rv, rv);
     if (uriSpec.Find("&realtype=message/rfc822") >= 0)
       mURLFetcher->mContentType = MESSAGE_RFC822;
     else
       mURLFetcher->mContentType = contentType;
   }
 
-  if (NS_SUCCEEDED(channel->GetContentCharset(charset)) && !charset.IsEmpty())
-  {
+  if (NS_SUCCEEDED(channel->GetContentCharset(charset)) && !charset.IsEmpty()) {
     mURLFetcher->mCharset = charset;
   }
 
   return NS_OK;
 }
 
 /** nsIStreamListener methods **/
 
-/* void onDataAvailable (in nsIRequest request, in nsIInputStream inStr, in unsigned long long sourceOffset, in unsigned long count); */
-NS_IMETHODIMP nsURLFetcherStreamConsumer::OnDataAvailable(nsIRequest *aRequest, nsIInputStream *inStr, uint64_t sourceOffset, uint32_t count)
-{
-  uint32_t        readLen = count;
-  uint32_t        wroteIt;
+/* void onDataAvailable (in nsIRequest request, in nsIInputStream inStr, in
+ * unsigned long long sourceOffset, in unsigned long count); */
+NS_IMETHODIMP nsURLFetcherStreamConsumer::OnDataAvailable(nsIRequest *aRequest,
+                                                          nsIInputStream *inStr,
+                                                          uint64_t sourceOffset,
+                                                          uint32_t count) {
+  uint32_t readLen = count;
+  uint32_t wroteIt;
 
-  if (!mURLFetcher)
-    return NS_ERROR_FAILURE;
+  if (!mURLFetcher) return NS_ERROR_FAILURE;
 
-  if (!mURLFetcher->mOutStream)
-    return NS_ERROR_INVALID_ARG;
+  if (!mURLFetcher->mOutStream) return NS_ERROR_INVALID_ARG;
 
-  if (mURLFetcher->mBufferSize < count)
-  {
+  if (mURLFetcher->mBufferSize < count) {
     PR_FREEIF(mURLFetcher->mBuffer);
 
     if (count > 0x1000)
       mURLFetcher->mBufferSize = count;
     else
       mURLFetcher->mBufferSize = 0x1000;
 
     mURLFetcher->mBuffer = (char *)PR_Malloc(mURLFetcher->mBufferSize);
     if (!mURLFetcher->mBuffer)
       return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
   }
 
   // read the data from the input stram...
   nsresult rv = inStr->Read(mURLFetcher->mBuffer, count, &readLen);
-  if (NS_FAILED(rv))
-    return rv;
+  if (NS_FAILED(rv)) return rv;
 
   // write to the output file...
   mURLFetcher->mOutStream->Write(mURLFetcher->mBuffer, readLen, &wroteIt);
 
   if (wroteIt != readLen)
     return NS_ERROR_FAILURE;
-  else
-  {
+  else {
     mURLFetcher->mTotalWritten += wroteIt;
     return NS_OK;
   }
 }
--- a/mailnews/compose/src/nsURLFetcher.h
+++ b/mailnews/compose/src/nsURLFetcher.h
@@ -22,19 +22,18 @@
 
 class nsMsgAttachmentHandler;
 
 class nsURLFetcher : public nsIURLFetcher,
                      public nsIStreamListener,
                      public nsIURIContentListener,
                      public nsIInterfaceRequestor,
                      public nsIWebProgressListener,
-                     public nsSupportsWeakReference
-{
-public:
+                     public nsSupportsWeakReference {
+ public:
   nsURLFetcher();
 
   /* this macro defines QueryInterface, AddRef and Release for this class */
   NS_DECL_ISUPPORTS
 
   // Methods for nsIURLFetcher
   NS_DECL_NSIURLFETCHER
 
@@ -48,54 +47,55 @@ public:
   NS_DECL_NSIURICONTENTLISTENER
 
   // Methods for nsIInterfaceRequestor
   NS_DECL_NSIINTERFACEREQUESTOR
 
   // Methods for nsIWebProgressListener
   NS_DECL_NSIWEBPROGRESSLISTENER
 
-protected:
-  nsresult InsertConverter(const char * aContentType);
+ protected:
+  nsresult InsertConverter(const char* aContentType);
 
-private:
+ private:
   virtual ~nsURLFetcher();
-  nsCOMPtr<nsIOutputStream>       mOutStream;               // the output file stream
-  nsCOMPtr<nsIFile>          mLocalFile;               // the output file itself
-  nsCOMPtr<nsIStreamListener>     mConverter;               // the stream converter, if needed
-  nsCString                  mConverterContentType;    // The content type of the converter
-  bool                            mStillRunning;  // Are we still running?
-  int32_t                         mTotalWritten;  // Size counter variable
-  char                            *mBuffer;                 // Buffer used for reading the data
-  uint32_t                        mBufferSize;              // Buffer size;
-  nsCString                  mContentType;             // The content type retrieved from the server
-  nsCString                  mCharset;                 // The charset retrieved from the server
-  RefPtr<nsMsgAttachmentHandler> mTagData;      // Tag data for callback...
-  nsAttachSaveCompletionCallback  mCallback;      // Callback to call once the file is saved...
-  nsCOMPtr<nsISupports>           mLoadCookie;    // load cookie used by the uri loader when we fetch the url
-  bool                            mOnStopRequestProcessed; // used to prevent calling OnStopRequest multiple times
-  bool                            mIsFile;        // This is used to check whether the URI is a local file.
+  nsCOMPtr<nsIOutputStream> mOutStream;    // the output file stream
+  nsCOMPtr<nsIFile> mLocalFile;            // the output file itself
+  nsCOMPtr<nsIStreamListener> mConverter;  // the stream converter, if needed
+  nsCString mConverterContentType;         // The content type of the converter
+  bool mStillRunning;                      // Are we still running?
+  int32_t mTotalWritten;                   // Size counter variable
+  char* mBuffer;                           // Buffer used for reading the data
+  uint32_t mBufferSize;                    // Buffer size;
+  nsCString mContentType;  // The content type retrieved from the server
+  nsCString mCharset;      // The charset retrieved from the server
+  RefPtr<nsMsgAttachmentHandler> mTagData;  // Tag data for callback...
+  nsAttachSaveCompletionCallback
+      mCallback;  // Callback to call once the file is saved...
+  nsCOMPtr<nsISupports>
+      mLoadCookie;  // load cookie used by the uri loader when we fetch the url
+  bool mOnStopRequestProcessed;  // used to prevent calling OnStopRequest
+                                 // multiple times
+  bool mIsFile;  // This is used to check whether the URI is a local file.
 
   friend class nsURLFetcherStreamConsumer;
 };
 
-
 /**
- * Stream consumer used for handling special content type like multipart/x-mixed-replace
+ * Stream consumer used for handling special content type like
+ * multipart/x-mixed-replace
  */
 
-class nsURLFetcherStreamConsumer : public nsIStreamListener
-{
-public:
+class nsURLFetcherStreamConsumer : public nsIStreamListener {
+ public:
   explicit nsURLFetcherStreamConsumer(nsURLFetcher* urlFetcher);
 
   /* additional members */
   NS_DECL_ISUPPORTS
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSIREQUESTOBSERVER
 
-private:
+ private:
   virtual ~nsURLFetcherStreamConsumer();
   nsURLFetcher* mURLFetcher;
 };
 
-
 #endif /* nsURLFetcher_h_ */