Bug 1546364 - Reformat to Google coding style in mailnews/news. rs=reformat
authorJorg K <jorgk@jorgk.com>
Fri, 26 Apr 2019 11:48:27 +0200
changeset 34354 9e527e651e5c6044973c705e74a7cd017bcb224f
parent 34353 2458408cc87e8c3127ecab8b88a734ba45abcd7d
child 34355 9dda6f78d5adea30f00e04659451a9bca6478841
push id2407
push userclokep@gmail.com
push dateMon, 20 May 2019 17:11:26 +0000
treeherdercomm-beta@193428fd6fd4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersreformat
bugs1546364
Bug 1546364 - Reformat to Google coding style in mailnews/news. rs=reformat # ignore-this-changeset
mailnews/news/public/nsMsgNewsCID.h
mailnews/news/src/nntpCore.h
mailnews/news/src/nsNNTPArticleList.cpp
mailnews/news/src/nsNNTPArticleList.h
mailnews/news/src/nsNNTPNewsgroupList.cpp
mailnews/news/src/nsNNTPNewsgroupList.h
mailnews/news/src/nsNNTPNewsgroupPost.cpp
mailnews/news/src/nsNNTPNewsgroupPost.h
mailnews/news/src/nsNNTPProtocol.cpp
mailnews/news/src/nsNNTPProtocol.h
mailnews/news/src/nsNewsDownloadDialogArgs.cpp
mailnews/news/src/nsNewsDownloadDialogArgs.h
mailnews/news/src/nsNewsDownloader.cpp
mailnews/news/src/nsNewsDownloader.h
mailnews/news/src/nsNewsFolder.cpp
mailnews/news/src/nsNewsFolder.h
mailnews/news/src/nsNewsUtils.cpp
mailnews/news/src/nsNewsUtils.h
mailnews/news/src/nsNntpIncomingServer.cpp
mailnews/news/src/nsNntpIncomingServer.h
mailnews/news/src/nsNntpMockChannel.cpp
mailnews/news/src/nsNntpMockChannel.h
mailnews/news/src/nsNntpService.cpp
mailnews/news/src/nsNntpService.h
mailnews/news/src/nsNntpUrl.cpp
mailnews/news/src/nsNntpUrl.h
--- a/mailnews/news/public/nsMsgNewsCID.h
+++ b/mailnews/news/public/nsMsgNewsCID.h
@@ -10,108 +10,115 @@
 #include "nsIFactory.h"
 #include "nsIComponentManager.h"
 #include "nsMsgBaseCID.h"
 
 //
 // nsMsgNewsFolder
 #define NS_NEWSFOLDERRESOURCE_CONTRACTID \
   NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX "news"
-#define NS_NEWSFOLDERRESOURCE_CID                      \
-{ /* 4ace448a-f6d4-11d2-880d-004005263078 */           \
- 0x4ace448a, 0xf6d4, 0x11d2,         \
- {0x88, 0x0d, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78}   \
-}
+#define NS_NEWSFOLDERRESOURCE_CID                    \
+  { /* 4ace448a-f6d4-11d2-880d-004005263078 */       \
+    0x4ace448a, 0xf6d4, 0x11d2, {                    \
+      0x88, 0x0d, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78 \
+    }                                                \
+  }
 
 //
 // nsNntpIncomingServer
 //
 #define NS_NNTPINCOMINGSERVER_CONTRACTID \
   NS_MSGINCOMINGSERVER_CONTRACTID_PREFIX "nntp"
 
-#define NS_NNTPINCOMINGSERVER_CID       \
-{ /* 6ff28d0a-f776-11d2-87ca-004005263078 */     \
- 0x6ff28d0a, 0xf776, 0x11d2,         \
- {0x87, 0xca, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78}   \
-}
+#define NS_NNTPINCOMINGSERVER_CID                    \
+  { /* 6ff28d0a-f776-11d2-87ca-004005263078 */       \
+    0x6ff28d0a, 0xf776, 0x11d2, {                    \
+      0x87, 0xca, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78 \
+    }                                                \
+  }
 
 //
 // nsNntpService
 //
 
-#define NS_NNTPPROTOCOLINFO_CONTRACTID    \
+#define NS_NNTPPROTOCOLINFO_CONTRACTID \
   NS_MSGPROTOCOLINFO_CONTRACTID_PREFIX "nntp"
 
 #define NS_NEWSPROTOCOLHANDLER_CONTRACTID \
   NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "news"
 #define NS_SNEWSPROTOCOLHANDLER_CONTRACTID \
   NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "snews"
 #define NS_NNTPPROTOCOLHANDLER_CONTRACTID \
   NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "nntp"
 #define NS_NEWSMESSAGESERVICE_CONTRACTID \
   "@mozilla.org/messenger/messageservice;1?type=news-message"
 #define NS_NNTPMESSAGESERVICE_CONTRACTID \
   "@mozilla.org/messenger/messageservice;1?type=news"
-#define NS_NNTPSERVICE_CONTRACTID \
-  "@mozilla.org/messenger/nntpservice;1"
+#define NS_NNTPSERVICE_CONTRACTID "@mozilla.org/messenger/nntpservice;1"
 #define NS_NEWSSTARTUPHANDLER_CONTRACTID \
   "@mozilla.org/commandlinehandler/general-startup;1?type=news"
 
-#define NS_NNTPSERVICE_CID                              \
-{ /* 4C9F90E1-E19B-11d2-806E-006008128C4E */      \
- 0x4c9f90e1, 0xe19b, 0x11d2,                            \
- {0x80, 0x6e, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e}   \
-}
+#define NS_NNTPSERVICE_CID                         \
+  { /* 4C9F90E1-E19B-11d2-806E-006008128C4E */     \
+    0x4c9f90e1, 0xe19b, 0x11d2, {                  \
+      0x80, 0x6e, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e \
+    }                                              \
+  }
 
 //
 // nsNNTPNewsgroupPost
 //
 #define NS_NNTPNEWSGROUPPOST_CONTRACTID \
   "@mozilla.org/messenger/nntpnewsgrouppost;1"
-#define NS_NNTPNEWSGROUPPOST_CID  \
-{ /* 30c60228-187e-11d3-842f-004005263078 */ \
- 0x30c60228, 0x187e, 0x11d3, \
- {0x84, 0x2f, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78} \
-}
+#define NS_NNTPNEWSGROUPPOST_CID                     \
+  { /* 30c60228-187e-11d3-842f-004005263078 */       \
+    0x30c60228, 0x187e, 0x11d3, {                    \
+      0x84, 0x2f, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78 \
+    }                                                \
+  }
 
 //
 // nsNNTPNewsgroupList
 //
 #define NS_NNTPNEWSGROUPLIST_CONTRACTID \
   "@mozilla.org/messenger/nntpnewsgrouplist;1"
-#define NS_NNTPNEWSGROUPLIST_CID \
-{ /* 631e9054-1893-11d3-9916-004005263078 */ \
- 0x631e9054, 0x1893, 0x11d3, \
- {0x99, 0x16, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78} \
-}
+#define NS_NNTPNEWSGROUPLIST_CID                     \
+  { /* 631e9054-1893-11d3-9916-004005263078 */       \
+    0x631e9054, 0x1893, 0x11d3, {                    \
+      0x99, 0x16, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78 \
+    }                                                \
+  }
 
 //
 // nsNNTPArticleList
 //
-#define NS_NNTPARTICLELIST_CONTRACTID \
-  "@mozilla.org/messenger/nntparticlelist;1"
-#define NS_NNTPARTICLELIST_CID  \
-{ /* 9f12bdf0-189f-11d3-973e-00805f916fd3 */ \
- 0x9f12bdf0, 0x189f, 0x11d3, \
- {0x97, 0x3e, 0x00, 0x80, 0x5f, 0x91, 0x6f, 0xd3} \
-}
+#define NS_NNTPARTICLELIST_CONTRACTID "@mozilla.org/messenger/nntparticlelist;1"
+#define NS_NNTPARTICLELIST_CID                       \
+  { /* 9f12bdf0-189f-11d3-973e-00805f916fd3 */       \
+    0x9f12bdf0, 0x189f, 0x11d3, {                    \
+      0x97, 0x3e, 0x00, 0x80, 0x5f, 0x91, 0x6f, 0xd3 \
+    }                                                \
+  }
 
 //
 // nsNntpUrl
 //
-#define NS_NNTPURL_CONTRACTID \
-  "@mozilla.org/messenger/nntpurl;1"
-#define NS_NNTPURL_CID                  \
-{ /* 196B4B30-E18C-11d2-806E-006008128C4E */      \
-  0x196b4b30, 0xe18c, 0x11d2,              \
-    { 0x80, 0x6e, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e } }
+#define NS_NNTPURL_CONTRACTID "@mozilla.org/messenger/nntpurl;1"
+#define NS_NNTPURL_CID                             \
+  { /* 196B4B30-E18C-11d2-806E-006008128C4E */     \
+    0x196b4b30, 0xe18c, 0x11d2, {                  \
+      0x80, 0x6e, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e \
+    }                                              \
+  }
 
 //
 // nsNewsDownloadDialogArgs
 //
 #define NS_NEWSDOWNLOADDIALOGARGS_CONTRACTID \
-   "@mozilla.org/messenger/newsdownloaddialogargs;1"
-#define NS_NEWSDOWNLOADDIALOGARGS_CID   \
-{ /* 1540689e-1dd2-11b2-933d-f0d1e460ef4a */    \
-  0x1540689e, 0x1dd2, 0x11b2,   \
-    { 0x93, 0x3d, 0xf0, 0xd1, 0xe4, 0x60, 0xef, 0x4a} }
+  "@mozilla.org/messenger/newsdownloaddialogargs;1"
+#define NS_NEWSDOWNLOADDIALOGARGS_CID                \
+  { /* 1540689e-1dd2-11b2-933d-f0d1e460ef4a */       \
+    0x1540689e, 0x1dd2, 0x11b2, {                    \
+      0x93, 0x3d, 0xf0, 0xd1, 0xe4, 0x60, 0xef, 0x4a \
+    }                                                \
+  }
 
-#endif // nsMsgNewsCID_h__
+#endif  // nsMsgNewsCID_h__
--- a/mailnews/news/src/nntpCore.h
+++ b/mailnews/news/src/nntpCore.h
@@ -1,28 +1,29 @@
 /* -*- 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 _NNTPCore_H__
 #define _NNTPCore_H__
 
-#define NEWS_MSGS_URL       "chrome://messenger/locale/news.properties"
+#define NEWS_MSGS_URL "chrome://messenger/locale/news.properties"
 
-// The following string constants are protocol strings. I'm defining them as macros here
-// so I don't have to sprinkle all of the strings throughout the protocol.
-#define NNTP_CMD_LIST_EXTENSIONS    "LIST EXTENSIONS" CRLF
-#define NNTP_CMD_MODE_READER      "MODE READER" CRLF
-#define NNTP_CMD_LIST_SEARCHES      "LIST SEARCHES" CRLF
-#define NNTP_CMD_LIST_SEARCH_FIELDS     "LIST SRCHFIELDS" CRLF
-#define NNTP_CMD_GET_PROPERTIES         "GET" CRLF
-#define NNTP_CMD_LIST_SUBSCRIPTIONS     "LIST SUBSCRIPTIONS" CRLF
-#define NNTP_CMD_POST        "POST" CRLF
-#define NNTP_CMD_QUIT        "QUIT" CRLF
+// The following string constants are protocol strings. I'm defining them as
+// macros here so I don't have to sprinkle all of the strings throughout the
+// protocol.
+#define NNTP_CMD_LIST_EXTENSIONS "LIST EXTENSIONS" CRLF
+#define NNTP_CMD_MODE_READER "MODE READER" CRLF
+#define NNTP_CMD_LIST_SEARCHES "LIST SEARCHES" CRLF
+#define NNTP_CMD_LIST_SEARCH_FIELDS "LIST SRCHFIELDS" CRLF
+#define NNTP_CMD_GET_PROPERTIES "GET" CRLF
+#define NNTP_CMD_LIST_SUBSCRIPTIONS "LIST SUBSCRIPTIONS" CRLF
+#define NNTP_CMD_POST "POST" CRLF
+#define NNTP_CMD_QUIT "QUIT" CRLF
 
 // end of protocol strings
 
 #define MK_NNTP_RESPONSE_HELP 100
 
 #define MK_NNTP_RESPONSE_POSTING_ALLOWED 200
 #define MK_NNTP_RESPONSE_POSTING_DENIED 201
 
@@ -37,127 +38,128 @@
 #define MK_NNTP_RESPONSE_ARTICLE_HEAD 221
 #define MK_NNTP_RESPONSE_ARTICLE_BODY 222
 #define MK_NNTP_RESPONSE_ARTICLE_NONE 223
 #define MK_NNTP_RESPONSE_ARTICLE_NO_GROUP 412
 #define MK_NNTP_RESPONSE_ARTICLE_NO_CURRENT 420
 #define MK_NNTP_RESPONSE_ARTICLE_NONEXIST 423
 #define MK_NNTP_RESPONSE_ARTICLE_NOTFOUND 430
 
-#define MK_NNTP_RESPONSE_GROUP_SELECTED   211
-#define MK_NNTP_RESPONSE_GROUP_NO_GROUP   411
+#define MK_NNTP_RESPONSE_GROUP_SELECTED 211
+#define MK_NNTP_RESPONSE_GROUP_NO_GROUP 411
 
-#define MK_NNTP_RESPONSE_IHAVE_OK         235
-#define MK_NNTP_RESPONSE_IHAVE_ARTICLE    335
+#define MK_NNTP_RESPONSE_IHAVE_OK 235
+#define MK_NNTP_RESPONSE_IHAVE_ARTICLE 335
 #define MK_NNTP_RESPONSE_IHAVE_NOT_WANTED 435
-#define MK_NNTP_RESPONSE_IHAVE_FAILED     436
-#define MK_NNTP_RESPONSE_IHAVE_REJECTED   437
+#define MK_NNTP_RESPONSE_IHAVE_FAILED 436
+#define MK_NNTP_RESPONSE_IHAVE_REJECTED 437
 
-#define MK_NNTP_RESPONSE_LAST_OK          223
-#define MK_NNTP_RESPONSE_LAST_NO_GROUP    412
-#define MK_NNTP_RESPONSE_LAST_NO_CURRENT  420
-#define MK_NNTP_RESPONSE_LAST_NO_ARTICLE  422
+#define MK_NNTP_RESPONSE_LAST_OK 223
+#define MK_NNTP_RESPONSE_LAST_NO_GROUP 412
+#define MK_NNTP_RESPONSE_LAST_NO_CURRENT 420
+#define MK_NNTP_RESPONSE_LAST_NO_ARTICLE 422
 
-#define MK_NNTP_RESPONSE_LIST_OK          215
+#define MK_NNTP_RESPONSE_LIST_OK 215
 
-#define MK_NNTP_RESPONSE_NEWGROUPS_OK     231
+#define MK_NNTP_RESPONSE_NEWGROUPS_OK 231
 
-#define MK_NNTP_RESPONSE_NEWNEWS_OK       230
+#define MK_NNTP_RESPONSE_NEWNEWS_OK 230
 
-#define MK_NNTP_RESPONSE_NEXT_OK          223
-#define MK_NNTP_RESPONSE_NEXT_NO_GROUP    412
-#define MK_NNTP_RESPONSE_NEXT_NO_CURRENT  420
-#define MK_NNTP_RESPONSE_NEXT_NO_ARTICLE  421
+#define MK_NNTP_RESPONSE_NEXT_OK 223
+#define MK_NNTP_RESPONSE_NEXT_NO_GROUP 412
+#define MK_NNTP_RESPONSE_NEXT_NO_CURRENT 420
+#define MK_NNTP_RESPONSE_NEXT_NO_ARTICLE 421
 
-#define MK_NNTP_RESPONSE_POST_OK          240
-#define MK_NNTP_RESPONSE_POST_SEND_NOW    340
-#define MK_NNTP_RESPONSE_POST_DENIED      440
-#define MK_NNTP_RESPONSE_POST_FAILED      441
+#define MK_NNTP_RESPONSE_POST_OK 240
+#define MK_NNTP_RESPONSE_POST_SEND_NOW 340
+#define MK_NNTP_RESPONSE_POST_DENIED 440
+#define MK_NNTP_RESPONSE_POST_FAILED 441
 
-#define MK_NNTP_RESPONSE_QUIT_OK          205
+#define MK_NNTP_RESPONSE_QUIT_OK 205
 
-#define MK_NNTP_RESPONSE_SLAVE_OK         202
+#define MK_NNTP_RESPONSE_SLAVE_OK 202
 
 #define MK_NNTP_RESPONSE_CHECK_NO_ARTICLE 238
-#define MK_NNTP_RESPONSE_CHECK_NO_ACCEPT  400
-#define MK_NNTP_RESPONSE_CHECK_LATER      431
-#define MK_NNTP_RESPONSE_CHECK_DONT_SEND  438
-#define MK_NNTP_RESPONSE_CHECK_DENIED     480
-#define MK_NNTP_RESPONSE_CHECK_ERROR      500
+#define MK_NNTP_RESPONSE_CHECK_NO_ACCEPT 400
+#define MK_NNTP_RESPONSE_CHECK_LATER 431
+#define MK_NNTP_RESPONSE_CHECK_DONT_SEND 438
+#define MK_NNTP_RESPONSE_CHECK_DENIED 480
+#define MK_NNTP_RESPONSE_CHECK_ERROR 500
 
-#define MK_NNTP_RESPONSE_XHDR_OK          221
-#define MK_NNTP_RESPONSE_XHDR_NO_GROUP    412
-#define MK_NNTP_RESPONSE_XHDR_NO_CURRENT  420
-#define MK_NNTP_RESPONSE_XHDR_NO_ARTICLE  430
-#define MK_NNTP_RESPONSE_XHDR_DENIED      502
+#define MK_NNTP_RESPONSE_XHDR_OK 221
+#define MK_NNTP_RESPONSE_XHDR_NO_GROUP 412
+#define MK_NNTP_RESPONSE_XHDR_NO_CURRENT 420
+#define MK_NNTP_RESPONSE_XHDR_NO_ARTICLE 430
+#define MK_NNTP_RESPONSE_XHDR_DENIED 502
 
-#define MK_NNTP_RESPONSE_XOVER_OK         224
-#define MK_NNTP_RESPONSE_XOVER_NO_GROUP   412
+#define MK_NNTP_RESPONSE_XOVER_OK 224
+#define MK_NNTP_RESPONSE_XOVER_NO_GROUP 412
 #define MK_NNTP_RESPONSE_XOVER_NO_CURRENT 420
-#define MK_NNTP_RESPONSE_XOVER_DENIED     502
+#define MK_NNTP_RESPONSE_XOVER_DENIED 502
 
-#define MK_NNTP_RESPONSE_XPAT_OK          221
-#define MK_NNTP_RESPONSE_XPAT_NO_ARTICLE  430
-#define MK_NNTP_RESPONSE_XPAT_DENIED      502
+#define MK_NNTP_RESPONSE_XPAT_OK 221
+#define MK_NNTP_RESPONSE_XPAT_NO_ARTICLE 430
+#define MK_NNTP_RESPONSE_XPAT_DENIED 502
 
-#define MK_NNTP_RESPONSE_AUTHINFO_OK      281
-#define MK_NNTP_RESPONSE_AUTHINFO_CONT    381
+#define MK_NNTP_RESPONSE_AUTHINFO_OK 281
+#define MK_NNTP_RESPONSE_AUTHINFO_CONT 381
 #define MK_NNTP_RESPONSE_AUTHINFO_REQUIRE 480
-#define MK_NNTP_RESPONSE_AUTHINFO_REJECT  482
-#define MK_NNTP_RESPONSE_AUTHINFO_DENIED  502
+#define MK_NNTP_RESPONSE_AUTHINFO_REJECT 482
+#define MK_NNTP_RESPONSE_AUTHINFO_DENIED 502
 
 #define MK_NNTP_RESPONSE_
 
-#define MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_OK      250
-#define MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_CONT    350
+#define MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_OK 250
+#define MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_CONT 350
 #define MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_REQUIRE 450
-#define MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_REJECT  452
+#define MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_REJECT 452
 
-#define MK_NNTP_RESPONSE_TYPE_INFO    1
-#define MK_NNTP_RESPONSE_TYPE_OK      2
-#define MK_NNTP_RESPONSE_TYPE_CONT    3
-#define MK_NNTP_RESPONSE_TYPE_CANNOT  4
-#define MK_NNTP_RESPONSE_TYPE_ERROR   5
+#define MK_NNTP_RESPONSE_TYPE_INFO 1
+#define MK_NNTP_RESPONSE_TYPE_OK 2
+#define MK_NNTP_RESPONSE_TYPE_CONT 3
+#define MK_NNTP_RESPONSE_TYPE_CANNOT 4
+#define MK_NNTP_RESPONSE_TYPE_ERROR 5
 
-#define MK_NNTP_RESPONSE_TYPE(x) (x/100)
+#define MK_NNTP_RESPONSE_TYPE(x) (x / 100)
 
-// the following used to be defined in allxpstr.h. Until we find a new values for these,
-// I'm defining them here because I don't want to link against xplib.lib...(mscott)
+// the following used to be defined in allxpstr.h. Until we find a new values
+// for these, I'm defining them here because I don't want to link against
+// xplib.lib...(mscott)
 
-#define MK_DATA_LOADED    1
-#define MK_EMPTY_NEWS_LIST  -227
-#define MK_INTERRUPTED    -201
-#define MK_MALFORMED_URL_ERROR  -209
-#define MK_NEWS_ERROR_FMT    -430
-#define MK_NNTP_CANCEL_CONFIRM  -426
+#define MK_DATA_LOADED 1
+#define MK_EMPTY_NEWS_LIST -227
+#define MK_INTERRUPTED -201
+#define MK_MALFORMED_URL_ERROR -209
+#define MK_NEWS_ERROR_FMT -430
+#define MK_NNTP_CANCEL_CONFIRM -426
 #define MK_NNTP_CANCEL_DISALLOWED -427
-#define MK_NNTP_NOT_CANCELLED    -429
-#define MK_OUT_OF_MEMORY     -207
-#define XP_CONFIRM_SAVE_NEWSGROUPS      -1
-#define XP_HTML_ARTICLE_EXPIRED        -1
-#define XP_HTML_NEWS_ERROR          -1
-#define XP_PROGRESS_READ_NEWSGROUPINFO     1
-#define XP_PROGRESS_RECEIVE_ARTICLE       1
-#define XP_PROGRESS_RECEIVE_LISTARTICLES   1
-#define XP_PROGRESS_RECEIVE_NEWSGROUP     1
-#define XP_PROGRESS_SORT_ARTICLES         1
-#define XP_PROGRESS_READ_NEWSGROUP_COUNTS   1
-#define XP_THERMO_PERCENT_FORM         1
-#define XP_PROMPT_ENTER_USERNAME       1
-#define MK_NNTP_AUTH_FAILED            -260
-#define MK_NNTP_ERROR_MESSAGE          -304
-#define MK_NNTP_NEWSGROUP_SCAN_ERROR    -305
-#define MK_NNTP_SERVER_ERROR          -217
-#define MK_NNTP_SERVER_NOT_CONFIGURED     -307
-#define MK_TCP_READ_ERROR          -252
-#define MK_TCP_WRITE_ERROR          -236
-#define MK_NNTP_CANCEL_ERROR        -428
-#define XP_CONNECT_NEWS_HOST_CONTACTED_WAITING_FOR_REPLY  1
+#define MK_NNTP_NOT_CANCELLED -429
+#define MK_OUT_OF_MEMORY -207
+#define XP_CONFIRM_SAVE_NEWSGROUPS -1
+#define XP_HTML_ARTICLE_EXPIRED -1
+#define XP_HTML_NEWS_ERROR -1
+#define XP_PROGRESS_READ_NEWSGROUPINFO 1
+#define XP_PROGRESS_RECEIVE_ARTICLE 1
+#define XP_PROGRESS_RECEIVE_LISTARTICLES 1
+#define XP_PROGRESS_RECEIVE_NEWSGROUP 1
+#define XP_PROGRESS_SORT_ARTICLES 1
+#define XP_PROGRESS_READ_NEWSGROUP_COUNTS 1
+#define XP_THERMO_PERCENT_FORM 1
+#define XP_PROMPT_ENTER_USERNAME 1
+#define MK_NNTP_AUTH_FAILED -260
+#define MK_NNTP_ERROR_MESSAGE -304
+#define MK_NNTP_NEWSGROUP_SCAN_ERROR -305
+#define MK_NNTP_SERVER_ERROR -217
+#define MK_NNTP_SERVER_NOT_CONFIGURED -307
+#define MK_TCP_READ_ERROR -252
+#define MK_TCP_WRITE_ERROR -236
+#define MK_NNTP_CANCEL_ERROR -428
+#define XP_CONNECT_NEWS_HOST_CONTACTED_WAITING_FOR_REPLY 1
 #define XP_PLEASE_ENTER_A_PASSWORD_FOR_NEWS_SERVER_ACCESS 1
-#define XP_GARBAGE_COLLECTING                1
-#define XP_MESSAGE_SENT_WAITING_NEWS_REPLY          1
-#define MK_MSG_DELIV_NEWS                  1
-#define MK_MSG_COLLABRA_DISABLED              1
-#define MK_MSG_EXPIRE_NEWS_ARTICLES                1
-#define MK_MSG_HTML_IMAP_NO_CACHED_BODY            1
-#define MK_MSG_CANT_MOVE_FOLDER                1
+#define XP_GARBAGE_COLLECTING 1
+#define XP_MESSAGE_SENT_WAITING_NEWS_REPLY 1
+#define MK_MSG_DELIV_NEWS 1
+#define MK_MSG_COLLABRA_DISABLED 1
+#define MK_MSG_EXPIRE_NEWS_ARTICLES 1
+#define MK_MSG_HTML_IMAP_NO_CACHED_BODY 1
+#define MK_MSG_CANT_MOVE_FOLDER 1
 
 #endif /* NNTPCore_H__ */
--- a/mailnews/news/src/nsNNTPArticleList.cpp
+++ b/mailnews/news/src/nsNNTPArticleList.cpp
@@ -1,104 +1,93 @@
 /* -*- 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/. */
 
-#include "msgCore.h"    // precompiled header...
+#include "msgCore.h"  // precompiled header...
 
 #include "nsCOMPtr.h"
 #include "nsNNTPArticleList.h"
 #include "nsIMsgFolder.h"
 #include "nsAutoPtr.h"
 #include "nsMsgKeyArray.h"
 
 NS_IMPL_ISUPPORTS(nsNNTPArticleList, nsINNTPArticleList)
 
-nsNNTPArticleList::nsNNTPArticleList()
-{
-}
+nsNNTPArticleList::nsNNTPArticleList() {}
 
-nsNNTPArticleList::~nsNNTPArticleList()
-{
+nsNNTPArticleList::~nsNNTPArticleList() {
   if (m_newsDB) {
     m_newsDB->Commit(nsMsgDBCommitType::kSessionCommit);
     m_newsDB->Close(true);
     m_newsDB = nullptr;
   }
 
   m_newsFolder = nullptr;
 }
 
 NS_IMETHODIMP
-nsNNTPArticleList::Initialize(nsIMsgNewsFolder *newsFolder)
-{
-    nsresult rv;
-    NS_ENSURE_ARG_POINTER(newsFolder);
+nsNNTPArticleList::Initialize(nsIMsgNewsFolder *newsFolder) {
+  nsresult rv;
+  NS_ENSURE_ARG_POINTER(newsFolder);
 
-    m_dbIndex = 0;
+  m_dbIndex = 0;
 
-    m_newsFolder = newsFolder;
+  m_newsFolder = newsFolder;
 
-    nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = folder->GetMsgDatabase(getter_AddRefs(m_newsDB));
-    NS_ENSURE_SUCCESS(rv,rv);
-    if (!m_newsDB) return NS_ERROR_UNEXPECTED;
+  rv = folder->GetMsgDatabase(getter_AddRefs(m_newsDB));
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (!m_newsDB) return NS_ERROR_UNEXPECTED;
 
-    RefPtr<nsMsgKeyArray> keys = new nsMsgKeyArray;
-    rv = m_newsDB->ListAllKeys(keys);
-    NS_ENSURE_SUCCESS(rv,rv);
-    keys->Sort();
-    m_idsInDB.AppendElements(keys->m_keys);
+  RefPtr<nsMsgKeyArray> keys = new nsMsgKeyArray;
+  rv = m_newsDB->ListAllKeys(keys);
+  NS_ENSURE_SUCCESS(rv, rv);
+  keys->Sort();
+  m_idsInDB.AppendElements(keys->m_keys);
 
-    return NS_OK;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNNTPArticleList::AddArticleKey(nsMsgKey key)
-{
+nsNNTPArticleList::AddArticleKey(nsMsgKey key) {
 #ifdef DEBUG
   m_idsOnServer.AppendElement(key);
 #endif
 
-  if (m_dbIndex < m_idsInDB.Length())
-  {
+  if (m_dbIndex < m_idsInDB.Length()) {
     nsMsgKey idInDBToCheck = m_idsInDB[m_dbIndex];
     // if there are keys in the database that aren't in the newsgroup
     // on the server, remove them. We probably shouldn't do this if
     // we have a copy of the article offline.
     // We'll add to m_idsDeleted for now and remove the id later
-    while (idInDBToCheck < key)
-    {
+    while (idInDBToCheck < key) {
       m_idsDeleted.AppendElement(idInDBToCheck);
-      if (m_dbIndex >= m_idsInDB.Length())
-        break;
+      if (m_dbIndex >= m_idsInDB.Length()) break;
       idInDBToCheck = m_idsInDB[++m_dbIndex];
     }
-    if (idInDBToCheck == key)
-      m_dbIndex++;
+    if (idInDBToCheck == key) m_dbIndex++;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNNTPArticleList::FinishAddingArticleKeys()
-{
-  // if the last n messages in the group are cancelled, they won't have gotten removed
-  // so we have to go and remove them now.
+nsNNTPArticleList::FinishAddingArticleKeys() {
+  // if the last n messages in the group are cancelled, they won't have gotten
+  // removed so we have to go and remove them now.
   if (m_dbIndex < m_idsInDB.Length())
     m_idsDeleted.AppendElements(&m_idsInDB[m_dbIndex],
-      m_idsInDB.Length() - m_dbIndex);
+                                m_idsInDB.Length() - m_dbIndex);
 
-  if (m_idsDeleted.Length())
-    m_newsFolder->RemoveMessages(m_idsDeleted);
+  if (m_idsDeleted.Length()) m_newsFolder->RemoveMessages(m_idsDeleted);
 
 #ifdef DEBUG
   // make sure none of the deleted turned up on the idsOnServer list
   for (uint32_t i = 0; i < m_idsDeleted.Length(); i++) {
     NS_ASSERTION(!m_idsOnServer.Contains((nsMsgKey)m_idsDeleted[i]),
-      "a deleted turned up on the idsOnServer list");
+                 "a deleted turned up on the idsOnServer list");
   }
 #endif
   return NS_OK;
 }
--- a/mailnews/news/src/nsNNTPArticleList.h
+++ b/mailnews/news/src/nsNNTPArticleList.h
@@ -8,33 +8,32 @@
 
 #include "nsCOMPtr.h"
 #include "nsINNTPArticleList.h"
 #include "nsIMsgNewsFolder.h"
 #include "nsIMsgDatabase.h"
 #include "MailNewsTypes.h"
 #include "nsTArray.h"
 
-class nsNNTPArticleList : public nsINNTPArticleList
-{
-public:
+class nsNNTPArticleList : public nsINNTPArticleList {
+ public:
   nsNNTPArticleList();
 
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSINNTPARTICLELIST
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSINNTPARTICLELIST
 
-protected:
+ protected:
   virtual ~nsNNTPArticleList();
 
-    nsTArray<nsMsgKey> m_idsInDB;
+  nsTArray<nsMsgKey> m_idsInDB;
 
 #ifdef DEBUG
-    nsTArray<nsMsgKey> m_idsOnServer;
+  nsTArray<nsMsgKey> m_idsOnServer;
 #endif
-    nsTArray<nsMsgKey> m_idsDeleted;
+  nsTArray<nsMsgKey> m_idsDeleted;
 
-    nsCOMPtr <nsIMsgNewsFolder> m_newsFolder;
-    nsCOMPtr <nsIMsgDatabase> m_newsDB;
+  nsCOMPtr<nsIMsgNewsFolder> m_newsFolder;
+  nsCOMPtr<nsIMsgDatabase> m_newsDB;
 
-    uint32_t  m_dbIndex;
+  uint32_t m_dbIndex;
 };
 
 #endif /* nsNNTPArticleList_h___ */
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -6,17 +6,17 @@
 /*
  * formerly listngst.cpp
  * This class should ultimately be part of a news group listing
  * state machine - either by inheritance or delegation.
  * Currently, a folder pane owns one and libnet news group listing
  * related messages get passed to this object.
  */
 
-#include "msgCore.h"    // precompiled header...
+#include "msgCore.h"  // precompiled header...
 #include "MailNewsTypes.h"
 #include "nsCOMPtr.h"
 #include "nsIDBFolderInfo.h"
 #include "nsINewsDatabase.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsCOMPtr.h"
 #include "nsPIDOMWindow.h"
 #include "mozIDOMWindow.h"
@@ -59,564 +59,509 @@
 #include "nsIMsgFilterCustomAction.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/Services.h"
 
 // update status on header download once per second
 #define MIN_STATUS_UPDATE_INTERVAL PRTime(PR_USEC_PER_SEC)
 
-
 nsNNTPNewsgroupList::nsNNTPNewsgroupList()
-  : m_finishingXover(false),
-  m_getOldMessages(false),
-  m_promptedAlready(false),
-  m_downloadAll(false),
-  m_maxArticles(0),
-  m_lastPercent(-1),
-  m_lastStatusUpdate(0),
-  m_lastProcessedNumber(0),
-  m_firstMsgNumber(0),
-  m_lastMsgNumber(0),
-  m_firstMsgToDownload(0),
-  m_lastMsgToDownload(0),
-  m_set(nullptr)
-{
+    : m_finishingXover(false),
+      m_getOldMessages(false),
+      m_promptedAlready(false),
+      m_downloadAll(false),
+      m_maxArticles(0),
+      m_lastPercent(-1),
+      m_lastStatusUpdate(0),
+      m_lastProcessedNumber(0),
+      m_firstMsgNumber(0),
+      m_lastMsgNumber(0),
+      m_firstMsgToDownload(0),
+      m_lastMsgToDownload(0),
+      m_set(nullptr) {
   memset(&m_knownArts, 0, sizeof(m_knownArts));
 }
 
-nsNNTPNewsgroupList::~nsNNTPNewsgroupList()
-{
-  CleanUp();
-}
+nsNNTPNewsgroupList::~nsNNTPNewsgroupList() { CleanUp(); }
 
-NS_IMPL_ISUPPORTS(nsNNTPNewsgroupList, nsINNTPNewsgroupList, nsIMsgFilterHitNotify)
+NS_IMPL_ISUPPORTS(nsNNTPNewsgroupList, nsINNTPNewsgroupList,
+                  nsIMsgFilterHitNotify)
 
-nsresult
-nsNNTPNewsgroupList::Initialize(nsINntpUrl *runningURL, nsIMsgNewsFolder *newsFolder)
-{
+nsresult nsNNTPNewsgroupList::Initialize(nsINntpUrl *runningURL,
+                                         nsIMsgNewsFolder *newsFolder) {
   m_newsFolder = newsFolder;
   m_runningURL = runningURL;
   m_knownArts.set = nsMsgKeySet::Create();
 
   nsresult rv = m_newsFolder->GetDatabaseWithoutCache(getter_AddRefs(m_newsDB));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   rv = folder->GetFilterList(m_msgWindow, getter_AddRefs(m_filterList));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   nsCString ngHeaders;
   m_filterList->GetArbitraryHeaders(ngHeaders);
   ParseString(ngHeaders, ' ', m_filterHeaders);
 
   nsCOMPtr<nsIMsgIncomingServer> server;
   rv = folder->GetServer(getter_AddRefs(server));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   rv = server->GetFilterList(m_msgWindow, getter_AddRefs(m_serverFilterList));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   nsAutoCString servHeaders;
   m_serverFilterList->GetArbitraryHeaders(servHeaders);
 
   nsTArray<nsCString> servArray;
   ParseString(servHeaders, ' ', servArray);
 
   // servArray may have duplicates already in m_filterHeaders.
-  for (uint32_t i = 0; i < servArray.Length(); i++)
-  {
+  for (uint32_t i = 0; i < servArray.Length(); i++) {
     if (!m_filterHeaders.Contains(servArray[i]))
       m_filterHeaders.AppendElement(servArray[i]);
   }
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupList::CleanUp()
-{
+nsresult nsNNTPNewsgroupList::CleanUp() {
   // here we make sure that there aren't missing articles in the unread set
-  // So if an article is the unread set, and the known arts set, but isn't in the
-  // db, then we should mark it read in the unread set.
-  if (m_newsDB)
-  {
-    if (m_knownArts.set && m_knownArts.set->getLength() && m_set->getLength())
-    {
-      nsCOMPtr <nsIDBFolderInfo> folderInfo;
+  // So if an article is the unread set, and the known arts set, but isn't in
+  // the db, then we should mark it read in the unread set.
+  if (m_newsDB) {
+    if (m_knownArts.set && m_knownArts.set->getLength() && m_set->getLength()) {
+      nsCOMPtr<nsIDBFolderInfo> folderInfo;
       m_newsDB->GetDBFolderInfo(getter_AddRefs(folderInfo));
       int32_t firstKnown = m_knownArts.set->GetFirstMember();
-      int32_t lastKnown =  m_knownArts.set->GetLastMember();
-      if (folderInfo)
-      {
+      int32_t lastKnown = m_knownArts.set->GetLastMember();
+      if (folderInfo) {
         uint32_t lastMissingCheck;
         folderInfo->GetUint32Property("lastMissingCheck", 0, &lastMissingCheck);
-        if (lastMissingCheck)
-          firstKnown = lastMissingCheck + 1;
+        if (lastMissingCheck) firstKnown = lastMissingCheck + 1;
       }
       bool foundMissingArticle = false;
-      while (firstKnown <= lastKnown)
-      {
+      while (firstKnown <= lastKnown) {
         int32_t firstUnreadStart, firstUnreadEnd;
-        if (firstKnown == 0)
-          firstKnown = 1;
-        m_set->FirstMissingRange(firstKnown, lastKnown, &firstUnreadStart, &firstUnreadEnd);
-        if (firstUnreadStart)
-        {
-          while (firstUnreadStart <= firstUnreadEnd)
-          {
+        if (firstKnown == 0) firstKnown = 1;
+        m_set->FirstMissingRange(firstKnown, lastKnown, &firstUnreadStart,
+                                 &firstUnreadEnd);
+        if (firstUnreadStart) {
+          while (firstUnreadStart <= firstUnreadEnd) {
             bool containsKey;
             m_newsDB->ContainsKey(firstUnreadStart, &containsKey);
-            if (!containsKey)
-            {
+            if (!containsKey) {
               m_set->Add(firstUnreadStart);
               foundMissingArticle = true;
             }
             firstUnreadStart++;
           }
           firstKnown = firstUnreadStart;
-        }
-        else
+        } else
           break;
-
       }
       if (folderInfo)
         folderInfo->SetUint32Property("lastMissingCheck", lastKnown);
 
-      if (foundMissingArticle)
-      {
+      if (foundMissingArticle) {
         nsresult rv;
         nsCOMPtr<nsINewsDatabase> db(do_QueryInterface(m_newsDB, &rv));
-        NS_ENSURE_SUCCESS(rv,rv);
+        NS_ENSURE_SUCCESS(rv, rv);
         db->SetReadSet(m_set);
       }
     }
     m_newsDB->Commit(nsMsgDBCommitType::kSessionCommit);
     m_newsDB->Close(true);
     m_newsDB = nullptr;
   }
 
-  if (m_knownArts.set)
-  {
+  if (m_knownArts.set) {
     delete m_knownArts.set;
     m_knownArts.set = nullptr;
   }
-  if (m_newsFolder)
-    m_newsFolder->NotifyFinishedDownloadinghdrs();
+  if (m_newsFolder) m_newsFolder->NotifyFinishedDownloadinghdrs();
 
   m_newsFolder = nullptr;
   m_runningURL = nullptr;
 
   return NS_OK;
 }
 
 #ifdef HAVE_CHANGELISTENER
-void nsNNTPNewsgroupList::OnAnnouncerGoingAway (ChangeAnnouncer *instigator)
-{
-}
+void nsNNTPNewsgroupList::OnAnnouncerGoingAway(ChangeAnnouncer *instigator) {}
 #endif
 
-static nsresult
-openWindow(nsIMsgWindow *aMsgWindow, const char *chromeURL,
-           nsINewsDownloadDialogArgs *param)
-{
+static nsresult openWindow(nsIMsgWindow *aMsgWindow, const char *chromeURL,
+                           nsINewsDownloadDialogArgs *param) {
   nsresult rv;
   NS_ENSURE_ARG_POINTER(aMsgWindow);
   nsCOMPtr<nsIDocShell> docShell;
   rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
-  if (NS_FAILED(rv))
-      return rv;
+  if (NS_FAILED(rv)) return rv;
 
   nsCOMPtr<mozIDOMWindowProxy> domWindow(do_GetInterface(docShell));
   NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
-  nsCOMPtr<nsPIDOMWindowOuter> parentWindow = nsPIDOMWindowOuter::From(domWindow);
+  nsCOMPtr<nsPIDOMWindowOuter> parentWindow =
+      nsPIDOMWindowOuter::From(domWindow);
 
-  nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
+  nsCOMPtr<nsISupportsInterfacePointer> ifptr =
+      do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   ifptr->SetData(param);
   ifptr->SetDataIID(&NS_GET_IID(nsINewsDownloadDialogArgs));
 
   nsCOMPtr<nsPIDOMWindowOuter> dialogWindow;
-  rv = parentWindow->OpenDialog(NS_ConvertASCIItoUTF16(chromeURL),
-                                NS_LITERAL_STRING("_blank"),
-                                NS_LITERAL_STRING("centerscreen,chrome,modal,titlebar"),
-                                ifptr, getter_AddRefs(dialogWindow));
+  rv = parentWindow->OpenDialog(
+      NS_ConvertASCIItoUTF16(chromeURL), NS_LITERAL_STRING("_blank"),
+      NS_LITERAL_STRING("centerscreen,chrome,modal,titlebar"), ifptr,
+      getter_AddRefs(dialogWindow));
 
   return rv;
 }
 
-nsresult
-nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow *aMsgWindow,
-                                              int32_t first_possible,
-                                              int32_t last_possible,
-                                              int32_t maxextra,
-                                              int32_t *first,
-                                              int32_t *last,
-                                              int32_t *status)
-{
+nsresult nsNNTPNewsgroupList::GetRangeOfArtsToDownload(
+    nsIMsgWindow *aMsgWindow, int32_t first_possible, int32_t last_possible,
+    int32_t maxextra, int32_t *first, int32_t *last, int32_t *status) {
   nsresult rv = NS_OK;
 
   NS_ENSURE_ARG_POINTER(first);
   NS_ENSURE_ARG_POINTER(last);
   NS_ENSURE_ARG_POINTER(status);
   *first = 0;
   *last = 0;
 
-  nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   m_msgWindow = aMsgWindow;
 
   nsCOMPtr<nsINewsDatabase> db(do_QueryInterface(m_newsDB, &rv));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   rv = db->GetReadSet(&m_set);
-  if (NS_FAILED(rv) || !m_set)
-    return rv;
+  if (NS_FAILED(rv) || !m_set) return rv;
 
-  m_set->SetLastMember(last_possible); // make sure highwater mark is valid.
+  m_set->SetLastMember(last_possible);  // make sure highwater mark is valid.
 
-  nsCOMPtr <nsIDBFolderInfo> newsGroupInfo;
+  nsCOMPtr<nsIDBFolderInfo> newsGroupInfo;
   rv = m_newsDB->GetDBFolderInfo(getter_AddRefs(newsGroupInfo));
   if (NS_SUCCEEDED(rv) && newsGroupInfo) {
     nsCString knownArtsString;
     nsMsgKey mark;
     newsGroupInfo->GetKnownArtsSet(getter_Copies(knownArtsString));
 
     rv = newsGroupInfo->GetHighWater(&mark);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     if (last_possible < ((int32_t)mark))
       newsGroupInfo->SetHighWater(last_possible);
-    if (m_knownArts.set)
-      delete m_knownArts.set;
+    if (m_knownArts.set) delete m_knownArts.set;
     m_knownArts.set = nsMsgKeySet::Create(knownArtsString.get());
-  }
-  else
-  {
-    if (m_knownArts.set)
-      delete m_knownArts.set;
+  } else {
+    if (m_knownArts.set) delete m_knownArts.set;
     m_knownArts.set = nsMsgKeySet::Create();
     nsMsgKey low, high;
     rv = m_newsDB->GetLowWaterArticleNum(&low);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
     rv = m_newsDB->GetHighWaterArticleNum(&high);
-    NS_ENSURE_SUCCESS(rv,rv);
-    m_knownArts.set->AddRange(low,high);
+    NS_ENSURE_SUCCESS(rv, rv);
+    m_knownArts.set->AddRange(low, high);
   }
 
   if (m_knownArts.set->IsMember(last_possible)) {
     nsString statusString;
     nsCOMPtr<nsIStringBundleService> bundleService =
-      mozilla::services::GetStringBundleService();
+        mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = bundle->GetStringFromName("noNewMessages", statusString);
     NS_ENSURE_SUCCESS(rv, rv);
 
     SetProgressStatus(statusString.get());
   }
 
-  if (maxextra <= 0 || last_possible < first_possible || last_possible < 1)
-  {
-    *status=0;
+  if (maxextra <= 0 || last_possible < first_possible || last_possible < 1) {
+    *status = 0;
     return NS_OK;
   }
 
   m_knownArts.first_possible = first_possible;
   m_knownArts.last_possible = last_possible;
 
-  nsCOMPtr <nsIMsgIncomingServer> server;
+  nsCOMPtr<nsIMsgIncomingServer> server;
   rv = folder->GetServer(getter_AddRefs(server));
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsINntpIncomingServer> nntpServer = do_QueryInterface(server, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   /* Determine if we only want to get just new articles or more messages.
-  If there are new articles at the end we haven't seen, we always want to get those first.
-  Otherwise, we get the newest articles we haven't gotten, if we're getting more.
-  My thought for now is that opening a newsgroup should only try to get new articles.
-  Selecting "More Messages" will first try to get unseen messages, then old messages. */
+  If there are new articles at the end we haven't seen, we always want to get
+  those first. Otherwise, we get the newest articles we haven't gotten, if we're
+  getting more. My thought for now is that opening a newsgroup should only try
+  to get new articles. Selecting "More Messages" will first try to get unseen
+  messages, then old messages. */
 
-  if (m_getOldMessages || !m_knownArts.set->IsMember(last_possible))
-  {
+  if (m_getOldMessages || !m_knownArts.set->IsMember(last_possible)) {
     bool notifyMaxExceededOn = true;
     rv = nntpServer->GetNotifyOn(&notifyMaxExceededOn);
     if (NS_FAILED(rv)) notifyMaxExceededOn = true;
 
-    // if the preference to notify when downloading more than x headers is not on,
-    // and we're downloading new headers, set maxextra to a very large number.
-    if (!m_getOldMessages && !notifyMaxExceededOn)
-      maxextra = 0x7FFFFFFFL;
-        int result =
-            m_knownArts.set->LastMissingRange(first_possible, last_possible,
-                                              first, last);
+    // if the preference to notify when downloading more than x headers is not
+    // on, and we're downloading new headers, set maxextra to a very large
+    // number.
+    if (!m_getOldMessages && !notifyMaxExceededOn) maxextra = 0x7FFFFFFFL;
+    int result = m_knownArts.set->LastMissingRange(first_possible,
+                                                   last_possible, first, last);
     if (result < 0) {
-            *status=result;
+      *status = result;
       return NS_ERROR_NOT_INITIALIZED;
-        }
-    if (*first > 0 && *last - *first >= maxextra)
-    {
-      if (!m_getOldMessages && !m_promptedAlready && notifyMaxExceededOn)
-      {
+    }
+    if (*first > 0 && *last - *first >= maxextra) {
+      if (!m_getOldMessages && !m_promptedAlready && notifyMaxExceededOn) {
         m_downloadAll = false;
-        nsCOMPtr<nsINewsDownloadDialogArgs> args = do_CreateInstance("@mozilla.org/messenger/newsdownloaddialogargs;1", &rv);
+        nsCOMPtr<nsINewsDownloadDialogArgs> args = do_CreateInstance(
+            "@mozilla.org/messenger/newsdownloaddialogargs;1", &rv);
         if (NS_FAILED(rv)) return rv;
-        NS_ENSURE_SUCCESS(rv,rv);
+        NS_ENSURE_SUCCESS(rv, rv);
 
         rv = args->SetArticleCount(*last - *first + 1);
-        NS_ENSURE_SUCCESS(rv,rv);
+        NS_ENSURE_SUCCESS(rv, rv);
 
         nsString groupName;
         rv = m_newsFolder->GetUnicodeName(groupName);
-        NS_ENSURE_SUCCESS(rv,rv);
+        NS_ENSURE_SUCCESS(rv, rv);
 
         rv = args->SetGroupName(groupName);
-        NS_ENSURE_SUCCESS(rv,rv);
+        NS_ENSURE_SUCCESS(rv, rv);
 
         // get the server key
         nsCString serverKey;
         rv = server->GetKey(serverKey);
-        NS_ENSURE_SUCCESS(rv,rv);
+        NS_ENSURE_SUCCESS(rv, rv);
 
         rv = args->SetServerKey(serverKey.get());
-        NS_ENSURE_SUCCESS(rv,rv);
+        NS_ENSURE_SUCCESS(rv, rv);
 
-        // we many not have a msgWindow if we are running an autosubscribe url from the browser
-        // and there isn't a 3 pane open.
+        // we many not have a msgWindow if we are running an autosubscribe url
+        // from the browser and there isn't a 3 pane open.
         //
-        // if we don't have one, bad things will happen when we fail to open up the "download headers dialog"
-        // (we will subscribe to the newsgroup, but it will appear like there are no messages!)
+        // if we don't have one, bad things will happen when we fail to open up
+        // the "download headers dialog" (we will subscribe to the newsgroup,
+        // but it will appear like there are no messages!)
         //
-        // for now, act like the "download headers dialog" came up, and the user hit cancel.  (very safe)
+        // for now, act like the "download headers dialog" came up, and the user
+        // hit cancel.  (very safe)
         //
-        // TODO, figure out why we aren't opening and using a 3 pane when the autosubscribe url is run.
-        // perhaps we can find an available 3 pane, and use it.
+        // TODO, figure out why we aren't opening and using a 3 pane when the
+        // autosubscribe url is run. perhaps we can find an available 3 pane,
+        // and use it.
 
         bool download = false;
 
         if (aMsgWindow) {
           rv = openWindow(aMsgWindow, DOWNLOAD_HEADERS_URL, args);
-          NS_ENSURE_SUCCESS(rv,rv);
+          NS_ENSURE_SUCCESS(rv, rv);
 
           rv = args->GetHitOK(&download);
-          NS_ENSURE_SUCCESS(rv,rv);
+          NS_ENSURE_SUCCESS(rv, rv);
         }
 
-      if (download) {
-         rv = args->GetDownloadAll(&m_downloadAll);
-         NS_ENSURE_SUCCESS(rv,rv);
-         m_maxArticles = 0;
-         rv = nntpServer->GetMaxArticles(&m_maxArticles);
-         NS_ENSURE_SUCCESS(rv,rv);
+        if (download) {
+          rv = args->GetDownloadAll(&m_downloadAll);
+          NS_ENSURE_SUCCESS(rv, rv);
+          m_maxArticles = 0;
+          rv = nntpServer->GetMaxArticles(&m_maxArticles);
+          NS_ENSURE_SUCCESS(rv, rv);
 
           maxextra = m_maxArticles;
-          if (!m_downloadAll)
-          {
+          if (!m_downloadAll) {
             bool markOldRead = false;
 
             rv = nntpServer->GetMarkOldRead(&markOldRead);
             if (NS_FAILED(rv)) markOldRead = false;
 
-            if (markOldRead && m_set)
-              m_set->AddRange(*first, *last - maxextra);
+            if (markOldRead && m_set) m_set->AddRange(*first, *last - maxextra);
             *first = *last - maxextra + 1;
           }
-        }
-        else
+        } else
           *first = *last = 0;
         m_promptedAlready = true;
-      }
-      else if (m_promptedAlready && !m_downloadAll)
+      } else if (m_promptedAlready && !m_downloadAll)
         *first = *last - m_maxArticles + 1;
       else if (!m_downloadAll)
         *first = *last - maxextra + 1;
     }
   }
 
   m_firstMsgToDownload = *first;
   m_lastMsgToDownload = *last;
-  *status=0;
+  *status = 0;
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupList::AddToKnownArticles(int32_t first, int32_t last)
-{
+nsresult nsNNTPNewsgroupList::AddToKnownArticles(int32_t first, int32_t last) {
   nsresult status;
 
-  if (!m_knownArts.set)
-  {
+  if (!m_knownArts.set) {
     m_knownArts.set = nsMsgKeySet::Create();
-    if (!m_knownArts.set)
-      return NS_ERROR_OUT_OF_MEMORY;
+    if (!m_knownArts.set) return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // XXX Casting int to nsresult
   status = static_cast<nsresult>(m_knownArts.set->AddRange(first, last));
 
   if (m_newsDB) {
     nsresult rv = NS_OK;
-    nsCOMPtr <nsIDBFolderInfo> newsGroupInfo;
+    nsCOMPtr<nsIDBFolderInfo> newsGroupInfo;
     rv = m_newsDB->GetDBFolderInfo(getter_AddRefs(newsGroupInfo));
     if (NS_SUCCEEDED(rv) && newsGroupInfo) {
       nsCString output;
       status = m_knownArts.set->Output(getter_Copies(output));
-      if (!output.IsEmpty())
-        newsGroupInfo->SetKnownArtsSet(output.get());
+      if (!output.IsEmpty()) newsGroupInfo->SetKnownArtsSet(output.get());
     }
   }
   return status;
 }
 
-nsresult
-nsNNTPNewsgroupList::InitXOVER(int32_t first_msg, int32_t last_msg)
-{
+nsresult nsNNTPNewsgroupList::InitXOVER(int32_t first_msg, int32_t last_msg) {
   /* Consistency checks, not that I know what to do if it fails (it will
    probably handle it OK...) */
   NS_ASSERTION(first_msg <= last_msg, "first > last");
 
   /* If any XOVER lines from the last time failed to come in, mark those
      messages as read. */
-  if (m_lastProcessedNumber < m_lastMsgNumber)
-  {
+  if (m_lastProcessedNumber < m_lastMsgNumber) {
     m_set->AddRange(m_lastProcessedNumber + 1, m_lastMsgNumber);
   }
   m_firstMsgNumber = first_msg;
   m_lastMsgNumber = last_msg;
   m_lastProcessedNumber = first_msg > 1 ? first_msg - 1 : 1;
   m_currentXHDRIndex = -1;
   return NS_OK;
 }
 
 // from RFC 822, don't translate
 #define FROM_HEADER "From: "
 #define SUBJECT_HEADER "Subject: "
 #define DATE_HEADER "Date: "
 
-nsresult
-nsNNTPNewsgroupList::ParseLine(char *line, uint32_t * message_number)
-{
+nsresult nsNNTPNewsgroupList::ParseLine(char *line, uint32_t *message_number) {
   nsresult rv = NS_OK;
-  nsCOMPtr <nsIMsgDBHdr> newMsgHdr;
+  nsCOMPtr<nsIMsgDBHdr> newMsgHdr;
 
   if (!line || !message_number) {
     return NS_ERROR_NULL_POINTER;
   }
 
   char *next = line;
 
-#define GET_TOKEN()                           \
-  line = next;                                \
-  next = (line ? PL_strchr (line, '\t') : 0); \
+#define GET_TOKEN()                          \
+  line = next;                               \
+  next = (line ? PL_strchr(line, '\t') : 0); \
   if (next) *next++ = 0
 
-  GET_TOKEN (); /* message number */
+  GET_TOKEN(); /* message number */
   *message_number = atol(line);
 
   if (atol(line) == 0) /* bogus xover data */
     return NS_ERROR_UNEXPECTED;
 
   m_newsDB->CreateNewHdr(*message_number, getter_AddRefs(newMsgHdr));
 
-  NS_ASSERTION(newMsgHdr, "CreateNewHdr didn't fail, but it returned a null newMsgHdr");
-  if (!newMsgHdr)
-    return NS_ERROR_NULL_POINTER;
+  NS_ASSERTION(newMsgHdr,
+               "CreateNewHdr didn't fail, but it returned a null newMsgHdr");
+  if (!newMsgHdr) return NS_ERROR_NULL_POINTER;
 
-  GET_TOKEN (); /* subject */
+  GET_TOKEN(); /* subject */
   if (line) {
-    const char *subject = line;  /* #### const evilness */
+    const char *subject = line; /* #### const evilness */
 
     uint32_t flags = 0;
     // ### should call IsHeaderRead here...
     /* strip "Re: " */
     nsCString modifiedSubject;
-    bool strippedRE = NS_MsgStripRE(nsDependentCString(subject), modifiedSubject);
-    if (strippedRE)
-      (void) newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
+    bool strippedRE =
+        NS_MsgStripRE(nsDependentCString(subject), modifiedSubject);
+    if (strippedRE) (void)newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
 
     // this will make sure read flags agree with newsrc
-    if (! (flags & nsMsgMessageFlags::Read))
+    if (!(flags & nsMsgMessageFlags::Read))
       rv = newMsgHdr->OrFlags(nsMsgMessageFlags::New, &flags);
 
     rv = newMsgHdr->SetSubject(strippedRE ? modifiedSubject.get() : subject);
 
-    if (NS_FAILED(rv))
-      return rv;
+    if (NS_FAILED(rv)) return rv;
   }
 
-  GET_TOKEN (); /* author */
+  GET_TOKEN(); /* author */
   if (line) {
     rv = newMsgHdr->SetAuthor(line);
-    if (NS_FAILED(rv))
-      return rv;
+    if (NS_FAILED(rv)) return rv;
   }
 
-  GET_TOKEN ();
+  GET_TOKEN();
   if (line) {
     PRTime date;
-    PRStatus status = PR_ParseTimeString (line, false, &date);
+    PRStatus status = PR_ParseTimeString(line, false, &date);
     if (PR_SUCCESS == status) {
       rv = newMsgHdr->SetDate(date); /* date */
-      if (NS_FAILED(rv))
-        return rv;
+      if (NS_FAILED(rv)) return rv;
     }
   }
 
-  GET_TOKEN (); /* message id */
+  GET_TOKEN(); /* message id */
   if (line) {
     char *strippedId = line;
-    if (strippedId[0] == '<')
-      strippedId++;
-    char * lastChar = strippedId + PL_strlen(strippedId) -1;
+    if (strippedId[0] == '<') strippedId++;
+    char *lastChar = strippedId + PL_strlen(strippedId) - 1;
 
-    if (*lastChar == '>')
-      *lastChar = '\0';
+    if (*lastChar == '>') *lastChar = '\0';
 
     rv = newMsgHdr->SetMessageId(strippedId);
-    if (NS_FAILED(rv))
-      return rv;
+    if (NS_FAILED(rv)) return rv;
   }
 
-  GET_TOKEN (); /* references */
+  GET_TOKEN(); /* references */
   if (line) {
     rv = newMsgHdr->SetReferences(line);
-    if (NS_FAILED(rv))
-      return rv;
+    if (NS_FAILED(rv)) return rv;
   }
 
-  GET_TOKEN (); /* bytes */
+  GET_TOKEN(); /* bytes */
   if (line) {
     uint32_t msgSize = 0;
-    msgSize = (line) ? atol (line) : 0;
+    msgSize = (line) ? atol(line) : 0;
 
     rv = newMsgHdr->SetMessageSize(msgSize);
     if (NS_FAILED(rv)) return rv;
   }
 
-  GET_TOKEN (); /* lines */
+  GET_TOKEN(); /* lines */
   if (line) {
     uint32_t numLines = 0;
-    numLines = line ? atol (line) : 0;
+    numLines = line ? atol(line) : 0;
     rv = newMsgHdr->SetLineCount(numLines);
     if (NS_FAILED(rv)) return rv;
   }
 
-  GET_TOKEN (); /* xref */
+  GET_TOKEN(); /* xref */
 
   m_newHeaders.AppendObject(newMsgHdr);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPNewsgroupList::ApplyFilterHit(nsIMsgFilter *aFilter, nsIMsgWindow *aMsgWindow, bool *aApplyMore)
-{
+NS_IMETHODIMP nsNNTPNewsgroupList::ApplyFilterHit(nsIMsgFilter *aFilter,
+                                                  nsIMsgWindow *aMsgWindow,
+                                                  bool *aApplyMore) {
   NS_ENSURE_ARG_POINTER(aFilter);
   NS_ENSURE_ARG_POINTER(aApplyMore);
   NS_ENSURE_TRUE(m_newMsgHdr, NS_ERROR_UNEXPECTED);
   NS_ENSURE_TRUE(m_newsDB, NS_ERROR_UNEXPECTED);
 
   // you can't move news messages, so applyMore is always true
   *aApplyMore = true;
 
@@ -630,697 +575,599 @@ NS_IMETHODIMP nsNNTPNewsgroupList::Apply
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool loggingEnabled = false;
   nsCOMPtr<nsIMsgFilterList> currentFilterList;
   rv = aFilter->GetFilterList(getter_AddRefs(currentFilterList));
   if (NS_SUCCEEDED(rv) && currentFilterList && numActions)
     currentFilterList->GetLoggingEnabled(&loggingEnabled);
 
-  for (uint32_t actionIndex = 0; actionIndex < numActions; actionIndex++)
-  {
+  for (uint32_t actionIndex = 0; actionIndex < numActions; actionIndex++) {
     nsCOMPtr<nsIMsgRuleAction> filterAction =
-      do_QueryElementAt(filterActionList, actionIndex, &rv);
-    if (NS_FAILED(rv) || !filterAction)
-      continue;
+        do_QueryElementAt(filterActionList, actionIndex, &rv);
+    if (NS_FAILED(rv) || !filterAction) continue;
 
     nsMsgRuleActionType actionType;
-    if (NS_SUCCEEDED(filterAction->GetType(&actionType)))
-    {
-      if (loggingEnabled)
-        (void) aFilter->LogRuleHit(filterAction, m_newMsgHdr);
+    if (NS_SUCCEEDED(filterAction->GetType(&actionType))) {
+      if (loggingEnabled) (void)aFilter->LogRuleHit(filterAction, m_newMsgHdr);
 
-      switch (actionType)
-      {
-      case nsMsgFilterAction::Delete:
-        m_addHdrToDB = false;
-        break;
-      case nsMsgFilterAction::MarkRead:
-        m_newsDB->MarkHdrRead(m_newMsgHdr, true, nullptr);
-        break;
-      case nsMsgFilterAction::MarkUnread:
-        m_newsDB->MarkHdrRead(m_newMsgHdr, false, nullptr);
-        break;
-      case nsMsgFilterAction::KillThread:
-        m_newMsgHdr->SetUint32Property("ProtoThreadFlags", nsMsgMessageFlags::Ignored);
-        break;
-      case nsMsgFilterAction::KillSubthread:
-        {
+      switch (actionType) {
+        case nsMsgFilterAction::Delete:
+          m_addHdrToDB = false;
+          break;
+        case nsMsgFilterAction::MarkRead:
+          m_newsDB->MarkHdrRead(m_newMsgHdr, true, nullptr);
+          break;
+        case nsMsgFilterAction::MarkUnread:
+          m_newsDB->MarkHdrRead(m_newMsgHdr, false, nullptr);
+          break;
+        case nsMsgFilterAction::KillThread:
+          m_newMsgHdr->SetUint32Property("ProtoThreadFlags",
+                                         nsMsgMessageFlags::Ignored);
+          break;
+        case nsMsgFilterAction::KillSubthread: {
           uint32_t newFlags;
           m_newMsgHdr->OrFlags(nsMsgMessageFlags::Ignored, &newFlags);
-        }
-        break;
-      case nsMsgFilterAction::WatchThread:
-        {
+        } break;
+        case nsMsgFilterAction::WatchThread: {
           uint32_t newFlags;
           m_newMsgHdr->OrFlags(nsMsgMessageFlags::Watched, &newFlags);
-        }
-        break;
-      case nsMsgFilterAction::MarkFlagged:
-        m_newMsgHdr->MarkFlagged(true);
-        break;
-      case nsMsgFilterAction::ChangePriority:
-        {
+        } break;
+        case nsMsgFilterAction::MarkFlagged:
+          m_newMsgHdr->MarkFlagged(true);
+          break;
+        case nsMsgFilterAction::ChangePriority: {
           nsMsgPriorityValue filterPriority;
           filterAction->GetPriority(&filterPriority);
           m_newMsgHdr->SetPriority(filterPriority);
+        } break;
+        case nsMsgFilterAction::AddTag: {
+          nsCString keyword;
+          filterAction->GetStrValue(keyword);
+          nsCOMPtr<nsIMutableArray> messageArray(
+              do_CreateInstance(NS_ARRAY_CONTRACTID));
+          messageArray->AppendElement(m_newMsgHdr);
+          nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
+          if (folder) folder->AddKeywordsToMessages(messageArray, keyword);
+          break;
         }
-        break;
-      case nsMsgFilterAction::AddTag:
-      {
-        nsCString keyword;
-        filterAction->GetStrValue(keyword);
-        nsCOMPtr<nsIMutableArray> messageArray(do_CreateInstance(NS_ARRAY_CONTRACTID));
-        messageArray->AppendElement(m_newMsgHdr);
-        nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
-        if (folder)
-          folder->AddKeywordsToMessages(messageArray, keyword);
-        break;
-      }
-      case nsMsgFilterAction::Label:
-        {
+        case nsMsgFilterAction::Label: {
           nsMsgLabelValue filterLabel;
           filterAction->GetLabel(&filterLabel);
           nsMsgKey msgKey;
           m_newMsgHdr->GetMessageKey(&msgKey);
           m_newsDB->SetLabel(msgKey, filterLabel);
-        }
-        break;
+        } break;
 
-      case nsMsgFilterAction::StopExecution:
-      {
-        // don't apply any more filters
-        *aApplyMore = false;
-      }
-      break;
+        case nsMsgFilterAction::StopExecution: {
+          // don't apply any more filters
+          *aApplyMore = false;
+        } break;
 
-      case nsMsgFilterAction::Custom:
-      {
-        nsCOMPtr<nsIMsgFilterCustomAction> customAction;
-        rv = filterAction->GetCustomAction(getter_AddRefs(customAction));
-        NS_ENSURE_SUCCESS(rv, rv);
+        case nsMsgFilterAction::Custom: {
+          nsCOMPtr<nsIMsgFilterCustomAction> customAction;
+          rv = filterAction->GetCustomAction(getter_AddRefs(customAction));
+          NS_ENSURE_SUCCESS(rv, rv);
 
-        nsAutoCString value;
-        filterAction->GetStrValue(value);
+          nsAutoCString value;
+          filterAction->GetStrValue(value);
 
-        nsCOMPtr<nsIMutableArray> messageArray(
-            do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
-        NS_ENSURE_TRUE(messageArray, rv);
-        messageArray->AppendElement(m_newMsgHdr);
+          nsCOMPtr<nsIMutableArray> messageArray(
+              do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
+          NS_ENSURE_TRUE(messageArray, rv);
+          messageArray->AppendElement(m_newMsgHdr);
 
-        customAction->Apply(messageArray, value, nullptr,
-                            nsMsgFilterType::NewsRule, aMsgWindow);
-      }
-      break;
+          customAction->Apply(messageArray, value, nullptr,
+                              nsMsgFilterType::NewsRule, aMsgWindow);
+        } break;
 
-      default:
-        NS_ERROR("unexpected action");
-        break;
+        default:
+          NS_ERROR("unexpected action");
+          break;
       }
     }
   }
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupList::ProcessXOVERLINE(const char *line, uint32_t *status)
-{
-  uint32_t message_number=0;
+nsresult nsNNTPNewsgroupList::ProcessXOVERLINE(const char *line,
+                                               uint32_t *status) {
+  uint32_t message_number = 0;
   //  int32_t lines;
   nsresult rv = NS_OK;
 
   NS_ASSERTION(line, "null ptr");
-  if (!line)
-    return NS_ERROR_NULL_POINTER;
+  if (!line) return NS_ERROR_NULL_POINTER;
 
-  if (m_newsDB)
-  {
+  if (m_newsDB) {
     char *xoverline = PL_strdup(line);
-    if (!xoverline)
-      return NS_ERROR_OUT_OF_MEMORY;
+    if (!xoverline) return NS_ERROR_OUT_OF_MEMORY;
     rv = ParseLine(xoverline, &message_number);
     PL_strfree(xoverline);
     xoverline = nullptr;
-    if (NS_FAILED(rv))
-      return rv;
-  }
-  else
+    if (NS_FAILED(rv)) return rv;
+  } else
     return NS_ERROR_NOT_INITIALIZED;
 
-  NS_ASSERTION(message_number > m_lastProcessedNumber ||
-               message_number == 1, "bad message_number");
-  if (m_set && message_number > m_lastProcessedNumber + 1)
-  {
-  /* There are some articles that XOVER skipped; they must no longer
-     exist.  Mark them as read in the newsrc, so we don't include them
-     next time in our estimated number of unread messages. */
-    if (m_set->AddRange(m_lastProcessedNumber + 1, message_number - 1))
-    {
-    /* This isn't really an important enough change to warrant causing
-       the newsrc file to be saved; we haven't gathered any information
-       that won't also be gathered for free next time.  */
+  NS_ASSERTION(message_number > m_lastProcessedNumber || message_number == 1,
+               "bad message_number");
+  if (m_set && message_number > m_lastProcessedNumber + 1) {
+    /* There are some articles that XOVER skipped; they must no longer
+       exist.  Mark them as read in the newsrc, so we don't include them
+       next time in our estimated number of unread messages. */
+    if (m_set->AddRange(m_lastProcessedNumber + 1, message_number - 1)) {
+      /* This isn't really an important enough change to warrant causing
+         the newsrc file to be saved; we haven't gathered any information
+         that won't also be gathered for free next time.  */
     }
   }
 
   m_lastProcessedNumber = message_number;
-  if (m_knownArts.set)
-  {
+  if (m_knownArts.set) {
     int result = m_knownArts.set->Add(message_number);
     if (result < 0) {
-      if (status)
-        *status = result;
+      if (status) *status = result;
       return NS_ERROR_NOT_INITIALIZED;
     }
   }
 
   if (message_number > m_lastMsgNumber)
     m_lastMsgNumber = message_number;
   else if (message_number < m_firstMsgNumber)
     m_firstMsgNumber = message_number;
 
   if (m_set) {
-    (void) m_set->IsMember(message_number);
+    (void)m_set->IsMember(message_number);
   }
 
   /* Update the progress meter with a percentage of articles retrieved */
-  if (m_lastMsgNumber > m_firstMsgNumber)
-  {
+  if (m_lastMsgNumber > m_firstMsgNumber) {
     int32_t totalToDownload = m_lastMsgToDownload - m_firstMsgToDownload + 1;
     int32_t lastIndex = m_lastProcessedNumber - m_firstMsgNumber + 1;
     int32_t numDownloaded = lastIndex;
     int32_t totIndex = m_lastMsgNumber - m_firstMsgNumber + 1;
 
     PRTime elapsedTime = PR_Now() - m_lastStatusUpdate;
 
     if (elapsedTime > MIN_STATUS_UPDATE_INTERVAL || lastIndex == totIndex)
       UpdateStatus(false, numDownloaded, totalToDownload);
   }
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupList::ResetXOVER()
-{
+nsresult nsNNTPNewsgroupList::ResetXOVER() {
   m_lastMsgNumber = m_firstMsgNumber;
   m_lastProcessedNumber = m_lastMsgNumber;
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupList::FinishXOVERLINE(int status, int *newstatus)
-{
+nsresult nsNNTPNewsgroupList::FinishXOVERLINE(int status, int *newstatus) {
   nsresult rv;
-  struct MSG_NewsKnown* k;
+  struct MSG_NewsKnown *k;
 
   /* If any XOVER lines from the last time failed to come in, mark those
      messages as read. */
 
   if (status >= 0 && m_lastProcessedNumber < m_lastMsgNumber) {
     m_set->AddRange(m_lastProcessedNumber + 1, m_lastMsgNumber);
   }
 
   if (m_lastProcessedNumber)
     AddToKnownArticles(m_firstMsgNumber, m_lastProcessedNumber);
 
   k = &m_knownArts;
 
-  if (k && k->set)
-  {
+  if (k && k->set) {
     int32_t n = k->set->FirstNonMember();
-    if (n < k->first_possible || n > k->last_possible)
-    {
+    if (n < k->first_possible || n > k->last_possible) {
       /* We know we've gotten all there is to know.
          Take advantage of that to update our counts... */
       // ### dmb
     }
   }
 
-  if (!m_finishingXover)
-  {
+  if (!m_finishingXover) {
     // turn on m_finishingXover - this is a horrible hack to avoid recursive
-    // calls which happen when the fe selects a message as a result of getting EndingUpdate,
-    // which interrupts this url right before it was going to finish and causes FinishXOver
-    // to get called again.
+    // calls which happen when the fe selects a message as a result of getting
+    // EndingUpdate, which interrupts this url right before it was going to
+    // finish and causes FinishXOver to get called again.
     m_finishingXover = true;
 
     // XXX is this correct?
     m_runningURL = nullptr;
 
     if (m_lastMsgNumber > 0) {
       nsAutoString firstStr;
       firstStr.AppendInt(m_lastProcessedNumber - m_firstMsgNumber + 1);
 
       nsAutoString lastStr;
       lastStr.AppendInt(m_lastMsgNumber - m_firstMsgNumber + 1);
 
       nsString statusString;
       nsCOMPtr<nsIStringBundleService> bundleService =
-        mozilla::services::GetStringBundleService();
+          mozilla::services::GetStringBundleService();
       NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
       nsCOMPtr<nsIStringBundle> bundle;
       rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
       NS_ENSURE_SUCCESS(rv, rv);
 
-      const char16_t *formatStrings[2] = { firstStr.get(), lastStr.get() };
-      rv = bundle->FormatStringFromName("downloadingArticles", formatStrings, 2, statusString);
+      const char16_t *formatStrings[2] = {firstStr.get(), lastStr.get()};
+      rv = bundle->FormatStringFromName("downloadingArticles", formatStrings, 2,
+                                        statusString);
       NS_ENSURE_SUCCESS(rv, rv);
 
       SetProgressStatus(statusString.get());
     }
   }
 
-  if (newstatus)
-    *newstatus=0;
+  if (newstatus) *newstatus = 0;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNNTPNewsgroupList::InitXHDR(nsACString &header)
-{
+nsNNTPNewsgroupList::InitXHDR(nsACString &header) {
   if (++m_currentXHDRIndex >= m_filterHeaders.Length())
     header.Truncate();
   else
     header.Assign(m_filterHeaders[m_currentXHDRIndex]);
   // Don't include these in our XHDR bouts, as they are already provided through
   // XOVER.
-  if (header.EqualsLiteral("message-id") ||
-      header.EqualsLiteral("references"))
+  if (header.EqualsLiteral("message-id") || header.EqualsLiteral("references"))
     return InitXHDR(header);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNNTPNewsgroupList::ProcessXHDRLine(const nsACString &line)
-{
+nsNNTPNewsgroupList::ProcessXHDRLine(const nsACString &line) {
   int32_t middle = line.FindChar(' ');
   nsCString value, key = PromiseFlatCString(line);
-  if (middle == -1)
-    return NS_OK;
-  value = Substring(line, middle+1);
+  if (middle == -1) return NS_OK;
+  value = Substring(line, middle + 1);
   key.SetLength((uint32_t)middle);
 
   // According to RFC 2980, some will send (none) instead.
   // So we don't treat this is an error.
-  if (key.CharAt(0) < '0' || key.CharAt(0) > '9')
-    return NS_OK;
+  if (key.CharAt(0) < '0' || key.CharAt(0) > '9') return NS_OK;
 
   nsresult rv;
   int32_t number = key.ToInteger(&rv);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
   // RFC 2980 specifies one or more spaces.
   value.Trim(" ");
 
   nsCOMPtr<nsIMsgDBHdr> header;
   rv = m_newsDB->GetMsgHdrForKey(number, getter_AddRefs(header));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = header->SetStringProperty(m_filterHeaders[m_currentXHDRIndex].get(), value.get());
+  rv = header->SetStringProperty(m_filterHeaders[m_currentXHDRIndex].get(),
+                                 value.get());
   NS_ENSURE_SUCCESS(rv, rv);
 
   int32_t totalToDownload = m_lastMsgToDownload - m_firstMsgToDownload + 1;
   int32_t numDownloaded = number - m_firstMsgNumber + 1;
 
   PRTime elapsedTime = PR_Now() - m_lastStatusUpdate;
 
   if (elapsedTime > MIN_STATUS_UPDATE_INTERVAL)
     UpdateStatus(true, numDownloaded, totalToDownload);
   return rv;
 }
 
 NS_IMETHODIMP
-nsNNTPNewsgroupList::InitHEAD(int32_t number)
-{
-  if (m_newMsgHdr)
-  {
+nsNNTPNewsgroupList::InitHEAD(int32_t number) {
+  if (m_newMsgHdr) {
     // Finish processing for this header
     // If HEAD didn't properly return, then the header won't be set
     m_newHeaders.AppendObject(m_newMsgHdr);
 
     int32_t totalToDownload = m_lastMsgToDownload - m_firstMsgToDownload + 1;
     int32_t lastIndex = m_lastProcessedNumber - m_firstMsgNumber + 1;
     int32_t numDownloaded = lastIndex;
     int32_t totIndex = m_lastMsgNumber - m_firstMsgNumber + 1;
 
     PRTime elapsedTime = PR_Now() - m_lastStatusUpdate;
 
     if (elapsedTime > MIN_STATUS_UPDATE_INTERVAL || lastIndex == totIndex)
       UpdateStatus(false, numDownloaded, totalToDownload);
   }
 
-  if (number >= 0)
-  {
-    if (m_newHeaders.Count() > 0 && m_lastMsgNumber == m_lastProcessedNumber)
-    {
+  if (number >= 0) {
+    if (m_newHeaders.Count() > 0 && m_lastMsgNumber == m_lastProcessedNumber) {
       // We have done some processing of messages. This means that we have
       // relics of headers from XOVER. Since we will get everything from HEAD
       // anyways, just clear the array.
       m_newHeaders.Clear();
     }
 
     nsresult rv = m_newsDB->CreateNewHdr(number, getter_AddRefs(m_newMsgHdr));
     m_lastProcessedNumber = number;
     NS_ENSURE_SUCCESS(rv, rv);
-  }
-  else
-  {
+  } else {
     AddToKnownArticles(m_firstMsgNumber, m_lastProcessedNumber);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNNTPNewsgroupList::HEADFailed(int32_t number)
-{
+nsNNTPNewsgroupList::HEADFailed(int32_t number) {
   m_set->Add(number);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNNTPNewsgroupList::ProcessHEADLine(const nsACString &line)
-{
+nsNNTPNewsgroupList::ProcessHEADLine(const nsACString &line) {
   int32_t colon = line.FindChar(':');
   nsCString header = PromiseFlatCString(line), value;
-  if (colon != -1)
-  {
-    value = Substring(line, colon+1);
+  if (colon != -1) {
+    value = Substring(line, colon + 1);
     header.SetLength((uint32_t)colon);
-  }
-  else if (line.CharAt(0) == ' ' || line.CharAt(0) == '\t') // We are continuing the header
+  } else if (line.CharAt(0) == ' ' ||
+             line.CharAt(0) == '\t')  // We are continuing the header
   {
-    m_thisLine += header; // Preserve whitespace (should we?)
+    m_thisLine += header;  // Preserve whitespace (should we?)
     return NS_OK;
-  }
-  else
-  {
-    return NS_OK; // We are malformed. Just ignore and hope for the best...
+  } else {
+    return NS_OK;  // We are malformed. Just ignore and hope for the best...
   }
 
   nsresult rv;
-  if (!m_lastHeader.IsEmpty())
-  {
+  if (!m_lastHeader.IsEmpty()) {
     rv = AddHeader(m_lastHeader.get(), m_thisLine.get());
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
 
   value.Trim(" ");
 
   ToLowerCase(header, m_lastHeader);
   m_thisLine.Assign(value);
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupList::AddHeader(const char *header, const char *value)
-{
+nsresult nsNNTPNewsgroupList::AddHeader(const char *header, const char *value) {
   nsresult rv = NS_OK;
   // The From, Date, and Subject headers have special requirements.
-  if (PL_strcmp(header, "from") == 0)
-  {
+  if (PL_strcmp(header, "from") == 0) {
     rv = m_newMsgHdr->SetAuthor(value);
-  }
-  else if (PL_strcmp(header, "date") == 0)
-  {
+  } else if (PL_strcmp(header, "date") == 0) {
     PRTime date;
-    PRStatus status = PR_ParseTimeString (value, false, &date);
-    if (PR_SUCCESS == status)
-      rv = m_newMsgHdr->SetDate(date);
-  }
-  else if (PL_strcmp(header, "subject") == 0)
-  {
+    PRStatus status = PR_ParseTimeString(value, false, &date);
+    if (PR_SUCCESS == status) rv = m_newMsgHdr->SetDate(date);
+  } else if (PL_strcmp(header, "subject") == 0) {
     const char *subject = value;
 
     uint32_t flags = 0;
     // ### should call IsHeaderRead here...
     /* strip "Re: " */
     nsCString modifiedSubject;
-    bool strippedRE = NS_MsgStripRE(nsDependentCString(subject), modifiedSubject);
+    bool strippedRE =
+        NS_MsgStripRE(nsDependentCString(subject), modifiedSubject);
     if (strippedRE)
       // this will make sure read flags agree with newsrc
-     (void) m_newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
+      (void)m_newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
 
-    if (! (flags & nsMsgMessageFlags::Read))
+    if (!(flags & nsMsgMessageFlags::Read))
       rv = m_newMsgHdr->OrFlags(nsMsgMessageFlags::New, &flags);
 
     rv = m_newMsgHdr->SetSubject(strippedRE ? modifiedSubject.get() : subject);
-  }
-  else if (PL_strcmp(header, "message-id") == 0)
-  {
+  } else if (PL_strcmp(header, "message-id") == 0) {
     rv = m_newMsgHdr->SetMessageId(value);
-  }
-  else if (PL_strcmp(header, "references") == 0)
-  {
+  } else if (PL_strcmp(header, "references") == 0) {
     rv = m_newMsgHdr->SetReferences(value);
-  }
-  else if (PL_strcmp(header, "bytes") == 0)
-  {
+  } else if (PL_strcmp(header, "bytes") == 0) {
     rv = m_newMsgHdr->SetMessageSize(atol(value));
-  }
-  else if (PL_strcmp(header, "lines") == 0)
-  {
+  } else if (PL_strcmp(header, "lines") == 0) {
     rv = m_newMsgHdr->SetLineCount(atol(value));
-  }
-  else if (m_filterHeaders.Contains(nsDependentCString(header)))
-  {
+  } else if (m_filterHeaders.Contains(nsDependentCString(header))) {
     rv = m_newMsgHdr->SetStringProperty(header, value);
   }
   return rv;
 }
 
-nsresult
-nsNNTPNewsgroupList::CallFilters()
-{
+nsresult nsNNTPNewsgroupList::CallFilters() {
   nsresult rv;
   nsCString filterString;
 
-  nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t filterCount = 0;
-  if (m_filterList)
-  {
+  if (m_filterList) {
     rv = m_filterList->GetFilterCount(&filterCount);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
 
   uint32_t serverFilterCount = 0;
-  if (m_serverFilterList)
-  {
+  if (m_serverFilterList) {
     rv = m_serverFilterList->GetFilterCount(&serverFilterCount);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
 
   uint32_t count = m_newHeaders.Count();
 
   // Notify MsgFolderListeners of message adds
-  nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
+  nsCOMPtr<nsIMsgFolderNotificationService> notifier(
+      do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
 
-  for (uint32_t i = 0; i < count; i++)
-  {
+  for (uint32_t i = 0; i < count; i++) {
     m_newMsgHdr = m_newHeaders[i];
-    if (!filterCount && !serverFilterCount)
-    {
+    if (!filterCount && !serverFilterCount) {
       m_newsDB->AddNewHdrToDB(m_newMsgHdr, true);
 
-      if (notifier)
-        notifier->NotifyMsgAdded(m_newMsgHdr);
+      if (notifier) notifier->NotifyMsgAdded(m_newMsgHdr);
       // mark the header as not yet reported classified
       nsMsgKey msgKey;
       m_newMsgHdr->GetMessageKey(&msgKey);
       folder->OrProcessingFlags(msgKey,
                                 nsMsgProcessingFlags::NotReportedClassified);
 
       continue;
     }
     m_addHdrToDB = true;
 
     // build up a "headers" for filter code
     nsCString subject, author, date;
     rv = m_newMsgHdr->GetSubject(getter_Copies(subject));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
     rv = m_newMsgHdr->GetAuthor(getter_Copies(author));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsCString fullHeaders;
-    if (!(author.IsEmpty()))
-    {
+    if (!(author.IsEmpty())) {
       fullHeaders.AppendLiteral(FROM_HEADER);
       fullHeaders += author;
       fullHeaders += '\0';
     }
 
-    if (!(subject.IsEmpty()))
-    {
+    if (!(subject.IsEmpty())) {
       fullHeaders.AppendLiteral(SUBJECT_HEADER);
       fullHeaders += subject;
       fullHeaders += '\0';
     }
 
-    for (uint32_t header = 0; header < m_filterHeaders.Length(); header++)
-    {
+    for (uint32_t header = 0; header < m_filterHeaders.Length(); header++) {
       nsCString retValue;
       m_newMsgHdr->GetStringProperty(m_filterHeaders[header].get(),
                                      getter_Copies(retValue));
-      if (!retValue.IsEmpty())
-      {
+      if (!retValue.IsEmpty()) {
         fullHeaders += m_filterHeaders[header];
         fullHeaders.AppendLiteral(": ");
         fullHeaders += retValue;
         fullHeaders += '\0';
       }
     }
 
     // The per-newsgroup filters should go first. If something stops filter
     // execution, then users should be able to override the global filters in
     // the per-newsgroup filters.
-    if (filterCount)
-    {
+    if (filterCount) {
       rv = m_filterList->ApplyFiltersToHdr(nsMsgFilterType::NewsRule,
-          m_newMsgHdr, folder, m_newsDB, fullHeaders, this, m_msgWindow);
+                                           m_newMsgHdr, folder, m_newsDB,
+                                           fullHeaders, this, m_msgWindow);
     }
-    if (serverFilterCount)
-    {
-      rv = m_serverFilterList->ApplyFiltersToHdr(nsMsgFilterType::NewsRule,
-          m_newMsgHdr, folder, m_newsDB, fullHeaders, this, m_msgWindow);
+    if (serverFilterCount) {
+      rv = m_serverFilterList->ApplyFiltersToHdr(
+          nsMsgFilterType::NewsRule, m_newMsgHdr, folder, m_newsDB, fullHeaders,
+          this, m_msgWindow);
     }
 
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
-    if (m_addHdrToDB)
-    {
+    if (m_addHdrToDB) {
       m_newsDB->AddNewHdrToDB(m_newMsgHdr, true);
-      if (notifier)
-        notifier->NotifyMsgAdded(m_newMsgHdr);
+      if (notifier) notifier->NotifyMsgAdded(m_newMsgHdr);
       // mark the header as not yet reported classified
       nsMsgKey msgKey;
       m_newMsgHdr->GetMessageKey(&msgKey);
       folder->OrProcessingFlags(msgKey,
                                 nsMsgProcessingFlags::NotReportedClassified);
     }
   }
   m_newHeaders.Clear();
   return NS_OK;
 }
 
-void
-nsNNTPNewsgroupList::SetProgressBarPercent(int32_t percent)
-{
-  if (!m_runningURL)
-    return;
+void nsNNTPNewsgroupList::SetProgressBarPercent(int32_t percent) {
+  if (!m_runningURL) return;
 
-  nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
   if (mailnewsUrl) {
-    nsCOMPtr <nsIMsgStatusFeedback> feedback;
+    nsCOMPtr<nsIMsgStatusFeedback> feedback;
     mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback));
 
     if (feedback) {
       feedback->ShowProgress(percent);
     }
   }
 }
 
-void
-nsNNTPNewsgroupList::SetProgressStatus(const char16_t *aMessage)
-{
-  if (!m_runningURL)
-    return;
+void nsNNTPNewsgroupList::SetProgressStatus(const char16_t *aMessage) {
+  if (!m_runningURL) return;
 
-  nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
   if (mailnewsUrl) {
-    nsCOMPtr <nsIMsgStatusFeedback> feedback;
+    nsCOMPtr<nsIMsgStatusFeedback> feedback;
     mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback));
 
     if (feedback) {
       // prepending the account name to the status message.
       nsresult rv;
-      nsCOMPtr <nsIMsgIncomingServer> server;
+      nsCOMPtr<nsIMsgIncomingServer> server;
       rv = mailnewsUrl->GetServer(getter_AddRefs(server));
       NS_ENSURE_SUCCESS_VOID(rv);
       nsString accountName;
       server->GetPrettyName(accountName);
       nsString statusMessage;
       nsCOMPtr<nsIStringBundleService> sbs =
-        mozilla::services::GetStringBundleService();
+          mozilla::services::GetStringBundleService();
       nsCOMPtr<nsIStringBundle> bundle;
-      rv = sbs->CreateBundle(MSGS_URL,
-                             getter_AddRefs(bundle));
+      rv = sbs->CreateBundle(MSGS_URL, getter_AddRefs(bundle));
       NS_ENSURE_SUCCESS_VOID(rv);
-      const char16_t *params[] = { accountName.get(), aMessage };
-      bundle->FormatStringFromName("statusMessage",
-                                   params, 2, statusMessage);
+      const char16_t *params[] = {accountName.get(), aMessage};
+      bundle->FormatStringFromName("statusMessage", params, 2, statusMessage);
 
       feedback->ShowStatusString(statusMessage);
     }
   }
 }
 
-void
-nsNNTPNewsgroupList::UpdateStatus(bool filtering, int32_t numDLed, int32_t totToDL)
-{
+void nsNNTPNewsgroupList::UpdateStatus(bool filtering, int32_t numDLed,
+                                       int32_t totToDL) {
   int32_t numerator = (filtering ? m_currentXHDRIndex + 1 : 1) * numDLed;
   int32_t denominator = (m_filterHeaders.Length() + 1) * totToDL;
   int32_t percent = numerator * 100 / denominator;
 
   nsAutoString numDownloadedStr;
   numDownloadedStr.AppendInt(numDLed);
 
   nsAutoString totalToDownloadStr;
   totalToDownloadStr.AppendInt(totToDL);
 
   nsAutoString newsgroupName;
   nsresult rv = m_newsFolder->GetUnicodeName(newsgroupName);
-  if (!NS_SUCCEEDED(rv))
-      return;
+  if (!NS_SUCCEEDED(rv)) return;
 
   nsString statusString;
   nsCOMPtr<nsIStringBundleService> bundleService =
-    mozilla::services::GetStringBundleService();
-  if (!bundleService)
-    return;
+      mozilla::services::GetStringBundleService();
+  if (!bundleService) return;
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
-  if (!NS_SUCCEEDED(rv))
-    return;
+  if (!NS_SUCCEEDED(rv)) return;
 
-  if (filtering)
-  {
+  if (filtering) {
     NS_ConvertUTF8toUTF16 header(m_filterHeaders[m_currentXHDRIndex]);
-    const char16_t *formatStrings[4] = { header.get(),
-      numDownloadedStr.get(), totalToDownloadStr.get(), newsgroupName.get() };
+    const char16_t *formatStrings[4] = {header.get(), numDownloadedStr.get(),
+                                        totalToDownloadStr.get(),
+                                        newsgroupName.get()};
     rv = bundle->FormatStringFromName("newNewsgroupFilteringHeaders",
-      formatStrings, 4, statusString);
+                                      formatStrings, 4, statusString);
+  } else {
+    const char16_t *formatStrings[3] = {
+        numDownloadedStr.get(), totalToDownloadStr.get(), newsgroupName.get()};
+    rv = bundle->FormatStringFromName("newNewsgroupHeaders", formatStrings, 3,
+                                      statusString);
   }
-  else
-  {
-    const char16_t *formatStrings[3] = { numDownloadedStr.get(),
-      totalToDownloadStr.get(), newsgroupName.get() };
-    rv = bundle->FormatStringFromName("newNewsgroupHeaders",
-      formatStrings, 3, statusString);
-  }
-  if (!NS_SUCCEEDED(rv))
-    return;
+  if (!NS_SUCCEEDED(rv)) return;
 
   SetProgressStatus(statusString.get());
   m_lastStatusUpdate = PR_Now();
 
   // only update the progress meter if it has changed
-  if (percent != m_lastPercent)
-  {
+  if (percent != m_lastPercent) {
     SetProgressBarPercent(percent);
     m_lastPercent = percent;
   }
 }
 
-NS_IMETHODIMP nsNNTPNewsgroupList::SetGetOldMessages(bool aGetOldMessages)
-{
+NS_IMETHODIMP nsNNTPNewsgroupList::SetGetOldMessages(bool aGetOldMessages) {
   m_getOldMessages = aGetOldMessages;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPNewsgroupList::GetGetOldMessages(bool *aGetOldMessages)
-{
+NS_IMETHODIMP nsNNTPNewsgroupList::GetGetOldMessages(bool *aGetOldMessages) {
   NS_ENSURE_ARG(aGetOldMessages);
 
   *aGetOldMessages = m_getOldMessages;
   return NS_OK;
 }
--- a/mailnews/news/src/nsNNTPNewsgroupList.h
+++ b/mailnews/news/src/nsNNTPNewsgroupList.h
@@ -22,76 +22,78 @@
 #include "nsIMsgWindow.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 
 /* The below is all stuff that we remember for netlib about which
    articles we've already seen in the current newsgroup. */
 
 typedef struct MSG_NewsKnown {
-  nsMsgKeySet* set; /* Set of articles we've already gotten
+  nsMsgKeySet *set; /* Set of articles we've already gotten
                        from the newsserver (if it's marked
                        "read", then we've already gotten it).
                        If an article is marked "read", it
                        doesn't mean we're actually displaying
                        it; it may be an article that no longer
                        exists, or it may be one that we've
                        marked read and we're only viewing
                        unread messages. */
 
   int32_t first_possible; /* The oldest article in this group. */
-  int32_t last_possible; /* The newest article in this group. */
+  int32_t last_possible;  /* The newest article in this group. */
 
   bool shouldGetOldest;
 } MSG_NewsKnown;
 
 // This class should ultimately be part of a news group listing
 // state machine - either by inheritance or delegation.
 // Currently, a folder pane owns one and libnet news group listing
 // related messages get passed to this object.
-class nsNNTPNewsgroupList : public nsINNTPNewsgroupList, public nsIMsgFilterHitNotify
+class nsNNTPNewsgroupList : public nsINNTPNewsgroupList,
+                            public nsIMsgFilterHitNotify
 #ifdef HAVE_CHANGELISTENER
 /* ,public ChangeListener */
 #endif
 {
-public:
+ public:
   nsNNTPNewsgroupList();
   NS_DECL_ISUPPORTS
   NS_DECL_NSINNTPNEWSGROUPLIST
   NS_DECL_NSIMSGFILTERHITNOTIFY
 
-private:
-  virtual  ~nsNNTPNewsgroupList();
+ private:
+  virtual ~nsNNTPNewsgroupList();
 
   nsresult CleanUp();
 
-  bool    m_finishingXover;
+  bool m_finishingXover;
 
 #ifdef HAVE_CHANGELISTENER
-  virtual void OnAnnouncerGoingAway (ChangeAnnouncer *instigator);
+  virtual void OnAnnouncerGoingAway(ChangeAnnouncer *instigator);
 #endif
   nsresult ParseLine(char *line, uint32_t *message_number);
   nsresult GetDatabase(const char *uri, nsIMsgDatabase **db);
   void SetProgressBarPercent(int32_t percent);
   void SetProgressStatus(const char16_t *aMessage);
 
   void UpdateStatus(bool filtering, int32_t numDled, int32_t totToDL);
 
-  nsresult AddHeader(const char * header, const char * value);
-protected:
+  nsresult AddHeader(const char *header, const char *value);
+
+ protected:
   bool m_getOldMessages;
   bool m_promptedAlready;
   bool m_downloadAll;
   int32_t m_maxArticles;
   int32_t m_lastPercent;
   PRTime m_lastStatusUpdate;
 
-  nsCOMPtr <nsIMsgNewsFolder> m_newsFolder;
-  nsCOMPtr <nsIMsgDatabase> m_newsDB;
-  nsCOMPtr <nsINntpUrl> m_runningURL;
+  nsCOMPtr<nsIMsgNewsFolder> m_newsFolder;
+  nsCOMPtr<nsIMsgDatabase> m_newsDB;
+  nsCOMPtr<nsINntpUrl> m_runningURL;
 
   /**
    * The last message that we have processed (XOVER or HEAD).
    */
   nsMsgKey m_lastProcessedNumber;
   /**
    * The endpoints of the message chunk we are actually downloading.
    */
@@ -104,21 +106,19 @@ protected:
   struct MSG_NewsKnown m_knownArts;
   nsMsgKeySet *m_set;
 
   nsTArray<nsCString> m_filterHeaders;
   uint32_t m_currentXHDRIndex;
   nsCString m_lastHeader;
   nsCString m_thisLine;
 
-private:
-  nsCOMPtr <nsIMsgWindow> m_msgWindow;
-  nsCOMPtr <nsIMsgFilterList> m_filterList;
-  nsCOMPtr <nsIMsgFilterList> m_serverFilterList;
-  nsCOMPtr <nsIMsgDBHdr> m_newMsgHdr; // current message header we're building
+ private:
+  nsCOMPtr<nsIMsgWindow> m_msgWindow;
+  nsCOMPtr<nsIMsgFilterList> m_filterList;
+  nsCOMPtr<nsIMsgFilterList> m_serverFilterList;
+  nsCOMPtr<nsIMsgDBHdr> m_newMsgHdr;  // current message header we're building
   nsCOMArray<nsIMsgDBHdr> m_newHeaders;
 
   bool m_addHdrToDB;
-
 };
 
 #endif /* nsNNTPNewsgroupListState_h___ */
-
--- a/mailnews/news/src/nsNNTPNewsgroupPost.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupPost.cpp
@@ -1,38 +1,31 @@
 /* -*- 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/. */
 
-#include "msgCore.h"    // precompiled header...
+#include "msgCore.h"  // precompiled header...
 #include "nsNNTPNewsgroupPost.h"
 
 NS_IMPL_ISUPPORTS(nsNNTPNewsgroupPost, nsINNTPNewsgroupPost)
 
-nsNNTPNewsgroupPost::nsNNTPNewsgroupPost()
-{
-  m_isControl=false;
-}
+nsNNTPNewsgroupPost::nsNNTPNewsgroupPost() { m_isControl = false; }
 
-nsNNTPNewsgroupPost::~nsNNTPNewsgroupPost()
-{
-}
+nsNNTPNewsgroupPost::~nsNNTPNewsgroupPost() {}
 
-#define IMPL_GETSET(attribute, member) \
-  NS_IMETHODIMP nsNNTPNewsgroupPost::Get##attribute(char **result) \
-  { \
-    NS_ENSURE_ARG_POINTER(result); \
-    *result = ToNewCString(member); \
-    return NS_OK; \
-  } \
-  NS_IMETHODIMP nsNNTPNewsgroupPost::Set##attribute(const char *aValue) \
-  { \
-    member.Assign(aValue); \
-    return NS_OK; \
+#define IMPL_GETSET(attribute, member)                                    \
+  NS_IMETHODIMP nsNNTPNewsgroupPost::Get##attribute(char **result) {      \
+    NS_ENSURE_ARG_POINTER(result);                                        \
+    *result = ToNewCString(member);                                       \
+    return NS_OK;                                                         \
+  }                                                                       \
+  NS_IMETHODIMP nsNNTPNewsgroupPost::Set##attribute(const char *aValue) { \
+    member.Assign(aValue);                                                \
+    return NS_OK;                                                         \
   }
 
 IMPL_GETSET(RelayVersion, m_header[IDX_HEADER_RELAYVERSION])
 IMPL_GETSET(PostingVersion, m_header[IDX_HEADER_POSTINGVERSION])
 IMPL_GETSET(From, m_header[IDX_HEADER_FROM])
 IMPL_GETSET(Date, m_header[IDX_HEADER_DATE])
 IMPL_GETSET(Subject, m_header[IDX_HEADER_SUBJECT])
 IMPL_GETSET(Path, m_header[IDX_HEADER_PATH])
@@ -41,54 +34,43 @@ IMPL_GETSET(Sender, m_header[IDX_HEADER_
 IMPL_GETSET(FollowupTo, m_header[IDX_HEADER_FOLLOWUPTO])
 IMPL_GETSET(DateReceived, m_header[IDX_HEADER_DATERECEIVED])
 IMPL_GETSET(Expires, m_header[IDX_HEADER_EXPIRES])
 IMPL_GETSET(Control, m_header[IDX_HEADER_CONTROL])
 IMPL_GETSET(Distribution, m_header[IDX_HEADER_DISTRIBUTION])
 IMPL_GETSET(Organization, m_header[IDX_HEADER_ORGANIZATION])
 IMPL_GETSET(Body, m_body)
 
-NS_IMETHODIMP nsNNTPNewsgroupPost::GetNewsgroups(char **result)
-{
+NS_IMETHODIMP nsNNTPNewsgroupPost::GetNewsgroups(char **result) {
   NS_ENSURE_ARG_POINTER(result);
   *result = ToNewCString(m_header[IDX_HEADER_NEWSGROUPS]);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPNewsgroupPost::GetReferences(char **result)
-{
+NS_IMETHODIMP nsNNTPNewsgroupPost::GetReferences(char **result) {
   NS_ENSURE_ARG_POINTER(result);
   *result = ToNewCString(m_header[IDX_HEADER_REFERENCES]);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPNewsgroupPost::GetIsControl(bool *result)
-{
+NS_IMETHODIMP nsNNTPNewsgroupPost::GetIsControl(bool *result) {
   NS_ENSURE_ARG_POINTER(result);
   *result = m_isControl;
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupPost::AddNewsgroup(const char *newsgroup)
-{
-    m_header[IDX_HEADER_NEWSGROUPS].AppendLiteral(", ");
-    m_header[IDX_HEADER_NEWSGROUPS].Append(newsgroup);
-    return NS_OK;
+nsresult nsNNTPNewsgroupPost::AddNewsgroup(const char *newsgroup) {
+  m_header[IDX_HEADER_NEWSGROUPS].AppendLiteral(", ");
+  m_header[IDX_HEADER_NEWSGROUPS].Append(newsgroup);
+  return NS_OK;
 }
 
-
-// the message can be stored in a file....allow accessors for getting and setting
-// the file name to post...
-nsresult
-nsNNTPNewsgroupPost::SetPostMessageFile(nsIFile * aPostMessageFile)
-{
+// the message can be stored in a file....allow accessors for getting and
+// setting the file name to post...
+nsresult nsNNTPNewsgroupPost::SetPostMessageFile(nsIFile *aPostMessageFile) {
   m_postMessageFile = aPostMessageFile;
   return NS_OK;
 }
 
-nsresult
-nsNNTPNewsgroupPost::GetPostMessageFile(nsIFile ** aPostMessageFile)
-{
-  if (aPostMessageFile)
-    NS_IF_ADDREF(*aPostMessageFile = m_postMessageFile);
+nsresult nsNNTPNewsgroupPost::GetPostMessageFile(nsIFile **aPostMessageFile) {
+  if (aPostMessageFile) NS_IF_ADDREF(*aPostMessageFile = m_postMessageFile);
   return NS_OK;
 }
--- a/mailnews/news/src/nsNNTPNewsgroupPost.h
+++ b/mailnews/news/src/nsNNTPNewsgroupPost.h
@@ -7,55 +7,54 @@
 #define __nsNNTPNewsgroupPost_h
 
 #include "msgCore.h"
 #include "nsINNTPNewsgroupPost.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsIFile.h"
 
-#define IDX_HEADER_FROM             0
-#define IDX_HEADER_NEWSGROUPS       1
-#define IDX_HEADER_SUBJECT          2
+#define IDX_HEADER_FROM 0
+#define IDX_HEADER_NEWSGROUPS 1
+#define IDX_HEADER_SUBJECT 2
 
 // set this to the last required header
-#define IDX_HEADER_LAST_REQUIRED    IDX_HEADER_SUBJECT
+#define IDX_HEADER_LAST_REQUIRED IDX_HEADER_SUBJECT
 
-#define IDX_HEADER_PATH             3
-#define IDX_HEADER_DATE             4
+#define IDX_HEADER_PATH 3
+#define IDX_HEADER_DATE 4
 
-#define IDX_HEADER_REPLYTO          5
-#define IDX_HEADER_SENDER           6
-#define IDX_HEADER_FOLLOWUPTO       7
-#define IDX_HEADER_DATERECEIVED     8
-#define IDX_HEADER_EXPIRES          9
-#define IDX_HEADER_CONTROL          10
-#define IDX_HEADER_DISTRIBUTION     11
-#define IDX_HEADER_ORGANIZATION     12
-#define IDX_HEADER_REFERENCES       13
+#define IDX_HEADER_REPLYTO 5
+#define IDX_HEADER_SENDER 6
+#define IDX_HEADER_FOLLOWUPTO 7
+#define IDX_HEADER_DATERECEIVED 8
+#define IDX_HEADER_EXPIRES 9
+#define IDX_HEADER_CONTROL 10
+#define IDX_HEADER_DISTRIBUTION 11
+#define IDX_HEADER_ORGANIZATION 12
+#define IDX_HEADER_REFERENCES 13
 
 // stuff that's required to be in the message,
 // but probably generated on the server
-#define IDX_HEADER_RELAYVERSION     14
-#define IDX_HEADER_POSTINGVERSION   15
-#define IDX_HEADER_MESSAGEID        16
+#define IDX_HEADER_RELAYVERSION 14
+#define IDX_HEADER_POSTINGVERSION 15
+#define IDX_HEADER_MESSAGEID 16
 
 // keep this in sync with the above
-#define HEADER_LAST                 IDX_HEADER_MESSAGEID
+#define HEADER_LAST IDX_HEADER_MESSAGEID
 
 class nsNNTPNewsgroupPost : public nsINNTPNewsgroupPost {
+ public:
+  nsNNTPNewsgroupPost();
 
-public:
-    nsNNTPNewsgroupPost();
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSINNTPNEWSGROUPPOST
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSINNTPNEWSGROUPPOST
 
-private:
-    virtual ~nsNNTPNewsgroupPost();
+ private:
+  virtual ~nsNNTPNewsgroupPost();
 
-    nsCOMPtr<nsIFile> m_postMessageFile;
-    nsCString m_header[HEADER_LAST+1];
-    nsCString m_body;
-    bool m_isControl;
+  nsCOMPtr<nsIFile> m_postMessageFile;
+  nsCString m_header[HEADER_LAST + 1];
+  nsCString m_body;
+  bool m_isControl;
 };
 
 #endif /* __nsNNTPNewsgroupPost_h */
--- a/mailnews/news/src/nsNNTPProtocol.cpp
+++ b/mailnews/news/src/nsNNTPProtocol.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 "MailNewsTypes.h"
 #include "nntpCore.h"
 #include "nsNetUtil.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgHdr.h"
 #include "nsNNTPProtocol.h"
 #include "nsIOutputStream.h"
 #include "nsIPipe.h"
@@ -77,238 +77,235 @@
 #include "nsICancelable.h"
 
 #include "nsIInputStreamPump.h"
 #include "nsIProxyInfo.h"
 #include "nsContentSecurityManager.h"
 
 #include <time.h>
 
-#undef GetPort  // XXX Windows!
-#undef SetPort  // XXX Windows!
-#undef PostMessage // avoid to collision with WinUser.h
-
-#define PREF_NEWS_CANCEL_CONFIRM  "news.cancel.confirm"
+#undef GetPort      // XXX Windows!
+#undef SetPort      // XXX Windows!
+#undef PostMessage  // avoid to collision with WinUser.h
+
+#define PREF_NEWS_CANCEL_CONFIRM "news.cancel.confirm"
 #define PREF_NEWS_CANCEL_ALERT_ON_SUCCESS "news.cancel.alert_on_success"
-#define READ_NEWS_LIST_COUNT_MAX 500 /* number of groups to process at a time when reading the list from the server */
-#define READ_NEWS_LIST_TIMEOUT 50  /* uSec to wait until doing more */
+#define READ_NEWS_LIST_COUNT_MAX                                              \
+  500 /* number of groups to process at a time when reading the list from the \
+         server */
+#define READ_NEWS_LIST_TIMEOUT 50 /* uSec to wait until doing more */
 #define RATE_STR_BUF_LEN 32
 #define UPDATE_THRESHOLD 25600 /* only update every 25 KB */
 
 using namespace mozilla::mailnews;
 using namespace mozilla;
 
 // NNTP extensions are supported yet
 // until the extension code is ported,
 // we'll skip right to the first nntp command
 // after doing "mode reader"
 // and "pushed" authentication (if necessary),
 //#define HAVE_NNTP_EXTENSIONS
 
 // quiet compiler warnings by defining these function prototypes
-char *MSG_UnEscapeSearchUrl (const char *commandSpecificData);
+char *MSG_UnEscapeSearchUrl(const char *commandSpecificData);
 
 /* Logging stuff */
 
 static mozilla::LazyLogModule NNTP("NNTP");
-#define out     LogLevel::Info
+#define out LogLevel::Info
 
 #define NNTP_LOG_READ(buf) \
-MOZ_LOG(NNTP, out, ("(%p) Receiving: %s", this, buf)) ;
-
-#define NNTP_LOG_WRITE(buf) \
-MOZ_LOG(NNTP, out, ("(%p) Sending: %s", this, buf)) ;
-
-#define NNTP_LOG_NOTE(buf) \
-MOZ_LOG(NNTP, out, ("(%p) %s",this, buf)) ;
-
+  MOZ_LOG(NNTP, out, ("(%p) Receiving: %s", this, buf));
+
+#define NNTP_LOG_WRITE(buf) MOZ_LOG(NNTP, out, ("(%p) Sending: %s", this, buf));
+
+#define NNTP_LOG_NOTE(buf) MOZ_LOG(NNTP, out, ("(%p) %s", this, buf));
+
+// clang-format off
 const char *const stateLabels[] = {
-"NNTP_RESPONSE",
+  "NNTP_RESPONSE",
 #ifdef BLOCK_UNTIL_AVAILABLE_CONNECTION
-"NNTP_BLOCK_UNTIL_CONNECTIONS_ARE_AVAILABLE",
-"NNTP_CONNECTIONS_ARE_AVAILABLE",
+  "NNTP_BLOCK_UNTIL_CONNECTIONS_ARE_AVAILABLE",
+  "NNTP_CONNECTIONS_ARE_AVAILABLE",
 #endif
-"NNTP_CONNECT",
-"NNTP_CONNECT_WAIT",
-"NNTP_LOGIN_RESPONSE",
-"NNTP_SEND_MODE_READER",
-"NNTP_SEND_MODE_READER_RESPONSE",
-"SEND_LIST_EXTENSIONS",
-"SEND_LIST_EXTENSIONS_RESPONSE",
-"SEND_LIST_SEARCHES",
-"SEND_LIST_SEARCHES_RESPONSE",
-"NNTP_LIST_SEARCH_HEADERS",
-"NNTP_LIST_SEARCH_HEADERS_RESPONSE",
-"NNTP_GET_PROPERTIES",
-"NNTP_GET_PROPERTIES_RESPONSE",
-"SEND_LIST_SUBSCRIPTIONS",
-"SEND_LIST_SUBSCRIPTIONS_RESPONSE",
-"SEND_FIRST_NNTP_COMMAND",
-"SEND_FIRST_NNTP_COMMAND_RESPONSE",
-"SETUP_NEWS_STREAM",
-"NNTP_BEGIN_AUTHORIZE",
-"NNTP_AUTHORIZE_RESPONSE",
-"NNTP_PASSWORD_RESPONSE",
-"NNTP_READ_LIST_BEGIN",
-"NNTP_READ_LIST",
-"DISPLAY_NEWSGROUPS",
-"NNTP_NEWGROUPS_BEGIN",
-"NNTP_NEWGROUPS",
-"NNTP_BEGIN_ARTICLE",
-"NNTP_READ_ARTICLE",
-"NNTP_XOVER_BEGIN",
-"NNTP_FIGURE_NEXT_CHUNK",
-"NNTP_XOVER_SEND",
-"NNTP_XOVER_RESPONSE",
-"NNTP_XOVER",
-"NEWS_PROCESS_XOVER",
-"NNTP_XHDR_SEND",
-"NNTP_XHDR_RESPONSE",
-"NNTP_READ_GROUP",
-"NNTP_READ_GROUP_RESPONSE",
-"NNTP_READ_GROUP_BODY",
-"NNTP_SEND_GROUP_FOR_ARTICLE",
-"NNTP_SEND_GROUP_FOR_ARTICLE_RESPONSE",
-"NNTP_SEND_ARTICLE_NUMBER",
-"NEWS_PROCESS_BODIES",
-"NNTP_PRINT_ARTICLE_HEADERS",
-"NNTP_SEND_POST_DATA",
-"NNTP_SEND_POST_DATA_RESPONSE",
-"NNTP_CHECK_FOR_MESSAGE",
-"NEWS_START_CANCEL",
-"NEWS_DO_CANCEL",
-"NNTP_XPAT_SEND",
-"NNTP_XPAT_RESPONSE",
-"NNTP_SEARCH",
-"NNTP_SEARCH_RESPONSE",
-"NNTP_SEARCH_RESULTS",
-"NNTP_LIST_PRETTY_NAMES",
-"NNTP_LIST_PRETTY_NAMES_RESPONSE",
-"NNTP_LIST_XACTIVE_RESPONSE",
-"NNTP_LIST_XACTIVE",
-"NNTP_LIST_GROUP",
-"NNTP_LIST_GROUP_RESPONSE",
-"NEWS_DONE",
-"NEWS_POST_DONE",
-"NEWS_ERROR",
-"NNTP_ERROR",
-"NEWS_FREE",
-"NNTP_SUSPENDED"
+  "NNTP_CONNECT",
+  "NNTP_CONNECT_WAIT",
+  "NNTP_LOGIN_RESPONSE",
+  "NNTP_SEND_MODE_READER",
+  "NNTP_SEND_MODE_READER_RESPONSE",
+  "SEND_LIST_EXTENSIONS",
+  "SEND_LIST_EXTENSIONS_RESPONSE",
+  "SEND_LIST_SEARCHES",
+  "SEND_LIST_SEARCHES_RESPONSE",
+  "NNTP_LIST_SEARCH_HEADERS",
+  "NNTP_LIST_SEARCH_HEADERS_RESPONSE",
+  "NNTP_GET_PROPERTIES",
+  "NNTP_GET_PROPERTIES_RESPONSE",
+  "SEND_LIST_SUBSCRIPTIONS",
+  "SEND_LIST_SUBSCRIPTIONS_RESPONSE",
+  "SEND_FIRST_NNTP_COMMAND",
+  "SEND_FIRST_NNTP_COMMAND_RESPONSE",
+  "SETUP_NEWS_STREAM",
+  "NNTP_BEGIN_AUTHORIZE",
+  "NNTP_AUTHORIZE_RESPONSE",
+  "NNTP_PASSWORD_RESPONSE",
+  "NNTP_READ_LIST_BEGIN",
+  "NNTP_READ_LIST",
+  "DISPLAY_NEWSGROUPS",
+  "NNTP_NEWGROUPS_BEGIN",
+  "NNTP_NEWGROUPS",
+  "NNTP_BEGIN_ARTICLE",
+  "NNTP_READ_ARTICLE",
+  "NNTP_XOVER_BEGIN",
+  "NNTP_FIGURE_NEXT_CHUNK",
+  "NNTP_XOVER_SEND",
+  "NNTP_XOVER_RESPONSE",
+  "NNTP_XOVER",
+  "NEWS_PROCESS_XOVER",
+  "NNTP_XHDR_SEND",
+  "NNTP_XHDR_RESPONSE",
+  "NNTP_READ_GROUP",
+  "NNTP_READ_GROUP_RESPONSE",
+  "NNTP_READ_GROUP_BODY",
+  "NNTP_SEND_GROUP_FOR_ARTICLE",
+  "NNTP_SEND_GROUP_FOR_ARTICLE_RESPONSE",
+  "NNTP_SEND_ARTICLE_NUMBER",
+  "NEWS_PROCESS_BODIES",
+  "NNTP_PRINT_ARTICLE_HEADERS",
+  "NNTP_SEND_POST_DATA",
+  "NNTP_SEND_POST_DATA_RESPONSE",
+  "NNTP_CHECK_FOR_MESSAGE",
+  "NEWS_START_CANCEL",
+  "NEWS_DO_CANCEL",
+  "NNTP_XPAT_SEND",
+  "NNTP_XPAT_RESPONSE",
+  "NNTP_SEARCH",
+  "NNTP_SEARCH_RESPONSE",
+  "NNTP_SEARCH_RESULTS",
+  "NNTP_LIST_PRETTY_NAMES",
+  "NNTP_LIST_PRETTY_NAMES_RESPONSE",
+  "NNTP_LIST_XACTIVE_RESPONSE",
+  "NNTP_LIST_XACTIVE",
+  "NNTP_LIST_GROUP",
+  "NNTP_LIST_GROUP_RESPONSE",
+  "NEWS_DONE",
+  "NEWS_POST_DONE",
+  "NEWS_ERROR",
+  "NNTP_ERROR",
+  "NEWS_FREE",
+  "NNTP_SUSPENDED"
 };
-
+// clang-format on
 
 /* end logging */
 
 /* Forward declarations */
 
-#define LIST_WANTED     0
-#define ARTICLE_WANTED  1
-#define CANCEL_WANTED   2
-#define GROUP_WANTED    3
-#define NEWS_POST       4
-#define NEW_GROUPS      5
-#define SEARCH_WANTED   6
-#define IDS_WANTED      7
+#define LIST_WANTED 0
+#define ARTICLE_WANTED 1
+#define CANCEL_WANTED 2
+#define GROUP_WANTED 3
+#define NEWS_POST 4
+#define NEW_GROUPS 5
+#define SEARCH_WANTED 6
+#define IDS_WANTED 7
 
 /* 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)
 
 /* the amount of time to subtract from the machine time
  * for the newgroup command sent to the nntp server
  */
-#define NEWGROUPS_TIME_OFFSET 60L*60L*12L   /* 12 hours */
+#define NEWGROUPS_TIME_OFFSET 60L * 60L * 12L /* 12 hours */
 
 ////////////////////////////////////////////////////////////////////////////////////////////
 // TEMPORARY HARD CODED FUNCTIONS
 ///////////////////////////////////////////////////////////////////////////////////////////
-#define NET_IS_SPACE(x) ((x)==' ' || (x)=='\t')
+#define NET_IS_SPACE(x) ((x) == ' ' || (x) == '\t')
 
 // turn "\xx" (with xx being hex numbers) in string into chars
-char *MSG_UnEscapeSearchUrl (const char *commandSpecificData)
-{
+char *MSG_UnEscapeSearchUrl(const char *commandSpecificData) {
   nsAutoCString result(commandSpecificData);
   int32_t slashpos = 0;
-  while ((slashpos = result.FindChar('\\', slashpos)) != kNotFound)
-  {
+  while ((slashpos = result.FindChar('\\', slashpos)) != kNotFound) {
     nsAutoCString hex;
     hex.Assign(Substring(result, slashpos + 1, 2));
     int32_t ch;
     nsresult rv;
     ch = hex.ToInteger(&rv, 16);
-    result.Replace(slashpos, 3, NS_SUCCEEDED(rv) && ch != 0 ? (char) ch : 'X');
+    result.Replace(slashpos, 3, NS_SUCCEEDED(rv) && ch != 0 ? (char)ch : 'X');
     slashpos++;
   }
   return ToNewCString(result);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////
 // END OF TEMPORARY HARD CODED FUNCTIONS
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED(nsNNTPProtocol, nsMsgProtocol, nsINNTPProtocol,
-  nsITimerCallback, nsICacheEntryOpenCallback, nsIMsgAsyncPromptListener, nsIProtocolProxyCallback)
+                            nsITimerCallback, nsICacheEntryOpenCallback,
+                            nsIMsgAsyncPromptListener, nsIProtocolProxyCallback)
 
 nsNNTPProtocol::nsNNTPProtocol(nsINntpIncomingServer *aServer, nsIURI *aURL,
                                nsIMsgWindow *aMsgWindow)
-: nsMsgProtocol(aURL),
-  m_connectionBusy(false),
-  m_nntpServer(aServer)
-{
+    : nsMsgProtocol(aURL), m_connectionBusy(false), m_nntpServer(aServer) {
   m_ProxyServer = nullptr;
   m_responseText = nullptr;
   m_dataBuf = nullptr;
 
   m_key = nsMsgKey_None;
 
   mBytesReceived = 0;
   mBytesReceivedSinceLastStatusUpdate = 0;
   m_startTime = PR_Now();
 
   if (aMsgWindow) {
     m_msgWindow = aMsgWindow;
   }
 
   m_runningURL = nullptr;
   m_fromCache = false;
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) creating",this));
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) initializing, so unset m_currentGroup",this));
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) creating", this));
+  MOZ_LOG(NNTP, LogLevel::Info,
+          ("(%p) initializing, so unset m_currentGroup", this));
   m_currentGroup.Truncate();
   m_lastActiveTimeStamp = 0;
 }
 
-nsNNTPProtocol::~nsNNTPProtocol()
-{
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) destroying",this));
+nsNNTPProtocol::~nsNNTPProtocol() {
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) destroying", this));
   if (m_nntpServer) {
     m_nntpServer->WriteNewsrcFile();
     m_nntpServer->RemoveConnection(this);
   }
   if (mUpdateTimer) {
     mUpdateTimer->Cancel();
     mUpdateTimer = nullptr;
   }
   Cleanup();
 }
 
-void nsNNTPProtocol::Cleanup()  //free char* member variables
+void nsNNTPProtocol::Cleanup()  // free char* member variables
 {
   PR_FREEIF(m_responseText);
   PR_FREEIF(m_dataBuf);
 }
 
-NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI *aURL, nsIMsgWindow *aMsgWindow)
-{
+NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI *aURL,
+                                         nsIMsgWindow *aMsgWindow) {
   if (aMsgWindow) {
     m_msgWindow = aMsgWindow;
   }
   nsMsgProtocol::InitFromURI(aURL);
 
   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_nntpServer);
   NS_ASSERTION(m_nntpServer, "nsNNTPProtocol need an m_nntpServer.");
   NS_ENSURE_TRUE(m_nntpServer, NS_ERROR_UNEXPECTED);
@@ -317,23 +314,24 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize
   NS_ENSURE_SUCCESS(rv, rv);
 
   int32_t socketType;
   rv = server->GetSocketType(&socketType);
   NS_ENSURE_SUCCESS(rv, rv);
 
   int32_t port = 0;
   rv = m_url->GetPort(&port);
-  if (NS_FAILED(rv) || (port<=0)) {
+  if (NS_FAILED(rv) || (port <= 0)) {
     rv = server->GetPort(&port);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    if (port<=0) {
-      port = (socketType == nsMsgSocketType::SSL) ?
-             nsINntpUrl::DEFAULT_NNTPS_PORT : nsINntpUrl::DEFAULT_NNTP_PORT;
+    if (port <= 0) {
+      port = (socketType == nsMsgSocketType::SSL)
+                 ? nsINntpUrl::DEFAULT_NNTPS_PORT
+                 : nsINntpUrl::DEFAULT_NNTP_PORT;
     }
 
     // Don't mutate/clone here.
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_url);
     rv = mailnewsurl->SetPortInternal(port);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
@@ -347,67 +345,61 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize
 
   // Initialize m_newsAction before possible use in ParseURL method
   m_runningURL->GetNewsAction(&m_newsAction);
 
   // parse url to get the msg folder and check if the message is in the folder's
   // local cache before opening a new socket and trying to download the message
   rv = ParseURL(m_url, group, m_messageID);
 
-  if (NS_SUCCEEDED(rv) && m_runningURL)
-  {
+  if (NS_SUCCEEDED(rv) && m_runningURL) {
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
-    if (mailnewsUrl)
-    {
-      if (aMsgWindow)
-        mailnewsUrl->SetMsgWindow(aMsgWindow);
-
-      if (m_newsAction == nsINntpUrl::ActionFetchArticle || m_newsAction == nsINntpUrl::ActionFetchPart
-          || m_newsAction == nsINntpUrl::ActionSaveMessageToDisk)
-      {
+    if (mailnewsUrl) {
+      if (aMsgWindow) mailnewsUrl->SetMsgWindow(aMsgWindow);
+
+      if (m_newsAction == nsINntpUrl::ActionFetchArticle ||
+          m_newsAction == nsINntpUrl::ActionFetchPart ||
+          m_newsAction == nsINntpUrl::ActionSaveMessageToDisk) {
         // Look for the content length
         nsCOMPtr<nsIMsgMessageUrl> msgUrl(do_QueryInterface(m_runningURL));
-        if (msgUrl)
-        {
+        if (msgUrl) {
           nsCOMPtr<nsIMsgDBHdr> msgHdr;
           msgUrl->GetMessageHeader(getter_AddRefs(msgHdr));
-          if (msgHdr)
-          {
+          if (msgHdr) {
             // Note that for attachments, the messageSize is going to be the
             // size of the entire message
             uint32_t messageSize;
             msgHdr->GetMessageSize(&messageSize);
             SetContentLength(messageSize);
           }
         }
 
         bool msgIsInLocalCache = false;
         mailnewsUrl->GetMsgIsInLocalCache(&msgIsInLocalCache);
         if (msgIsInLocalCache || WeAreOffline())
-          return NS_OK; // probably don't need to do anything else - definitely don't want
+          return NS_OK;  // probably don't need to do anything else - definitely
+                         // don't want
         // to open the socket.
       }
     }
-  }
-  else {
+  } else {
     return rv;
   }
 
-  if (!m_socketIsOpen)
-  {
+  if (!m_socketIsOpen) {
     m_nextState = NNTP_LOGIN_RESPONSE;
-  }
-  else {
+  } else {
     m_nextState = SEND_FIRST_NNTP_COMMAND;
   }
-  m_dataBuf = (char *) PR_Malloc(sizeof(char) * OUTPUT_BUFFER_SIZE);
+  m_dataBuf = (char *)PR_Malloc(sizeof(char) * OUTPUT_BUFFER_SIZE);
   m_dataBufSize = OUTPUT_BUFFER_SIZE;
 
   if (!m_lineStreamBuffer)
-    m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, true /* create new lines */);
+    m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE,
+                                                   true /* create new lines */);
 
   m_typeWanted = 0;
   m_responseCode = 0;
   m_previousResponseCode = 0;
   m_responseText = nullptr;
 
   m_firstArticle = 0;
   m_lastArticle = 0;
@@ -422,390 +414,374 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize
   m_originalContentLength = 0;
   m_cancelID.Truncate();
   m_cancelFromHdr.Truncate();
   m_cancelNewsgroups.Truncate();
   m_cancelDistribution.Truncate();
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::GetIsBusy(bool *aIsBusy)
-{
+NS_IMETHODIMP nsNNTPProtocol::GetIsBusy(bool *aIsBusy) {
   NS_ENSURE_ARG_POINTER(aIsBusy);
   *aIsBusy = m_connectionBusy;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::SetIsBusy(bool aIsBusy)
-{
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) setting busy to %d",this, aIsBusy));
+NS_IMETHODIMP nsNNTPProtocol::SetIsBusy(bool aIsBusy) {
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) setting busy to %d", this, aIsBusy));
   m_connectionBusy = aIsBusy;
 
   // Maybe we could load another URI.
-  if (!aIsBusy && m_nntpServer)
-    m_nntpServer->PrepareForNextUrl(this);
+  if (!aIsBusy && m_nntpServer) m_nntpServer->PrepareForNextUrl(this);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::GetIsCachedConnection(bool *aIsCachedConnection)
-{
+NS_IMETHODIMP nsNNTPProtocol::GetIsCachedConnection(bool *aIsCachedConnection) {
   NS_ENSURE_ARG_POINTER(aIsCachedConnection);
   *aIsCachedConnection = m_fromCache;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::SetIsCachedConnection(bool aIsCachedConnection)
-{
+NS_IMETHODIMP nsNNTPProtocol::SetIsCachedConnection(bool aIsCachedConnection) {
   m_fromCache = aIsCachedConnection;
   return NS_OK;
 }
 
 /* void GetLastActiveTimeStamp (out PRTime aTimeStamp); */
-NS_IMETHODIMP nsNNTPProtocol::GetLastActiveTimeStamp(PRTime *aTimeStamp)
-{
+NS_IMETHODIMP nsNNTPProtocol::GetLastActiveTimeStamp(PRTime *aTimeStamp) {
   NS_ENSURE_ARG_POINTER(aTimeStamp);
   *aTimeStamp = m_lastActiveTimeStamp;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::LoadNewsUrl(nsIURI * aURL, nsISupports * aConsumer)
-{
+NS_IMETHODIMP nsNNTPProtocol::LoadNewsUrl(nsIURI *aURL,
+                                          nsISupports *aConsumer) {
   // clear the previous channel listener and use the new one....
   // don't reuse an existing channel listener
   m_channelListener = nullptr;
   m_channelListener = do_QueryInterface(aConsumer);
-  nsCOMPtr<nsINntpUrl> newsUrl (do_QueryInterface(aURL));
+  nsCOMPtr<nsINntpUrl> newsUrl(do_QueryInterface(aURL));
   newsUrl->GetNewsAction(&m_newsAction);
 
   SetupPartExtractorListener(m_channelListener);
   return LoadUrl(aURL, aConsumer);
 }
 
-
-// WARNING: the cache stream listener is intended to be accessed from the UI thread!
-// it will NOT create another proxy for the stream listener that gets passed in...
-class nsNntpCacheStreamListener : public nsIStreamListener
-{
-public:
+// WARNING: the cache stream listener is intended to be accessed from the UI
+// thread! it will NOT create another proxy for the stream listener that gets
+// passed in...
+class nsNntpCacheStreamListener : public nsIStreamListener {
+ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
 
-  nsNntpCacheStreamListener ();
-
-  nsresult Init(nsIStreamListener * aStreamListener, nsIChannel* channel, nsIMsgMailNewsUrl *aRunningUrl);
-protected:
+  nsNntpCacheStreamListener();
+
+  nsresult Init(nsIStreamListener *aStreamListener, nsIChannel *channel,
+                nsIMsgMailNewsUrl *aRunningUrl);
+
+ protected:
   virtual ~nsNntpCacheStreamListener();
-    nsCOMPtr<nsIChannel> mChannelToUse;
+  nsCOMPtr<nsIChannel> mChannelToUse;
   nsCOMPtr<nsIStreamListener> mListener;
   nsCOMPtr<nsIMsgMailNewsUrl> mRunningUrl;
 };
 
 NS_IMPL_ADDREF(nsNntpCacheStreamListener)
 NS_IMPL_RELEASE(nsNntpCacheStreamListener)
 
 NS_INTERFACE_MAP_BEGIN(nsNntpCacheStreamListener)
-   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamListener)
-   NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
-   NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamListener)
+  NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
+  NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
 NS_INTERFACE_MAP_END
 
-nsNntpCacheStreamListener::nsNntpCacheStreamListener()
-{
-}
-
-nsNntpCacheStreamListener::~nsNntpCacheStreamListener()
-{}
-
-nsresult nsNntpCacheStreamListener::Init(nsIStreamListener * aStreamListener, nsIChannel* channel,
-                                         nsIMsgMailNewsUrl *aRunningUrl)
-{
+nsNntpCacheStreamListener::nsNntpCacheStreamListener() {}
+
+nsNntpCacheStreamListener::~nsNntpCacheStreamListener() {}
+
+nsresult nsNntpCacheStreamListener::Init(nsIStreamListener *aStreamListener,
+                                         nsIChannel *channel,
+                                         nsIMsgMailNewsUrl *aRunningUrl) {
   NS_ENSURE_ARG(aStreamListener);
   NS_ENSURE_ARG(channel);
 
   mChannelToUse = channel;
 
   mListener = aStreamListener;
   mRunningUrl = aRunningUrl;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsNntpCacheStreamListener::OnStartRequest(nsIRequest *request)
-{
-  nsCOMPtr <nsILoadGroup> loadGroup;
+nsNntpCacheStreamListener::OnStartRequest(nsIRequest *request) {
+  nsCOMPtr<nsILoadGroup> loadGroup;
 
   NS_ASSERTION(mChannelToUse, "null channel in OnStartRequest");
-  if (mChannelToUse)
-    mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
+  if (mChannelToUse) mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
   if (loadGroup)
     loadGroup->AddRequest(mChannelToUse, nullptr /* context isupports */);
   return (mListener) ? mListener->OnStartRequest(mChannelToUse) : NS_OK;
 }
 
 NS_IMETHODIMP
-nsNntpCacheStreamListener::OnStopRequest(nsIRequest *request, nsresult aStatus)
-{
+nsNntpCacheStreamListener::OnStopRequest(nsIRequest *request,
+                                         nsresult aStatus) {
   nsresult rv = NS_OK;
   NS_ASSERTION(mListener, "this assertion is for Bug 531794 comment 7");
-  if (mListener)
-    mListener->OnStopRequest(mChannelToUse, aStatus);
-  nsCOMPtr <nsILoadGroup> loadGroup;
+  if (mListener) mListener->OnStopRequest(mChannelToUse, aStatus);
+  nsCOMPtr<nsILoadGroup> loadGroup;
   NS_ASSERTION(mChannelToUse, "null channel in OnStopRequest");
-  if (mChannelToUse)
-    mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
-  if (loadGroup)
-    loadGroup->RemoveRequest(mChannelToUse, nullptr, aStatus);
+  if (mChannelToUse) mChannelToUse->GetLoadGroup(getter_AddRefs(loadGroup));
+  if (loadGroup) loadGroup->RemoveRequest(mChannelToUse, nullptr, aStatus);
 
   // clear out mem cache entry so we're not holding onto it.
-  if (mRunningUrl)
-    mRunningUrl->SetMemCacheEntry(nullptr);
+  if (mRunningUrl) mRunningUrl->SetMemCacheEntry(nullptr);
 
   mListener = nullptr;
-  nsCOMPtr <nsINNTPProtocol> nntpProtocol = do_QueryInterface(mChannelToUse);
+  nsCOMPtr<nsINNTPProtocol> nntpProtocol = do_QueryInterface(mChannelToUse);
   if (nntpProtocol) {
     rv = nntpProtocol->SetIsBusy(false);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   mChannelToUse = nullptr;
   return rv;
 }
 
 NS_IMETHODIMP
-nsNntpCacheStreamListener::OnDataAvailable(nsIRequest *request, nsIInputStream * aInStream, uint64_t aSourceOffset, uint32_t aCount)
-{
-    NS_ENSURE_STATE(mListener);
-    return mListener->OnDataAvailable(mChannelToUse, aInStream, aSourceOffset, aCount);
+nsNntpCacheStreamListener::OnDataAvailable(nsIRequest *request,
+                                           nsIInputStream *aInStream,
+                                           uint64_t aSourceOffset,
+                                           uint32_t aCount) {
+  NS_ENSURE_STATE(mListener);
+  return mListener->OnDataAvailable(mChannelToUse, aInStream, aSourceOffset,
+                                    aCount);
 }
 
-NS_IMETHODIMP nsNNTPProtocol::GetOriginalURI(nsIURI* *aURI)
-{
-    // News does not seem to have the notion of an original URI (See Bug #193317)
-    NS_IF_ADDREF(*aURI = m_url);
-    return NS_OK;
+NS_IMETHODIMP nsNNTPProtocol::GetOriginalURI(nsIURI **aURI) {
+  // News does not seem to have the notion of an original URI (See Bug #193317)
+  NS_IF_ADDREF(*aURI = m_url);
+  return NS_OK;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::SetOriginalURI(nsIURI* aURI)
-{
-    // News does not seem to have the notion of an original URI (See Bug #193317)
-    return NS_OK;       // ignore
+NS_IMETHODIMP nsNNTPProtocol::SetOriginalURI(nsIURI *aURI) {
+  // News does not seem to have the notion of an original URI (See Bug #193317)
+  return NS_OK;  // ignore
 }
 
-nsresult nsNNTPProtocol::SetupPartExtractorListener(nsIStreamListener * aConsumer)
-{
+nsresult nsNNTPProtocol::SetupPartExtractorListener(
+    nsIStreamListener *aConsumer) {
   bool convertData = false;
   nsresult rv = NS_OK;
 
-  if (m_newsAction == nsINntpUrl::ActionFetchArticle)
-  {
+  if (m_newsAction == nsINntpUrl::ActionFetchArticle) {
     nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(m_runningURL, &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoCString queryStr;
     rv = msgUrl->GetQuery(queryStr);
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
 
     // check if this is a filter plugin requesting the message.
     // in that case, set up a text converter
-    convertData = (queryStr.Find("header=filter") != kNotFound
-      || queryStr.Find("header=attach") != kNotFound);
-  }
-  else
-  {
+    convertData = (queryStr.Find("header=filter") != kNotFound ||
+                   queryStr.Find("header=attach") != kNotFound);
+  } else {
     convertData = (m_newsAction == nsINntpUrl::ActionFetchPart);
   }
-  if (convertData)
-  {
-    nsCOMPtr<nsIStreamConverterService> converter = do_GetService("@mozilla.org/streamConverters;1");
-    if (converter && aConsumer)
-    {
+  if (convertData) {
+    nsCOMPtr<nsIStreamConverterService> converter =
+        do_GetService("@mozilla.org/streamConverters;1");
+    if (converter && aConsumer) {
       nsCOMPtr<nsIStreamListener> newConsumer;
       nsCOMPtr<nsIChannel> channel;
       QueryInterface(NS_GET_IID(nsIChannel), getter_AddRefs(channel));
-      converter->AsyncConvertData("message/rfc822", "*/*",
-           aConsumer, channel, getter_AddRefs(newConsumer));
-      if (newConsumer)
-        m_channelListener = newConsumer;
+      converter->AsyncConvertData("message/rfc822", "*/*", aConsumer, channel,
+                                  getter_AddRefs(newConsumer));
+      if (newConsumer) m_channelListener = newConsumer;
     }
   }
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::ReadFromMemCache(nsICacheEntry *entry)
-{
+nsresult nsNNTPProtocol::ReadFromMemCache(nsICacheEntry *entry) {
   NS_ENSURE_ARG(entry);
 
   nsCOMPtr<nsIInputStream> cacheStream;
   nsresult rv = entry->OpenInputStream(0, getter_AddRefs(cacheStream));
 
-  if (NS_SUCCEEDED(rv))
-  {
+  if (NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIInputStreamPump> pump;
     rv = NS_NewInputStreamPump(getter_AddRefs(pump), cacheStream.forget());
     if (NS_FAILED(rv)) return rv;
 
     nsCString group;
     // do this to get m_key set, so that marking the message read will work.
     rv = ParseURL(m_url, group, m_messageID);
 
     RefPtr<nsNntpCacheStreamListener> cacheListener =
-      new nsNntpCacheStreamListener();
+        new nsNntpCacheStreamListener();
 
     SetLoadGroup(m_loadGroup);
     m_typeWanted = ARTICLE_WANTED;
 
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
-    cacheListener->Init(m_channelListener, static_cast<nsIChannel *>(this), mailnewsUrl);
-
-    mContentType = ""; // reset the content type for the upcoming read....
+    cacheListener->Init(m_channelListener, static_cast<nsIChannel *>(this),
+                        mailnewsUrl);
+
+    mContentType = "";  // reset the content type for the upcoming read....
 
     rv = pump->AsyncRead(cacheListener, m_channelContext);
 
-    if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
+    if (NS_SUCCEEDED(rv))  // ONLY if we succeeded in actually starting the read
+                           // should we return
     {
-      // we're not calling nsMsgProtocol::AsyncRead(), which calls nsNNTPProtocol::LoadUrl, so we need to take care of some stuff it does.
+      // we're not calling nsMsgProtocol::AsyncRead(), which calls
+      // nsNNTPProtocol::LoadUrl, so we need to take care of some stuff it does.
       m_channelListener = nullptr;
       return rv;
     }
   }
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::ReadFromNewsConnection()
-{
+nsresult nsNNTPProtocol::ReadFromNewsConnection() {
   // we might end up here if we thought we had a news message offline
   // but it turned out not to be so. In which case, we need to
   // recall Initialize().
-  if (!m_socketIsOpen || !m_dataBuf)
-  {
+  if (!m_socketIsOpen || !m_dataBuf) {
     nsresult rv = Initialize(m_url, m_msgWindow);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  // XXX TODO: m_channelContext should be passes as URI on the channel. Previously passed as context.
+  // XXX TODO: m_channelContext should be passes as URI on the channel.
+  // Previously passed as context.
   return nsMsgProtocol::AsyncOpen(m_channelListener);
 }
 
-// for messages stored in our offline cache, we have special code to handle that...
-// If it's in the local cache, we return true and we can abort the download because
-// this method does the rest of the work.
-bool nsNNTPProtocol::ReadFromLocalCache()
-{
+// for messages stored in our offline cache, we have special code to handle
+// that... If it's in the local cache, we return true and we can abort the
+// download because this method does the rest of the work.
+bool nsNNTPProtocol::ReadFromLocalCache() {
   bool msgIsInLocalCache = false;
   nsresult rv = NS_OK;
   nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
   mailnewsUrl->GetMsgIsInLocalCache(&msgIsInLocalCache);
 
-  if (msgIsInLocalCache)
-  {
-    nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder);
-    if (folder && NS_SUCCEEDED(rv))
-    {
-    // we want to create a file channel and read the msg from there.
+  if (msgIsInLocalCache) {
+    nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(m_newsFolder);
+    if (folder && NS_SUCCEEDED(rv)) {
+      // we want to create a file channel and read the msg from there.
       nsCOMPtr<nsIInputStream> fileStream;
-      int64_t offset=0;
-      uint32_t size=0;
-      rv = folder->GetOfflineFileStream(m_key, &offset, &size, getter_AddRefs(fileStream));
+      int64_t offset = 0;
+      uint32_t size = 0;
+      rv = folder->GetOfflineFileStream(m_key, &offset, &size,
+                                        getter_AddRefs(fileStream));
 
       // get the file stream from the folder, somehow (through the message or
-      // folder sink?) We also need to set the transfer offset to the message offset
-      if (fileStream && NS_SUCCEEDED(rv))
-      {
-        // dougt - This may break the ablity to "cancel" a read from offline mail reading.
-        // fileChannel->SetLoadGroup(m_loadGroup);
+      // folder sink?) We also need to set the transfer offset to the message
+      // offset
+      if (fileStream && NS_SUCCEEDED(rv)) {
+        // dougt - This may break the ablity to "cancel" a read from offline
+        // mail reading. fileChannel->SetLoadGroup(m_loadGroup);
 
         m_typeWanted = ARTICLE_WANTED;
 
         RefPtr<nsNntpCacheStreamListener> cacheListener =
-          new nsNntpCacheStreamListener();
-
-        cacheListener->Init(m_channelListener, static_cast<nsIChannel *>(this), mailnewsUrl);
-
-        // create a stream pump that will async read the specified amount of data.
+            new nsNntpCacheStreamListener();
+
+        cacheListener->Init(m_channelListener, static_cast<nsIChannel *>(this),
+                            mailnewsUrl);
+
+        // create a stream pump that will async read the specified amount of
+        // data.
         // XXX make size 64-bit int
-        RefPtr<SlicedInputStream> slicedStream =
-          new SlicedInputStream(fileStream.forget(), uint64_t(offset), uint64_t(size));
+        RefPtr<SlicedInputStream> slicedStream = new SlicedInputStream(
+            fileStream.forget(), uint64_t(offset), uint64_t(size));
         nsCOMPtr<nsIInputStreamPump> pump;
         rv = NS_NewInputStreamPump(getter_AddRefs(pump), slicedStream.forget());
         if (NS_SUCCEEDED(rv))
           rv = pump->AsyncRead(cacheListener, m_channelContext);
 
-        if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
+        if (NS_SUCCEEDED(rv))  // ONLY if we succeeded in actually starting the
+                               // read should we return
         {
           mContentType.Truncate();
           m_channelListener = nullptr;
           NNTP_LOG_NOTE("Loading message from offline storage");
           return true;
         }
-      }
-      else
+      } else
         mailnewsUrl->SetMsgIsInLocalCache(false);
     }
   }
 
   return false;
 }
 
 NS_IMETHODIMP
-nsNNTPProtocol::OnCacheEntryAvailable(nsICacheEntry *entry, bool aNew, nsIApplicationCache* aAppCache, nsresult status)
-{
+nsNNTPProtocol::OnCacheEntryAvailable(nsICacheEntry *entry, bool aNew,
+                                      nsIApplicationCache *aAppCache,
+                                      nsresult status) {
   nsresult rv = NS_OK;
 
-  if (NS_SUCCEEDED(status))
-  {
-    nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL, &rv);
+  if (NS_SUCCEEDED(status)) {
+    nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl =
+        do_QueryInterface(m_runningURL, &rv);
     mailnewsUrl->SetMemCacheEntry(entry);
 
     // Insert a "stream T" into the flow so data gets written to both.
-    if (aNew)
-    {
-      // use a stream listener Tee to force data into the cache and to our current channel listener...
+    if (aNew) {
+      // use a stream listener Tee to force data into the cache and to our
+      // current channel listener...
       nsCOMPtr<nsIStreamListener> newListener;
-      nsCOMPtr<nsIStreamListenerTee> tee = do_CreateInstance(NS_STREAMLISTENERTEE_CONTRACTID, &rv);
+      nsCOMPtr<nsIStreamListenerTee> tee =
+          do_CreateInstance(NS_STREAMLISTENERTEE_CONTRACTID, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsCOMPtr<nsIOutputStream> outStream;
       rv = entry->OpenOutputStream(0, -1, getter_AddRefs(outStream));
       NS_ENSURE_SUCCESS(rv, rv);
 
       rv = tee->Init(m_channelListener, outStream, nullptr);
       NS_ENSURE_SUCCESS(rv, rv);
       m_channelListener = tee;
-    }
-    else
-    {
+    } else {
       rv = ReadFromMemCache(entry);
       if (NS_SUCCEEDED(rv)) {
         entry->MarkValid();
-        return NS_OK; // kick out if reading from the cache succeeded...
+        return NS_OK;  // kick out if reading from the cache succeeded...
       }
     }
-  } // if we got a valid entry back from the cache...
-
-  // if reading from the cache failed or if we are writing into the cache, default to ReadFromNewsConnection.
+  }  // if we got a valid entry back from the cache...
+
+  // if reading from the cache failed or if we are writing into the cache,
+  // default to ReadFromNewsConnection.
   return ReadFromNewsConnection();
 }
 
 NS_IMETHODIMP
-nsNNTPProtocol::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appCache,
-                                  uint32_t* aResult)
-{
+nsNNTPProtocol::OnCacheEntryCheck(nsICacheEntry *entry,
+                                  nsIApplicationCache *appCache,
+                                  uint32_t *aResult) {
   *aResult = nsICacheEntryOpenCallback::ENTRY_WANTED;
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::OpenCacheEntry()
-{
+nsresult nsNNTPProtocol::OpenCacheEntry() {
   nsresult rv = NS_OK;
-  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL, &rv);
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl =
+      do_QueryInterface(m_runningURL, &rv);
   // get the cache session from our nntp service...
-  nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
+  nsCOMPtr<nsINntpService> nntpService =
+      do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsICacheStorage> cacheStorage;
   rv = nntpService->GetCacheStorage(getter_AddRefs(cacheStorage));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Open a cache entry with key = url, no extension.
   nsCOMPtr<nsIURI> uri;
@@ -822,312 +798,276 @@ nsresult nsNNTPProtocol::OpenCacheEntry(
     path.SetLength(pos);
     rv = NS_MutateURI(uri).SetPathQueryRef(path).Finalize(newUri);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return cacheStorage->AsyncOpenURI(newUri ? newUri : uri, EmptyCString(),
                                     nsICacheStorage::OPEN_NORMALLY, this);
 }
 
-NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *aListener)
-{
+NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(nsIStreamListener *aListener) {
   nsCOMPtr<nsIStreamListener> listener = aListener;
-  nsresult rv = nsContentSecurityManager::doContentSecurityCheck(this, listener);
+  nsresult rv =
+      nsContentSecurityManager::doContentSecurityCheck(this, listener);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl =
+      do_QueryInterface(m_runningURL, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   int32_t port;
   rv = mailnewsUrl->GetPort(&port);
-  if (NS_FAILED(rv))
-      return rv;
+  if (NS_FAILED(rv)) return rv;
 
   rv = NS_CheckPortSafety(port, "news");
-  if (NS_FAILED(rv))
-      return rv;
-
-  nsCOMPtr <nsIURI> uri;
+  if (NS_FAILED(rv)) return rv;
+
+  nsCOMPtr<nsIURI> uri;
   GetURI(getter_AddRefs(uri));
   m_channelContext = uri;
   m_channelListener = listener;
   m_runningURL->GetNewsAction(&m_newsAction);
 
   // Before running through the connection, try to see if we can grab the data
   // from the offline storage or the memory cache. Only actions retrieving
   // messages can be cached.
   if (mailnewsUrl && (m_newsAction == nsINntpUrl::ActionFetchArticle ||
                       m_newsAction == nsINntpUrl::ActionFetchPart ||
-                      m_newsAction == nsINntpUrl::ActionSaveMessageToDisk))
-  {
+                      m_newsAction == nsINntpUrl::ActionSaveMessageToDisk)) {
     SetupPartExtractorListener(m_channelListener);
 
     // Attempt to get the message from the offline storage cache. If this
     // succeeds, we don't need to use our connection, so tell the server that we
     // are ready for the next URL.
-    if (ReadFromLocalCache())
-    {
-      if (m_nntpServer)
-        m_nntpServer->PrepareForNextUrl(this);
+    if (ReadFromLocalCache()) {
+      if (m_nntpServer) m_nntpServer->PrepareForNextUrl(this);
       return NS_OK;
     }
 
     // If it wasn't offline, try to get the cache from memory. If this call
     // succeeds, we probably won't need the connection, but the cache might fail
     // later on. The code there will determine if we need to fallback and will
     // handle informing the server of our readiness.
-    if (NS_SUCCEEDED(OpenCacheEntry()))
-      return NS_OK;
+    if (NS_SUCCEEDED(OpenCacheEntry())) return NS_OK;
   }
 
-  return nsMsgProtocol::AsyncOpen(listener);  // Context already attached to the channel.
+  return nsMsgProtocol::AsyncOpen(
+      listener);  // Context already attached to the channel.
 }
 
-void nsNNTPProtocol::PostLoadAssertions()
-{
-
+void nsNNTPProtocol::PostLoadAssertions() {
   // Make sure that we have the information we need to be able to run the
   // URLs
   NS_ASSERTION(m_nntpServer, "Parsing must result in an m_nntpServer");
-  if (m_typeWanted == ARTICLE_WANTED)
-  {
+  if (m_typeWanted == ARTICLE_WANTED) {
     if (m_key != nsMsgKey_None)
       NS_ASSERTION(m_newsFolder, "ARTICLE_WANTED needs m_newsFolder w/ key");
     else
-      NS_ASSERTION(!m_messageID.IsEmpty(), "ARTICLE_WANTED needs m_messageID w/o key");
-  }
-  else if (m_typeWanted == CANCEL_WANTED)
-  {
+      NS_ASSERTION(!m_messageID.IsEmpty(),
+                   "ARTICLE_WANTED needs m_messageID w/o key");
+  } else if (m_typeWanted == CANCEL_WANTED) {
     NS_ASSERTION(!m_messageID.IsEmpty(), "CANCEL_WANTED needs m_messageID");
     NS_ASSERTION(m_newsFolder, "CANCEL_WANTED needs m_newsFolder");
     NS_ASSERTION(m_key != nsMsgKey_None, "CANCEL_WANTED needs m_key");
-  }
-  else if (m_typeWanted == GROUP_WANTED)
+  } else if (m_typeWanted == GROUP_WANTED)
     NS_ASSERTION(m_newsFolder, "GROUP_WANTED needs m_newsFolder");
   else if (m_typeWanted == SEARCH_WANTED)
     NS_ASSERTION(!m_searchData.IsEmpty(), "SEARCH_WANTED needs m_searchData");
   else if (m_typeWanted == IDS_WANTED)
     NS_ASSERTION(m_newsFolder, "IDS_WANTED needs m_newsFolder");
 }
 
-nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
-{
+nsresult nsNNTPProtocol::LoadUrl(nsIURI *aURL, nsISupports *aConsumer) {
   NS_ENSURE_ARG_POINTER(aURL);
 
   nsCString group;
   mContentType.Truncate();
   nsresult rv = NS_OK;
 
   m_runningURL = do_QueryInterface(aURL, &rv);
   if (NS_FAILED(rv)) return rv;
   m_runningURL->GetNewsAction(&m_newsAction);
 
   SetIsBusy(true);
 
   rv = ParseURL(aURL, group, m_messageID);
-  NS_ASSERTION(NS_SUCCEEDED(rv),"failed to parse news url");
-  //if (NS_FAILED(rv)) return rv;
+  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to parse news url");
+  // if (NS_FAILED(rv)) return rv;
   // XXX group returned from ParseURL is assumed to be in UTF-8
   NS_ASSERTION(MsgIsUTF8(group), "newsgroup name is not in UTF-8");
   NS_ASSERTION(m_nntpServer, "Parsing must result in an m_nntpServer");
 
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) m_messageID = %s", this, m_messageID.get()));
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) group = %s", this, group.get()));
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) m_key = %d",this,m_key));
+  MOZ_LOG(NNTP, LogLevel::Info,
+          ("(%p) m_messageID = %s", this, m_messageID.get()));
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) group = %s", this, group.get()));
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) m_key = %d", this, m_key));
 
   if (m_newsAction == nsINntpUrl::ActionFetchArticle ||
       m_newsAction == nsINntpUrl::ActionFetchPart ||
       m_newsAction == nsINntpUrl::ActionSaveMessageToDisk)
     m_typeWanted = ARTICLE_WANTED;
   else if (m_newsAction == nsINntpUrl::ActionCancelArticle)
     m_typeWanted = CANCEL_WANTED;
-  else if (m_newsAction == nsINntpUrl::ActionPostArticle)
-  {
+  else if (m_newsAction == nsINntpUrl::ActionPostArticle) {
     m_typeWanted = NEWS_POST;
     m_messageID = "";
-  }
-  else if (m_newsAction == nsINntpUrl::ActionListIds)
-  {
+  } else if (m_newsAction == nsINntpUrl::ActionListIds) {
     m_typeWanted = IDS_WANTED;
     rv = m_nntpServer->FindGroup(group, getter_AddRefs(m_newsFolder));
-  }
-  else if (m_newsAction == nsINntpUrl::ActionSearch)
-  {
+  } else if (m_newsAction == nsINntpUrl::ActionSearch) {
     m_typeWanted = SEARCH_WANTED;
 
     // Get the search data
     nsCString commandSpecificData;
     nsCOMPtr<nsIURL> url = do_QueryInterface(m_runningURL);
     rv = url->GetQuery(commandSpecificData);
     NS_ENSURE_SUCCESS(rv, rv);
     MsgUnescapeString(commandSpecificData, 0, m_searchData);
 
     rv = m_nntpServer->FindGroup(group, getter_AddRefs(m_newsFolder));
-    if (!m_newsFolder)
-      goto FAIL;
-  }
-  else if (m_newsAction == nsINntpUrl::ActionGetNewNews)
-  {
+    if (!m_newsFolder) goto FAIL;
+  } else if (m_newsAction == nsINntpUrl::ActionGetNewNews) {
     bool containsGroup = true;
     rv = m_nntpServer->ContainsNewsgroup(group, &containsGroup);
-    if (NS_FAILED(rv))
-      goto FAIL;
-
-    if (!containsGroup)
-    {
+    if (NS_FAILED(rv)) goto FAIL;
+
+    if (!containsGroup) {
       // We have the name of a newsgroup which we're not subscribed to,
       // the next step is to ask the user whether we should subscribe to it.
       nsCOMPtr<nsIPrompt> dialog;
 
-      if (m_msgWindow)
-        m_msgWindow->GetPromptDialog(getter_AddRefs(dialog));
-
-      if (!dialog)
-      {
-         nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
-         wwatch->GetNewPrompter(nullptr, getter_AddRefs(dialog));
+      if (m_msgWindow) m_msgWindow->GetPromptDialog(getter_AddRefs(dialog));
+
+      if (!dialog) {
+        nsCOMPtr<nsIWindowWatcher> wwatch(
+            do_GetService(NS_WINDOWWATCHER_CONTRACTID));
+        wwatch->GetNewPrompter(nullptr, getter_AddRefs(dialog));
       }
 
       nsString statusString, confirmText;
       nsCOMPtr<nsIStringBundle> bundle;
       nsCOMPtr<nsIStringBundleService> bundleService =
-        mozilla::services::GetStringBundleService();
+          mozilla::services::GetStringBundleService();
 
       // to handle non-ASCII newsgroup names, we store them internally
       // as escaped. decode and unescape the newsgroup name so we'll
       // display a proper name.
 
       nsAutoString unescapedName;
       rv = NS_MsgDecodeUnescapeURLPath(group, unescapedName);
-      NS_ENSURE_SUCCESS(rv,rv);
+      NS_ENSURE_SUCCESS(rv, rv);
 
       bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
-      const char16_t *formatStrings[1] = { unescapedName.get() };
-
-      rv = bundle->FormatStringFromName(
-        "autoSubscribeText", formatStrings, 1,
-        confirmText);
-      NS_ENSURE_SUCCESS(rv,rv);
+      const char16_t *formatStrings[1] = {unescapedName.get()};
+
+      rv = bundle->FormatStringFromName("autoSubscribeText", formatStrings, 1,
+                                        confirmText);
+      NS_ENSURE_SUCCESS(rv, rv);
 
       bool confirmResult = false;
       rv = dialog->Confirm(nullptr, confirmText.get(), &confirmResult);
       NS_ENSURE_SUCCESS(rv, rv);
 
-      if (confirmResult)
-      {
-         rv = m_nntpServer->SubscribeToNewsgroup(group);
-         containsGroup = true;
-      }
-      else
-      {
+      if (confirmResult) {
+        rv = m_nntpServer->SubscribeToNewsgroup(group);
+        containsGroup = true;
+      } else {
         // XXX FIX ME
         // the way news is current written, we've already opened the socket
         // and initialized the connection.
         //
-        // until that is fixed, when the user cancels an autosubscribe, we've got to close it and clean up after ourselves
+        // until that is fixed, when the user cancels an autosubscribe, we've
+        // got to close it and clean up after ourselves
         //
         // see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108293
         // another problem, autosubscribe urls are ending up as cache entries
         // because the default action on nntp urls is ActionFetchArticle
         //
         // see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108294
         if (m_runningURL)
-          FinishMemCacheEntry(false); // cleanup mem cache entry
+          FinishMemCacheEntry(false);  // cleanup mem cache entry
 
         return CloseConnection();
       }
     }
 
-    // If we have a group (since before, or just subscribed), set the m_newsFolder.
-    if (containsGroup)
-    {
+    // If we have a group (since before, or just subscribed), set the
+    // m_newsFolder.
+    if (containsGroup) {
       rv = m_nntpServer->FindGroup(group, getter_AddRefs(m_newsFolder));
-      if (!m_newsFolder)
-        goto FAIL;
+      if (!m_newsFolder) goto FAIL;
     }
     m_typeWanted = GROUP_WANTED;
-  }
-  else if (m_newsAction == nsINntpUrl::ActionListGroups)
+  } else if (m_newsAction == nsINntpUrl::ActionListGroups)
     m_typeWanted = LIST_WANTED;
   else if (m_newsAction == nsINntpUrl::ActionListNewGroups)
     m_typeWanted = NEW_GROUPS;
   else if (!m_messageID.IsEmpty() || m_key != nsMsgKey_None)
     m_typeWanted = ARTICLE_WANTED;
-  else
-  {
+  else {
     MOZ_ASSERT_UNREACHABLE("Unknown news action");
     rv = NS_ERROR_FAILURE;
   }
 
-    // if this connection comes from the cache, we need to initialize the
-    // load group here, by generating the start request notification. nsMsgProtocol::OnStartRequest
-    // ignores the first parameter (which is supposed to be the channel) so we'll pass in null.
-    if (m_fromCache)
-      nsMsgProtocol::OnStartRequest(nullptr);
-
-      /* At this point, we're all done parsing the URL, and know exactly
-      what we want to do with it.
-    */
+  // if this connection comes from the cache, we need to initialize the
+  // load group here, by generating the start request notification.
+  // nsMsgProtocol::OnStartRequest ignores the first parameter (which is
+  // supposed to be the channel) so we'll pass in null.
+  if (m_fromCache) nsMsgProtocol::OnStartRequest(nullptr);
+
+  /* At this point, we're all done parsing the URL, and know exactly
+  what we want to do with it.
+*/
 
 FAIL:
-    if (NS_FAILED(rv))
-    {
-      AlertError(0, nullptr);
-      return rv;
+  if (NS_FAILED(rv)) {
+    AlertError(0, nullptr);
+    return rv;
+  } else {
+    if (!m_socketIsOpen) {
+      m_nextStateAfterResponse = m_nextState;
+      m_nextState = NNTP_RESPONSE;
+
+      // Calls LoadUrl in nsNNTPProtocol::OnProxyAvailable
+      rv = MsgExamineForProxyAsync(this, this, getter_AddRefs(m_proxyRequest));
+      if (NS_FAILED(rv)) {
+        rv = LoadUrlInternal(nullptr);
+      }
+    } else {
+      rv = nsMsgProtocol::LoadUrl(aURL, aConsumer);
     }
-    else
-    {
-      if (!m_socketIsOpen)
-      {
-        m_nextStateAfterResponse = m_nextState;
-        m_nextState = NNTP_RESPONSE;
-
-        // Calls LoadUrl in nsNNTPProtocol::OnProxyAvailable
-        rv = MsgExamineForProxyAsync(this, this, getter_AddRefs(m_proxyRequest));
-        if (NS_FAILED(rv)) {
-          rv = LoadUrlInternal(nullptr);
-        }
-      }
-      else
-      {
-        rv = nsMsgProtocol::LoadUrl(aURL, aConsumer);
-      }
-      if (NS_SUCCEEDED(rv))
-        PostLoadAssertions();
-    }
-
-    return rv;
+    if (NS_SUCCEEDED(rv)) PostLoadAssertions();
+  }
+
+  return rv;
 }
 
 // nsIProtocolProxyCallback
 NS_IMETHODIMP
 nsNNTPProtocol::OnProxyAvailable(nsICancelable *aRequest, nsIChannel *aChannel,
-                                 nsIProxyInfo *aProxyInfo, nsresult aStatus)
-{
-  MOZ_ASSERT(aChannel == this, "Should never request a proxy for anyone but ourselves");
+                                 nsIProxyInfo *aProxyInfo, nsresult aStatus) {
+  MOZ_ASSERT(aChannel == this,
+             "Should never request a proxy for anyone but ourselves");
 
   // If we're called with NS_BINDING_ABORTED, we came here via Cancel().
   // Otherwise, no checking of 'aStatus' here, see
   // nsHttpChannel::OnProxyAvailable(). Status is non-fatal and we just kick on.
-  if (aStatus == NS_BINDING_ABORTED)
-    return NS_ERROR_FAILURE;
+  if (aStatus == NS_BINDING_ABORTED) return NS_ERROR_FAILURE;
 
   nsresult rv = LoadUrlInternal(aProxyInfo);
   if (NS_FAILED(rv)) {
     return Cancel(rv);
   }
 
   PostLoadAssertions();
 
   return rv;
 }
 
-nsresult
-nsNNTPProtocol::LoadUrlInternal(nsIProxyInfo* aProxyInfo)
-{
+nsresult nsNNTPProtocol::LoadUrlInternal(nsIProxyInfo *aProxyInfo) {
   m_proxyRequest = nullptr;
 
   nsresult rv;
   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_nntpServer, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString hostName;
   int32_t port = 0;
@@ -1138,2063 +1078,1916 @@ nsNNTPProtocol::LoadUrlInternal(nsIProxy
 
   rv = m_url->GetPort(&port);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = server->GetSocketType(&socketType);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIInterfaceRequestor> ir;
-  if (socketType != nsMsgSocketType::plain && m_msgWindow)
-  {
+  if (socketType != nsMsgSocketType::plain && m_msgWindow) {
     nsCOMPtr<nsIDocShell> docShell;
     m_msgWindow->GetRootDocShell(getter_AddRefs(docShell));
     ir = do_QueryInterface(docShell);
   }
 
-  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) opening connection to %s on port %d",
-    this, hostName.get(), port));
-
-  rv = OpenNetworkSocketWithInfo(hostName.get(), port,
-    (socketType == nsMsgSocketType::SSL) ? "ssl" : nullptr,
-    aProxyInfo, ir);
+  MOZ_LOG(
+      NNTP, LogLevel::Info,
+      ("(%p) opening connection to %s on port %d", this, hostName.get(), port));
+
+  rv = OpenNetworkSocketWithInfo(
+      hostName.get(), port,
+      (socketType == nsMsgSocketType::SSL) ? "ssl" : nullptr, aProxyInfo, ir);
 
   rv = nsMsgProtocol::LoadUrl(m_url, m_consumer);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return rv;
 }
 
-void nsNNTPProtocol::FinishMemCacheEntry(bool valid)
-{
-  nsCOMPtr <nsICacheEntry> memCacheEntry;
+void nsNNTPProtocol::FinishMemCacheEntry(bool valid) {
+  nsCOMPtr<nsICacheEntry> memCacheEntry;
   nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
-  if (mailnewsurl)
-    mailnewsurl->GetMemCacheEntry(getter_AddRefs(memCacheEntry));
-  if (memCacheEntry)
-  {
+  if (mailnewsurl) mailnewsurl->GetMemCacheEntry(getter_AddRefs(memCacheEntry));
+  if (memCacheEntry) {
     if (valid)
       memCacheEntry->MarkValid();
     else
       memCacheEntry->AsyncDoom(nullptr);
   }
 }
 
-// stop binding is a "notification" informing us that the stream associated with aURL is going away.
-NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIRequest *request, nsresult aStatus)
-{
-    // either remove mem cache entry, or mark it valid if url successful and
-    // command succeeded
-    FinishMemCacheEntry(NS_SUCCEEDED(aStatus)
-      && MK_NNTP_RESPONSE_TYPE(m_responseCode) == MK_NNTP_RESPONSE_TYPE_OK);
-
-    nsMsgProtocol::OnStopRequest(request, aStatus);
-
-    // nsMsgProtocol::OnStopRequest() has called m_channelListener. There is
-    // no need to be called again in CloseSocket(). Let's clear it here.
-    if (m_channelListener) {
-        m_channelListener = nullptr;
-    }
-
-  // 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
+// stop binding is a "notification" informing us that the stream associated with
+// aURL is going away.
+NS_IMETHODIMP nsNNTPProtocol::OnStopRequest(nsIRequest *request,
+                                            nsresult aStatus) {
+  // either remove mem cache entry, or mark it valid if url successful and
+  // command succeeded
+  FinishMemCacheEntry(NS_SUCCEEDED(aStatus) &&
+                      MK_NNTP_RESPONSE_TYPE(m_responseCode) ==
+                          MK_NNTP_RESPONSE_TYPE_OK);
+
+  nsMsgProtocol::OnStopRequest(request, aStatus);
+
+  // nsMsgProtocol::OnStopRequest() has called m_channelListener. There is
+  // no need to be called again in CloseSocket(). Let's clear it here.
+  if (m_channelListener) {
+    m_channelListener = nullptr;
+  }
+
+  // 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
   return CloseSocket();
 }
 
 NS_IMETHODIMP nsNNTPProtocol::Cancel(nsresult status)  // handle stop button
 {
-    if (m_proxyRequest)
-    {
-      m_proxyRequest->Cancel(NS_BINDING_ABORTED);
-
-      // Note that nsMsgProtocol::Cancel() also calls
-      // nsProtocolProxyService::Cancel(), so no need to call it twice
-      // (although it self-protects against multiple calls).
-      m_proxyRequest = nullptr;
-    }
-
-    m_nextState = NNTP_ERROR;
-    return nsMsgProtocol::Cancel(NS_BINDING_ABORTED);
+  if (m_proxyRequest) {
+    m_proxyRequest->Cancel(NS_BINDING_ABORTED);
+
+    // Note that nsMsgProtocol::Cancel() also calls
+    // nsProtocolProxyService::Cancel(), so no need to call it twice
+    // (although it self-protects against multiple calls).
+    m_proxyRequest = nullptr;
+  }
+
+  m_nextState = NNTP_ERROR;
+  return nsMsgProtocol::Cancel(NS_BINDING_ABORTED);
 }
 
-nsresult
-nsNNTPProtocol::ParseURL(nsIURI *aURL, nsCString &aGroup, nsCString &aMessageID)
-{
-    NS_ENSURE_ARG_POINTER(aURL);
-
-    MOZ_LOG(NNTP, LogLevel::Info,("(%p) ParseURL",this));
-
-    nsresult rv;
-    nsCOMPtr <nsIMsgFolder> folder;
-    nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(m_runningURL, &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(msgUrl, &rv);
+nsresult nsNNTPProtocol::ParseURL(nsIURI *aURL, nsCString &aGroup,
+                                  nsCString &aMessageID) {
+  NS_ENSURE_ARG_POINTER(aURL);
+
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) ParseURL", this));
+
+  nsresult rv;
+  nsCOMPtr<nsIMsgFolder> folder;
+  nsCOMPtr<nsINntpService> nntpService =
+      do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(m_runningURL, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(msgUrl, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsCString spec;
+  rv = msgUrl->GetOriginalSpec(getter_Copies(spec));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  // if the original spec is non empty, use it to determine m_newsFolder and
+  // m_key
+  if (!spec.IsEmpty()) {
+    MOZ_LOG(NNTP, LogLevel::Info,
+            ("(%p) original message spec = %s", this, spec.get()));
+
+    rv = nntpService->DecomposeNewsURI(spec.get(), getter_AddRefs(folder),
+                                       &m_key);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCString spec;
-    rv = msgUrl->GetOriginalSpec(getter_Copies(spec));
-    NS_ENSURE_SUCCESS(rv,rv);
-
-    // if the original spec is non empty, use it to determine m_newsFolder and m_key
-    if (!spec.IsEmpty()) {
-        MOZ_LOG(NNTP, LogLevel::Info,("(%p) original message spec = %s",this,spec.get()));
-
-        rv = nntpService->DecomposeNewsURI(spec.get(), getter_AddRefs(folder), &m_key);
-        NS_ENSURE_SUCCESS(rv,rv);
-
-        // since we are reading a message in this folder, we can set m_newsFolder
-        m_newsFolder = do_QueryInterface(folder, &rv);
-        NS_ENSURE_SUCCESS(rv,rv);
-
-        // if we are cancelling, we aren't done.  we still need to parse out the messageID from the url
-        // later, we'll use m_newsFolder and m_key to delete the message from the DB, if the cancel is successful.
-        if (m_newsAction != nsINntpUrl::ActionCancelArticle) {
-            return NS_OK;
-        }
+    // since we are reading a message in this folder, we can set m_newsFolder
+    m_newsFolder = do_QueryInterface(folder, &rv);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    // if we are cancelling, we aren't done.  we still need to parse out the
+    // messageID from the url later, we'll use m_newsFolder and m_key to delete
+    // the message from the DB, if the cancel is successful.
+    if (m_newsAction != nsINntpUrl::ActionCancelArticle) {
+      return NS_OK;
     }
-    else {
-        // clear this, we'll set it later.
-        m_newsFolder = nullptr;
-        m_currentGroup.Truncate();
-    }
+  } else {
+    // clear this, we'll set it later.
+    m_newsFolder = nullptr;
+    m_currentGroup.Truncate();
+  }
 
   // Load the values from the URL for parsing.
   rv = m_runningURL->GetGroup(aGroup);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = m_runningURL->GetMessageID(aMessageID);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_ASSERTION(aMessageID.IsEmpty() || aMessageID != aGroup, "something not null");
+  NS_ASSERTION(aMessageID.IsEmpty() || aMessageID != aGroup,
+               "something not null");
 
   // If we are cancelling, we've got our message id, m_key, and m_newsFolder.
   // Bail out now to prevent messing those up.
-  if (m_newsAction == nsINntpUrl::ActionCancelArticle)
-    return NS_OK;
+  if (m_newsAction == nsINntpUrl::ActionCancelArticle) return NS_OK;
 
   rv = m_runningURL->GetKey(&m_key);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Check if the key is in the local cache.
   // It's possible that we're have a server/group/key combo that doesn't exist
   // (think nntp://server/group/key), so not having the folder isn't a bad
   // thing.
-  if (m_key != nsMsgKey_None)
-  {
+  if (m_key != nsMsgKey_None) {
     rv = mailnewsUrl->GetFolder(getter_AddRefs(folder));
     m_newsFolder = do_QueryInterface(folder);
 
-    if (NS_SUCCEEDED(rv) && m_newsFolder)
-    {
+    if (NS_SUCCEEDED(rv) && m_newsFolder) {
       bool useLocalCache = false;
       rv = folder->HasMsgOffline(m_key, &useLocalCache);
-      NS_ENSURE_SUCCESS(rv,rv);
+      NS_ENSURE_SUCCESS(rv, rv);
 
       // set message is in local cache
       rv = mailnewsUrl->SetMsgIsInLocalCache(useLocalCache);
-      NS_ENSURE_SUCCESS(rv,rv);
+      NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   return NS_OK;
 }
 /*
- * Writes the data contained in dataBuffer into the current output stream. It also informs
- * the transport layer that this data is now available for transmission.
- * Returns a positive number for success, 0 for failure (not all the bytes were written to the
- * stream, etc). We need to make another pass through this file to install an error system (mscott)
+ * Writes the data contained in dataBuffer into the current output stream. It
+ * also informs the transport layer that this data is now available for
+ * transmission. Returns a positive number for success, 0 for failure (not all
+ * the bytes were written to the stream, etc). We need to make another pass
+ * through this file to install an error system (mscott)
  */
 
-nsresult nsNNTPProtocol::SendData(const char * dataBuffer, bool aSuppressLogging)
-{
-    if (!aSuppressLogging) {
-        NNTP_LOG_WRITE(dataBuffer);
-    }
-    else {
-        MOZ_LOG(NNTP, out, ("(%p) Logging suppressed for this command (it probably contained authentication information)", this));
-    }
-
-  return nsMsgProtocol::SendData(dataBuffer); // base class actually transmits the data
+nsresult nsNNTPProtocol::SendData(const char *dataBuffer,
+                                  bool aSuppressLogging) {
+  if (!aSuppressLogging) {
+    NNTP_LOG_WRITE(dataBuffer);
+  } else {
+    MOZ_LOG(NNTP, out,
+            ("(%p) Logging suppressed for this command (it probably contained "
+             "authentication information)",
+             this));
+  }
+
+  return nsMsgProtocol::SendData(
+      dataBuffer);  // base class actually transmits the data
 }
 
 /* gets the response code from the nntp server and the
  * response line
  *
  * returns the TCP return code from the read
  */
-nsresult nsNNTPProtocol::NewsResponse(nsIInputStream *inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::NewsResponse(nsIInputStream *inputStream,
+                                      uint32_t length) {
   uint32_t status = 0;
 
   NS_ASSERTION(nullptr != inputStream, "invalid input stream");
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
+  char *line =
+      m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
 
   NNTP_LOG_READ(line);
 
-  if(pauseForMoreData)
-  {
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  if(!line)
-    return NS_ERROR_FAILURE;
-
-  ClearFlag(NNTP_PAUSE_FOR_READ);  /* don't pause if we got a line */
+  if (!line) return NS_ERROR_FAILURE;
+
+  ClearFlag(NNTP_PAUSE_FOR_READ); /* don't pause if we got a line */
 
   /* almost correct */
-  if(status > 1)
-  {
+  if (status > 1) {
     mBytesReceived += status;
     mBytesReceivedSinceLastStatusUpdate += status;
   }
 
   m_previousResponseCode = m_responseCode;
 
   PR_sscanf(line, "%d", &m_responseCode);
 
   if (m_responseCode && PL_strlen(line) > 3)
     NS_MsgSACopy(&m_responseText, line + 4);
   else
     NS_MsgSACopy(&m_responseText, line);
 
   /* authentication required can come at any time
-  */
+   */
   if (MK_NNTP_RESPONSE_AUTHINFO_REQUIRE == m_responseCode ||
-    MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_REQUIRE == m_responseCode)
-  {
+      MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_REQUIRE == m_responseCode) {
     m_nextState = NNTP_BEGIN_AUTHORIZE;
-  }
-  else {
+  } else {
     m_nextState = m_nextStateAfterResponse;
   }
 
   PR_FREEIF(line);
   return NS_OK;
 }
 
 /* interpret the server response after the connect
  *
  * returns negative if the server responds unexpectedly
  */
 
-nsresult nsNNTPProtocol::LoginResponse()
-{
+nsresult nsNNTPProtocol::LoginResponse() {
   bool postingAllowed = m_responseCode == MK_NNTP_RESPONSE_POSTING_ALLOWED;
 
-  if(MK_NNTP_RESPONSE_TYPE(m_responseCode)!=MK_NNTP_RESPONSE_TYPE_OK)
-  {
+  if (MK_NNTP_RESPONSE_TYPE(m_responseCode) != MK_NNTP_RESPONSE_TYPE_OK) {
     AlertError(MK_NNTP_ERROR_MESSAGE, m_responseText);
 
     m_nextState = NNTP_ERROR;
     return NS_ERROR_FAILURE;
   }
 
   m_nntpServer->SetPostingAllowed(postingAllowed);
   m_nextState = NNTP_SEND_MODE_READER;
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::SendModeReader()
-{
+nsresult nsNNTPProtocol::SendModeReader() {
   nsresult rv = NS_OK;
 
   rv = SendData(NNTP_CMD_MODE_READER);
-    m_nextState = NNTP_RESPONSE;
-    m_nextStateAfterResponse = NNTP_SEND_MODE_READER_RESPONSE;
-    SetFlag(NNTP_PAUSE_FOR_READ);
-
-    NS_ENSURE_SUCCESS(rv,rv);
-    return rv;
+  m_nextState = NNTP_RESPONSE;
+  m_nextStateAfterResponse = NNTP_SEND_MODE_READER_RESPONSE;
+  SetFlag(NNTP_PAUSE_FOR_READ);
+
+  NS_ENSURE_SUCCESS(rv, rv);
+  return rv;
 }
 
-nsresult nsNNTPProtocol::SendModeReaderResponse()
-{
+nsresult nsNNTPProtocol::SendModeReaderResponse() {
   SetFlag(NNTP_READER_PERFORMED);
 
   /* ignore the response code and continue
    */
   bool pushAuth = false;
   nsresult rv = NS_OK;
 
   NS_ASSERTION(m_nntpServer, "no server, see bug #107797");
   if (m_nntpServer) {
     rv = m_nntpServer->GetPushAuth(&pushAuth);
   }
   if (NS_SUCCEEDED(rv) && pushAuth) {
-    /* if the news host is set up to require volunteered (pushed) authentication,
-    * do that before we do anything else
-    */
+    /* if the news host is set up to require volunteered (pushed)
+     * authentication, do that before we do anything else
+     */
     m_nextState = NNTP_BEGIN_AUTHORIZE;
-  }
-  else {
+  } else {
 #ifdef HAVE_NNTP_EXTENSIONS
     m_nextState = SEND_LIST_EXTENSIONS;
 #else
     m_nextState = SEND_FIRST_NNTP_COMMAND;
-#endif  /* HAVE_NNTP_EXTENSIONS */
+#endif /* HAVE_NNTP_EXTENSIONS */
   }
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::SendListExtensions()
-{
+nsresult nsNNTPProtocol::SendListExtensions() {
   nsresult rv = SendData(NNTP_CMD_LIST_EXTENSIONS);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = SEND_LIST_EXTENSIONS_RESPONSE;
   ClearFlag(NNTP_PAUSE_FOR_READ);
   return rv;
 }
 
-nsresult nsNNTPProtocol::SendListExtensionsResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::SendListExtensionsResponse(nsIInputStream *inputStream,
+                                                    uint32_t length) {
   nsresult rv = NS_OK;
 
-  if (MK_NNTP_RESPONSE_TYPE(m_responseCode) == MK_NNTP_RESPONSE_TYPE_OK)
-  {
+  if (MK_NNTP_RESPONSE_TYPE(m_responseCode) == MK_NNTP_RESPONSE_TYPE_OK) {
     uint32_t status = 0;
     bool pauseForMoreData = false;
-    char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-    if(pauseForMoreData)
-    {
+    char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                  pauseForMoreData, &rv);
+
+    if (pauseForMoreData) {
       SetFlag(NNTP_PAUSE_FOR_READ);
       return NS_OK;
     }
-    if (!line)
-      return rv;  /* no line yet */
-
-        if ('.' != line[0]) {
-            m_nntpServer->AddExtension(line);
-        }
-    else
-    {
+    if (!line) return rv; /* no line yet */
+
+    if ('.' != line[0]) {
+      m_nntpServer->AddExtension(line);
+    } else {
       /* tell libmsg that it's ok to ask this news host for extensions */
       m_nntpServer->SetSupportsExtensions(true);
       /* all extensions received */
       m_nextState = SEND_LIST_SEARCHES;
       ClearFlag(NNTP_PAUSE_FOR_READ);
     }
-  }
-  else
-  {
+  } else {
     /* LIST EXTENSIONS not recognized
      * tell libmsg not to ask for any more extensions and move on to
      * the real NNTP command we were trying to do. */
 
-     m_nntpServer->SetSupportsExtensions(false);
-     m_nextState = SEND_FIRST_NNTP_COMMAND;
+    m_nntpServer->SetSupportsExtensions(false);
+    m_nextState = SEND_FIRST_NNTP_COMMAND;
   }
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::SendListSearches()
-{
-    nsresult rv;
-    bool searchable=false;
-
-    rv = m_nntpServer->QueryExtension("SEARCH",&searchable);
-    if (NS_SUCCEEDED(rv) && searchable)
-  {
+nsresult nsNNTPProtocol::SendListSearches() {
+  nsresult rv;
+  bool searchable = false;
+
+  rv = m_nntpServer->QueryExtension("SEARCH", &searchable);
+  if (NS_SUCCEEDED(rv) && searchable) {
     rv = SendData(NNTP_CMD_LIST_SEARCHES);
 
     m_nextState = NNTP_RESPONSE;
     m_nextStateAfterResponse = SEND_LIST_SEARCHES_RESPONSE;
     SetFlag(NNTP_PAUSE_FOR_READ);
-  }
-  else
-  {
+  } else {
     /* since SEARCH isn't supported, move on to GET */
     m_nextState = NNTP_GET_PROPERTIES;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::SendListSearchesResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::SendListSearchesResponse(nsIInputStream *inputStream,
+                                                  uint32_t length) {
   uint32_t status = 0;
   nsresult rv = NS_OK;
 
   NS_ASSERTION(inputStream, "invalid input stream");
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
+  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                pauseForMoreData, &rv);
 
   NNTP_LOG_READ(line);
 
-  if(pauseForMoreData)
-  {
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
-  if (!line)
-    return rv;  /* no line yet */
-
-  if ('.' != line[0])
-  {
-        nsAutoCString charset;
-        nsAutoString lineUtf16;
-        if (NS_FAILED(m_nntpServer->GetCharset(charset)) ||
-            NS_FAILED(nsMsgI18NConvertToUnicode(charset,
-                                                nsDependentCString(line),
-                                                lineUtf16)))
-            CopyUTF8toUTF16(nsDependentCString(line), lineUtf16);
+  if (!line) return rv; /* no line yet */
+
+  if ('.' != line[0]) {
+    nsAutoCString charset;
+    nsAutoString lineUtf16;
+    if (NS_FAILED(m_nntpServer->GetCharset(charset)) ||
+        NS_FAILED(nsMsgI18NConvertToUnicode(charset, nsDependentCString(line),
+                                            lineUtf16)))
+      CopyUTF8toUTF16(nsDependentCString(line), lineUtf16);
 
     m_nntpServer->AddSearchableGroup(lineUtf16);
-  }
-  else
-  {
+  } else {
     /* all searchable groups received */
-    /* LIST SRCHFIELDS is legal if the server supports the SEARCH extension, which */
+    /* LIST SRCHFIELDS is legal if the server supports the SEARCH extension,
+     * which */
     /* we already know it does */
     m_nextState = NNTP_LIST_SEARCH_HEADERS;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
 
   PR_FREEIF(line);
   return rv;
 }
 
-nsresult nsNNTPProtocol::SendListSearchHeaders()
-{
+nsresult nsNNTPProtocol::SendListSearchHeaders() {
   nsresult rv = SendData(NNTP_CMD_LIST_SEARCH_FIELDS);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NNTP_LIST_SEARCH_HEADERS_RESPONSE;
   SetFlag(NNTP_PAUSE_FOR_READ);
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::SendListSearchHeadersResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::SendListSearchHeadersResponse(
+    nsIInputStream *inputStream, uint32_t length) {
   uint32_t status = 0;
   nsresult rv;
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if(pauseForMoreData)
-  {
+  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
-  if (!line)
-    return rv;  /* no line yet */
+  if (!line) return rv; /* no line yet */
 
   if ('.' != line[0])
-        m_nntpServer->AddSearchableHeader(line);
-  else
-  {
+    m_nntpServer->AddSearchableHeader(line);
+  else {
     m_nextState = NNTP_GET_PROPERTIES;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
 
   PR_FREEIF(line);
   return rv;
 }
 
-nsresult nsNNTPProtocol::GetProperties()
-{
-    nsresult rv;
-    bool setget=false;
-
-    rv = m_nntpServer->QueryExtension("SETGET",&setget);
-    if (NS_SUCCEEDED(rv) && setget)
-  {
+nsresult nsNNTPProtocol::GetProperties() {
+  nsresult rv;
+  bool setget = false;
+
+  rv = m_nntpServer->QueryExtension("SETGET", &setget);
+  if (NS_SUCCEEDED(rv) && setget) {
     rv = SendData(NNTP_CMD_GET_PROPERTIES);
     m_nextState = NNTP_RESPONSE;
     m_nextStateAfterResponse = NNTP_GET_PROPERTIES_RESPONSE;
     SetFlag(NNTP_PAUSE_FOR_READ);
-  }
-  else
-  {
+  } else {
     /* since GET isn't supported, move on LIST SUBSCRIPTIONS */
     m_nextState = SEND_LIST_SUBSCRIPTIONS;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
   return rv;
 }
 
-nsresult nsNNTPProtocol::GetPropertiesResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::GetPropertiesResponse(nsIInputStream *inputStream,
+                                               uint32_t length) {
   uint32_t status = 0;
   nsresult rv;
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if(pauseForMoreData)
-  {
+  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
-  if (!line)
-    return rv;  /* no line yet */
-
-  if ('.' != line[0])
-  {
+  if (!line) return rv; /* no line yet */
+
+  if ('.' != line[0]) {
     char *propertyName = NS_xstrdup(line);
-    if (propertyName)
-    {
+    if (propertyName) {
       char *space = PL_strchr(propertyName, ' ');
-      if (space)
-      {
+      if (space) {
         char *propertyValue = space + 1;
         *space = '\0';
-                m_nntpServer->AddPropertyForGet(propertyName, propertyValue);
+        m_nntpServer->AddPropertyForGet(propertyName, propertyValue);
       }
       PR_Free(propertyName);
     }
-  }
-  else
-  {
+  } else {
     /* all GET properties received, move on to LIST SUBSCRIPTIONS */
     m_nextState = SEND_LIST_SUBSCRIPTIONS;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
 
   PR_FREEIF(line);
   return rv;
 }
 
-nsresult nsNNTPProtocol::SendListSubscriptions()
-{
-    nsresult rv = NS_OK;
-/* TODO: is this needed for anything?
-#if 0
-    bool searchable=false;
-    rv = m_nntpServer->QueryExtension("LISTSUBSCR",&listsubscr);
-    if (NS_SUCCEEDED(rv) && listsubscr)
-#else
-  if (0)
-#endif
-  {
-    rv = SendData(NNTP_CMD_LIST_SUBSCRIPTIONS);
-    m_nextState = NNTP_RESPONSE;
-    m_nextStateAfterResponse = SEND_LIST_SUBSCRIPTIONS_RESPONSE;
-    SetFlag(NNTP_PAUSE_FOR_READ);
-  }
-  else
-*/
+nsresult nsNNTPProtocol::SendListSubscriptions() {
+  nsresult rv = NS_OK;
+  /* TODO: is this needed for anything?
+  #if 0
+      bool searchable=false;
+      rv = m_nntpServer->QueryExtension("LISTSUBSCR",&listsubscr);
+      if (NS_SUCCEEDED(rv) && listsubscr)
+  #else
+    if (0)
+  #endif
+    {
+      rv = SendData(NNTP_CMD_LIST_SUBSCRIPTIONS);
+      m_nextState = NNTP_RESPONSE;
+      m_nextStateAfterResponse = SEND_LIST_SUBSCRIPTIONS_RESPONSE;
+      SetFlag(NNTP_PAUSE_FOR_READ);
+    }
+    else
+  */
   {
     /* since LIST SUBSCRIPTIONS isn't supported, move on to real work */
     m_nextState = SEND_FIRST_NNTP_COMMAND;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::SendListSubscriptionsResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::SendListSubscriptionsResponse(
+    nsIInputStream *inputStream, uint32_t length) {
   uint32_t status = 0;
   nsresult rv;
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if(pauseForMoreData)
-  {
+  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
-  if (!line)
-    return rv;  /* no line yet */
-
-  if ('.' != line[0])
-  {
-        NS_ERROR("fix me");
+  if (!line) return rv; /* no line yet */
+
+  if ('.' != line[0]) {
+    NS_ERROR("fix me");
 #if 0
     char *url = PR_smprintf ("%s//%s/%s", NEWS_SCHEME, m_hostName, line);
     if (url)
       MSG_AddSubscribedNewsgroup (cd->pane, url);
 #endif
-  }
-  else
-  {
+  } else {
     /* all default subscriptions received */
     m_nextState = SEND_FIRST_NNTP_COMMAND;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
 
   PR_FREEIF(line);
   return rv;
 }
 
 /* figure out what the first command is and send it
  *
  * returns the status from the NETWrite */
 
-nsresult nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
-{
-    char *command=0;
-
-    if (m_typeWanted == ARTICLE_WANTED) {
-        if (m_key != nsMsgKey_None) {
-            nsresult rv;
-            nsCString newsgroupName;
-            if (m_newsFolder) {
-                rv = m_newsFolder->GetRawName(newsgroupName);
-                NS_ENSURE_SUCCESS(rv,rv);
-            }
-            MOZ_LOG(NNTP, LogLevel::Info,
-                   ("(%p) current group = %s, desired group = %s", this,
-                   m_currentGroup.get(), newsgroupName.get()));
-            // if the current group is the desired group, we can just issue the ARTICLE command
-            // if not, we have to do a GROUP first
-            if (newsgroupName.Equals(m_currentGroup))
-              m_nextState = NNTP_SEND_ARTICLE_NUMBER;
-            else
-              m_nextState = NNTP_SEND_GROUP_FOR_ARTICLE;
-
-            ClearFlag(NNTP_PAUSE_FOR_READ);
-            return NS_OK;
-        }
-    }
-
-    if(m_typeWanted == NEWS_POST)
-    {  /* posting to the news group */
-        NS_MsgSACopy(&command, "POST");
+nsresult nsNNTPProtocol::SendFirstNNTPCommand(nsIURI *url) {
+  char *command = 0;
+
+  if (m_typeWanted == ARTICLE_WANTED) {
+    if (m_key != nsMsgKey_None) {
+      nsresult rv;
+      nsCString newsgroupName;
+      if (m_newsFolder) {
+        rv = m_newsFolder->GetRawName(newsgroupName);
+        NS_ENSURE_SUCCESS(rv, rv);
+      }
+      MOZ_LOG(NNTP, LogLevel::Info,
+              ("(%p) current group = %s, desired group = %s", this,
+               m_currentGroup.get(), newsgroupName.get()));
+      // if the current group is the desired group, we can just issue the
+      // ARTICLE command if not, we have to do a GROUP first
+      if (newsgroupName.Equals(m_currentGroup))
+        m_nextState = NNTP_SEND_ARTICLE_NUMBER;
+      else
+        m_nextState = NNTP_SEND_GROUP_FOR_ARTICLE;
+
+      ClearFlag(NNTP_PAUSE_FOR_READ);
+      return NS_OK;
     }
-  else if (m_typeWanted == NEW_GROUPS)
-  {
-      uint32_t last_update;
-      nsresult rv;
-
-      if (!m_nntpServer)
-      {
-        NNTP_LOG_NOTE("m_nntpServer is null, panic!");
-        return NS_ERROR_FAILURE;
-      }
-      rv = m_nntpServer->GetLastUpdatedTime(&last_update);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      if (!last_update)
-    {
-        NS_MsgSACopy(&command, "LIST");
-      }
-    else
-      {
-        char small_buf[64];
-        PRExplodedTime  expandedTime;
-        PRTime t_usec = (PRTime)last_update * PR_USEC_PER_SEC;
-        PR_ExplodeTime(t_usec, PR_LocalTimeParameters, &expandedTime);
-        PR_FormatTimeUSEnglish(small_buf, sizeof(small_buf),
-                               "NEWGROUPS %y%m%d %H%M%S", &expandedTime);
-        NS_MsgSACopy(&command, small_buf);
-      }
   }
-    else if(m_typeWanted == LIST_WANTED)
-    {
-      nsresult rv;
+
+  if (m_typeWanted == NEWS_POST) { /* posting to the news group */
+    NS_MsgSACopy(&command, "POST");
+  } else if (m_typeWanted == NEW_GROUPS) {
+    uint32_t last_update;
+    nsresult rv;
+
+    if (!m_nntpServer) {
+      NNTP_LOG_NOTE("m_nntpServer is null, panic!");
+      return NS_ERROR_FAILURE;
+    }
+    rv = m_nntpServer->GetLastUpdatedTime(&last_update);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    if (!last_update) {
+      NS_MsgSACopy(&command, "LIST");
+    } else {
+      char small_buf[64];
+      PRExplodedTime expandedTime;
+      PRTime t_usec = (PRTime)last_update * PR_USEC_PER_SEC;
+      PR_ExplodeTime(t_usec, PR_LocalTimeParameters, &expandedTime);
+      PR_FormatTimeUSEnglish(small_buf, sizeof(small_buf),
+                             "NEWGROUPS %y%m%d %H%M%S", &expandedTime);
+      NS_MsgSACopy(&command, small_buf);
+    }
+  } else if (m_typeWanted == LIST_WANTED) {
+    nsresult rv;
 
     ClearFlag(NNTP_USE_FANCY_NEWSGROUP);
 
-        NS_ASSERTION(m_nntpServer, "no m_nntpServer");
+    NS_ASSERTION(m_nntpServer, "no m_nntpServer");
     if (!m_nntpServer) {
-          NNTP_LOG_NOTE("m_nntpServer is null, panic!");
-          return NS_ERROR_FAILURE;
+      NNTP_LOG_NOTE("m_nntpServer is null, panic!");
+      return NS_ERROR_FAILURE;
+    }
+
+    bool xactive = false;
+    rv = m_nntpServer->QueryExtension("XACTIVE", &xactive);
+    if (NS_SUCCEEDED(rv) && xactive) {
+      NS_MsgSACopy(&command, "LIST XACTIVE");
+      SetFlag(NNTP_USE_FANCY_NEWSGROUP);
+    } else {
+      NS_MsgSACopy(&command, "LIST");
     }
-
-      bool xactive=false;
-      rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
-      if (NS_SUCCEEDED(rv) && xactive)
-      {
-        NS_MsgSACopy(&command, "LIST XACTIVE");
-        SetFlag(NNTP_USE_FANCY_NEWSGROUP);
-      }
-      else
-      {
-        NS_MsgSACopy(&command, "LIST");
-      }
-  }
-  else if(m_typeWanted == GROUP_WANTED)
-    {
-        nsresult rv = NS_ERROR_NULL_POINTER;
-
-        NS_ASSERTION(m_newsFolder, "m_newsFolder is null, panic!");
-        if (!m_newsFolder) return NS_ERROR_FAILURE;
-
-        nsCString group_name;
-        rv = m_newsFolder->GetRawName(group_name);
-        NS_ASSERTION(NS_SUCCEEDED(rv),"failed to get newsgroup name");
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        m_firstArticle = 0;
-        m_lastArticle = 0;
-
-        NS_MsgSACopy(&command, "GROUP ");
-        NS_MsgSACat(&command, group_name.get());
-      }
-  else if (m_typeWanted == SEARCH_WANTED)
-  {
+  } else if (m_typeWanted == GROUP_WANTED) {
+    nsresult rv = NS_ERROR_NULL_POINTER;
+
+    NS_ASSERTION(m_newsFolder, "m_newsFolder is null, panic!");
+    if (!m_newsFolder) return NS_ERROR_FAILURE;
+
+    nsCString group_name;
+    rv = m_newsFolder->GetRawName(group_name);
+    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get newsgroup name");
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    m_firstArticle = 0;
+    m_lastArticle = 0;
+
+    NS_MsgSACopy(&command, "GROUP ");
+    NS_MsgSACat(&command, group_name.get());
+  } else if (m_typeWanted == SEARCH_WANTED) {
     nsresult rv;
-    MOZ_LOG(NNTP, LogLevel::Info,("(%p) doing GROUP for XPAT", this));
+    MOZ_LOG(NNTP, LogLevel::Info, ("(%p) doing GROUP for XPAT", this));
     nsCString group_name;
 
     /* for XPAT, we have to GROUP into the group before searching */
     if (!m_newsFolder) {
-        NNTP_LOG_NOTE("m_newsFolder is null, panic!");
-        return NS_ERROR_FAILURE;
+      NNTP_LOG_NOTE("m_newsFolder is null, panic!");
+      return NS_ERROR_FAILURE;
     }
     rv = m_newsFolder->GetRawName(group_name);
     NS_ENSURE_SUCCESS(rv, rv);
 
     NS_MsgSACopy(&command, "GROUP ");
-    NS_MsgSACat (&command, group_name.get());
+    NS_MsgSACat(&command, group_name.get());
 
     // force a GROUP next time
     m_currentGroup.Truncate();
     m_nextState = NNTP_RESPONSE;
     m_nextStateAfterResponse = NNTP_XPAT_SEND;
-  }
-  else if (m_typeWanted == IDS_WANTED)
-  {
+  } else if (m_typeWanted == IDS_WANTED) {
     m_nextState = NNTP_LIST_GROUP;
     return NS_OK;
-  }
-  else  /* article or cancel */
+  } else /* article or cancel */
   {
     NS_ASSERTION(!m_messageID.IsEmpty(), "No message ID, bailing!");
     if (m_messageID.IsEmpty()) return NS_ERROR_FAILURE;
 
     if (m_typeWanted == CANCEL_WANTED)
       NS_MsgSACopy(&command, "HEAD ");
     else {
-      NS_ASSERTION(m_typeWanted == ARTICLE_WANTED, "not cancel, and not article");
+      NS_ASSERTION(m_typeWanted == ARTICLE_WANTED,
+                   "not cancel, and not article");
       NS_MsgSACopy(&command, "ARTICLE ");
     }
 
-    if (m_messageID[0] != '<')
-      NS_MsgSACat(&command,"<");
+    if (m_messageID[0] != '<') NS_MsgSACat(&command, "<");
 
     NS_MsgSACat(&command, m_messageID.get());
 
-    if (PL_strchr(command+8, '>')==0)
-      NS_MsgSACat(&command,">");
+    if (PL_strchr(command + 8, '>') == 0) NS_MsgSACat(&command, ">");
   }
 
   NS_MsgSACat(&command, CRLF);
   nsresult rv = SendData(command);
   PR_Free(command);
 
   m_nextState = NNTP_RESPONSE;
   if (m_typeWanted != SEARCH_WANTED)
     m_nextStateAfterResponse = SEND_FIRST_NNTP_COMMAND_RESPONSE;
   SetFlag(NNTP_PAUSE_FOR_READ);
   return rv;
 } /* sent first command */
 
-
 /* interprets the server response from the first command sent
  *
  * returns negative if the server responds unexpectedly
  */
 
-nsresult nsNNTPProtocol::SendFirstNNTPCommandResponse()
-{
+nsresult nsNNTPProtocol::SendFirstNNTPCommandResponse() {
   int32_t major_opcode = MK_NNTP_RESPONSE_TYPE(m_responseCode);
 
-  if((major_opcode == MK_NNTP_RESPONSE_TYPE_CONT &&
-    m_typeWanted == NEWS_POST)
-    || (major_opcode == MK_NNTP_RESPONSE_TYPE_OK &&
-    m_typeWanted != NEWS_POST) )
-  {
-
+  if ((major_opcode == MK_NNTP_RESPONSE_TYPE_CONT &&
+       m_typeWanted == NEWS_POST) ||
+      (major_opcode == MK_NNTP_RESPONSE_TYPE_OK && m_typeWanted != NEWS_POST)) {
     m_nextState = SETUP_NEWS_STREAM;
     SetFlag(NNTP_SOME_PROTOCOL_SUCCEEDED);
     return NS_OK;
-  }
-  else
-  {
+  } else {
     nsresult rv = NS_OK;
 
     nsString group_name;
     NS_ASSERTION(m_newsFolder, "no newsFolder");
-    if (m_newsFolder)
-      rv = m_newsFolder->GetUnicodeName(group_name);
+    if (m_newsFolder) rv = m_newsFolder->GetUnicodeName(group_name);
 
     if (m_responseCode == MK_NNTP_RESPONSE_GROUP_NO_GROUP &&
-      m_typeWanted == GROUP_WANTED) {
-      MOZ_LOG(NNTP, LogLevel::Info,("(%p) group (%s) not found, so unset"
-                                 " m_currentGroup", this,
-                                 NS_ConvertUTF16toUTF8(group_name).get()));
+        m_typeWanted == GROUP_WANTED) {
+      MOZ_LOG(NNTP, LogLevel::Info,
+              ("(%p) group (%s) not found, so unset"
+               " m_currentGroup",
+               this, NS_ConvertUTF16toUTF8(group_name).get()));
       m_currentGroup.Truncate();
 
       m_nntpServer->GroupNotFound(m_msgWindow, group_name, true /* opening */);
     }
 
     /* if the server returned a 400 error then it is an expected
-    * error.  the NEWS_ERROR state will not sever the connection
-    */
-    if(major_opcode == MK_NNTP_RESPONSE_TYPE_CANNOT)
+     * error.  the NEWS_ERROR state will not sever the connection
+     */
+    if (major_opcode == MK_NNTP_RESPONSE_TYPE_CANNOT)
       m_nextState = NEWS_ERROR;
     else
       m_nextState = NNTP_ERROR;
     // if we have no channel listener, then we're likely downloading
     // the message for offline use (or at least not displaying it)
     bool savingArticleOffline = (m_channelListener == nullptr);
 
-    if (m_runningURL)
-      FinishMemCacheEntry(false);  // cleanup mem cache entry
+    if (m_runningURL) FinishMemCacheEntry(false);  // cleanup mem cache entry
 
     if (NS_SUCCEEDED(rv) && !group_name.IsEmpty() && !savingArticleOffline) {
       nsCString uri(NS_LITERAL_CSTRING("about:newserror?r="));
       nsCString escapedResponse;
-      MsgEscapeURL(nsDependentCString(m_responseText), nsINetUtil::ESCAPE_URL_QUERY, escapedResponse);
+      MsgEscapeURL(nsDependentCString(m_responseText),
+                   nsINetUtil::ESCAPE_URL_QUERY, escapedResponse);
       uri.Append(escapedResponse);
 
       if ((m_key != nsMsgKey_None) && m_newsFolder) {
         nsCString messageID;
         nsCString escapedMessageID;
         rv = m_newsFolder->GetMessageIdForKey(m_key, messageID);
         if (NS_SUCCEEDED(rv)) {
           uri.AppendLiteral("&m=");
-          MsgEscapeURL(messageID, nsINetUtil::ESCAPE_URL_QUERY, escapedMessageID);
+          MsgEscapeURL(messageID, nsINetUtil::ESCAPE_URL_QUERY,
+                       escapedMessageID);
           uri.Append(escapedMessageID);
           uri.AppendLiteral("&k=");
           uri.AppendInt(m_key);
         }
       }
 
       if (m_newsFolder) {
-        nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
+        nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
         if (NS_SUCCEEDED(rv) && folder) {
           nsCString folderURI;
           nsCString escapedFolderURI;
           rv = folder->GetURI(folderURI);
           if (NS_SUCCEEDED(rv)) {
             uri.AppendLiteral("&f=");
-            MsgEscapeURL(folderURI, nsINetUtil::ESCAPE_URL_QUERY, escapedFolderURI);
+            MsgEscapeURL(folderURI, nsINetUtil::ESCAPE_URL_QUERY,
+                         escapedFolderURI);
             uri.Append(escapedFolderURI);
           }
         }
       }
 
       if (!m_msgWindow) {
-        nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
+        nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl =
+            do_QueryInterface(m_runningURL);
         if (mailnewsurl) {
           rv = mailnewsurl->GetMsgWindow(getter_AddRefs(m_msgWindow));
-          NS_ENSURE_SUCCESS(rv,rv);
+          NS_ENSURE_SUCCESS(rv, rv);
         }
       }
       if (!m_msgWindow) return NS_ERROR_FAILURE;
 
       // note, this will cause us to close the connection.
       // this will call nsDocShell::LoadURI(), which will
       // call nsDocShell::Stop(STOP_NETWORK), which will eventually
       // call nsNNTPProtocol::Cancel(), which will close the socket.
       // we need to fix this, since the connection is still valid.
-      rv = m_msgWindow->DisplayURIInMessagePane(NS_ConvertASCIItoUTF16(uri), true,
-                                                nsContentUtils::GetSystemPrincipal());
-      NS_ENSURE_SUCCESS(rv,rv);
+      rv = m_msgWindow->DisplayURIInMessagePane(
+          NS_ConvertASCIItoUTF16(uri), true,
+          nsContentUtils::GetSystemPrincipal());
+      NS_ENSURE_SUCCESS(rv, rv);
     }
-    // let's take the opportunity of removing the hdr from the db so we don't try to download
-    // it again.
-    else if (savingArticleOffline)
-    {
+    // let's take the opportunity of removing the hdr from the db so we don't
+    // try to download it again.
+    else if (savingArticleOffline) {
       if ((m_key != nsMsgKey_None) && (m_newsFolder)) {
-         rv = m_newsFolder->RemoveMessage(m_key);
+        rv = m_newsFolder->RemoveMessage(m_key);
       }
     }
     return NS_ERROR_FAILURE;
   }
 }
 
-nsresult nsNNTPProtocol::SendGroupForArticle()
-{
+nsresult nsNNTPProtocol::SendGroupForArticle() {
   nsresult rv;
 
   nsCString groupname;
   rv = m_newsFolder->GetRawName(groupname);
   NS_ASSERTION(NS_SUCCEEDED(rv) && !groupname.IsEmpty(), "no group name");
 
   char outputBuffer[OUTPUT_BUFFER_SIZE];
 
-  PR_snprintf(outputBuffer,
-      OUTPUT_BUFFER_SIZE,
-      "GROUP %.512s" CRLF,
-      groupname.get());
+  PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "GROUP %.512s" CRLF,
+              groupname.get());
 
   rv = SendData(outputBuffer);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NNTP_SEND_GROUP_FOR_ARTICLE_RESPONSE;
   SetFlag(NNTP_PAUSE_FOR_READ);
   return rv;
 }
 
-nsresult
-nsNNTPProtocol::SetCurrentGroup()
-{
+nsresult nsNNTPProtocol::SetCurrentGroup() {
   nsCString groupname;
   NS_ASSERTION(m_newsFolder, "no news folder");
   if (!m_newsFolder) {
     m_currentGroup.Truncate();
     return NS_ERROR_UNEXPECTED;
   }
 
   mozilla::DebugOnly<nsresult> rv = m_newsFolder->GetRawName(groupname);
   NS_ASSERTION(NS_SUCCEEDED(rv) && !groupname.IsEmpty(), "no group name");
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) SetCurrentGroup to %s",this, groupname.get()));
+  MOZ_LOG(NNTP, LogLevel::Info,
+          ("(%p) SetCurrentGroup to %s", this, groupname.get()));
   m_currentGroup = groupname;
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::SendGroupForArticleResponse()
-{
+nsresult nsNNTPProtocol::SendGroupForArticleResponse() {
   /* ignore the response code and continue
    */
   m_nextState = NNTP_SEND_ARTICLE_NUMBER;
 
   return SetCurrentGroup();
 }
 
-
-nsresult nsNNTPProtocol::SendArticleNumber()
-{
+nsresult nsNNTPProtocol::SendArticleNumber() {
   char outputBuffer[OUTPUT_BUFFER_SIZE];
   PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "ARTICLE %lu" CRLF, m_key);
 
   nsresult rv = SendData(outputBuffer);
 
-    m_nextState = NNTP_RESPONSE;
-    m_nextStateAfterResponse = SEND_FIRST_NNTP_COMMAND_RESPONSE;
-    SetFlag(NNTP_PAUSE_FOR_READ);
+  m_nextState = NNTP_RESPONSE;
+  m_nextStateAfterResponse = SEND_FIRST_NNTP_COMMAND_RESPONSE;
+  SetFlag(NNTP_PAUSE_FOR_READ);
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::BeginArticle()
-{
+nsresult nsNNTPProtocol::BeginArticle() {
   if (m_typeWanted != ARTICLE_WANTED && m_typeWanted != CANCEL_WANTED)
     return NS_OK;
 
-  /*  Set up the HTML stream
-   */
+    /*  Set up the HTML stream
+     */
 
 #ifdef NO_ARTICLE_CACHEING
-  ce->format_out = CLEAR_CACHE_BIT (ce->format_out);
+  ce->format_out = CLEAR_CACHE_BIT(ce->format_out);
 #endif
 
   // if we have a channel listener,
   // create a pipe to pump the message into...the output will go to whoever
   // is consuming the message display
   //
   // the pipe must have an unlimited length since we are going to be filling
   // it on the main thread while reading it from the main thread.  iow, the
   // write must not block!! (see bug 190988)
   //
   if (m_channelListener) {
-      nsCOMPtr<nsIPipe> pipe = do_CreateInstance("@mozilla.org/pipe;1");
-      nsresult rv = pipe->Init(false, false, 4096, PR_UINT32_MAX);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      // These always succeed because the pipe is initialized above.
-      MOZ_ALWAYS_SUCCEEDS(pipe->GetInputStream(getter_AddRefs(mDisplayInputStream)));
-      MOZ_ALWAYS_SUCCEEDS(pipe->GetOutputStream(getter_AddRefs(mDisplayOutputStream)));
+    nsCOMPtr<nsIPipe> pipe = do_CreateInstance("@mozilla.org/pipe;1");
+    nsresult rv = pipe->Init(false, false, 4096, PR_UINT32_MAX);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    // These always succeed because the pipe is initialized above.
+    MOZ_ALWAYS_SUCCEEDS(
+        pipe->GetInputStream(getter_AddRefs(mDisplayInputStream)));
+    MOZ_ALWAYS_SUCCEEDS(
+        pipe->GetOutputStream(getter_AddRefs(mDisplayOutputStream)));
   }
 
   m_nextState = NNTP_READ_ARTICLE;
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::DisplayArticle(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::DisplayArticle(nsIInputStream *inputStream,
+                                        uint32_t length) {
   uint32_t line_length = 0;
 
   bool pauseForMoreData = false;
-  if (m_channelListener)
-  {
+  if (m_channelListener) {
     nsresult rv = NS_OK;
-    char *line = m_lineStreamBuffer->ReadNextLine(inputStream, line_length, pauseForMoreData, &rv, true);
-    if (pauseForMoreData)
-    {
+    char *line = m_lineStreamBuffer->ReadNextLine(inputStream, line_length,
+                                                  pauseForMoreData, &rv, true);
+    if (pauseForMoreData) {
       uint64_t inlength = 0;
       mDisplayInputStream->Available(&inlength);
-      if (inlength > 0) // broadcast our batched up ODA changes
-        m_channelListener->OnDataAvailable(this, mDisplayInputStream, 0, std::min(inlength, uint64_t(PR_UINT32_MAX)));
+      if (inlength > 0)  // broadcast our batched up ODA changes
+        m_channelListener->OnDataAvailable(
+            this, mDisplayInputStream, 0,
+            std::min(inlength, uint64_t(PR_UINT32_MAX)));
       SetFlag(NNTP_PAUSE_FOR_READ);
       PR_Free(line);
       return rv;
     }
 
-    if (m_newsFolder)
-      m_newsFolder->NotifyDownloadedLine(line, m_key);
+    if (m_newsFolder) m_newsFolder->NotifyDownloadedLine(line, m_key);
 
     // line only contains a single dot -> message end
-    if (line_length == 1 + MSG_LINEBREAK_LEN && line[0] == '.')
-    {
+    if (line_length == 1 + MSG_LINEBREAK_LEN && line[0] == '.') {
       m_nextState = NEWS_DONE;
 
       ClearFlag(NNTP_PAUSE_FOR_READ);
 
       uint64_t inlength = 0;
       mDisplayInputStream->Available(&inlength);
-      if (inlength > 0) // broadcast our batched up ODA changes
-        m_channelListener->OnDataAvailable(this, mDisplayInputStream, 0, std::min(inlength, uint64_t(PR_UINT32_MAX)));
+      if (inlength > 0)  // broadcast our batched up ODA changes
+        m_channelListener->OnDataAvailable(
+            this, mDisplayInputStream, 0,
+            std::min(inlength, uint64_t(PR_UINT32_MAX)));
       PR_Free(line);
       return rv;
-    }
-    else // we aren't finished with the message yet
+    } else  // we aren't finished with the message yet
     {
       uint32_t count = 0;
 
       // skip over the quoted '.'
       if (line_length > 1 && line[0] == '.' && line[1] == '.')
-        mDisplayOutputStream->Write(line+1, line_length-1, &count);
+        mDisplayOutputStream->Write(line + 1, line_length - 1, &count);
       else
         mDisplayOutputStream->Write(line, line_length, &count);
     }
 
     PR_Free(line);
   }
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::ReadArticle(nsIInputStream *inputStream,
+                                     uint32_t length) {
   uint32_t status = 0;
   nsresult rv;
   char *outputBuffer;
 
   bool pauseForMoreData = false;
 
   // if we have a channel listener, spool directly to it....
   // otherwise we must be doing something like save to disk or cancel
   // in which case we are doing the work.
-  if (m_channelListener)
-    return DisplayArticle(inputStream, length);
-
-
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv, true);
-  if (m_newsFolder && line)
-  {
+  if (m_channelListener) return DisplayArticle(inputStream, length);
+
+  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                pauseForMoreData, &rv, true);
+  if (m_newsFolder && line) {
     const char *unescapedLine = line;
     // lines beginning with '.' are escaped by nntp server
     // or is it just '.' on a line by itself?
-    if (line[0] == '.' && line[1] == '.')
-      unescapedLine++;
+    if (line[0] == '.' && line[1] == '.') unescapedLine++;
     m_newsFolder->NotifyDownloadedLine(unescapedLine, m_key);
-
   }
 
-  if(pauseForMoreData)
-  {
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
-  if(status > 1)
-  {
+  if (status > 1) {
     mBytesReceived += status;
     mBytesReceivedSinceLastStatusUpdate += status;
   }
 
-  if(!line)
-    return rv;  /* no line yet or error */
-
-  if (m_typeWanted == CANCEL_WANTED && m_responseCode != MK_NNTP_RESPONSE_ARTICLE_HEAD)
-  {
+  if (!line) return rv; /* no line yet or error */
+
+  if (m_typeWanted == CANCEL_WANTED &&
+      m_responseCode != MK_NNTP_RESPONSE_ARTICLE_HEAD) {
     /* HEAD command failed. */
     PR_FREEIF(line);
     return NS_ERROR_FAILURE;
   }
 
-  if (line[0] == '.' && line[MSG_LINEBREAK_LEN + 1] == 0)
-  {
+  if (line[0] == '.' && line[MSG_LINEBREAK_LEN + 1] == 0) {
     if (m_typeWanted == CANCEL_WANTED)
       m_nextState = NEWS_START_CANCEL;
     else
       m_nextState = NEWS_DONE;
 
     ClearFlag(NNTP_PAUSE_FOR_READ);
-  }
-  else
-  {
+  } else {
     if (line[0] == '.')
       outputBuffer = line + 1;
     else
       outputBuffer = line;
 
-      /* Don't send content-type to mime parser if we're doing a cancel
-      because it confuses mime parser into not parsing.
-      */
-    if (m_typeWanted != CANCEL_WANTED || strncmp(outputBuffer, "Content-Type:", 13))
-    {
-      // if we are attempting to cancel, we want to snarf the headers and save the aside, which is what
-      // ParseHeaderForCancel() does.
+    /* Don't send content-type to mime parser if we're doing a cancel
+    because it confuses mime parser into not parsing.
+    */
+    if (m_typeWanted != CANCEL_WANTED ||
+        strncmp(outputBuffer, "Content-Type:", 13)) {
+      // if we are attempting to cancel, we want to snarf the headers and save
+      // the aside, which is what ParseHeaderForCancel() does.
       if (m_typeWanted == CANCEL_WANTED) {
         ParseHeaderForCancel(outputBuffer);
       }
-
     }
   }
 
   PR_Free(line);
 
   return NS_OK;
 }
 
-void nsNNTPProtocol::ParseHeaderForCancel(char *buf)
-{
-    static int lastHeader = 0;
-    nsAutoCString header(buf);
-    if (header.First() == ' ' || header.First() == '\t') {
-        header.StripWhitespace();
-        // Add folded line to header if needed.
-        switch (lastHeader) {
-        case 1:
-            m_cancelFromHdr += header;
-            break;
-        case 2:
-            m_cancelID += header;
-            break;
-        case 3:
-            m_cancelNewsgroups += header;
-            break;
-        case 4:
-            m_cancelDistribution += header;
-            break;
-        }
-        // Other folded lines are of no interest.
-        return;
-    }
-
-    lastHeader = 0;
-    int32_t colon = header.FindChar(':');
-    if (!colon)
-    return;
-
-    nsCString value(Substring(header, colon + 1));
-    value.StripWhitespace();
-
-    switch (header.First()) {
-    case 'F': case 'f':
-        if (header.Find("From", /* ignoreCase = */ true) == 0) {
-            m_cancelFromHdr = value;
-            lastHeader = 1;
-        }
+void nsNNTPProtocol::ParseHeaderForCancel(char *buf) {
+  static int lastHeader = 0;
+  nsAutoCString header(buf);
+  if (header.First() == ' ' || header.First() == '\t') {
+    header.StripWhitespace();
+    // Add folded line to header if needed.
+    switch (lastHeader) {
+      case 1:
+        m_cancelFromHdr += header;
         break;
-    case 'M': case 'm':
-        if (header.Find("Message-ID", /* ignoreCase = */ true) == 0) {
-            m_cancelID = value;
-            lastHeader = 2;
-        }
+      case 2:
+        m_cancelID += header;
         break;
-    case 'N': case 'n':
-        if (header.Find("Newsgroups", /* ignoreCase = */ true) == 0) {
-            m_cancelNewsgroups = value;
-            lastHeader = 3;
-        }
+      case 3:
+        m_cancelNewsgroups += header;
         break;
-     case 'D': case 'd':
-        if (header.Find("Distributions", /* ignoreCase = */ true) == 0) {
-            m_cancelDistribution = value;
-            lastHeader = 4;
-        }
+      case 4:
+        m_cancelDistribution += header;
         break;
     }
+    // Other folded lines are of no interest.
+    return;
+  }
+
+  lastHeader = 0;
+  int32_t colon = header.FindChar(':');
+  if (!colon) return;
+
+  nsCString value(Substring(header, colon + 1));
+  value.StripWhitespace();
+
+  switch (header.First()) {
+    case 'F':
+    case 'f':
+      if (header.Find("From", /* ignoreCase = */ true) == 0) {
+        m_cancelFromHdr = value;
+        lastHeader = 1;
+      }
+      break;
+    case 'M':
+    case 'm':
+      if (header.Find("Message-ID", /* ignoreCase = */ true) == 0) {
+        m_cancelID = value;
+        lastHeader = 2;
+      }
+      break;
+    case 'N':
+    case 'n':
+      if (header.Find("Newsgroups", /* ignoreCase = */ true) == 0) {
+        m_cancelNewsgroups = value;
+        lastHeader = 3;
+      }
+      break;
+    case 'D':
+    case 'd':
+      if (header.Find("Distributions", /* ignoreCase = */ true) == 0) {
+        m_cancelDistribution = value;
+        lastHeader = 4;
+      }
+      break;
+  }
 
   return;
 }
 
-nsresult nsNNTPProtocol::BeginAuthorization()
-{
-  char * command = 0;
+nsresult nsNNTPProtocol::BeginAuthorization() {
+  char *command = 0;
   nsresult rv = NS_OK;
 
   if (!m_newsFolder && m_nntpServer) {
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_nntpServer);
     if (m_nntpServer) {
       nsCOMPtr<nsIMsgFolder> rootFolder;
       rv = server->GetRootFolder(getter_AddRefs(rootFolder));
       if (NS_SUCCEEDED(rv) && rootFolder) {
         m_newsFolder = do_QueryInterface(rootFolder);
       }
     }
   }
 
   NS_ASSERTION(m_newsFolder, "no m_newsFolder");
-  if (!m_newsFolder)
-    return NS_ERROR_FAILURE;
+  if (!m_newsFolder) return NS_ERROR_FAILURE;
 
   // We want to get authentication credentials, but it is possible that the
   // master password prompt will end up being synchronous. In that case, check
   // to see if we already have the credentials stored.
   nsCString username, password;
   rv = m_newsFolder->GetGroupUsername(username);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = m_newsFolder->GetGroupPassword(password);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If we don't have either a username or a password, queue an asynchronous
   // prompt.
-  if (username.IsEmpty() || password.IsEmpty())
-  {
+  if (username.IsEmpty() || password.IsEmpty()) {
     nsCOMPtr<nsIMsgAsyncPrompter> asyncPrompter =
-      do_GetService(NS_MSGASYNCPROMPTER_CONTRACTID, &rv);
+        do_GetService(NS_MSGASYNCPROMPTER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Get the key to coalesce auth prompts.
     bool singleSignon = false;
     m_nntpServer->GetSingleSignon(&singleSignon);
 
     nsCString queueKey;
     nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_nntpServer);
     server->GetKey(queueKey);
-    if (!singleSignon)
-    {
+    if (!singleSignon) {
       nsCString groupName;
       m_newsFolder->GetRawName(groupName);
       queueKey += groupName;
     }
 
     // If we were called back from HandleAuthenticationFailure, we must have
     // been handling the response of an authorization state. In that case,
     // let's hurry up on the auth request
     bool didAuthFail = m_nextStateAfterResponse == NNTP_AUTHORIZE_RESPONSE ||
-      m_nextStateAfterResponse == NNTP_PASSWORD_RESPONSE;
+                       m_nextStateAfterResponse == NNTP_PASSWORD_RESPONSE;
     rv = asyncPrompter->QueueAsyncAuthPrompt(queueKey, didAuthFail, this);
     NS_ENSURE_SUCCESS(rv, rv);
 
     m_nextState = NNTP_SUSPENDED;
-    if (m_request)
-      m_request->Suspend();
+    if (m_request) m_request->Suspend();
     return NS_OK;
   }
 
   NS_MsgSACopy(&command, "AUTHINFO user ");
-  MOZ_LOG(NNTP,  LogLevel::Info,("(%p) use %s as the username", this, username.get()));
+  MOZ_LOG(NNTP, LogLevel::Info,
+          ("(%p) use %s as the username", this, username.get()));
   NS_MsgSACat(&command, username.get());
   NS_MsgSACat(&command, CRLF);
 
   rv = SendData(command);
 
   PR_Free(command);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NNTP_AUTHORIZE_RESPONSE;
 
   SetFlag(NNTP_PAUSE_FOR_READ);
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::AuthorizationResponse()
-{
+nsresult nsNNTPProtocol::AuthorizationResponse() {
   nsresult rv = NS_OK;
 
   if (MK_NNTP_RESPONSE_AUTHINFO_OK == m_responseCode ||
-    MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_OK == m_responseCode)
-  {
+      MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_OK == m_responseCode) {
     /* successful login */
 #ifdef HAVE_NNTP_EXTENSIONS
     bool pushAuth;
     /* If we're here because the host demanded authentication before we
-    * even sent a single command, then jump back to the beginning of everything
-    */
+     * even sent a single command, then jump back to the beginning of everything
+     */
     rv = m_nntpServer->GetPushAuth(&pushAuth);
 
-    if (!TestFlag(NNTP_READER_PERFORMED))
-      m_nextState = NNTP_SEND_MODE_READER;
-      /* If we're here because the host needs pushed authentication, then we
-      * should jump back to SEND_LIST_EXTENSIONS
-    */
+    if (!TestFlag(NNTP_READER_PERFORMED)) m_nextState = NNTP_SEND_MODE_READER;
+    /* If we're here because the host needs pushed authentication, then we
+     * should jump back to SEND_LIST_EXTENSIONS
+     */
     else if (NS_SUCCEEDED(rv) && pushAuth)
       m_nextState = SEND_LIST_EXTENSIONS;
     else
       /* Normal authentication */
       m_nextState = SEND_FIRST_NNTP_COMMAND;
 #else
     if (!TestFlag(NNTP_READER_PERFORMED))
       m_nextState = NNTP_SEND_MODE_READER;
     else
       m_nextState = SEND_FIRST_NNTP_COMMAND;
 #endif /* HAVE_NNTP_EXTENSIONS */
 
     return NS_OK;
-  }
-  else if (MK_NNTP_RESPONSE_AUTHINFO_CONT == m_responseCode)
-  {
-    char * command = 0;
+  } else if (MK_NNTP_RESPONSE_AUTHINFO_CONT == m_responseCode) {
+    char *command = 0;
 
     // Since we had to have called BeginAuthorization to get here, we've already
     // prompted for the authorization credentials. Just grab them without a
     // further prompt.
     nsCString password;
     rv = m_newsFolder->GetGroupPassword(password);
-    if (NS_FAILED(rv) || password.IsEmpty())
-      return NS_ERROR_FAILURE;
+    if (NS_FAILED(rv) || password.IsEmpty()) return NS_ERROR_FAILURE;
 
     NS_MsgSACopy(&command, "AUTHINFO pass ");
     NS_MsgSACat(&command, password.get());
     NS_MsgSACat(&command, CRLF);
 
     rv = SendData(command, true);
 
     PR_FREEIF(command);
 
     m_nextState = NNTP_RESPONSE;
     m_nextStateAfterResponse = NNTP_PASSWORD_RESPONSE;
     SetFlag(NNTP_PAUSE_FOR_READ);
 
     return rv;
-  }
-  else
-  {
+  } else {
     /* login failed */
     HandleAuthenticationFailure();
     return NS_OK;
   }
 
   NS_ERROR("should never get here");
   return NS_ERROR_FAILURE;
-
 }
 
-nsresult nsNNTPProtocol::PasswordResponse()
-{
+nsresult nsNNTPProtocol::PasswordResponse() {
   if (MK_NNTP_RESPONSE_AUTHINFO_OK == m_responseCode ||
-    MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_OK == m_responseCode)
-  {
+      MK_NNTP_RESPONSE_AUTHINFO_SIMPLE_OK == m_responseCode) {
     /* successful login */
 #ifdef HAVE_NNTP_EXTENSIONS
     bool pushAuth;
     /* If we're here because the host demanded authentication before we
-    * even sent a single command, then jump back to the beginning of everything
-    */
+     * even sent a single command, then jump back to the beginning of everything
+     */
     nsresult rv = m_nntpServer->GetPushAuth(&pushAuth);
 
-    if (!TestFlag(NNTP_READER_PERFORMED))
-      m_nextState = NNTP_SEND_MODE_READER;
-      /* If we're here because the host needs pushed authentication, then we
-      * should jump back to SEND_LIST_EXTENSIONS
-    */
+    if (!TestFlag(NNTP_READER_PERFORMED)) m_nextState = NNTP_SEND_MODE_READER;
+    /* If we're here because the host needs pushed authentication, then we
+     * should jump back to SEND_LIST_EXTENSIONS
+     */
     else if (NS_SUCCEEDED(rv) && pushAuth)
       m_nextState = SEND_LIST_EXTENSIONS;
     else
       /* Normal authentication */
       m_nextState = SEND_FIRST_NNTP_COMMAND;
 #else
     if (!TestFlag(NNTP_READER_PERFORMED))
       m_nextState = NNTP_SEND_MODE_READER;
     else
       m_nextState = SEND_FIRST_NNTP_COMMAND;
 #endif /* HAVE_NNTP_EXTENSIONS */
     return NS_OK;
-  }
-  else
-  {
+  } else {
     HandleAuthenticationFailure();
     return NS_OK;
   }
 
   NS_ERROR("should never get here");
   return NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::OnPromptStartAsync(nsIMsgAsyncPromptCallback *aCallback)
-{
+NS_IMETHODIMP nsNNTPProtocol::OnPromptStartAsync(
+    nsIMsgAsyncPromptCallback *aCallback) {
   bool result = false;
   OnPromptStart(&result);
   return aCallback->OnAuthResult(result);
 }
 
-NS_IMETHODIMP nsNNTPProtocol::OnPromptStart(bool *authAvailable)
-{
+NS_IMETHODIMP nsNNTPProtocol::OnPromptStart(bool *authAvailable) {
   NS_ENSURE_ARG_POINTER(authAvailable);
   NS_ENSURE_STATE(m_nextState == NNTP_SUSPENDED);
 
-  if (!m_newsFolder)
-  {
+  if (!m_newsFolder) {
     // If we don't have a news folder, we may have been closed already.
     NNTP_LOG_NOTE("Canceling queued authentication prompt");
     *authAvailable = false;
     return NS_OK;
   }
 
   bool didAuthFail = m_nextState == NNTP_AUTHORIZE_RESPONSE ||
-    m_nextState == NNTP_PASSWORD_RESPONSE;
-  nsresult rv = m_newsFolder->GetAuthenticationCredentials(m_msgWindow,
-    true, didAuthFail, authAvailable);
+                     m_nextState == NNTP_PASSWORD_RESPONSE;
+  nsresult rv = m_newsFolder->GetAuthenticationCredentials(
+      m_msgWindow, true, didAuthFail, authAvailable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // What we do depends on whether or not we have valid credentials
   return *authAvailable ? OnPromptAuthAvailable() : OnPromptCanceled();
 }
 
-NS_IMETHODIMP nsNNTPProtocol::OnPromptAuthAvailable()
-{
+NS_IMETHODIMP nsNNTPProtocol::OnPromptAuthAvailable() {
   NS_ENSURE_STATE(m_nextState == NNTP_SUSPENDED);
 
   // We previously suspended the request; now resume it to read input
-  if (m_request)
-    m_request->Resume();
+  if (m_request) m_request->Resume();
 
   // Now we have our password details accessible from the group, so just call
   // into the state machine to start the process going again.
   m_nextState = NNTP_BEGIN_AUTHORIZE;
   return ProcessProtocolState(nullptr, nullptr, 0, 0);
 }
 
-NS_IMETHODIMP nsNNTPProtocol::OnPromptCanceled()
-{
+NS_IMETHODIMP nsNNTPProtocol::OnPromptCanceled() {
   NS_ENSURE_STATE(m_nextState == NNTP_SUSPENDED);
 
   // We previously suspended the request; now resume it to read input
-  if (m_request)
-    m_request->Resume();
+  if (m_request) m_request->Resume();
 
   // Since the prompt was canceled, we can no longer continue the connection.
   // Thus, we need to go to the NNTP_ERROR state.
   m_nextState = NNTP_ERROR;
   return ProcessProtocolState(nullptr, nullptr, 0, 0);
 }
 
-nsresult nsNNTPProtocol::DisplayNewsgroups()
-{
+nsresult nsNNTPProtocol::DisplayNewsgroups() {
   m_nextState = NEWS_DONE;
   ClearFlag(NNTP_PAUSE_FOR_READ);
 
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) DisplayNewsgroups()",this));
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) DisplayNewsgroups()", this));
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::BeginNewsgroups()
-{
+nsresult nsNNTPProtocol::BeginNewsgroups() {
   m_nextState = NNTP_NEWGROUPS;
   mBytesReceived = 0;
-    mBytesReceivedSinceLastStatusUpdate = 0;
-    m_startTime = PR_Now();
+  mBytesReceivedSinceLastStatusUpdate = 0;
+  m_startTime = PR_Now();
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::ProcessNewsgroups(nsIInputStream * inputStream, uint32_t length)
-{
-  char *line, *lineToFree, *s, *s1=NULL, *s2=NULL;
+nsresult nsNNTPProtocol::ProcessNewsgroups(nsIInputStream *inputStream,
+                                           uint32_t length) {
+  char *line, *lineToFree, *s, *s1 = NULL, *s2 = NULL;
   uint32_t status = 0;
   nsresult rv = NS_OK;
 
   bool pauseForMoreData = false;
-  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if(pauseForMoreData)
-  {
+  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                       pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  if(!line)
-    return rv;  /* no line yet */
-
-                     /* End of list?
+  if (!line) return rv; /* no line yet */
+
+  /* End of list?
    */
-  if (line[0]=='.' && line[1]=='\0')
-  {
+  if (line[0] == '.' && line[1] == '\0') {
     ClearFlag(NNTP_PAUSE_FOR_READ);
-    bool xactive=false;
-    rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
-    if (NS_SUCCEEDED(rv) && xactive)
-    {
+    bool xactive = false;
+    rv = m_nntpServer->QueryExtension("XACTIVE", &xactive);
+    if (NS_SUCCEEDED(rv) && xactive) {
       nsAutoCString groupName;
       rv = m_nntpServer->GetFirstGroupNeedingExtraInfo(groupName);
       if (NS_SUCCEEDED(rv)) {
         rv = m_nntpServer->FindGroup(groupName, getter_AddRefs(m_newsFolder));
         NS_ASSERTION(NS_SUCCEEDED(rv), "FindGroup failed");
         m_nextState = NNTP_LIST_XACTIVE;
-        MOZ_LOG(NNTP, LogLevel::Info,("(%p) listing xactive for %s", this,
-                                   groupName.get()));
+        MOZ_LOG(NNTP, LogLevel::Info,
+                ("(%p) listing xactive for %s", this, groupName.get()));
         PR_Free(lineToFree);
         return NS_OK;
       }
     }
     m_nextState = NEWS_DONE;
 
     PR_Free(lineToFree);
-    if(status > 0)
+    if (status > 0)
       return NS_OK;
     else
       return rv;
-  }
-  else if (line [0] == '.' && line [1] == '.')
+  } else if (line[0] == '.' && line[1] == '.')
     /* The NNTP server quotes all lines beginning with "." by doubling it. */
     line++;
 
-    /* almost correct
-  */
-  if(status > 1)
-  {
+  /* almost correct
+   */
+  if (status > 1) {
     mBytesReceived += status;
     mBytesReceivedSinceLastStatusUpdate += status;
   }
 
   /* format is "rec.arts.movies.past-films 7302 7119 y"
    */
-  s = PL_strchr (line, ' ');
-  if (s)
-  {
+  s = PL_strchr(line, ' ');
+  if (s) {
     *s = 0;
-    s1 = s+1;
-    s = PL_strchr (s1, ' ');
-    if (s)
-    {
+    s1 = s + 1;
+    s = PL_strchr(s1, ' ');
+    if (s) {
       *s = 0;
-      s2 = s+1;
-      s = PL_strchr (s2, ' ');
-      if (s)
-      {
+      s2 = s + 1;
+      s = PL_strchr(s2, ' ');
+      if (s) {
         *s = 0;
       }
     }
   }
 
   mBytesReceived += status;
   mBytesReceivedSinceLastStatusUpdate += status;
 
   NS_ASSERTION(m_nntpServer, "no nntp incoming server");
   if (m_nntpServer) {
     rv = m_nntpServer->AddNewsgroupToList(line);
-    NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
+    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to add to subscribe ds");
   }
 
-  bool xactive=false;
-  rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
-  if (NS_SUCCEEDED(rv) && xactive)
-  {
+  bool xactive = false;
+  rv = m_nntpServer->QueryExtension("XACTIVE", &xactive);
+  if (NS_SUCCEEDED(rv) && xactive) {
     nsAutoCString charset;
     nsAutoString lineUtf16;
     if (NS_SUCCEEDED(m_nntpServer->GetCharset(charset)) &&
-        NS_SUCCEEDED(nsMsgI18NConvertToUnicode(charset,
-                                               nsDependentCString(line),
-                                               lineUtf16)))
+        NS_SUCCEEDED(nsMsgI18NConvertToUnicode(
+            charset, nsDependentCString(line), lineUtf16)))
       m_nntpServer->SetGroupNeedsExtraInfo(NS_ConvertUTF16toUTF8(lineUtf16),
                                            true);
     else
       m_nntpServer->SetGroupNeedsExtraInfo(nsDependentCString(line), true);
   }
 
   PR_Free(lineToFree);
   return rv;
 }
 
 /* Ahhh, this like print's out the headers and stuff
  *
  * always returns 0
  */
 
-nsresult nsNNTPProtocol::BeginReadNewsList()
-{
+nsresult nsNNTPProtocol::BeginReadNewsList() {
   m_readNewsListCount = 0;
-    mNumGroupsListed = 0;
-    m_nextState = NNTP_READ_LIST;
-
-    mBytesReceived = 0;
-    mBytesReceivedSinceLastStatusUpdate = 0;
-    m_startTime = PR_Now();
+  mNumGroupsListed = 0;
+  m_nextState = NNTP_READ_LIST;
+
+  mBytesReceived = 0;
+  mBytesReceivedSinceLastStatusUpdate = 0;
+  m_startTime = PR_Now();
 
   return NS_OK;
 }
 
-#define RATE_CONSTANT 976.5625      /* PR_USEC_PER_SEC / 1024 bytes */
-
-static void ComputeRate(int32_t bytes, PRTime startTime, float *rate)
-{
+#define RATE_CONSTANT 976.5625 /* PR_USEC_PER_SEC / 1024 bytes */
+
+static void ComputeRate(int32_t bytes, PRTime startTime, float *rate) {
   // rate = (bytes / USECS since start) * RATE_CONSTANT
 
   // compute usecs since we started.
   int32_t delta = (int32_t)(PR_Now() - startTime);
 
   // compute rate
   if (delta > 0) {
-    *rate = (float) ((bytes * RATE_CONSTANT) / delta);
-  }
-  else {
+    *rate = (float)((bytes * RATE_CONSTANT) / delta);
+  } else {
     *rate = 0.0;
   }
 }
 
 /* display a list of all or part of the newsgroups list
  * from the news server
  */
-nsresult nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::ReadNewsList(nsIInputStream *inputStream,
+                                      uint32_t length) {
   nsresult rv = NS_OK;
-  int32_t i=0;
+  int32_t i = 0;
   uint32_t status = 1;
 
   bool pauseForMoreData = false;
   char *line, *lineToFree;
-  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if (pauseForMoreData)
-  {
+  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                       pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     PR_Free(lineToFree);
     return NS_OK;
   }
 
-  if (!line)
-    return rv;  /* no line yet */
+  if (!line) return rv; /* no line yet */
 
   /* End of list? */
-  if (line[0]=='.' && line[1]=='\0')
-  {
-    bool listpnames=false;
+  if (line[0] == '.' && line[1] == '\0') {
+    bool listpnames = false;
     NS_ASSERTION(m_nntpServer, "no nntp incoming server");
     if (m_nntpServer) {
-      rv = m_nntpServer->QueryExtension("LISTPNAMES",&listpnames);
+      rv = m_nntpServer->QueryExtension("LISTPNAMES", &listpnames);
     }
     if (NS_SUCCEEDED(rv) && listpnames)
       m_nextState = NNTP_LIST_PRETTY_NAMES;
     else
       m_nextState = DISPLAY_NEWSGROUPS;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     PR_Free(lineToFree);
     return NS_OK;
-  }
-  else if (line[0] == '.')
-  {
-    if ((line[1] == ' ') || (line[1] == '.' && line [2] == '.' && line[3] == ' '))
-    {
+  } else if (line[0] == '.') {
+    if ((line[1] == ' ') ||
+        (line[1] == '.' && line[2] == '.' && line[3] == ' ')) {
       // some servers send "... 0000000001 0000000002 y"
       // and some servers send ". 0000000001 0000000002 y"
       // just skip that those lines
       // see bug #69231 and #123560
       PR_Free(lineToFree);
       return rv;
     }
-    // The NNTP server quotes all lines beginning with "." by doubling it, so unquote
+    // The NNTP server quotes all lines beginning with "." by doubling it, so
+    // unquote
     line++;
   }
 
   /* almost correct
-  */
-  if(status > 1)
-  {
+   */
+  if (status > 1) {
     mBytesReceived += status;
     mBytesReceivedSinceLastStatusUpdate += status;
 
-    if ((mBytesReceivedSinceLastStatusUpdate > UPDATE_THRESHOLD) && m_msgWindow) {
+    if ((mBytesReceivedSinceLastStatusUpdate > UPDATE_THRESHOLD) &&
+        m_msgWindow) {
       mBytesReceivedSinceLastStatusUpdate = 0;
 
-      nsCOMPtr <nsIMsgStatusFeedback> msgStatusFeedback;
+      nsCOMPtr<nsIMsgStatusFeedback> msgStatusFeedback;
 
       rv = m_msgWindow->GetStatusFeedback(getter_AddRefs(msgStatusFeedback));
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsString statusString;
 
       nsCOMPtr<nsIStringBundleService> bundleService =
-        mozilla::services::GetStringBundleService();
+          mozilla::services::GetStringBundleService();
       NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
       nsCOMPtr<nsIStringBundle> bundle;
       rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsAutoString bytesStr;
       bytesStr.AppendInt(mBytesReceived / 1024);
 
       // compute the rate, and then convert it have one
       // decimal precision.
       float rate = 0.0;
       ComputeRate(mBytesReceived, m_startTime, &rate);
       char rate_buf[RATE_STR_BUF_LEN];
-      PR_snprintf(rate_buf,RATE_STR_BUF_LEN,"%.1f", rate);
+      PR_snprintf(rate_buf, RATE_STR_BUF_LEN, "%.1f", rate);
 
       nsAutoString numGroupsStr;
       numGroupsStr.AppendInt(mNumGroupsListed);
       NS_ConvertASCIItoUTF16 rateStr(rate_buf);
 
-      const char16_t *formatStrings[3] = { numGroupsStr.get(), bytesStr.get(), rateStr.get()};
-      rv = bundle->FormatStringFromName("bytesReceived",
-        formatStrings, 3,
-        statusString);
+      const char16_t *formatStrings[3] = {numGroupsStr.get(), bytesStr.get(),
+                                          rateStr.get()};
+      rv = bundle->FormatStringFromName("bytesReceived", formatStrings, 3,
+                                        statusString);
 
       rv = msgStatusFeedback->ShowStatusString(statusString);
       if (NS_FAILED(rv)) {
         PR_Free(lineToFree);
         return rv;
       }
     }
   }
 
   /* find whitespace separator if it exits */
-  for(i=0; line[i] != '\0' && !NET_IS_SPACE(line[i]); i++)
-    ;  /* null body */
+  for (i = 0; line[i] != '\0' && !NET_IS_SPACE(line[i]); i++)
+    ; /* null body */
 
   line[i] = 0; /* terminate group name */
 
   /* store all the group names */
   NS_ASSERTION(m_nntpServer, "no nntp incoming server");
   if (m_nntpServer) {
     m_readNewsListCount++;
     mNumGroupsListed++;
     rv = m_nntpServer->AddNewsgroupToList(line);
-//    NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
+    //    NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
     // since it's not fatal, don't let this error stop the LIST command.
     rv = NS_OK;
-  }
-  else
+  } else
     rv = NS_ERROR_FAILURE;
 
   if (m_readNewsListCount == READ_NEWS_LIST_COUNT_MAX) {
     m_readNewsListCount = 0;
     if (mUpdateTimer) {
       mUpdateTimer->Cancel();
       mUpdateTimer = nullptr;
     }
     mUpdateTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
-    NS_ASSERTION(NS_SUCCEEDED(rv),"failed to create timer");
+    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create timer");
     if (NS_FAILED(rv)) {
       PR_Free(lineToFree);
       return rv;
     }
 
     mInputStream = inputStream;
 
     const uint32_t kUpdateTimerDelay = READ_NEWS_LIST_TIMEOUT;
-    rv = mUpdateTimer->InitWithCallback(static_cast<nsITimerCallback*>(this), kUpdateTimerDelay,
-      nsITimer::TYPE_ONE_SHOT);
-    NS_ASSERTION(NS_SUCCEEDED(rv),"failed to init timer");
+    rv = mUpdateTimer->InitWithCallback(static_cast<nsITimerCallback *>(this),
+                                        kUpdateTimerDelay,
+                                        nsITimer::TYPE_ONE_SHOT);
+    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to init timer");
     if (NS_FAILED(rv)) {
       PR_Free(lineToFree);
       return rv;
     }
 
     m_nextState = NNTP_SUSPENDED;
 
     // suspend necko request until timeout
     // might not have a request if someone called CloseSocket()
     // see bug #195440
-    if (m_request)
-      m_request->Suspend();
+    if (m_request) m_request->Suspend();
   }
 
   PR_Free(lineToFree);
   return rv;
 }
 
 NS_IMETHODIMP
-nsNNTPProtocol::Notify(nsITimer *timer)
-{
+nsNNTPProtocol::Notify(nsITimer *timer) {
   NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!");
-  mUpdateTimer = nullptr;    // release my hold
+  mUpdateTimer = nullptr;  // release my hold
   TimerCallback();
   return NS_OK;
 }
 
-void nsNNTPProtocol::TimerCallback()
-{
-  MOZ_LOG(NNTP, LogLevel::Info,("nsNNTPProtocol::TimerCallback\n"));
+void nsNNTPProtocol::TimerCallback() {
+  MOZ_LOG(NNTP, LogLevel::Info, ("nsNNTPProtocol::TimerCallback\n"));
   m_nextState = NNTP_READ_LIST;
 
   // process whatever is already in the buffer at least once.
   //
   // NOTE: while downloading, it would almost be enough to just
   // resume necko since it will call us again with data.  however,
   // if we are at the end of the data stream then we must call
   // ProcessProtocolState since necko will not call us again.
   //
   // NOTE: this function may Suspend necko.  Suspend is a reference
   // counted (i.e., two suspends requires two resumes before the
   // request will actually be resumed).
   //
-  ProcessProtocolState(nullptr, mInputStream, 0,0);
+  ProcessProtocolState(nullptr, mInputStream, 0, 0);
 
   // resume necko request
   // might not have a request if someone called CloseSocket()
   // see bug #195440
-  if (m_request)
-    m_request->Resume();
+  if (m_request) m_request->Resume();
 
   return;
 }
 
-void nsNNTPProtocol::HandleAuthenticationFailure()
-{
+void nsNNTPProtocol::HandleAuthenticationFailure() {
   nsCOMPtr<nsIMsgIncomingServer> server(do_QueryInterface(m_nntpServer));
   nsCString hostname;
   server->GetRealHostName(hostname);
   nsCString username;
   server->GetRealUsername(username);
   nsString accountname;
   server->GetPrettyName(accountname);
 
   int32_t choice = 1;
   MsgPromptLoginFailed(m_msgWindow, hostname, username, accountname, &choice);
 
-  if (choice == 1) // Cancel
+  if (choice == 1)  // Cancel
   {
     // When the user requests to cancel the connection, we can't do anything
     // anymore.
     NNTP_LOG_NOTE("Password failed, user opted to cancel connection");
     m_nextState = NNTP_ERROR;
     return;
   }
 
-  if (choice == 2) // New password
+  if (choice == 2)  // New password
   {
     NNTP_LOG_NOTE("Password failed, user opted to enter new password");
     NS_ASSERTION(m_newsFolder, "no newsFolder");
     m_newsFolder->ForgetAuthenticationCredentials();
-  }
-  else if (choice == 0) // Retry
+  } else if (choice == 0)  // Retry
   {
     NNTP_LOG_NOTE("Password failed, user opted to retry");
   }
 
   // At this point, we've either forgotten the password or opted to retry. In
   // both cases, we need to try to auth with the password again, so return to
   // the authentication state.
   m_nextState = NNTP_BEGIN_AUTHORIZE;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // XOVER, XHDR, and HEAD processing code
 // Used for filters
 // State machine explanation located in doxygen comments for nsNNTPProtocol
 ///////////////////////////////////////////////////////////////////////////////
 
-nsresult nsNNTPProtocol::BeginReadXover()
-{
-  int32_t count;     /* Response fields */
+nsresult nsNNTPProtocol::BeginReadXover() {
+  int32_t count; /* Response fields */
   nsresult rv = NS_OK;
 
   rv = SetCurrentGroup();
   NS_ENSURE_SUCCESS(rv, rv);
 
   /* Make sure we never close and automatically reopen the connection at this
   point; we'll confuse libmsg too much... */
 
   SetFlag(NNTP_SOME_PROTOCOL_SUCCEEDED);
 
   /* We have just issued a GROUP command and read the response.
   Now parse that response to help decide which articles to request
   xover data for.
    */
-  PR_sscanf(m_responseText,
-    "%d %d %d",
-    &count,
-    &m_firstPossibleArticle,
-    &m_lastPossibleArticle);
+  PR_sscanf(m_responseText, "%d %d %d", &count, &m_firstPossibleArticle,
+            &m_lastPossibleArticle);
 
   m_newsgroupList = do_CreateInstance(NS_NNTPNEWSGROUPLIST_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = m_newsgroupList->Initialize(m_runningURL, m_newsFolder);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = m_newsFolder->UpdateSummaryFromNNTPInfo(m_firstPossibleArticle, m_lastPossibleArticle, count);
+  rv = m_newsFolder->UpdateSummaryFromNNTPInfo(m_firstPossibleArticle,
+                                               m_lastPossibleArticle, count);
   NS_ENSURE_SUCCESS(rv, rv);
 
   m_numArticlesLoaded = 0;
 
   // if the user sets max_articles to a bogus value, get them everything
   m_numArticlesWanted = m_maxArticles > 0 ? m_maxArticles : 1L << 30;
 
   m_nextState = NNTP_FIGURE_NEXT_CHUNK;
   ClearFlag(NNTP_PAUSE_FOR_READ);
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::FigureNextChunk()
-{
-    nsresult rv = NS_OK;
+nsresult nsNNTPProtocol::FigureNextChunk() {
+  nsresult rv = NS_OK;
   int32_t status = 0;
 
-  if (m_firstArticle > 0)
-  {
-      MOZ_LOG(NNTP, LogLevel::Info,("(%p) add to known articles:  %d - %d", this, m_firstArticle, m_lastArticle));
-
-      if (NS_SUCCEEDED(rv) && m_newsgroupList) {
-          rv = m_newsgroupList->AddToKnownArticles(m_firstArticle,
-                                                 m_lastArticle);
-      }
+  if (m_firstArticle > 0) {
+    MOZ_LOG(NNTP, LogLevel::Info,
+            ("(%p) add to known articles:  %d - %d", this, m_firstArticle,
+             m_lastArticle));
+
+    if (NS_SUCCEEDED(rv) && m_newsgroupList) {
+      rv = m_newsgroupList->AddToKnownArticles(m_firstArticle, m_lastArticle);
+    }
 
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  if (m_numArticlesLoaded >= m_numArticlesWanted)
-  {
+  if (m_numArticlesLoaded >= m_numArticlesWanted) {
     m_nextState = NEWS_PROCESS_XOVER;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-    NS_ASSERTION(m_newsgroupList, "no newsgroupList");
-    if (!m_newsgroupList) return NS_ERROR_FAILURE;
-
-    bool getOldMessages = false;
-    if (m_runningURL) {
-      rv = m_runningURL->GetGetOldMessages(&getOldMessages);
-      NS_ENSURE_SUCCESS(rv, rv);
-    }
-
-    rv = m_newsgroupList->SetGetOldMessages(getOldMessages);
+  NS_ASSERTION(m_newsgroupList, "no newsgroupList");
+  if (!m_newsgroupList) return NS_ERROR_FAILURE;
+
+  bool getOldMessages = false;
+  if (m_runningURL) {
+    rv = m_runningURL->GetGetOldMessages(&getOldMessages);
     NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = m_newsgroupList->GetRangeOfArtsToDownload(m_msgWindow,
-      m_firstPossibleArticle,
-      m_lastPossibleArticle,
-      m_numArticlesWanted - m_numArticlesLoaded,
-      &(m_firstArticle),
-      &(m_lastArticle),
-      &status);
+  }
+
+  rv = m_newsgroupList->SetGetOldMessages(getOldMessages);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = m_newsgroupList->GetRangeOfArtsToDownload(
+      m_msgWindow, m_firstPossibleArticle, m_lastPossibleArticle,
+      m_numArticlesWanted - m_numArticlesLoaded, &(m_firstArticle),
+      &(m_lastArticle), &status);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (m_firstArticle <= 0 || m_firstArticle > m_lastArticle)
-  {
+  if (m_firstArticle <= 0 || m_firstArticle > m_lastArticle) {
     /* Nothing more to get. */
     m_nextState = NEWS_PROCESS_XOVER;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) Chunk will be (%d-%d)", this, m_firstArticle, m_lastArticle));
+  MOZ_LOG(NNTP, LogLevel::Info,
+          ("(%p) Chunk will be (%d-%d)", this, m_firstArticle, m_lastArticle));
 
   m_articleNumber = m_firstArticle;
 
-    /* was MSG_InitXOVER() */
-    if (m_newsgroupList) {
-        rv = m_newsgroupList->InitXOVER(m_firstArticle, m_lastArticle);
+  /* was MSG_InitXOVER() */
+  if (m_newsgroupList) {
+    rv = m_newsgroupList->InitXOVER(m_firstArticle, m_lastArticle);
   }
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   ClearFlag(NNTP_PAUSE_FOR_READ);
   if (TestFlag(NNTP_NO_XOVER_SUPPORT))
     m_nextState = NNTP_READ_GROUP;
   else
     m_nextState = NNTP_XOVER_SEND;
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::XoverSend()
-{
+nsresult nsNNTPProtocol::XoverSend() {
   char outputBuffer[OUTPUT_BUFFER_SIZE];
 
-    PR_snprintf(outputBuffer,
-        OUTPUT_BUFFER_SIZE,
-        "XOVER %d-%d" CRLF,
-        m_firstArticle,
-        m_lastArticle);
-
-    m_nextState = NNTP_RESPONSE;
-    m_nextStateAfterResponse = NNTP_XOVER_RESPONSE;
-    SetFlag(NNTP_PAUSE_FOR_READ);
+  PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "XOVER %d-%d" CRLF,
+              m_firstArticle, m_lastArticle);
+
+  m_nextState = NNTP_RESPONSE;
+  m_nextStateAfterResponse = NNTP_XOVER_RESPONSE;
+  SetFlag(NNTP_PAUSE_FOR_READ);
 
   return SendData(outputBuffer);
 }
 
 /* see if the xover response is going to return us data
  * if the proper code isn't returned then assume xover
  * isn't supported and use
  * normal read_group
  */
 
-nsresult nsNNTPProtocol::ReadXoverResponse()
-{
+nsresult nsNNTPProtocol::ReadXoverResponse() {
 #ifdef TEST_NO_XOVER_SUPPORT
-  m_responseCode = MK_NNTP_RESPONSE_CHECK_ERROR; /* pretend XOVER generated an error */
+  m_responseCode =
+      MK_NNTP_RESPONSE_CHECK_ERROR; /* pretend XOVER generated an error */
 #endif
 
-    if(m_responseCode != MK_NNTP_RESPONSE_XOVER_OK)
-    {
-        /* If we didn't get back "224 data follows" from the XOVER request,
-       then that must mean that this server doesn't support XOVER.  Or
-       maybe the server's XOVER support is busted or something.  So,
-       in that case, fall back to the very slow HEAD method.
-
-       But, while debugging here at HQ, getting into this state means
-       something went very wrong, since our servers do XOVER.  Thus
-       the assert.
-         */
+  if (m_responseCode != MK_NNTP_RESPONSE_XOVER_OK) {
+    /* If we didn't get back "224 data follows" from the XOVER request,
+   then that must mean that this server doesn't support XOVER.  Or
+   maybe the server's XOVER support is busted or something.  So,
+   in that case, fall back to the very slow HEAD method.
+
+   But, while debugging here at HQ, getting into this state means
+   something went very wrong, since our servers do XOVER.  Thus
+   the assert.
+     */
     /*NS_ASSERTION (0,"something went very wrong");*/
     m_nextState = NNTP_READ_GROUP;
     SetFlag(NNTP_NO_XOVER_SUPPORT);
-    }
-    else
-    {
-        m_nextState = NNTP_XOVER;
-    }
-
-    return NS_OK;  /* continue */
+  } else {
+    m_nextState = NNTP_XOVER;
+  }
+
+  return NS_OK; /* continue */
 }
 
 /* process the xover list as it comes from the server
  * and load it into the sort list.
  */
 
-nsresult nsNNTPProtocol::ReadXover(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::ReadXover(nsIInputStream *inputStream,
+                                   uint32_t length) {
   char *line, *lineToFree;
   nsresult rv;
   uint32_t status = 1;
 
   bool pauseForMoreData = false;
-  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if(pauseForMoreData)
-  {
+  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                       pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  if(!line)
-    return rv;  /* no line yet or TCP error */
-
-  if(line[0] == '.' && line[1] == '\0')
-  {
+  if (!line) return rv; /* no line yet or TCP error */
+
+  if (line[0] == '.' && line[1] == '\0') {
     m_nextState = NNTP_XHDR_SEND;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     PR_Free(lineToFree);
     return NS_OK;
-  }
-  else if (line [0] == '.' && line [1] == '.')
+  } else if (line[0] == '.' && line[1] == '.')
     /* The NNTP server quotes all lines beginning with "." by doubling it. */
     line++;
 
-    /* almost correct
-  */
-  if(status > 1)
-  {
+  /* almost correct
+   */
+  if (status > 1) {
     mBytesReceived += status;
     mBytesReceivedSinceLastStatusUpdate += status;
   }
 
   rv = m_newsgroupList->ProcessXOVERLINE(line, &status);
   NS_ASSERTION(NS_SUCCEEDED(rv), "failed to process the XOVERLINE");
 
   m_numArticlesLoaded++;
   PR_Free(lineToFree);
   return rv;
 }
 
 /* Finished processing all the XOVER data.
-*/
-
-nsresult nsNNTPProtocol::ProcessXover()
-{
+ */
+
+nsresult nsNNTPProtocol::ProcessXover() {
   nsresult rv;
 
   /* xover_parse_state stored in MSG_Pane cd->pane */
   NS_ASSERTION(m_newsgroupList, "no newsgroupList");
   if (!m_newsgroupList) return NS_ERROR_FAILURE;
 
   // Some people may use the notifications in CallFilters to close the cached
   // connections, which will clear m_newsgroupList. So we keep a copy for
@@ -3206,400 +2999,360 @@ nsresult nsNNTPProtocol::ProcessXover()
   m_newsgroupList = nullptr;
   if (NS_SUCCEEDED(rv) && status < 0) return NS_ERROR_FAILURE;
 
   m_nextState = NEWS_DONE;
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::XhdrSend()
-{
+nsresult nsNNTPProtocol::XhdrSend() {
   nsCString header;
   m_newsgroupList->InitXHDR(header);
-  if (header.IsEmpty())
-  {
+  if (header.IsEmpty()) {
     m_nextState = NNTP_FIGURE_NEXT_CHUNK;
     return NS_OK;
   }
 
   char outputBuffer[OUTPUT_BUFFER_SIZE];
   PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "XHDR %s %d-%d" CRLF,
               header.get(), m_firstArticle, m_lastArticle);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NNTP_XHDR_RESPONSE;
   SetFlag(NNTP_PAUSE_FOR_READ);
 
   return SendData(outputBuffer);
 }
 
-nsresult nsNNTPProtocol::XhdrResponse(nsIInputStream *inputStream)
-{
-  if (m_responseCode != MK_NNTP_RESPONSE_XHDR_OK)
-  {
+nsresult nsNNTPProtocol::XhdrResponse(nsIInputStream *inputStream) {
+  if (m_responseCode != MK_NNTP_RESPONSE_XHDR_OK) {
     m_nextState = NNTP_READ_GROUP;
     // The reasoning behind setting this flag and not an XHDR flag is that we
     // are going to have to use HEAD instead. At that point, using XOVER as
     // well is just wasting bandwidth.
     SetFlag(NNTP_NO_XOVER_SUPPORT);
     return NS_OK;
   }
 
   char *line, *lineToFree;
   nsresult rv;
   uint32_t status = 1;
 
   bool pauseForMoreData = false;
-  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if (pauseForMoreData)
-  {
+  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                       pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  if (!line)
-    return rv;  /* no line yet or TCP error */
-
-  if (line[0] == '.' && line[1] == '\0')
-  {
+  if (!line) return rv; /* no line yet or TCP error */
+
+  if (line[0] == '.' && line[1] == '\0') {
     m_nextState = NNTP_XHDR_SEND;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     PR_Free(lineToFree);
     return NS_OK;
   }
 
-  if (status > 1)
-  {
+  if (status > 1) {
     mBytesReceived += status;
     mBytesReceivedSinceLastStatusUpdate += status;
   }
 
   rv = m_newsgroupList->ProcessXHDRLine(nsDependentCString(line));
   NS_ASSERTION(NS_SUCCEEDED(rv), "failed to process the XHDRLINE");
 
   m_numArticlesLoaded++;
   PR_Free(lineToFree);
   return rv;
 }
 
-nsresult nsNNTPProtocol::ReadHeaders()
-{
-  if(m_articleNumber > m_lastArticle)
-  {  /* end of groups */
+nsresult nsNNTPProtocol::ReadHeaders() {
+  if (m_articleNumber > m_lastArticle) { /* end of groups */
 
     m_newsgroupList->InitHEAD(-1);
     m_nextState = NNTP_FIGURE_NEXT_CHUNK;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
-  }
-  else
-  {
+  } else {
     m_newsgroupList->InitHEAD(m_articleNumber);
 
     char outputBuffer[OUTPUT_BUFFER_SIZE];
-    PR_snprintf(outputBuffer,
-      OUTPUT_BUFFER_SIZE,
-      "HEAD %ld" CRLF,
-      m_articleNumber++);
+    PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "HEAD %ld" CRLF,
+                m_articleNumber++);
     m_nextState = NNTP_RESPONSE;
     m_nextStateAfterResponse = NNTP_READ_GROUP_RESPONSE;
 
     SetFlag(NNTP_PAUSE_FOR_READ);
     return SendData(outputBuffer);
   }
 }
 
 /* See if the "HEAD" command was successful
-*/
-
-nsresult nsNNTPProtocol::ReadNewsgroupResponse()
-{
-  if (m_responseCode == MK_NNTP_RESPONSE_ARTICLE_HEAD)
-  {     /* Head follows - parse it:*/
+ */
+
+nsresult nsNNTPProtocol::ReadNewsgroupResponse() {
+  if (m_responseCode ==
+      MK_NNTP_RESPONSE_ARTICLE_HEAD) { /* Head follows - parse it:*/
     m_nextState = NNTP_READ_GROUP_BODY;
 
     return NS_OK;
-  }
-  else
-  {
+  } else {
     m_newsgroupList->HEADFailed(m_articleNumber);
     m_nextState = NNTP_READ_GROUP;
     return NS_OK;
   }
 }
 
 /* read the body of the "HEAD" command
-*/
-nsresult nsNNTPProtocol::ReadNewsgroupBody(nsIInputStream * inputStream, uint32_t length)
-{
+ */
+nsresult nsNNTPProtocol::ReadNewsgroupBody(nsIInputStream *inputStream,
+                                           uint32_t length) {
   char *line, *lineToFree;
   nsresult rv;
   uint32_t status = 1;
 
   bool pauseForMoreData = false;
-  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if(pauseForMoreData)
-  {
+  line = lineToFree = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                       pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
   /* if TCP error of if there is not a full line yet return
-  */
-  if(!line)
-    return rv;
-
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) read_group_body: got line: %s|",this,line));
+   */
+  if (!line) return rv;
+
+  MOZ_LOG(NNTP, LogLevel::Info,
+          ("(%p) read_group_body: got line: %s|", this, line));
 
   /* End of body? */
-  if (line[0]=='.' && line[1]=='\0')
-  {
+  if (line[0] == '.' && line[1] == '\0') {
     m_nextState = NNTP_READ_GROUP;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
-  }
-  else if (line [0] == '.' && line [1] == '.')
+  } else if (line[0] == '.' && line[1] == '.')
     /* The NNTP server quotes all lines beginning with "." by doubling it. */
     line++;
 
   nsCString safe_line(line);
   rv = m_newsgroupList->ProcessHEADLine(safe_line);
   PR_Free(lineToFree);
   return rv;
 }
 
-
-nsresult nsNNTPProtocol::GetNewsStringByID(int32_t stringID, char16_t **aString)
-{
+nsresult nsNNTPProtocol::GetNewsStringByID(int32_t stringID,
+                                           char16_t **aString) {
   nsresult rv;
   nsAutoString resultString(NS_LITERAL_STRING("???"));
 
-  if (!m_stringBundle)
-  {
+  if (!m_stringBundle) {
     nsCOMPtr<nsIStringBundleService> bundleService =
-      mozilla::services::GetStringBundleService();
+        mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
-    rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(m_stringBundle));
+    rv = bundleService->CreateBundle(NEWS_MSGS_URL,
+                                     getter_AddRefs(m_stringBundle));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   if (m_stringBundle) {
     nsAutoString str;
     rv = m_stringBundle->GetStringFromID(stringID, str);
 
     if (NS_FAILED(rv)) {
       resultString.AssignLiteral("[StringID");
       resultString.AppendInt(stringID);
       resultString.AppendLiteral("?]");
       *aString = ToNewUnicode(resultString);
-    }
-    else {
+    } else {
       *aString = ToNewUnicode(str);
     }
-  }
-  else {
+  } else {
     rv = NS_OK;
     *aString = ToNewUnicode(resultString);
   }
   return rv;
 }
 
-nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName, char16_t **aString)
-{
+nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName,
+                                             char16_t **aString) {
   nsresult rv;
   nsAutoString resultString(NS_LITERAL_STRING("???"));
-  if (!m_stringBundle)
-  {
+  if (!m_stringBundle) {
     nsCOMPtr<nsIStringBundleService> bundleService =
-      mozilla::services::GetStringBundleService();
+        mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
-    rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(m_stringBundle));
+    rv = bundleService->CreateBundle(NEWS_MSGS_URL,
+                                     getter_AddRefs(m_stringBundle));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  if (m_stringBundle)
-  {
+  if (m_stringBundle) {
     nsAutoString str;
     rv = m_stringBundle->GetStringFromName(aName, str);
 
-    if (NS_FAILED(rv))
-    {
+    if (NS_FAILED(rv)) {
       resultString.AssignLiteral("[StringName");
       resultString.Append(NS_ConvertASCIItoUTF16(aName));
       resultString.AppendLiteral("?]");
       *aString = ToNewUnicode(resultString);
-    }
-    else
-    {
+    } else {
       *aString = ToNewUnicode(str);
     }
-  }
-  else
-  {
+  } else {
     rv = NS_OK;
     *aString = ToNewUnicode(resultString);
   }
   return rv;
 }
 
-// sspitzer:  PostMessageInFile is derived from nsSmtpProtocol::SendMessageInFile()
-nsresult nsNNTPProtocol::PostMessageInFile(nsIFile *postMessageFile)
-{
-    nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningURL);
-    if (url && postMessageFile)
-        nsMsgProtocol::PostMessage(url, postMessageFile);
-
-    SetFlag(NNTP_PAUSE_FOR_READ);
-
-    // for now, we are always done at this point..we aren't making multiple
-    // calls to post data...
-
-    // always issue a '.' and CRLF when we are done...
-    PL_strcpy(m_dataBuf, "." CRLF);
-    SendData(m_dataBuf);
-    m_nextState = NNTP_RESPONSE;
-    m_nextStateAfterResponse = NNTP_SEND_POST_DATA_RESPONSE;
-    return NS_OK;
+// sspitzer:  PostMessageInFile is derived from
+// nsSmtpProtocol::SendMessageInFile()
+nsresult nsNNTPProtocol::PostMessageInFile(nsIFile *postMessageFile) {
+  nsCOMPtr<nsIURI> url = do_QueryInterface(m_runningURL);
+  if (url && postMessageFile) nsMsgProtocol::PostMessage(url, postMessageFile);
+
+  SetFlag(NNTP_PAUSE_FOR_READ);
+
+  // for now, we are always done at this point..we aren't making multiple
+  // calls to post data...
+
+  // always issue a '.' and CRLF when we are done...
+  PL_strcpy(m_dataBuf, "." CRLF);
+  SendData(m_dataBuf);
+  m_nextState = NNTP_RESPONSE;
+  m_nextStateAfterResponse = NNTP_SEND_POST_DATA_RESPONSE;
+  return NS_OK;
 }
 
-nsresult nsNNTPProtocol::PostData()
-{
-    /* returns 0 on done and negative on error
-     * positive if it needs to continue.
-     */
-    NNTP_LOG_NOTE("nsNNTPProtocol::PostData()");
-    nsresult rv = NS_OK;
-
-    nsCOMPtr <nsINNTPNewsgroupPost> message;
-    rv = m_runningURL->GetMessageToPost(getter_AddRefs(message));
-    if (NS_SUCCEEDED(rv))
-    {
-        nsCOMPtr<nsIFile> filePath;
-        rv = message->GetPostMessageFile(getter_AddRefs(filePath));
-        if (NS_SUCCEEDED(rv))
-            PostMessageInFile(filePath);
-     }
-
-    return NS_OK;
+nsresult nsNNTPProtocol::PostData() {
+  /* returns 0 on done and negative on error
+   * positive if it needs to continue.
+   */
+  NNTP_LOG_NOTE("nsNNTPProtocol::PostData()");
+  nsresult rv = NS_OK;
+
+  nsCOMPtr<nsINNTPNewsgroupPost> message;
+  rv = m_runningURL->GetMessageToPost(getter_AddRefs(message));
+  if (NS_SUCCEEDED(rv)) {
+    nsCOMPtr<nsIFile> filePath;
+    rv = message->GetPostMessageFile(getter_AddRefs(filePath));
+    if (NS_SUCCEEDED(rv)) PostMessageInFile(filePath);
+  }
+
+  return NS_OK;
 }
 
-
 /* interpret the response code from the server
  * after the post is done
  */
-nsresult nsNNTPProtocol::PostDataResponse()
-{
-  if (m_responseCode != MK_NNTP_RESPONSE_POST_OK)
-  {
-    AlertError(MK_NNTP_ERROR_MESSAGE,m_responseText);
+nsresult nsNNTPProtocol::PostDataResponse() {
+  if (m_responseCode != MK_NNTP_RESPONSE_POST_OK) {
+    AlertError(MK_NNTP_ERROR_MESSAGE, m_responseText);
     m_nextState = NEWS_ERROR;
     return NS_ERROR_FAILURE;
   }
-    m_nextState = NEWS_POST_DONE;
+  m_nextState = NEWS_POST_DONE;
   ClearFlag(NNTP_PAUSE_FOR_READ);
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::CheckForArticle()
-{
+nsresult nsNNTPProtocol::CheckForArticle() {
   m_nextState = NEWS_ERROR;
   if (m_responseCode >= 220 && m_responseCode <= 223) {
     /* Yes, this article is already there, we're all done. */
     return NS_OK;
-  }
-  else
-  {
-  /* The article isn't there, so the failure we had earlier wasn't due to
-     a duplicate message-id.  Return the error from that previous
-     posting attempt (which is already in ce->URL_s->error_msg). */
+  } else {
+    /* The article isn't there, so the failure we had earlier wasn't due to
+       a duplicate message-id.  Return the error from that previous
+       posting attempt (which is already in ce->URL_s->error_msg). */
     return NS_ERROR_FAILURE;
   }
 }
 
-nsresult nsNNTPProtocol::StartCancel()
-{
+nsresult nsNNTPProtocol::StartCancel() {
   nsresult rv = SendData(NNTP_CMD_POST);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NEWS_DO_CANCEL;
   SetFlag(NNTP_PAUSE_FOR_READ);
   return rv;
 }
 
-void nsNNTPProtocol::CheckIfAuthor(nsIMsgIdentity *aIdentity, const nsCString &aOldFrom, nsCString &aFrom)
-{
+void nsNNTPProtocol::CheckIfAuthor(nsIMsgIdentity *aIdentity,
+                                   const nsCString &aOldFrom,
+                                   nsCString &aFrom) {
   nsAutoCString from;
   nsresult rv = aIdentity->GetEmail(from);
-  if (NS_FAILED(rv))
-    return;
-  MOZ_LOG(NNTP, LogLevel::Info,("from = %s", from.get()));
+  if (NS_FAILED(rv)) return;
+  MOZ_LOG(NNTP, LogLevel::Info, ("from = %s", from.get()));
 
   nsCString us;
   nsCString them;
   ExtractEmail(EncodedHeader(from), us);
   ExtractEmail(EncodedHeader(aOldFrom), them);
 
-  MOZ_LOG(NNTP, LogLevel::Info,("us = %s, them = %s", us.get(), them.get()));
-
-  if (us.Equals(them, nsCaseInsensitiveCStringComparator()))
-    aFrom = from;
+  MOZ_LOG(NNTP, LogLevel::Info, ("us = %s, them = %s", us.get(), them.get()));
+
+  if (us.Equals(them, nsCaseInsensitiveCStringComparator())) aFrom = from;
 }
 
-nsresult nsNNTPProtocol::DoCancel()
-{
-    int32_t status = 0;
-    bool failure = false;
-    nsresult rv = NS_OK;
-    bool requireConfirmationForCancel = true;
-    bool showAlertAfterCancel = true;
+nsresult nsNNTPProtocol::DoCancel() {
+  int32_t status = 0;
+  bool failure = false;
+  nsresult rv = NS_OK;
+  bool requireConfirmationForCancel = true;
+  bool showAlertAfterCancel = true;
 
   /* #### Should we do a more real check than this?  If the POST command
-     didn't respond with "MK_NNTP_RESPONSE_POST_SEND_NOW Ok", then it's not ready for us to throw a
-     message at it...   But the normal posting code doesn't do this check.
-     Why?
+     didn't respond with "MK_NNTP_RESPONSE_POST_SEND_NOW Ok", then it's not
+     ready for us to throw a message at it...   But the normal posting code
+     doesn't do this check. Why?
    */
-  NS_ASSERTION (m_responseCode == MK_NNTP_RESPONSE_POST_SEND_NOW, "code != POST_SEND_NOW");
+  NS_ASSERTION(m_responseCode == MK_NNTP_RESPONSE_POST_SEND_NOW,
+               "code != POST_SEND_NOW");
 
   nsCOMPtr<nsIStringBundleService> bundleService =
-    mozilla::services::GetStringBundleService();
+      mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(bundleService, NS_ERROR_OUT_OF_MEMORY);
 
   nsCOMPtr<nsIStringBundle> brandBundle;
   bundleService->CreateBundle("chrome://branding/locale/brand.properties",
                               getter_AddRefs(brandBundle));
   NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);
 
   nsString brandFullName;
   rv = brandBundle->GetStringFromName("brandFullName", brandFullName);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   NS_ConvertUTF16toUTF8 appName(brandFullName);
 
   nsCString newsgroups(m_cancelNewsgroups);
-  nsCString distribution (m_cancelDistribution);
-  nsCString id (m_cancelID);
+  nsCString distribution(m_cancelDistribution);
+  nsCString id(m_cancelID);
   nsCString oldFrom(m_cancelFromHdr);
 
-  nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIPrefBranch> prefBranch =
+      do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrompt> dialog;
-  if (m_runningURL)
-  {
-    nsCOMPtr<nsIMsgMailNewsUrl> msgUrl (do_QueryInterface(m_runningURL));
+  if (m_runningURL) {
+    nsCOMPtr<nsIMsgMailNewsUrl> msgUrl(do_QueryInterface(m_runningURL));
     rv = GetPromptDialogFromUrl(msgUrl, getter_AddRefs(dialog));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  if (id.IsEmpty() || newsgroups.IsEmpty())
-    return NS_ERROR_FAILURE;
+  if (id.IsEmpty() || newsgroups.IsEmpty()) return NS_ERROR_FAILURE;
 
   m_cancelNewsgroups.Truncate();
   m_cancelDistribution.Truncate();
   m_cancelFromHdr.Truncate();
   m_cancelID.Truncate();
 
   nsString alertText;
   nsString confirmText;
@@ -3610,86 +3363,83 @@ nsresult nsNNTPProtocol::DoCancel()
 
   /* Make sure that this loser isn't cancelling someone else's posting.
      Yes, there are occasionally good reasons to do so.  Those people
      capable of making that decision (news admins) have other tools with
      which to cancel postings (like telnet.)
 
      Don't do this if server tells us it will validate user. DMB 3/19/97
    */
-  bool cancelchk=false;
-  rv = m_nntpServer->QueryExtension("CANCELCHK",&cancelchk);
+  bool cancelchk = false;
+  rv = m_nntpServer->QueryExtension("CANCELCHK", &cancelchk);
   nsCString from;
-  if (NS_SUCCEEDED(rv) && !cancelchk)
-  {
+  if (NS_SUCCEEDED(rv) && !cancelchk) {
     NNTP_LOG_NOTE("CANCELCHK not supported");
 
     // get the current identity from the news session....
     nsCOMPtr<nsIMsgAccountManager> accountManager =
-      do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+        do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
     if (NS_SUCCEEDED(rv) && accountManager) {
       nsCOMPtr<nsIArray> identities;
       rv = accountManager->GetAllIdentities(getter_AddRefs(identities));
       NS_ENSURE_SUCCESS(rv, rv);
 
       uint32_t length;
       rv = identities->GetLength(&length);
       NS_ENSURE_SUCCESS(rv, rv);
 
-      for (uint32_t i = 0; i < length && from.IsEmpty(); ++i)
-      {
-        nsCOMPtr<nsIMsgIdentity> identity(do_QueryElementAt(identities, i, &rv));
-        if (NS_SUCCEEDED(rv))
-          CheckIfAuthor(identity, oldFrom, from);
+      for (uint32_t i = 0; i < length && from.IsEmpty(); ++i) {
+        nsCOMPtr<nsIMsgIdentity> identity(
+            do_QueryElementAt(identities, i, &rv));
+        if (NS_SUCCEEDED(rv)) CheckIfAuthor(identity, oldFrom, from);
       }
     }
 
-    if (from.IsEmpty())
-    {
+    if (from.IsEmpty()) {
       GetNewsStringByName("cancelDisallowed", getter_Copies(alertText));
       rv = dialog->Alert(nullptr, alertText.get());
       // XXX:  todo, check rv?
 
-      /* After the cancel is disallowed, Make the status update to be the same as though the
-         cancel was allowed, otherwise, the newsgroup is not able to take further requests as
-         reported here */
+      /* After the cancel is disallowed, Make the status update to be the same
+         as though the cancel was allowed, otherwise, the newsgroup is not able
+         to take further requests as reported here */
       status = MK_NNTP_CANCEL_DISALLOWED;
       m_nextState = NNTP_RESPONSE;
       m_nextStateAfterResponse = NNTP_SEND_POST_DATA_RESPONSE;
       SetFlag(NNTP_PAUSE_FOR_READ);
       failure = true;
       goto FAIL;
-    }
-    else
-    {
-      MOZ_LOG(NNTP, LogLevel::Info,("(%p) CANCELCHK not supported, so post the cancel message as %s", this, from.get()));
+    } else {
+      MOZ_LOG(NNTP, LogLevel::Info,
+              ("(%p) CANCELCHK not supported, so post the cancel message as %s",
+               this, from.get()));
     }
-  }
-  else
+  } else
     NNTP_LOG_NOTE("CANCELCHK supported, don't do the us vs. them test");
 
-  // QA needs to be able to disable this confirm dialog, for the automated tests.  see bug #31057
-  rv = prefBranch->GetBoolPref(PREF_NEWS_CANCEL_CONFIRM, &requireConfirmationForCancel);
+  // QA needs to be able to disable this confirm dialog, for the automated
+  // tests.  see bug #31057
+  rv = prefBranch->GetBoolPref(PREF_NEWS_CANCEL_CONFIRM,
+                               &requireConfirmationForCancel);
   if (NS_FAILED(rv) || requireConfirmationForCancel) {
     /* Last chance to cancel the cancel.*/
     GetNewsStringByName("cancelConfirm", getter_Copies(confirmText));
     bool dummyValue = false;
-    rv = dialog->ConfirmEx(nullptr, confirmText.get(), nsIPrompt::STD_YES_NO_BUTTONS,
-                           nullptr, nullptr, nullptr, nullptr, &dummyValue, &confirmCancelResult);
-    if (NS_FAILED(rv))
-      confirmCancelResult = 1; // Default to No.
-  }
-  else
-    confirmCancelResult = 0; // Default to Yes.
+    rv = dialog->ConfirmEx(nullptr, confirmText.get(),
+                           nsIPrompt::STD_YES_NO_BUTTONS, nullptr, nullptr,
+                           nullptr, nullptr, &dummyValue, &confirmCancelResult);
+    if (NS_FAILED(rv)) confirmCancelResult = 1;  // Default to No.
+  } else
+    confirmCancelResult = 0;  // Default to Yes.
 
   if (confirmCancelResult != 0) {
-      // they cancelled the cancel
-      status = MK_NNTP_NOT_CANCELLED;
-      failure = true;
-      goto FAIL;
+    // they cancelled the cancel
+    status = MK_NNTP_NOT_CANCELLED;
+    failure = true;
+    goto FAIL;
   }
 
   otherHeaders.AppendLiteral("Control: cancel ");
   otherHeaders += id;
   otherHeaders.AppendLiteral(CRLF);
   if (!distribution.IsEmpty()) {
     otherHeaders.AppendLiteral("Distribution: ");
     otherHeaders += distribution;
@@ -3701,150 +3451,137 @@ nsresult nsNNTPProtocol::DoCancel()
   otherHeaders.AppendLiteral(CRLF);
 
   m_cancelStatus = 0;
 
   {
     /* NET_BlockingWrite() should go away soon? I think. */
     /* The following are what we really need to cancel a posted message */
     char *data;
-    data = PR_smprintf("From: %s" CRLF
-                       "Newsgroups: %s" CRLF
-                       "Subject: cancel %s" CRLF
-                       "References: %s" CRLF
-                       "%s" /* otherHeaders, already with CRLF */
-                       CRLF /* body separator */
-                       "This message was cancelled from within %s." CRLF /* body */
-                       "." CRLF, /* trailing message terminator "." */
-                       from.get(), newsgroups.get(), id.get(), id.get(),
-                       otherHeaders.get(), appName.get());
+    data = PR_smprintf(
+        "From: %s" CRLF "Newsgroups: %s" CRLF "Subject: cancel %s" CRLF
+        "References: %s" CRLF "%s" /* otherHeaders, already with CRLF */
+        CRLF                       /* body separator */
+        "This message was cancelled from within %s." CRLF /* body */
+        "." CRLF, /* trailing message terminator "." */
+        from.get(), newsgroups.get(), id.get(), id.get(), otherHeaders.get(),
+        appName.get());
 
     rv = SendData(data);
-    PR_Free (data);
+    PR_Free(data);
     if (NS_FAILED(rv)) {
       nsAutoCString errorText;
       errorText.AppendInt(status);
       AlertError(MK_TCP_WRITE_ERROR, errorText.get());
       failure = true;
       goto FAIL;
     }
 
     SetFlag(NNTP_PAUSE_FOR_READ);
     m_nextState = NNTP_RESPONSE;
     m_nextStateAfterResponse = NNTP_SEND_POST_DATA_RESPONSE;
 
-    // QA needs to be able to turn this alert off, for the automate tests.  see bug #31057
-    rv = prefBranch->GetBoolPref(PREF_NEWS_CANCEL_ALERT_ON_SUCCESS, &showAlertAfterCancel);
+    // QA needs to be able to turn this alert off, for the automate tests.  see
+    // bug #31057
+    rv = prefBranch->GetBoolPref(PREF_NEWS_CANCEL_ALERT_ON_SUCCESS,
+                                 &showAlertAfterCancel);
     if (NS_FAILED(rv) || showAlertAfterCancel) {
       GetNewsStringByName("messageCancelled", getter_Copies(alertText));
       rv = dialog->Alert(nullptr, alertText.get());
       // XXX:  todo, check rv?
     }
 
     if (!m_runningURL) return NS_ERROR_FAILURE;
 
     // delete the message from the db here.
-    NS_ASSERTION(NS_SUCCEEDED(rv) && m_newsFolder && (m_key != nsMsgKey_None), "need more to remove this message from the db");
+    NS_ASSERTION(NS_SUCCEEDED(rv) && m_newsFolder && (m_key != nsMsgKey_None),
+                 "need more to remove this message from the db");
     if ((m_key != nsMsgKey_None) && (m_newsFolder))
-       rv = m_newsFolder->RemoveMessage(m_key);
-
+      rv = m_newsFolder->RemoveMessage(m_key);
   }
 
 FAIL:
-  NS_ASSERTION(m_newsFolder,"no news folder");
+  NS_ASSERTION(m_newsFolder, "no news folder");
   if (m_newsFolder)
-    rv = ( failure ) ? m_newsFolder->CancelFailed()
-                     : m_newsFolder->CancelComplete();
+    rv = (failure) ? m_newsFolder->CancelFailed()
+                   : m_newsFolder->CancelComplete();
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::XPATSend()
-{
+nsresult nsNNTPProtocol::XPATSend() {
   nsresult rv = NS_OK;
   int32_t slash = m_searchData.FindChar('/');
 
-  if (slash >= 0)
-  {
+  if (slash >= 0) {
     /* extract the XPAT encoding for one query term */
     /* char *next_search = NULL; */
     char *command = NULL;
     char *unescapedCommand = NULL;
     char *endOfTerm = NULL;
-    NS_MsgSACopy (&command, m_searchData.get() + slash + 1);
+    NS_MsgSACopy(&command, m_searchData.get() + slash + 1);
     endOfTerm = PL_strchr(command, '/');
-    if (endOfTerm)
-      *endOfTerm = '\0';
+    if (endOfTerm) *endOfTerm = '\0';
     NS_MsgSACat(&command, CRLF);
 
     unescapedCommand = MSG_UnEscapeSearchUrl(command);
 
     /* send one term off to the server */
     rv = SendData(unescapedCommand);
 
     m_nextState = NNTP_RESPONSE;
     m_nextStateAfterResponse = NNTP_XPAT_RESPONSE;
     SetFlag(NNTP_PAUSE_FOR_READ);
 
     PR_Free(command);
     PR_Free(unescapedCommand);
-  }
-  else
-  {
+  } else {
     m_nextState = NEWS_DONE;
   }
   return rv;
 }
 
-nsresult nsNNTPProtocol::XPATResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::XPATResponse(nsIInputStream *inputStream,
+                                      uint32_t length) {
   uint32_t status = 1;
   nsresult rv;
 
-  if (m_responseCode != MK_NNTP_RESPONSE_XPAT_OK)
-  {
-    AlertError(MK_NNTP_ERROR_MESSAGE,m_responseText);
+  if (m_responseCode != MK_NNTP_RESPONSE_XPAT_OK) {
+    AlertError(MK_NNTP_ERROR_MESSAGE, m_responseText);
     m_nextState = NNTP_ERROR;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_ERROR_FAILURE;
   }
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
+  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                pauseForMoreData, &rv);
 
   NNTP_LOG_READ(line);
 
-  if(pauseForMoreData)
-  {
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  if (line)
-  {
-    if (line[0] != '.')
-    {
+  if (line) {
+    if (line[0] != '.') {
       long articleNumber;
       PR_sscanf(line, "%ld", &articleNumber);
       nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
-      if (mailnewsurl)
-      {
-        nsCOMPtr <nsIMsgSearchSession> searchSession;
-        nsCOMPtr <nsIMsgSearchAdapter> searchAdapter;
+      if (mailnewsurl) {
+        nsCOMPtr<nsIMsgSearchSession> searchSession;
+        nsCOMPtr<nsIMsgSearchAdapter> searchAdapter;
         mailnewsurl->GetSearchSession(getter_AddRefs(searchSession));
-        if (searchSession)
-        {
+        if (searchSession) {
           searchSession->GetRunningAdapter(getter_AddRefs(searchAdapter));
-          if (searchAdapter)
-            searchAdapter->AddHit((uint32_t) articleNumber);
+          if (searchAdapter) searchAdapter->AddHit((uint32_t)articleNumber);
         }
       }
-    }
-    else
-    {
+    } else {
       /* set up the next term for next time around */
       int32_t slash = m_searchData.FindChar('/');
 
       if (slash >= 0)
         m_searchData.Cut(0, slash + 1);
       else
         m_searchData.Truncate();
 
@@ -3853,64 +3590,57 @@ nsresult nsNNTPProtocol::XPATResponse(ns
       PR_FREEIF(line);
       return NS_OK;
     }
   }
   PR_FREEIF(line);
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::ListPrettyNames()
-{
-
+nsresult nsNNTPProtocol::ListPrettyNames() {
   nsCString group_name;
   char outputBuffer[OUTPUT_BUFFER_SIZE];
 
   m_newsFolder->GetRawName(group_name);
-  PR_snprintf(outputBuffer,
-    OUTPUT_BUFFER_SIZE,
-    "LIST PRETTYNAMES %.512s" CRLF,
-    group_name.get());
+  PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "LIST PRETTYNAMES %.512s" CRLF,
+              group_name.get());
 
   nsresult rv = SendData(outputBuffer);
   NNTP_LOG_NOTE(outputBuffer);
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NNTP_LIST_PRETTY_NAMES_RESPONSE;
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::ListPrettyNamesResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::ListPrettyNamesResponse(nsIInputStream *inputStream,
+                                                 uint32_t length) {
   uint32_t status = 0;
 
-  if (m_responseCode != MK_NNTP_RESPONSE_LIST_OK)
-  {
+  if (m_responseCode != MK_NNTP_RESPONSE_LIST_OK) {
     m_nextState = DISPLAY_NEWSGROUPS;
     /*    m_nextState = NEWS_DONE; */
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
+  char *line =
+      m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
 
   NNTP_LOG_READ(line);
 
-  if(pauseForMoreData)
-  {
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  if (line)
-  {
-    if (line[0] != '.')
-    {
-#if 0 // SetPrettyName is not yet implemented. No reason to bother
+  if (line) {
+    if (line[0] != '.') {
+#if 0  // SetPrettyName is not yet implemented. No reason to bother
       int i;
       /* find whitespace separator if it exits */
       for (i=0; line[i] != '\0' && !NET_IS_SPACE(line[i]); i++)
         ;  /* null body */
 
       char *prettyName;
       if(line[i] == '\0')
         prettyName = &line[i];
@@ -3928,699 +3658,661 @@ nsresult nsNNTPProtocol::ListPrettyNames
           CopyUTF8toUTF16(prettyName, prettyNameUtf16);
         }
         m_nntpServer->SetPrettyNameForGroup(lineUtf16, prettyNameUtf16);
 
         MOZ_LOG(NNTP, LogLevel::Info,("(%p) adding pretty name %s", this,
                NS_ConvertUTF16toUTF8(prettyNameUtf16).get()));
       }
 #endif
-    }
-    else
-    {
-      m_nextState = DISPLAY_NEWSGROUPS;  /* this assumes we were doing a list */
+    } else {
+      m_nextState = DISPLAY_NEWSGROUPS; /* this assumes we were doing a list */
       /*      m_nextState = NEWS_DONE;   */ /* ### dmb - don't really know */
       ClearFlag(NNTP_PAUSE_FOR_READ);
       PR_FREEIF(line);
       return NS_OK;
     }
   }
   PR_FREEIF(line);
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::ListXActive()
-{
+nsresult nsNNTPProtocol::ListXActive() {
   nsCString group_name;
   nsresult rv;
   rv = m_newsFolder->GetRawName(group_name);
   NS_ENSURE_SUCCESS(rv, rv);
 
   char outputBuffer[OUTPUT_BUFFER_SIZE];
 
-  PR_snprintf(outputBuffer,
-    OUTPUT_BUFFER_SIZE,
-    "LIST XACTIVE %.512s" CRLF,
-    group_name.get());
+  PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "LIST XACTIVE %.512s" CRLF,
+              group_name.get());
 
   rv = SendData(outputBuffer);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NNTP_LIST_XACTIVE_RESPONSE;
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::ListXActiveResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::ListXActiveResponse(nsIInputStream *inputStream,
+                                             uint32_t length) {
   uint32_t status = 0;
   nsresult rv;
 
   NS_ASSERTION(m_responseCode == MK_NNTP_RESPONSE_LIST_OK, "code != LIST_OK");
-  if (m_responseCode != MK_NNTP_RESPONSE_LIST_OK)
-  {
+  if (m_responseCode != MK_NNTP_RESPONSE_LIST_OK) {
     m_nextState = DISPLAY_NEWSGROUPS;
     /*    m_nextState = NEWS_DONE; */
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
+  char *line =
+      m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
 
   NNTP_LOG_READ(line);
 
-  if(pauseForMoreData)
-  {
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-   /* almost correct */
-  if(status > 1)
-  {
+  /* almost correct */
+  if (status > 1) {
     mBytesReceived += status;
     mBytesReceivedSinceLastStatusUpdate += status;
   }
 
-  if (line)
-  {
-    if (line[0] != '.')
-    {
+  if (line) {
+    if (line[0] != '.') {
       char *s = line;
       /* format is "rec.arts.movies.past-films 7302 7119 csp"
-      */
-      while (*s && !NET_IS_SPACE(*s))
-        s++;
-      if (*s)
-      {
-        char flags[32];  /* ought to be big enough */
+       */
+      while (*s && !NET_IS_SPACE(*s)) s++;
+      if (*s) {
+        char flags[32]; /* ought to be big enough */
         *s = 0;
-        PR_sscanf(s + 1,
-          "%d %d %31s",
-          &m_firstPossibleArticle,
-          &m_lastPossibleArticle,
-          flags);
-
+        PR_sscanf(s + 1, "%d %d %31s", &m_firstPossibleArticle,
+                  &m_lastPossibleArticle, flags);
 
         NS_ASSERTION(m_nntpServer, "no nntp incoming server");
         if (m_nntpServer) {
           rv = m_nntpServer->AddNewsgroupToList(line);
-          NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
+          NS_ASSERTION(NS_SUCCEEDED(rv), "failed to add to subscribe ds");
         }
 
         /* we're either going to list prettynames first, or list
         all prettynames every time, so we won't care so much
         if it gets interrupted. */
-        MOZ_LOG(NNTP, LogLevel::Info,("(%p) got xactive for %s of %s", this, line, flags));
+        MOZ_LOG(NNTP, LogLevel::Info,
+                ("(%p) got xactive for %s of %s", this, line, flags));
         /*  This isn't required, because the extra info is
         initialized to false for new groups. And it's
         an expensive call.
         */
         /* MSG_SetGroupNeedsExtraInfo(cd->host, line, false); */
       }
-    }
-    else
-    {
-      bool xactive=false;
-      rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
-      if (m_typeWanted == NEW_GROUPS &&
-        NS_SUCCEEDED(rv) && xactive)
-      {
-        nsCOMPtr <nsIMsgNewsFolder> old_newsFolder;
+    } else {
+      bool xactive = false;
+      rv = m_nntpServer->QueryExtension("XACTIVE", &xactive);
+      if (m_typeWanted == NEW_GROUPS && NS_SUCCEEDED(rv) && xactive) {
+        nsCOMPtr<nsIMsgNewsFolder> old_newsFolder;
         old_newsFolder = m_newsFolder;
         nsCString groupName;
 
         rv = m_nntpServer->GetFirstGroupNeedingExtraInfo(groupName);
         NS_ENSURE_SUCCESS(rv, rv);
-        rv = m_nntpServer->FindGroup(groupName,
-                                     getter_AddRefs(m_newsFolder));
+        rv = m_nntpServer->FindGroup(groupName, getter_AddRefs(m_newsFolder));
         NS_ENSURE_SUCCESS(rv, rv);
 
         // see if we got a different group
         if (old_newsFolder && m_newsFolder &&
-          (old_newsFolder.get() != m_newsFolder.get()))
-          /* make sure we're not stuck on the same group */
+            (old_newsFolder.get() != m_newsFolder.get()))
+        /* make sure we're not stuck on the same group */
         {
-          MOZ_LOG(NNTP, LogLevel::Info,("(%p) listing xactive for %s", this, groupName.get()));
+          MOZ_LOG(NNTP, LogLevel::Info,
+                  ("(%p) listing xactive for %s", this, groupName.get()));
           m_nextState = NNTP_LIST_XACTIVE;
           ClearFlag(NNTP_PAUSE_FOR_READ);
           PR_FREEIF(line);
           return NS_OK;
-        }
-        else
-        {
+        } else {
           m_newsFolder = nullptr;
         }
       }
       bool listpname;
-      rv = m_nntpServer->QueryExtension("LISTPNAME",&listpname);
+      rv = m_nntpServer->QueryExtension("LISTPNAME", &listpname);
       if (NS_SUCCEEDED(rv) && listpname)
         m_nextState = NNTP_LIST_PRETTY_NAMES;
       else
-        m_nextState = DISPLAY_NEWSGROUPS;  /* this assumes we were doing a list - who knows? */
+        m_nextState = DISPLAY_NEWSGROUPS; /* this assumes we were doing a list -
+                                             who knows? */
       /*      m_nextState = NEWS_DONE;   */ /* ### dmb - don't really know */
       ClearFlag(NNTP_PAUSE_FOR_READ);
       PR_FREEIF(line);
       return NS_OK;
     }
   }
   PR_FREEIF(line);
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::SendListGroup()
-{
+nsresult nsNNTPProtocol::SendListGroup() {
   nsresult rv;
   char outputBuffer[OUTPUT_BUFFER_SIZE];
 
-  NS_ASSERTION(m_newsFolder,"no newsFolder");
+  NS_ASSERTION(m_newsFolder, "no newsFolder");
   if (!m_newsFolder) return NS_ERROR_FAILURE;
   nsCString newsgroupName;
 
   rv = m_newsFolder->GetRawName(newsgroupName);
-  NS_ENSURE_SUCCESS(rv,rv);
-
-  PR_snprintf(outputBuffer,
-    OUTPUT_BUFFER_SIZE,
-    "listgroup %.512s" CRLF,
-    newsgroupName.get());
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  PR_snprintf(outputBuffer, OUTPUT_BUFFER_SIZE, "listgroup %.512s" CRLF,
+              newsgroupName.get());
 
   m_articleList = do_CreateInstance(NS_NNTPARTICLELIST_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   rv = m_articleList->Initialize(m_newsFolder);
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   rv = SendData(outputBuffer);
 
   m_nextState = NNTP_RESPONSE;
   m_nextStateAfterResponse = NNTP_LIST_GROUP_RESPONSE;
   SetFlag(NNTP_PAUSE_FOR_READ);
 
   return rv;
 }
 
-nsresult nsNNTPProtocol::SendListGroupResponse(nsIInputStream * inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::SendListGroupResponse(nsIInputStream *inputStream,
+                                               uint32_t length) {
   uint32_t status = 0;
 
-  NS_ASSERTION(m_responseCode == MK_NNTP_RESPONSE_GROUP_SELECTED, "code != GROUP_SELECTED");
-  if (m_responseCode != MK_NNTP_RESPONSE_GROUP_SELECTED)
-  {
+  NS_ASSERTION(m_responseCode == MK_NNTP_RESPONSE_GROUP_SELECTED,
+               "code != GROUP_SELECTED");
+  if (m_responseCode != MK_NNTP_RESPONSE_GROUP_SELECTED) {
     m_nextState = NEWS_DONE;
     ClearFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
-
-  if(pauseForMoreData)
-  {
+  char *line =
+      m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
 
-  if (line)
-  {
+  if (line) {
     mozilla::DebugOnly<nsresult> rv;
-    if (line[0] != '.')
-    {
+    if (line[0] != '.') {
       nsMsgKey found_id = nsMsgKey_None;
       PR_sscanf(line, "%ld", &found_id);
       rv = m_articleList->AddArticleKey(found_id);
       NS_ASSERTION(NS_SUCCEEDED(rv), "add article key failed");
-    }
-    else
-    {
+    } else {
       rv = m_articleList->FinishAddingArticleKeys();
       NS_ASSERTION(NS_SUCCEEDED(rv), "finish adding article key failed");
       m_articleList = nullptr;
-      m_nextState = NEWS_DONE;   /* ### dmb - don't really know */
+      m_nextState = NEWS_DONE; /* ### dmb - don't really know */
       ClearFlag(NNTP_PAUSE_FOR_READ);
       PR_FREEIF(line);
       return NS_OK;
     }
   }
   PR_FREEIF(line);
   return NS_OK;
 }
 
-
-nsresult nsNNTPProtocol::Search()
-{
+nsresult nsNNTPProtocol::Search() {
   NS_ERROR("Search not implemented");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-nsresult nsNNTPProtocol::SearchResponse()
-{
+nsresult nsNNTPProtocol::SearchResponse() {
   if (MK_NNTP_RESPONSE_TYPE(m_responseCode) == MK_NNTP_RESPONSE_TYPE_OK)
     m_nextState = NNTP_SEARCH_RESULTS;
   else
     m_nextState = NEWS_DONE;
   ClearFlag(NNTP_PAUSE_FOR_READ);
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::SearchResults(nsIInputStream *inputStream, uint32_t length)
-{
+nsresult nsNNTPProtocol::SearchResults(nsIInputStream *inputStream,
+                                       uint32_t length) {
   uint32_t status = 1;
   nsresult rv;
 
   bool pauseForMoreData = false;
-  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv);
-
-  if(pauseForMoreData)
-  {
+  char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status,
+                                                pauseForMoreData, &rv);
+
+  if (pauseForMoreData) {
     SetFlag(NNTP_PAUSE_FOR_READ);
     return NS_OK;
   }
-  if (!line)
-    return rv;  /* no line yet */
-
-  if ('.' == line[0])
-  {
+  if (!line) return rv; /* no line yet */
+
+  if ('.' == line[0]) {
     /* all overview lines received */
     m_nextState = NEWS_DONE;
     ClearFlag(NNTP_PAUSE_FOR_READ);
   }
   PR_FREEIF(line);
   return rv;
 }
 
-/* Sets state for the transfer. This used to be known as net_setup_news_stream */
-nsresult nsNNTPProtocol::SetupForTransfer()
-{
-  if (m_typeWanted == NEWS_POST)
-  {
+/* Sets state for the transfer. This used to be known as net_setup_news_stream
+ */
+nsresult nsNNTPProtocol::SetupForTransfer() {
+  if (m_typeWanted == NEWS_POST) {
     m_nextState = NNTP_SEND_POST_DATA;
-  }
-  else if(m_typeWanted == LIST_WANTED)
-  {
+  } else if (m_typeWanted == LIST_WANTED) {
     if (TestFlag(NNTP_USE_FANCY_NEWSGROUP))
       m_nextState = NNTP_LIST_XACTIVE_RESPONSE;
     else
       m_nextState = NNTP_READ_LIST_BEGIN;
-  }
-  else if(m_typeWanted == GROUP_WANTED)
+  } else if (m_typeWanted == GROUP_WANTED)
     m_nextState = NNTP_XOVER_BEGIN;
-  else if(m_typeWanted == NEW_GROUPS)
+  else if (m_typeWanted == NEW_GROUPS)
     m_nextState = NNTP_NEWGROUPS_BEGIN;
-  else if(m_typeWanted == ARTICLE_WANTED ||
-    m_typeWanted== CANCEL_WANTED)
+  else if (m_typeWanted == ARTICLE_WANTED || m_typeWanted == CANCEL_WANTED)
     m_nextState = NNTP_BEGIN_ARTICLE;
-  else if (m_typeWanted== SEARCH_WANTED)
+  else if (m_typeWanted == SEARCH_WANTED)
     m_nextState = NNTP_XPAT_SEND;
-  else
-  {
+  else {
     NS_ERROR("unexpected");
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 // The following method is used for processing the news state machine.
-// It returns a negative number (mscott: we'll change this to be an enumerated type which we'll coordinate
-// with the netlib folks?) when we are done processing.
+// It returns a negative number (mscott: we'll change this to be an enumerated
+// type which we'll coordinate with the netlib folks?) when we are done
+// processing.
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
-nsresult nsNNTPProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
-                                              uint64_t sourceOffset, uint32_t length)
-{
+nsresult nsNNTPProtocol::ProcessProtocolState(nsIURI *url,
+                                              nsIInputStream *inputStream,
+                                              uint64_t sourceOffset,
+                                              uint32_t length) {
   nsresult status = NS_OK;
   nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
-  if (inputStream && (!mailnewsurl || !m_nntpServer))
-  {
+  if (inputStream && (!mailnewsurl || !m_nntpServer)) {
     // In these cases, we are going to return since our data is effectively
     // invalid. However, nsInputStream would really rather that we at least read
     // some of our input data (even if not all of it). Therefore, we'll read a
     // little bit.
     char buffer[128];
     uint32_t readData = 0;
     inputStream->Read(buffer, 127, &readData);
     buffer[readData] = '\0';
     MOZ_LOG(NNTP, LogLevel::Debug, ("(%p) Ignoring data: %s", this, buffer));
   }
 
-  if (!mailnewsurl)
-    return NS_OK; // probably no data available - it's OK.
-
-  if (!m_nntpServer)
-  {
+  if (!mailnewsurl) return NS_OK;  // probably no data available - it's OK.
+
+  if (!m_nntpServer) {
     // Parsing must result in our m_nntpServer being set, so we should never
     // have a case where m_nntpServer being false is safe. Most likely, we have
     // already closed our socket and we are merely flushing out the socket
     // receive queue. Since the user told us to stop, don't process any more
     // input.
     return inputStream ? inputStream->Close() : NS_OK;
   }
 
   ClearFlag(NNTP_PAUSE_FOR_READ);
 
-  while(!TestFlag(NNTP_PAUSE_FOR_READ))
-  {
-    MOZ_LOG(NNTP, LogLevel::Info,("(%p) Next state: %s",this, stateLabels[m_nextState]));
-    // examine our current state and call an appropriate handler for that state.....
-    switch(m_nextState)
-    {
-    case NNTP_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = NewsResponse(inputStream, length);
-      break;
-
-      // mscott: I've removed the states involving connections on the assumption
-      // that core netlib will now be managing that information.
-
-    case NNTP_LOGIN_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = LoginResponse();
-      break;
-
-    case NNTP_SEND_MODE_READER:
-      status = SendModeReader();
-      break;
-
-    case NNTP_SEND_MODE_READER_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendModeReaderResponse();
-      break;
-
-    case SEND_LIST_EXTENSIONS:
-      status = SendListExtensions();
-      break;
-    case SEND_LIST_EXTENSIONS_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendListExtensionsResponse(inputStream, length);
-      break;
-    case SEND_LIST_SEARCHES:
-      status = SendListSearches();
-      break;
-    case SEND_LIST_SEARCHES_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendListSearchesResponse(inputStream, length);
-      break;
-    case NNTP_LIST_SEARCH_HEADERS:
-      status = SendListSearchHeaders();
-      break;
-    case NNTP_LIST_SEARCH_HEADERS_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendListSearchHeadersResponse(inputStream, length);
-      break;
-    case NNTP_GET_PROPERTIES:
-      status = GetProperties();
-      break;
-    case NNTP_GET_PROPERTIES_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = GetPropertiesResponse(inputStream, length);
-      break;
-    case SEND_LIST_SUBSCRIPTIONS:
-      status = SendListSubscriptions();
-      break;
-    case SEND_LIST_SUBSCRIPTIONS_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendListSubscriptionsResponse(inputStream, length);
-      break;
-
-    case SEND_FIRST_NNTP_COMMAND:
-      status = SendFirstNNTPCommand(url);
-      break;
-    case SEND_FIRST_NNTP_COMMAND_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendFirstNNTPCommandResponse();
-      break;
-
-    case NNTP_SEND_GROUP_FOR_ARTICLE:
-      status = SendGroupForArticle();
-      break;
-    case NNTP_SEND_GROUP_FOR_ARTICLE_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendGroupForArticleResponse();
-      break;
-    case NNTP_SEND_ARTICLE_NUMBER:
-      status = SendArticleNumber();
-      break;
-
-    case SETUP_NEWS_STREAM:
-      status = SetupForTransfer();
-      break;
-
-    case NNTP_BEGIN_AUTHORIZE:
-      status = BeginAuthorization();
-      break;
-
-    case NNTP_AUTHORIZE_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = AuthorizationResponse();
-      break;
-
-    case NNTP_PASSWORD_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = PasswordResponse();
-      break;
-
-      // read list
-    case NNTP_READ_LIST_BEGIN:
-      status = BeginReadNewsList();
-      break;
-    case NNTP_READ_LIST:
-      status = ReadNewsList(inputStream, length);
-      break;
-
-      // news group
-    case DISPLAY_NEWSGROUPS:
-      status = DisplayNewsgroups();
-      break;
-    case NNTP_NEWGROUPS_BEGIN:
-      status = BeginNewsgroups();
-      break;
-    case NNTP_NEWGROUPS:
-      status = ProcessNewsgroups(inputStream, length);
-      break;
-
-      // article specific
-    case NNTP_BEGIN_ARTICLE:
-      status = BeginArticle();
-      break;
-
-    case NNTP_READ_ARTICLE:
-      status = ReadArticle(inputStream, length);
-      break;
-
-    case NNTP_XOVER_BEGIN:
-      status = BeginReadXover();
-      break;
-
-    case NNTP_FIGURE_NEXT_CHUNK:
-      status = FigureNextChunk();
-      break;
-
-    case NNTP_XOVER_SEND:
-      status = XoverSend();
-      break;
-
-    case NNTP_XOVER:
-      status = ReadXover(inputStream, length);
-      break;
-
-    case NNTP_XOVER_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = ReadXoverResponse();
-      break;
-
-    case NEWS_PROCESS_XOVER:
-    case NEWS_PROCESS_BODIES:
-      status = ProcessXover();
-      break;
-
-    case NNTP_XHDR_SEND:
-      status = XhdrSend();
-      break;
-
-    case NNTP_XHDR_RESPONSE:
-      status = XhdrResponse(inputStream);
-      break;
-
-    case NNTP_READ_GROUP:
-      status = ReadHeaders();
-      break;
-
-    case NNTP_READ_GROUP_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = ReadNewsgroupResponse();
-      break;
-
-    case NNTP_READ_GROUP_BODY:
-      status = ReadNewsgroupBody(inputStream, length);
-      break;
-
-    case NNTP_SEND_POST_DATA:
-      status = PostData();
-      break;
-    case NNTP_SEND_POST_DATA_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = PostDataResponse();
-      break;
-
-    case NNTP_CHECK_FOR_MESSAGE:
-      status = CheckForArticle();
-      break;
-
-      // cancel
-    case NEWS_START_CANCEL:
-      status = StartCancel();
-      break;
-
-    case NEWS_DO_CANCEL:
-      status = DoCancel();
-      break;
-
-      // XPAT
-    case NNTP_XPAT_SEND:
-      status = XPATSend();
-      break;
-    case NNTP_XPAT_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = XPATResponse(inputStream, length);
-      break;
-
-      // search
-    case NNTP_SEARCH:
-      status = Search();
-      break;
-    case NNTP_SEARCH_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SearchResponse();
-      break;
-    case NNTP_SEARCH_RESULTS:
-      status = SearchResults(inputStream, length);
-      break;
-
-
-    case NNTP_LIST_PRETTY_NAMES:
-      status = ListPrettyNames();
-      break;
-    case NNTP_LIST_PRETTY_NAMES_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = ListPrettyNamesResponse(inputStream, length);
-      break;
-    case NNTP_LIST_XACTIVE:
-      status = ListXActive();
-      break;
-    case NNTP_LIST_XACTIVE_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = ListXActiveResponse(inputStream, length);
-      break;
-    case NNTP_LIST_GROUP:
-      status = SendListGroup();
-      break;
-    case NNTP_LIST_GROUP_RESPONSE:
-      if (inputStream == nullptr)
-        SetFlag(NNTP_PAUSE_FOR_READ);
-      else
-        status = SendListGroupResponse(inputStream, length);
-      break;
-    case NEWS_DONE:
-      m_nextState = NEWS_FREE;
-      break;
-    case NEWS_POST_DONE:
-      NNTP_LOG_NOTE("NEWS_POST_DONE");
-      mailnewsurl->SetUrlState(false, NS_OK);
-      m_nextState = NEWS_FREE;
-      break;
-    case NEWS_ERROR:
-      NNTP_LOG_NOTE("NEWS_ERROR");
-      if (m_responseCode == MK_NNTP_RESPONSE_ARTICLE_NOTFOUND || m_responseCode == MK_NNTP_RESPONSE_ARTICLE_NONEXIST)
-        mailnewsurl->SetUrlState(false, NS_MSG_NEWS_ARTICLE_NOT_FOUND);
-      else
-        mailnewsurl->SetUrlState(false, NS_ERROR_FAILURE);
-      m_nextState = NEWS_FREE;
-      break;
-    case NNTP_ERROR:
-      // XXX do we really want to remove the connection from
-      // the cache on error?
-      /* check if this connection came from the cache or if it was
-      * a new connection.  If it was not new lets start it over
-      * again.  But only if we didn't have any successful protocol
-      * dialog at all.
-      */
-      FinishMemCacheEntry(false);  // cleanup mem cache entry
-      if (m_responseCode != MK_NNTP_RESPONSE_ARTICLE_NOTFOUND && m_responseCode != MK_NNTP_RESPONSE_ARTICLE_NONEXIST)
-        return CloseConnection();
-      MOZ_FALLTHROUGH;
-    case NEWS_FREE:
-      // Remember when we last used this connection
-      m_lastActiveTimeStamp = PR_Now();
-      CleanupAfterRunningUrl();
-      MOZ_FALLTHROUGH;
-    case NNTP_SUSPENDED:
-      return NS_OK;
-      break;
-    default:
-      /* big error */
-      return NS_ERROR_FAILURE;
-
-    } // end switch
+  while (!TestFlag(NNTP_PAUSE_FOR_READ)) {
+    MOZ_LOG(NNTP, LogLevel::Info,
+            ("(%p) Next state: %s", this, stateLabels[m_nextState]));
+    // examine our current state and call an appropriate handler for that
+    // state.....
+    switch (m_nextState) {
+      case NNTP_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = NewsResponse(inputStream, length);
+        break;
+
+        // mscott: I've removed the states involving connections on the
+        // assumption that core netlib will now be managing that information.
+
+      case NNTP_LOGIN_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = LoginResponse();
+        break;
+
+      case NNTP_SEND_MODE_READER:
+        status = SendModeReader();
+        break;
+
+      case NNTP_SEND_MODE_READER_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendModeReaderResponse();
+        break;
+
+      case SEND_LIST_EXTENSIONS:
+        status = SendListExtensions();
+        break;
+      case SEND_LIST_EXTENSIONS_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendListExtensionsResponse(inputStream, length);
+        break;
+      case SEND_LIST_SEARCHES:
+        status = SendListSearches();
+        break;
+      case SEND_LIST_SEARCHES_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendListSearchesResponse(inputStream, length);
+        break;
+      case NNTP_LIST_SEARCH_HEADERS:
+        status = SendListSearchHeaders();
+        break;
+      case NNTP_LIST_SEARCH_HEADERS_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendListSearchHeadersResponse(inputStream, length);
+        break;
+      case NNTP_GET_PROPERTIES:
+        status = GetProperties();
+        break;
+      case NNTP_GET_PROPERTIES_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = GetPropertiesResponse(inputStream, length);
+        break;
+      case SEND_LIST_SUBSCRIPTIONS:
+        status = SendListSubscriptions();
+        break;
+      case SEND_LIST_SUBSCRIPTIONS_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendListSubscriptionsResponse(inputStream, length);
+        break;
+
+      case SEND_FIRST_NNTP_COMMAND:
+        status = SendFirstNNTPCommand(url);
+        break;
+      case SEND_FIRST_NNTP_COMMAND_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendFirstNNTPCommandResponse();
+        break;
+
+      case NNTP_SEND_GROUP_FOR_ARTICLE:
+        status = SendGroupForArticle();
+        break;
+      case NNTP_SEND_GROUP_FOR_ARTICLE_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendGroupForArticleResponse();
+        break;
+      case NNTP_SEND_ARTICLE_NUMBER:
+        status = SendArticleNumber();
+        break;
+
+      case SETUP_NEWS_STREAM:
+        status = SetupForTransfer();
+        break;
+
+      case NNTP_BEGIN_AUTHORIZE:
+        status = BeginAuthorization();
+        break;
+
+      case NNTP_AUTHORIZE_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = AuthorizationResponse();
+        break;
+
+      case NNTP_PASSWORD_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = PasswordResponse();
+        break;
+
+        // read list
+      case NNTP_READ_LIST_BEGIN:
+        status = BeginReadNewsList();
+        break;
+      case NNTP_READ_LIST:
+        status = ReadNewsList(inputStream, length);
+        break;
+
+        // news group
+      case DISPLAY_NEWSGROUPS:
+        status = DisplayNewsgroups();
+        break;
+      case NNTP_NEWGROUPS_BEGIN:
+        status = BeginNewsgroups();
+        break;
+      case NNTP_NEWGROUPS:
+        status = ProcessNewsgroups(inputStream, length);
+        break;
+
+        // article specific
+      case NNTP_BEGIN_ARTICLE:
+        status = BeginArticle();
+        break;
+
+      case NNTP_READ_ARTICLE:
+        status = ReadArticle(inputStream, length);
+        break;
+
+      case NNTP_XOVER_BEGIN:
+        status = BeginReadXover();
+        break;
+
+      case NNTP_FIGURE_NEXT_CHUNK:
+        status = FigureNextChunk();
+        break;
+
+      case NNTP_XOVER_SEND:
+        status = XoverSend();
+        break;
+
+      case NNTP_XOVER:
+        status = ReadXover(inputStream, length);
+        break;
+
+      case NNTP_XOVER_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = ReadXoverResponse();
+        break;
+
+      case NEWS_PROCESS_XOVER:
+      case NEWS_PROCESS_BODIES:
+        status = ProcessXover();
+        break;
+
+      case NNTP_XHDR_SEND:
+        status = XhdrSend();
+        break;
+
+      case NNTP_XHDR_RESPONSE:
+        status = XhdrResponse(inputStream);
+        break;
+
+      case NNTP_READ_GROUP:
+        status = ReadHeaders();
+        break;
+
+      case NNTP_READ_GROUP_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = ReadNewsgroupResponse();
+        break;
+
+      case NNTP_READ_GROUP_BODY:
+        status = ReadNewsgroupBody(inputStream, length);
+        break;
+
+      case NNTP_SEND_POST_DATA:
+        status = PostData();
+        break;
+      case NNTP_SEND_POST_DATA_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = PostDataResponse();
+        break;
+
+      case NNTP_CHECK_FOR_MESSAGE:
+        status = CheckForArticle();
+        break;
+
+        // cancel
+      case NEWS_START_CANCEL:
+        status = StartCancel();
+        break;
+
+      case NEWS_DO_CANCEL:
+        status = DoCancel();
+        break;
+
+        // XPAT
+      case NNTP_XPAT_SEND:
+        status = XPATSend();
+        break;
+      case NNTP_XPAT_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = XPATResponse(inputStream, length);
+        break;
+
+        // search
+      case NNTP_SEARCH:
+        status = Search();
+        break;
+      case NNTP_SEARCH_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SearchResponse();
+        break;
+      case NNTP_SEARCH_RESULTS:
+        status = SearchResults(inputStream, length);
+        break;
+
+      case NNTP_LIST_PRETTY_NAMES:
+        status = ListPrettyNames();
+        break;
+      case NNTP_LIST_PRETTY_NAMES_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = ListPrettyNamesResponse(inputStream, length);
+        break;
+      case NNTP_LIST_XACTIVE:
+        status = ListXActive();
+        break;
+      case NNTP_LIST_XACTIVE_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = ListXActiveResponse(inputStream, length);
+        break;
+      case NNTP_LIST_GROUP:
+        status = SendListGroup();
+        break;
+      case NNTP_LIST_GROUP_RESPONSE:
+        if (inputStream == nullptr)
+          SetFlag(NNTP_PAUSE_FOR_READ);
+        else
+          status = SendListGroupResponse(inputStream, length);
+        break;
+      case NEWS_DONE:
+        m_nextState = NEWS_FREE;
+        break;
+      case NEWS_POST_DONE:
+        NNTP_LOG_NOTE("NEWS_POST_DONE");
+        mailnewsurl->SetUrlState(false, NS_OK);
+        m_nextState = NEWS_FREE;
+        break;
+      case NEWS_ERROR:
+        NNTP_LOG_NOTE("NEWS_ERROR");
+        if (m_responseCode == MK_NNTP_RESPONSE_ARTICLE_NOTFOUND ||
+            m_responseCode == MK_NNTP_RESPONSE_ARTICLE_NONEXIST)
+          mailnewsurl->SetUrlState(false, NS_MSG_NEWS_ARTICLE_NOT_FOUND);
+        else
+          mailnewsurl->SetUrlState(false, NS_ERROR_FAILURE);
+        m_nextState = NEWS_FREE;
+        break;
+      case NNTP_ERROR:
+        // XXX do we really want to remove the connection from
+        // the cache on error?
+        /* check if this connection came from the cache or if it was
+         * a new connection.  If it was not new lets start it over
+         * again.  But only if we didn't have any successful protocol
+         * dialog at all.
+         */
+        FinishMemCacheEntry(false);  // cleanup mem cache entry
+        if (m_responseCode != MK_NNTP_RESPONSE_ARTICLE_NOTFOUND &&
+            m_responseCode != MK_NNTP_RESPONSE_ARTICLE_NONEXIST)
+          return CloseConnection();
+        MOZ_FALLTHROUGH;
+      case NEWS_FREE:
+        // Remember when we last used this connection
+        m_lastActiveTimeStamp = PR_Now();
+        CleanupAfterRunningUrl();
+        MOZ_FALLTHROUGH;
+      case NNTP_SUSPENDED:
+        return NS_OK;
+        break;
+      default:
+        /* big error */
+        return NS_ERROR_FAILURE;
+
+    }  // end switch
 
     if (NS_FAILED(status) && m_nextState != NEWS_ERROR &&
-        m_nextState != NNTP_ERROR && m_nextState != NEWS_FREE)
-    {
+        m_nextState != NNTP_ERROR && m_nextState != NEWS_FREE) {
       m_nextState = NNTP_ERROR;
       ClearFlag(NNTP_PAUSE_FOR_READ);
     }
 
   } /* end big while */
 
   return NS_OK; /* keep going */
 }
 
-NS_IMETHODIMP nsNNTPProtocol::CloseConnection()
-{
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) ClosingConnection",this));
-  SendData(NNTP_CMD_QUIT); // this will cause OnStopRequest get called, which will call CloseSocket()
+NS_IMETHODIMP nsNNTPProtocol::CloseConnection() {
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) ClosingConnection", this));
+  SendData(NNTP_CMD_QUIT);  // this will cause OnStopRequest get called, which
+                            // will call CloseSocket()
   // break some cycles
   CleanupNewsgroupList();
 
   if (m_nntpServer) {
     m_nntpServer->RemoveConnection(this);
     m_nntpServer = nullptr;
   }
   CloseSocket();
@@ -4630,54 +4322,50 @@ NS_IMETHODIMP nsNNTPProtocol::CloseConne
     m_articleList->FinishAddingArticleKeys();
     m_articleList = nullptr;
   }
 
   m_key = nsMsgKey_None;
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::CleanupNewsgroupList()
-{
-    nsresult rv;
-    if (!m_newsgroupList) return NS_OK;
+nsresult nsNNTPProtocol::CleanupNewsgroupList() {
+  nsresult rv;
+  if (!m_newsgroupList) return NS_OK;
   int32_t status = 0;
-    rv = m_newsgroupList->FinishXOVERLINE(0,&status);
-    m_newsgroupList = nullptr;
-    NS_ASSERTION(NS_SUCCEEDED(rv), "FinishXOVERLINE failed");
-    return rv;
+  rv = m_newsgroupList->FinishXOVERLINE(0, &status);
+  m_newsgroupList = nullptr;
+  NS_ASSERTION(NS_SUCCEEDED(rv), "FinishXOVERLINE failed");
+  return rv;
 }
 
-nsresult nsNNTPProtocol::CleanupAfterRunningUrl()
-{
+nsresult nsNNTPProtocol::CleanupAfterRunningUrl() {
   /* do we need to know if we're parsing xover to call finish xover?  */
   /* yes, I think we do! Why did I think we should??? */
   /* If we've gotten to NEWS_FREE and there is still XOVER
   data, there was an error or we were interrupted or
   something.  So, tell libmsg there was an abnormal
   exit so that it can free its data. */
 
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) CleanupAfterRunningUrl()", this));
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) CleanupAfterRunningUrl()", this));
 
   // send StopRequest notification after we've cleaned up the protocol
   // because it can synchronously causes a new url to get run in the
   // protocol - truly evil, but we're stuck at the moment.
-  if (m_channelListener)
-    (void) m_channelListener->OnStopRequest(this, NS_OK);
+  if (m_channelListener) (void)m_channelListener->OnStopRequest(this, NS_OK);
 
   if (m_loadGroup)
-    (void) m_loadGroup->RemoveRequest(static_cast<nsIRequest *>(this), nullptr, NS_OK);
+    (void)m_loadGroup->RemoveRequest(static_cast<nsIRequest *>(this), nullptr,
+                                     NS_OK);
   CleanupNewsgroupList();
 
   // clear out mem cache entry so we're not holding onto it.
-  if (m_runningURL)
-  {
+  if (m_runningURL) {
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
-    if (mailnewsurl)
-    {
+    if (mailnewsurl) {
       mailnewsurl->SetUrlState(false, NS_OK);
       mailnewsurl->SetMemCacheEntry(nullptr);
     }
   }
 
   Cleanup();
 
   mDisplayInputStream = nullptr;
@@ -4690,101 +4378,92 @@ nsresult nsNNTPProtocol::CleanupAfterRun
   m_loadGroup = nullptr;
   mCallbacks = nullptr;
 
   // disable timeout before caching.
   nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport);
   if (strans)
     strans->SetTimeout(nsISocketTransport::TIMEOUT_READ_WRITE, PR_UINT32_MAX);
 
-  // don't mark ourselves as not busy until we are done cleaning up the connection. it should be the
-  // last thing we do.
+  // don't mark ourselves as not busy until we are done cleaning up the
+  // connection. it should be the last thing we do.
   SetIsBusy(false);
 
   return NS_OK;
 }
 
-nsresult nsNNTPProtocol::CloseSocket()
-{
-  MOZ_LOG(NNTP, LogLevel::Info,("(%p) ClosingSocket()",this));
+nsresult nsNNTPProtocol::CloseSocket() {
+  MOZ_LOG(NNTP, LogLevel::Info, ("(%p) ClosingSocket()", this));
 
   if (m_nntpServer) {
     m_nntpServer->RemoveConnection(this);
     m_nntpServer = nullptr;
   }
 
-  CleanupAfterRunningUrl(); // is this needed?
+  CleanupAfterRunningUrl();  // is this needed?
   return nsMsgProtocol::CloseSocket();
 }
 
-void nsNNTPProtocol::SetProgressBarPercent(uint32_t aProgress, uint32_t aProgressMax)
-{
+void nsNNTPProtocol::SetProgressBarPercent(uint32_t aProgress,
+                                           uint32_t aProgressMax) {
   // XXX 64-bit
   if (mProgressEventSink)
     mProgressEventSink->OnProgress(this, m_channelContext, uint64_t(aProgress),
                                    uint64_t(aProgressMax));
 }
 
-nsresult
-nsNNTPProtocol::SetProgressStatus(const char16_t *aMessage)
-{
+nsresult nsNNTPProtocol::SetProgressStatus(const char16_t *aMessage) {
   nsresult rv = NS_OK;
   if (mProgressEventSink)
     rv = mProgressEventSink->OnStatus(this, m_channelContext, NS_OK, aMessage);
   return rv;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::GetContentType(nsACString &aContentType)
-{
-
+NS_IMETHODIMP nsNNTPProtocol::GetContentType(nsACString &aContentType) {
   // if we've been set with a content type, then return it....
   // this happens when we go through libmime now as it sets our new content type
-  if (!mContentType.IsEmpty())
-  {
+  if (!mContentType.IsEmpty()) {
     aContentType = mContentType;
     return NS_OK;
   }
 
   // otherwise do what we did before...
 
   if (m_typeWanted == GROUP_WANTED)
     aContentType.AssignLiteral("x-application-newsgroup");
   else if (m_typeWanted == IDS_WANTED)
     aContentType.AssignLiteral("x-application-newsgroup-listids");
   else
     aContentType.AssignLiteral("message/rfc822");
   return NS_OK;
 }
 
-nsresult
-nsNNTPProtocol::AlertError(int32_t errorCode, const char *text)
-{
+nsresult nsNNTPProtocol::AlertError(int32_t errorCode, const char *text) {
   nsresult rv = NS_OK;
 
   // get the prompt from the running url....
   if (m_runningURL) {
-    nsCOMPtr<nsIMsgMailNewsUrl> msgUrl (do_QueryInterface(m_runningURL));
+    nsCOMPtr<nsIMsgMailNewsUrl> msgUrl(do_QueryInterface(m_runningURL));
     nsCOMPtr<nsIPrompt> dialog;
     rv = GetPromptDialogFromUrl(msgUrl, getter_AddRefs(dialog));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsString alertText;
     rv = GetNewsStringByID(MK_NNTP_ERROR_MESSAGE, getter_Copies(alertText));
-    NS_ENSURE_SUCCESS(rv,rv);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (text) {
       alertText.Append(' ');
       alertText.Append(NS_ConvertASCIItoUTF16(text));
     }
     rv = dialog->Alert(nullptr, alertText.get());
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return rv;
 }
 
-NS_IMETHODIMP nsNNTPProtocol::GetCurrentFolder(nsIMsgFolder **aFolder)
-{
+NS_IMETHODIMP nsNNTPProtocol::GetCurrentFolder(nsIMsgFolder **aFolder) {
   nsresult rv = NS_ERROR_NULL_POINTER;
   NS_ENSURE_ARG_POINTER(aFolder);
   if (m_newsFolder)
-    rv = m_newsFolder->QueryInterface(NS_GET_IID(nsIMsgFolder), (void **) aFolder);
+    rv = m_newsFolder->QueryInterface(NS_GET_IID(nsIMsgFolder),
+                                      (void **)aFolder);
   return rv;
 }
-
--- a/mailnews/news/src/nsNNTPProtocol.h
+++ b/mailnews/news/src/nsNNTPProtocol.h
@@ -29,138 +29,142 @@
 
 // this is only needed as long as our libmime hack is in place
 #include "prio.h"
 
 // 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 NNTP_PAUSE_FOR_READ      0x00000001  /* should we pause for the next read */
-#define NNTP_PROXY_AUTH_REQUIRED    0x00000002  /* is auth required */
-#define NNTP_SENT_PROXY_AUTH        0x00000004  /* have we sent a proxy auth? */
-#define NNTP_READER_PERFORMED       0x00000010  /* have we sent any cmds to the server yet? */
-#define NNTP_USE_FANCY_NEWSGROUP    0x00000020  /* use LIST XACTIVE or LIST */
-#define NNTP_DESTROY_PROGRESS_GRAPH 0x00000040  /* do we need to destroy graph progress */
-#define NNTP_SOME_PROTOCOL_SUCCEEDED 0x0000080  /* some protocol has succeeded so don't kill the connection */
-#define NNTP_NO_XOVER_SUPPORT       0x00000100  /* xover command is not supported here */
+#define NNTP_PAUSE_FOR_READ 0x00000001 /* should we pause for the next read */
+#define NNTP_PROXY_AUTH_REQUIRED 0x00000002 /* is auth required */
+#define NNTP_SENT_PROXY_AUTH 0x00000004     /* have we sent a proxy auth? */
+#define NNTP_READER_PERFORMED \
+  0x00000010 /* have we sent any cmds to the server yet? */
+#define NNTP_USE_FANCY_NEWSGROUP 0x00000020 /* use LIST XACTIVE or LIST */
+#define NNTP_DESTROY_PROGRESS_GRAPH \
+  0x00000040 /* do we need to destroy graph progress */
+#define NNTP_SOME_PROTOCOL_SUCCEEDED \
+  0x0000080 /* some protocol has succeeded so don't kill the connection */
+#define NNTP_NO_XOVER_SUPPORT \
+  0x00000100 /* xover command is not supported here */
 
 /* states of the machine
  */
 typedef enum _StatesEnum {
-NNTP_RESPONSE,
+  NNTP_RESPONSE,
 #ifdef BLOCK_UNTIL_AVAILABLE_CONNECTION
-NNTP_BLOCK_UNTIL_CONNECTIONS_ARE_AVAILABLE,
-NNTP_CONNECTIONS_ARE_AVAILABLE,
+  NNTP_BLOCK_UNTIL_CONNECTIONS_ARE_AVAILABLE,
+  NNTP_CONNECTIONS_ARE_AVAILABLE,
 #endif
-NNTP_CONNECT,
-NNTP_CONNECT_WAIT,
-NNTP_LOGIN_RESPONSE,
-NNTP_SEND_MODE_READER,
-NNTP_SEND_MODE_READER_RESPONSE,
-SEND_LIST_EXTENSIONS,
-SEND_LIST_EXTENSIONS_RESPONSE,
-SEND_LIST_SEARCHES,
-SEND_LIST_SEARCHES_RESPONSE,
-NNTP_LIST_SEARCH_HEADERS,
-NNTP_LIST_SEARCH_HEADERS_RESPONSE,
-NNTP_GET_PROPERTIES,
-NNTP_GET_PROPERTIES_RESPONSE,
-SEND_LIST_SUBSCRIPTIONS,
-SEND_LIST_SUBSCRIPTIONS_RESPONSE,
-SEND_FIRST_NNTP_COMMAND,
-SEND_FIRST_NNTP_COMMAND_RESPONSE,
-SETUP_NEWS_STREAM,
-NNTP_BEGIN_AUTHORIZE,
-NNTP_AUTHORIZE_RESPONSE,
-NNTP_PASSWORD_RESPONSE,
-NNTP_READ_LIST_BEGIN,
-NNTP_READ_LIST,
-DISPLAY_NEWSGROUPS,
-NNTP_NEWGROUPS_BEGIN,
-NNTP_NEWGROUPS,
-NNTP_BEGIN_ARTICLE,
-NNTP_READ_ARTICLE,
-NNTP_XOVER_BEGIN,
-NNTP_FIGURE_NEXT_CHUNK,
-NNTP_XOVER_SEND,
-NNTP_XOVER_RESPONSE,
-NNTP_XOVER,
-NEWS_PROCESS_XOVER,
-NNTP_XHDR_SEND,
-NNTP_XHDR_RESPONSE,
-NNTP_READ_GROUP,
-NNTP_READ_GROUP_RESPONSE,
-NNTP_READ_GROUP_BODY,
-NNTP_SEND_GROUP_FOR_ARTICLE,
-NNTP_SEND_GROUP_FOR_ARTICLE_RESPONSE,
-NNTP_SEND_ARTICLE_NUMBER,
-NEWS_PROCESS_BODIES,
-NNTP_PRINT_ARTICLE_HEADERS,
-NNTP_SEND_POST_DATA,
-NNTP_SEND_POST_DATA_RESPONSE,
-NNTP_CHECK_FOR_MESSAGE,
-NEWS_START_CANCEL,
-NEWS_DO_CANCEL,
-NNTP_XPAT_SEND,
-NNTP_XPAT_RESPONSE,
-NNTP_SEARCH,
-NNTP_SEARCH_RESPONSE,
-NNTP_SEARCH_RESULTS,
-NNTP_LIST_PRETTY_NAMES,
-NNTP_LIST_PRETTY_NAMES_RESPONSE,
-NNTP_LIST_XACTIVE,
-NNTP_LIST_XACTIVE_RESPONSE,
-NNTP_LIST_GROUP,
-NNTP_LIST_GROUP_RESPONSE,
-NEWS_DONE,
-NEWS_POST_DONE,
-NEWS_ERROR,
-NNTP_ERROR,
-NEWS_FREE,
-NNTP_SUSPENDED
+  NNTP_CONNECT,
+  NNTP_CONNECT_WAIT,
+  NNTP_LOGIN_RESPONSE,
+  NNTP_SEND_MODE_READER,
+  NNTP_SEND_MODE_READER_RESPONSE,
+  SEND_LIST_EXTENSIONS,
+  SEND_LIST_EXTENSIONS_RESPONSE,
+  SEND_LIST_SEARCHES,
+  SEND_LIST_SEARCHES_RESPONSE,
+  NNTP_LIST_SEARCH_HEADERS,
+  NNTP_LIST_SEARCH_HEADERS_RESPONSE,
+  NNTP_GET_PROPERTIES,
+  NNTP_GET_PROPERTIES_RESPONSE,
+  SEND_LIST_SUBSCRIPTIONS,
+  SEND_LIST_SUBSCRIPTIONS_RESPONSE,
+  SEND_FIRST_NNTP_COMMAND,
+  SEND_FIRST_NNTP_COMMAND_RESPONSE,
+  SETUP_NEWS_STREAM,
+  NNTP_BEGIN_AUTHORIZE,
+  NNTP_AUTHORIZE_RESPONSE,
+  NNTP_PASSWORD_RESPONSE,
+  NNTP_READ_LIST_BEGIN,
+  NNTP_READ_LIST,
+  DISPLAY_NEWSGROUPS,
+  NNTP_NEWGROUPS_BEGIN,
+  NNTP_NEWGROUPS,
+  NNTP_BEGIN_ARTICLE,
+  NNTP_READ_ARTICLE,
+  NNTP_XOVER_BEGIN,
+  NNTP_FIGURE_NEXT_CHUNK,
+  NNTP_XOVER_SEND,
+  NNTP_XOVER_RESPONSE,
+  NNTP_XOVER,
+  NEWS_PROCESS_XOVER,
+  NNTP_XHDR_SEND,
+  NNTP_XHDR_RESPONSE,
+  NNTP_READ_GROUP,
+  NNTP_READ_GROUP_RESPONSE,
+  NNTP_READ_GROUP_BODY,
+  NNTP_SEND_GROUP_FOR_ARTICLE,
+  NNTP_SEND_GROUP_FOR_ARTICLE_RESPONSE,
+  NNTP_SEND_ARTICLE_NUMBER,
+  NEWS_PROCESS_BODIES,
+  NNTP_PRINT_ARTICLE_HEADERS,
+  NNTP_SEND_POST_DATA,
+  NNTP_SEND_POST_DATA_RESPONSE,
+  NNTP_CHECK_FOR_MESSAGE,
+  NEWS_START_CANCEL,
+  NEWS_DO_CANCEL,
+  NNTP_XPAT_SEND,
+  NNTP_XPAT_RESPONSE,
+  NNTP_SEARCH,
+  NNTP_SEARCH_RESPONSE,
+  NNTP_SEARCH_RESULTS,
+  NNTP_LIST_PRETTY_NAMES,
+  NNTP_LIST_PRETTY_NAMES_RESPONSE,
+  NNTP_LIST_XACTIVE,
+  NNTP_LIST_XACTIVE_RESPONSE,
+  NNTP_LIST_GROUP,
+  NNTP_LIST_GROUP_RESPONSE,
+  NEWS_DONE,
+  NEWS_POST_DONE,
+  NEWS_ERROR,
+  NNTP_ERROR,
+  NEWS_FREE,
+  NNTP_SUSPENDED
 } StatesEnum;
 
 class nsICacheEntry;
 
 class nsNNTPProtocol : public nsMsgProtocol,
                        public nsINNTPProtocol,
                        public nsITimerCallback,
                        public nsICacheEntryOpenCallback,
                        public nsIMsgAsyncPromptListener,
-                       public nsIProtocolProxyCallback
-{
-public:
+                       public nsIProtocolProxyCallback {
+ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSINNTPPROTOCOL
   NS_DECL_NSICACHEENTRYOPENCALLBACK
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_NSIMSGASYNCPROMPTLISTENER
   NS_DECL_NSIPROTOCOLPROXYCALLBACK
 
   // Creating a protocol instance requires the URL
   // need to call Initialize after we do a new of nsNNTPProtocol
   nsNNTPProtocol(nsINntpIncomingServer *aServer, nsIURI *aURL,
                  nsIMsgWindow *aMsgWindow);
 
-  // stop binding is a "notification" informing us that the stream associated with aURL is going away.
+  // stop binding is a "notification" informing us that the stream associated
+  // with aURL is going away.
   NS_IMETHOD OnStopRequest(nsIRequest *request, nsresult aStatus) override;
 
-  char * m_ProxyServer;    /* proxy server hostname */
+  char *m_ProxyServer; /* proxy server hostname */
 
   NS_IMETHOD Cancel(nsresult status) override;  // handle stop button
   NS_IMETHOD GetContentType(nsACString &aContentType) override;
   NS_IMETHOD AsyncOpen(nsIStreamListener *listener) override;
-  NS_IMETHOD GetOriginalURI(nsIURI* *aURI) override;
-  NS_IMETHOD SetOriginalURI(nsIURI* aURI) override;
+  NS_IMETHOD GetOriginalURI(nsIURI **aURI) override;
+  NS_IMETHOD SetOriginalURI(nsIURI *aURI) override;
   void PostLoadAssertions();
 
-  nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer) override;
+  nsresult LoadUrl(nsIURI *aURL, nsISupports *aConsumer) override;
 
-private:
+ private:
   virtual ~nsNNTPProtocol();
   /**
    * Triggers the protocol state machine.
    * Most of the time, this machine will read as much input as it can before
    * closing.
    *
    * This method additionally handles some states not covered by other methods:
    * NEWS_DONE: Alias for NEWS_FREE
@@ -170,138 +174,151 @@ private:
    * NEWS_FREE: Cleans up from the current URL and prepares for the next one
    * NNTP_SUSPENDED: A state where the state machine does not read input until
    *                 re-enabled by a non-network related callback
    *
    * @note Use of NNTP_SUSPENDED is dangerous: if input comes along the socket,
    * the code will not read the input stream at all. Therefore, it is strongly
    * advised to suspend the request before using this state.
    */
-  virtual nsresult ProcessProtocolState(nsIURI * url, nsIInputStream * inputStream,
-                                        uint64_t sourceOffset, uint32_t length) override;
+  virtual nsresult ProcessProtocolState(nsIURI *url,
+                                        nsIInputStream *inputStream,
+                                        uint64_t sourceOffset,
+                                        uint32_t length) override;
   virtual nsresult CloseSocket() override;
 
   // we have our own implementation of SendData which writes to the nntp log
   // and then calls the base class to transmit the data
-  nsresult SendData(const char * dataBuffer, bool aSuppressLogging = false) override;
+  nsresult SendData(const char *dataBuffer,
+                    bool aSuppressLogging = false) override;
 
-  nsresult LoadUrlInternal(nsIProxyInfo* aProxyInfo);
+  nsresult LoadUrlInternal(nsIProxyInfo *aProxyInfo);
   nsresult CleanupAfterRunningUrl();
-  void Cleanup(); //free char* member variables
+  void Cleanup();  // free char* member variables
 
   void ParseHeaderForCancel(char *buf);
 
-  virtual const char* GetType() override { return "nntp"; }
+  virtual const char *GetType() override { return "nntp"; }
 
-  static void CheckIfAuthor(nsIMsgIdentity *aIdentity, const nsCString &aOldFrom, nsCString &aFrom);
+  static void CheckIfAuthor(nsIMsgIdentity *aIdentity,
+                            const nsCString &aOldFrom, nsCString &aFrom);
 
-  nsCOMPtr <nsINNTPNewsgroupList> m_newsgroupList;
-  nsCOMPtr <nsINNTPArticleList> m_articleList;
+  nsCOMPtr<nsINNTPNewsgroupList> m_newsgroupList;
+  nsCOMPtr<nsINNTPArticleList> m_articleList;
 
-  nsCOMPtr <nsIMsgNewsFolder> m_newsFolder;
-  nsCOMPtr <nsIMsgWindow> m_msgWindow;
+  nsCOMPtr<nsIMsgNewsFolder> m_newsFolder;
+  nsCOMPtr<nsIMsgWindow> m_msgWindow;
 
   nsCOMPtr<nsIAsyncInputStream> mDisplayInputStream;
   nsCOMPtr<nsIAsyncOutputStream> mDisplayOutputStream;
-  RefPtr<nsMsgLineStreamBuffer> m_lineStreamBuffer; // used to efficiently extract lines from the incoming data stream
+  RefPtr<nsMsgLineStreamBuffer>
+      m_lineStreamBuffer;  // used to efficiently extract lines from the
+                           // incoming data stream
   // the nsINntpURL that is currently running
   nsCOMPtr<nsINntpUrl> m_runningURL;
-  bool        m_connectionBusy;
-  bool        m_fromCache;  // is this connection from the cache?
-  PRTime      m_lastActiveTimeStamp;
+  bool m_connectionBusy;
+  bool m_fromCache;  // is this connection from the cache?
+  PRTime m_lastActiveTimeStamp;
   nsNewsAction m_newsAction;
-  nsCOMPtr <nsISupports> m_consumer;
+  nsCOMPtr<nsISupports> m_consumer;
 
-  // 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.
-  StatesEnum  m_nextState;
-  StatesEnum  m_nextStateAfterResponse;
-  int32_t     m_typeWanted;     /* Article, List, or Group */
-  int32_t     m_responseCode;    /* code returned from NNTP server */
-  int32_t   m_previousResponseCode;
-  char       *m_responseText;   /* text returned from NNTP server */
+  // 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.
+  StatesEnum m_nextState;
+  StatesEnum m_nextStateAfterResponse;
+  int32_t m_typeWanted;   /* Article, List, or Group */
+  int32_t m_responseCode; /* code returned from NNTP server */
+  int32_t m_previousResponseCode;
+  char *m_responseText; /* text returned from NNTP server */
 
-  char    *m_dataBuf;
-  uint32_t   m_dataBufSize;
+  char *m_dataBuf;
+  uint32_t m_dataBufSize;
 
   /* for group command */
-  nsCString m_currentGroup;     /* current group */
+  nsCString m_currentGroup; /* current group */
 
-  int32_t   m_firstArticle;
-  int32_t   m_lastArticle;
-  int32_t   m_firstPossibleArticle;
-  int32_t   m_lastPossibleArticle;
+  int32_t m_firstArticle;
+  int32_t m_lastArticle;
+  int32_t m_firstPossibleArticle;
+  int32_t m_lastPossibleArticle;
 
-  int32_t    m_numArticlesLoaded;  /* How many articles we got XOVER lines for. */
-  int32_t    m_numArticlesWanted; /* How many articles we wanted to get XOVER lines for. */
-  int32_t   m_maxArticles;        /* max articles to get during an XOVER */
+  int32_t m_numArticlesLoaded; /* How many articles we got XOVER lines for. */
+  int32_t m_numArticlesWanted; /* How many articles we wanted to get XOVER lines
+                                  for. */
+  int32_t m_maxArticles;       /* max articles to get during an XOVER */
 
   // Cancelation specific state. In particular, the headers that should be
   // used for the cancelation message.
   nsCString m_cancelFromHdr;
   nsCString m_cancelNewsgroups;
   nsCString m_cancelDistribution;
   nsCString m_cancelID;
-  int32_t    m_cancelStatus;
+  int32_t m_cancelStatus;
 
   // variable for ReadNewsList
-  int32_t   m_readNewsListCount;
+  int32_t m_readNewsListCount;
 
-  // Per news article state information. (article number, author, subject, id, etc
+  // Per news article state information. (article number, author, subject, id,
+  // etc
   nsCString m_messageID;
-  int32_t   m_articleNumber;   /* current article number */
+  int32_t m_articleNumber; /* current article number */
   nsCString m_searchData;
 
-  int32_t   m_originalContentLength; /* the content length at the time of calling graph progress */
+  int32_t m_originalContentLength; /* the content length at the time of calling
+                                      graph progress */
 
   nsCOMPtr<nsIStringBundle> m_stringBundle;
 
   nsCOMPtr<nsINntpIncomingServer> m_nntpServer;
 
   nsresult GetNewsStringByName(const char *aName, char16_t **aString);
   nsresult GetNewsStringByID(int32_t stringID, char16_t **aString);
 
-  nsresult PostMessageInFile(nsIFile * filePath);
+  nsresult PostMessageInFile(nsIFile *filePath);
 
   //////////////////////////////////////////////////////////////////////////////
   // Communication methods --> Reading and writing protocol
   //////////////////////////////////////////////////////////////////////////////
 
-  int32_t ReadLine(nsIInputStream * inputStream, uint32_t length, char ** line);
+  int32_t ReadLine(nsIInputStream *inputStream, uint32_t length, char **line);
 
   //////////////////////////////////////////////////////////////////////////////
   // 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.
   //////////////////////////////////////////////////////////////////////////////
 
-  // gets the response code from the nntp server and the response line. Returns the TCP return code
-  // from the read.
+  // gets the response code from the nntp server and the response line. Returns
+  // the TCP return code from the read.
   nsresult NewsResponse(nsIInputStream *inputStream, uint32_t length);
 
   // Interpret the server response after the connect.
   // Returns negative if the server responds unexpectedly
   nsresult LoginResponse();
   nsresult SendModeReader();
   nsresult SendModeReaderResponse();
 
   nsresult SendListExtensions();
-  nsresult SendListExtensionsResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult SendListExtensionsResponse(nsIInputStream *inputStream,
+                                      uint32_t length);
 
   nsresult SendListSearches();
-  nsresult SendListSearchesResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult SendListSearchesResponse(nsIInputStream *inputStream,
+                                    uint32_t length);
 
   nsresult SendListSearchHeaders();
-  nsresult SendListSearchHeadersResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult SendListSearchHeadersResponse(nsIInputStream *inputStream,
+                                         uint32_t length);
 
   nsresult GetProperties();
   nsresult GetPropertiesResponse(nsIInputStream *inputStream, uint32_t length);
 
   nsresult SendListSubscriptions();
-  nsresult SendListSubscriptionsResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult SendListSubscriptionsResponse(nsIInputStream *inputStream,
+                                         uint32_t length);
 
   // Figure out what the first command is and send it.
   // Returns the status from the NETWrite.
   nsresult SendFirstNNTPCommand(nsIURI *url);
 
   // Interprets the server response from the first command sent.
   // returns negative if the server responds unexpectedly.
   nsresult SendFirstNNTPCommandResponse();
@@ -448,27 +465,26 @@ private:
   /**
    * This state, NNTP_PROCESS_XOVER, is the final step of the filter-processing
    * code. Currently, all it does is cleans up the unread count and calls the
    * filters, both via nsNNTPNewsgroupList.
    * Followed by: NEWS_DONE
    */
   nsresult ProcessXover();
 
-
-
   // Canceling
   nsresult StartCancel();
   nsresult DoCancel();
 
   // XPAT
   nsresult XPATSend();
   nsresult XPATResponse(nsIInputStream *inputStream, uint32_t length);
   nsresult ListPrettyNames();
-  nsresult ListPrettyNamesResponse(nsIInputStream *inputStream, uint32_t length);
+  nsresult ListPrettyNamesResponse(nsIInputStream *inputStream,
+                                   uint32_t length);
 
   nsresult ListXActive();
   nsresult ListXActiveResponse(nsIInputStream *inputStream, uint32_t length);
 
   // for "?list-ids"
   nsresult SendListGroup();
   nsresult SendListGroupResponse(nsIInputStream *inputStream, uint32_t length);
 
@@ -484,31 +500,36 @@ private:
   nsresult ParseURL(nsIURI *aURL, nsCString &aGroup, nsCString &aMessageID);
 
   void SetProgressBarPercent(uint32_t aProgress, uint32_t aProgressMax);
   nsresult SetProgressStatus(const char16_t *aMessage);
   nsresult InitializeNewsFolderFromUri(const char *uri);
   void TimerCallback();
 
   void HandleAuthenticationFailure();
-  nsCOMPtr <nsIInputStream> mInputStream;
-  nsCOMPtr <nsITimer> mUpdateTimer;
+  nsCOMPtr<nsIInputStream> mInputStream;
+  nsCOMPtr<nsITimer> mUpdateTimer;
   nsresult AlertError(int32_t errorCode, const char *text);
   int32_t mBytesReceived;
   int32_t mBytesReceivedSinceLastStatusUpdate;
   PRTime m_startTime;
   int32_t mNumGroupsListed;
   nsMsgKey m_key;
 
-  nsresult SetCurrentGroup(); /* sets m_currentGroup.  should be called after doing a successful GROUP command */
-  nsresult CleanupNewsgroupList(); /* cleans up m_newsgroupList, and set it to null */
+  nsresult SetCurrentGroup(); /* sets m_currentGroup.  should be called after
+                                 doing a successful GROUP command */
+  nsresult
+  CleanupNewsgroupList(); /* cleans up m_newsgroupList, and set it to null */
 
   // cache related helper methods
-  void FinishMemCacheEntry(bool valid); // either mark it valid, or doom it
-  nsresult OpenCacheEntry(); // makes a request to the cache service for a cache entry for a url
-  bool ReadFromLocalCache(); // attempts to read the url out of our local (offline) cache....
-  nsresult ReadFromNewsConnection(); // creates a new news connection to read the url
-  nsresult ReadFromMemCache(nsICacheEntry *entry); // attempts to read the url out of our memory cache
-  nsresult SetupPartExtractorListener(nsIStreamListener * aConsumer);
+  void FinishMemCacheEntry(bool valid);  // either mark it valid, or doom it
+  nsresult OpenCacheEntry();  // makes a request to the cache service for a
+                              // cache entry for a url
+  bool ReadFromLocalCache();  // attempts to read the url out of our local
+                              // (offline) cache....
+  nsresult
+  ReadFromNewsConnection();  // creates a new news connection to read the url
+  nsresult ReadFromMemCache(nsICacheEntry *entry);  // attempts to read the url
+                                                    // out of our memory cache
+  nsresult SetupPartExtractorListener(nsIStreamListener *aConsumer);
 };
 
-
 #endif  // nsNNTPProtocol_h___
--- a/mailnews/news/src/nsNewsDownloadDialogArgs.cpp
+++ b/mailnews/news/src/nsNewsDownloadDialogArgs.cpp
@@ -1,91 +1,79 @@
 /* -*- 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 "nsNewsDownloadDialogArgs.h"
 
-nsNewsDownloadDialogArgs::nsNewsDownloadDialogArgs()
-{
-    mArticleCount = 0;
-    mServerKey = "";
-    mHitOK = false;
-    mDownloadAll = false;
+nsNewsDownloadDialogArgs::nsNewsDownloadDialogArgs() {
+  mArticleCount = 0;
+  mServerKey = "";
+  mHitOK = false;
+  mDownloadAll = false;
 }
 
-nsNewsDownloadDialogArgs::~nsNewsDownloadDialogArgs()
-{
-}
+nsNewsDownloadDialogArgs::~nsNewsDownloadDialogArgs() {}
 
 NS_IMPL_ISUPPORTS(nsNewsDownloadDialogArgs, nsINewsDownloadDialogArgs)
 
-NS_IMETHODIMP nsNewsDownloadDialogArgs::GetGroupName(nsAString & aGroupName)
- {
-    aGroupName = mGroupName;
+NS_IMETHODIMP nsNewsDownloadDialogArgs::GetGroupName(nsAString &aGroupName) {
+  aGroupName = mGroupName;
 
-    return NS_OK;
- }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::SetGroupName(const nsAString & aGroupName)
- {
+  return NS_OK;
+}
+NS_IMETHODIMP nsNewsDownloadDialogArgs::SetGroupName(
+    const nsAString &aGroupName) {
+  mGroupName = aGroupName;
 
-     mGroupName = aGroupName;
-
-     return NS_OK;
- }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::GetArticleCount(int32_t *aArticleCount)
-{
-    NS_ENSURE_ARG_POINTER(aArticleCount);
+  return NS_OK;
+}
+NS_IMETHODIMP nsNewsDownloadDialogArgs::GetArticleCount(
+    int32_t *aArticleCount) {
+  NS_ENSURE_ARG_POINTER(aArticleCount);
 
-    *aArticleCount = mArticleCount;
+  *aArticleCount = mArticleCount;
 
-    return NS_OK;
+  return NS_OK;
 }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::SetArticleCount(int32_t aArticleCount)
-{
-    mArticleCount = aArticleCount;
+NS_IMETHODIMP nsNewsDownloadDialogArgs::SetArticleCount(int32_t aArticleCount) {
+  mArticleCount = aArticleCount;
 
-    return NS_OK;
+  return NS_OK;
 }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::GetServerKey(char * *aServerKey)
-{
-    NS_ENSURE_ARG_POINTER(aServerKey);
+NS_IMETHODIMP nsNewsDownloadDialogArgs::GetServerKey(char **aServerKey) {
+  NS_ENSURE_ARG_POINTER(aServerKey);
 
-    *aServerKey = ToNewCString(mServerKey);
-    return NS_OK;
+  *aServerKey = ToNewCString(mServerKey);
+  return NS_OK;
 }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::SetServerKey(const char * aServerKey)
-{
-    NS_ENSURE_ARG_POINTER(aServerKey);
+NS_IMETHODIMP nsNewsDownloadDialogArgs::SetServerKey(const char *aServerKey) {
+  NS_ENSURE_ARG_POINTER(aServerKey);
 
-    mServerKey = aServerKey;
+  mServerKey = aServerKey;
 
-    return NS_OK;
+  return NS_OK;
 }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::GetHitOK(bool *aHitOK)
-{
-    NS_ENSURE_ARG_POINTER(aHitOK);
+NS_IMETHODIMP nsNewsDownloadDialogArgs::GetHitOK(bool *aHitOK) {
+  NS_ENSURE_ARG_POINTER(aHitOK);
 
-    *aHitOK = mHitOK;
+  *aHitOK = mHitOK;
 
-    return NS_OK;
+  return NS_OK;
 }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::SetHitOK(bool aHitOK)
-{
-    mHitOK = aHitOK;
+NS_IMETHODIMP nsNewsDownloadDialogArgs::SetHitOK(bool aHitOK) {
+  mHitOK = aHitOK;
 
-    return NS_OK;
+  return NS_OK;
 }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::GetDownloadAll(bool *aDownloadAll)
-{
-    NS_ENSURE_ARG_POINTER(aDownloadAll);
+NS_IMETHODIMP nsNewsDownloadDialogArgs::GetDownloadAll(bool *aDownloadAll) {
+  NS_ENSURE_ARG_POINTER(aDownloadAll);
 
-    *aDownloadAll = mDownloadAll;
+  *aDownloadAll = mDownloadAll;
 
-    return NS_OK;
+  return NS_OK;
 }
-NS_IMETHODIMP nsNewsDownloadDialogArgs::SetDownloadAll(bool aDownloadAll)
-{
-    mDownloadAll = aDownloadAll;
+NS_IMETHODIMP nsNewsDownloadDialogArgs::SetDownloadAll(bool aDownloadAll) {
+  mDownloadAll = aDownloadAll;
 
-    return NS_OK;
+  return NS_OK;
 }
--- a/mailnews/news/src/nsNewsDownloadDialogArgs.h
+++ b/mailnews/news/src/nsNewsDownloadDialogArgs.h
@@ -4,27 +4,26 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsNewsDownloadDialogArgs_h__
 #define nsNewsDownloadDialogArgs_h__
 
 #include "nsINewsDownloadDialogArgs.h"
 #include "nsString.h"
 
-class nsNewsDownloadDialogArgs : public nsINewsDownloadDialogArgs
-{
-public:
+class nsNewsDownloadDialogArgs : public nsINewsDownloadDialogArgs {
+ public:
   nsNewsDownloadDialogArgs();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSINEWSDOWNLOADDIALOGARGS
 
-private:
+ private:
   virtual ~nsNewsDownloadDialogArgs();
 
   nsString mGroupName;
   int32_t mArticleCount;
   nsCString mServerKey;
   bool mHitOK;
   bool mDownloadAll;
 };
 
-#endif // nsNewsDownloadDialogArgs_h__
+#endif  // nsNewsDownloadDialogArgs_h__
--- a/mailnews/news/src/nsNewsDownloader.cpp
+++ b/mailnews/news/src/nsNewsDownloader.cpp
@@ -20,559 +20,490 @@
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
 #include "nsArrayUtils.h"
 
 // This file contains the news article download state machine.
 
-// if pIds is not null, download the articles whose id's are passed in. Otherwise,
-// which articles to download is determined by nsNewsDownloader object,
-// or subclasses thereof. News can download marked objects, for example.
-nsresult nsNewsDownloader::DownloadArticles(nsIMsgWindow *window, nsIMsgFolder *folder, nsTArray<nsMsgKey> *pIds)
-{
+// if pIds is not null, download the articles whose id's are passed in.
+// Otherwise, which articles to download is determined by nsNewsDownloader
+// object, or subclasses thereof. News can download marked objects, for example.
+nsresult nsNewsDownloader::DownloadArticles(nsIMsgWindow *window,
+                                            nsIMsgFolder *folder,
+                                            nsTArray<nsMsgKey> *pIds) {
   if (pIds != nullptr)
     m_keysToDownload.InsertElementsAt(0, pIds->Elements(), pIds->Length());
 
-  if (!m_keysToDownload.IsEmpty())
-    m_downloadFromKeys = true;
+  if (!m_keysToDownload.IsEmpty()) m_downloadFromKeys = true;
 
   m_folder = folder;
   m_window = window;
   m_numwrote = 0;
 
   bool headersToDownload = GetNextHdrToRetrieve();
   // should we have a special error code for failure here?
   return (headersToDownload) ? DownloadNext(true) : NS_ERROR_FAILURE;
 }
 
 /* Saving news messages
  */
 
 NS_IMPL_ISUPPORTS(nsNewsDownloader, nsIUrlListener, nsIMsgSearchNotify)
 
-nsNewsDownloader::nsNewsDownloader(nsIMsgWindow *window, nsIMsgDatabase *msgDB, nsIUrlListener *listener)
-{
+nsNewsDownloader::nsNewsDownloader(nsIMsgWindow *window, nsIMsgDatabase *msgDB,
+                                   nsIUrlListener *listener) {
   m_numwrote = 0;
   m_downloadFromKeys = false;
   m_newsDB = msgDB;
   m_abort = false;
   m_listener = listener;
   m_window = window;
   m_lastPercent = -1;
   m_lastProgressTime = 0;
   // not the perfect place for this, but I think it will work.
-  if (m_window)
-    m_window->SetStopped(false);
+  if (m_window) m_window->SetStopped(false);
 }
 
-nsNewsDownloader::~nsNewsDownloader()
-{
+nsNewsDownloader::~nsNewsDownloader() {
   if (m_listener)
-    m_listener->OnStopRunningUrl(/* don't have a url */nullptr, m_status);
-  if (m_newsDB)
-  {
+    m_listener->OnStopRunningUrl(/* don't have a url */ nullptr, m_status);
+  if (m_newsDB) {
     m_newsDB->Commit(nsMsgDBCommitType::kLargeCommit);
     m_newsDB = nullptr;
   }
 }
 
-NS_IMETHODIMP nsNewsDownloader::OnStartRunningUrl(nsIURI* url)
-{
-  return NS_OK;
-}
+NS_IMETHODIMP nsNewsDownloader::OnStartRunningUrl(nsIURI *url) { return NS_OK; }
 
-NS_IMETHODIMP nsNewsDownloader::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
-{
+NS_IMETHODIMP nsNewsDownloader::OnStopRunningUrl(nsIURI *url,
+                                                 nsresult exitCode) {
   bool stopped = false;
-  if (m_window)
-    m_window->GetStopped(&stopped);
-  if (stopped)
-    exitCode = NS_BINDING_ABORTED;
+  if (m_window) m_window->GetStopped(&stopped);
+  if (stopped) exitCode = NS_BINDING_ABORTED;
 
- nsresult rv = exitCode;
+  nsresult rv = exitCode;
   if (NS_SUCCEEDED(exitCode) || exitCode == NS_MSG_NEWS_ARTICLE_NOT_FOUND)
     rv = DownloadNext(false);
 
   return rv;
 }
 
-nsresult nsNewsDownloader::DownloadNext(bool firstTimeP)
-{
+nsresult nsNewsDownloader::DownloadNext(bool firstTimeP) {
   nsresult rv;
-  if (!firstTimeP)
-  {
+  if (!firstTimeP) {
     bool moreHeaders = GetNextHdrToRetrieve();
-    if (!moreHeaders)
-    {
-      if (m_listener)
-        m_listener->OnStopRunningUrl(nullptr, NS_OK);
+    if (!moreHeaders) {
+      if (m_listener) m_listener->OnStopRunningUrl(nullptr, NS_OK);
       return NS_OK;
     }
   }
   StartDownload();
   m_wroteAnyP = false;
-  nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID,&rv);
+  nsCOMPtr<nsINntpService> nntpService =
+      do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return nntpService->FetchMessage(m_folder, m_keyToDownload, m_window, nullptr, this, nullptr);
+  return nntpService->FetchMessage(m_folder, m_keyToDownload, m_window, nullptr,
+                                   this, nullptr);
 }
 
-bool DownloadNewsArticlesToOfflineStore::GetNextHdrToRetrieve()
-{
+bool DownloadNewsArticlesToOfflineStore::GetNextHdrToRetrieve() {
   nsresult rv;
 
-  if (m_downloadFromKeys)
-    return nsNewsDownloader::GetNextHdrToRetrieve();
+  if (m_downloadFromKeys) return nsNewsDownloader::GetNextHdrToRetrieve();
 
   if (m_headerEnumerator == nullptr)
     rv = m_newsDB->EnumerateMessages(getter_AddRefs(m_headerEnumerator));
 
   bool hasMore = false;
 
-  while (NS_SUCCEEDED(rv = m_headerEnumerator->HasMoreElements(&hasMore)) && hasMore)
-  {
-    nsCOMPtr <nsISupports> supports;
+  while (NS_SUCCEEDED(rv = m_headerEnumerator->HasMoreElements(&hasMore)) &&
+         hasMore) {
+    nsCOMPtr<nsISupports> supports;
     rv = m_headerEnumerator->GetNext(getter_AddRefs(supports));
     m_newsHeader = do_QueryInterface(supports);
     NS_ENSURE_SUCCESS(rv, false);
     uint32_t hdrFlags;
     m_newsHeader->GetFlags(&hdrFlags);
-    if (hdrFlags & nsMsgMessageFlags::Marked)
-    {
+    if (hdrFlags & nsMsgMessageFlags::Marked) {
       m_newsHeader->GetMessageKey(&m_keyToDownload);
       break;
-    }
-    else
-    {
+    } else {
       m_newsHeader = nullptr;
     }
   }
   return hasMore;
 }
 
 void nsNewsDownloader::Abort() {}
 void nsNewsDownloader::Complete() {}
 
-bool nsNewsDownloader::GetNextHdrToRetrieve()
-{
+bool nsNewsDownloader::GetNextHdrToRetrieve() {
   nsresult rv;
-  if (m_downloadFromKeys)
-  {
-    if (m_numwrote >= (int32_t) m_keysToDownload.Length())
-      return false;
+  if (m_downloadFromKeys) {
+    if (m_numwrote >= (int32_t)m_keysToDownload.Length()) return false;
 
     m_keyToDownload = m_keysToDownload[m_numwrote++];
     int32_t percent;
-    percent = (100 * m_numwrote) / (int32_t) m_keysToDownload.Length();
+    percent = (100 * m_numwrote) / (int32_t)m_keysToDownload.Length();
 
     int64_t nowMS = 0;
     if (percent < 100)  // always need to do 100%
     {
       nowMS = PR_IntervalToMilliseconds(PR_IntervalNow());
-      if (nowMS - m_lastProgressTime < 750)
-        return true;
+      if (nowMS - m_lastProgressTime < 750) return true;
     }
 
     m_lastProgressTime = nowMS;
     nsCOMPtr<nsIStringBundleService> bundleService =
-      mozilla::services::GetStringBundleService();
+        mozilla::services::GetStringBundleService();
     NS_ENSURE_TRUE(bundleService, false);
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, false);
 
     nsAutoString firstStr;
     firstStr.AppendInt(m_numwrote);
     nsAutoString totalStr;
     totalStr.AppendInt(int(m_keysToDownload.Length()));
     nsString prettyName;
     nsString statusString;
 
     m_folder->GetPrettyName(prettyName);
 
-    const char16_t *formatStrings[3] = { firstStr.get(), totalStr.get(), prettyName.get() };
+    const char16_t *formatStrings[3] = {firstStr.get(), totalStr.get(),
+                                        prettyName.get()};
     rv = bundle->FormatStringFromName("downloadingArticlesForOffline",
                                       formatStrings, 3, statusString);
     NS_ENSURE_SUCCESS(rv, false);
     ShowProgress(statusString.get(), percent);
     return true;
   }
   NS_ASSERTION(false, "shouldn't get here if we're not downloading from keys.");
   return false;  // shouldn't get here if we're not downloading from keys.
 }
 
-nsresult nsNewsDownloader::ShowProgress(const char16_t *progressString, int32_t percent)
-{
-  if (!m_statusFeedback)
-  {
-    if (m_window)
-      m_window->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
+nsresult nsNewsDownloader::ShowProgress(const char16_t *progressString,
+                                        int32_t percent) {
+  if (!m_statusFeedback) {
+    if (m_window) m_window->GetStatusFeedback(getter_AddRefs(m_statusFeedback));
   }
-  if (m_statusFeedback)
-  {
+  if (m_statusFeedback) {
     m_statusFeedback->ShowStatusString(nsDependentString(progressString));
-    if (percent != m_lastPercent)
-    {
+    if (percent != m_lastPercent) {
       m_statusFeedback->ShowProgress(percent);
       m_lastPercent = percent;
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP DownloadNewsArticlesToOfflineStore::OnStartRunningUrl(nsIURI* url)
-{
+NS_IMETHODIMP DownloadNewsArticlesToOfflineStore::OnStartRunningUrl(
+    nsIURI *url) {
   return NS_OK;
 }
 
-
-NS_IMETHODIMP DownloadNewsArticlesToOfflineStore::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
-{
+NS_IMETHODIMP DownloadNewsArticlesToOfflineStore::OnStopRunningUrl(
+    nsIURI *url, nsresult exitCode) {
   m_status = exitCode;
-  if (m_newsHeader != nullptr)
-  {
+  if (m_newsHeader != nullptr) {
 #ifdef DEBUG_bienvenu
     //    XP_Trace("finished retrieving %ld\n", m_newsHeader->GetMessageKey());
 #endif
-    if (m_newsDB)
-    {
+    if (m_newsDB) {
       nsMsgKey msgKey;
       m_newsHeader->GetMessageKey(&msgKey);
       m_newsDB->MarkMarked(msgKey, false, nullptr);
     }
   }
   m_newsHeader = nullptr;
   return nsNewsDownloader::OnStopRunningUrl(url, exitCode);
 }
 
-int DownloadNewsArticlesToOfflineStore::FinishDownload()
-{
-  return 0;
-}
+int DownloadNewsArticlesToOfflineStore::FinishDownload() { return 0; }
 
-
-NS_IMETHODIMP nsNewsDownloader::OnSearchHit(nsIMsgDBHdr *header, nsIMsgFolder *folder)
-{
+NS_IMETHODIMP nsNewsDownloader::OnSearchHit(nsIMsgDBHdr *header,
+                                            nsIMsgFolder *folder) {
   NS_ENSURE_ARG(header);
 
-
   uint32_t msgFlags;
   header->GetFlags(&msgFlags);
   // only need to download articles we don't already have...
-  if (! (msgFlags & nsMsgMessageFlags::Offline))
-  {
+  if (!(msgFlags & nsMsgMessageFlags::Offline)) {
     nsMsgKey key;
     header->GetMessageKey(&key);
     m_keysToDownload.AppendElement(key);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP nsNewsDownloader::OnSearchDone(nsresult status)
-{
-  if (m_keysToDownload.IsEmpty())
-  {
-    if (m_listener)
-      return m_listener->OnStopRunningUrl(nullptr, NS_OK);
+NS_IMETHODIMP nsNewsDownloader::OnSearchDone(nsresult status) {
+  if (m_keysToDownload.IsEmpty()) {
+    if (m_listener) return m_listener->OnStopRunningUrl(nullptr, NS_OK);
   }
-  nsresult rv = DownloadArticles(m_window, m_folder,
-                  /* we've already set m_keysToDownload, so don't pass it in */ nullptr);
+  nsresult rv = DownloadArticles(
+      m_window, m_folder,
+      /* we've already set m_keysToDownload, so don't pass it in */ nullptr);
   if (NS_FAILED(rv))
-    if (m_listener)
-      m_listener->OnStopRunningUrl(nullptr, rv);
+    if (m_listener) m_listener->OnStopRunningUrl(nullptr, rv);
 
   return rv;
 }
-NS_IMETHODIMP nsNewsDownloader::OnNewSearch()
-{
-  return NS_OK;
-}
+NS_IMETHODIMP nsNewsDownloader::OnNewSearch() { return NS_OK; }
 
-int DownloadNewsArticlesToOfflineStore::StartDownload()
-{
+int DownloadNewsArticlesToOfflineStore::StartDownload() {
   m_newsDB->GetMsgHdrForKey(m_keyToDownload, getter_AddRefs(m_newsHeader));
   return 0;
 }
 
-DownloadNewsArticlesToOfflineStore::DownloadNewsArticlesToOfflineStore(nsIMsgWindow *window, nsIMsgDatabase *db, nsIUrlListener *listener)
-  : nsNewsDownloader(window, db, listener)
-{
+DownloadNewsArticlesToOfflineStore::DownloadNewsArticlesToOfflineStore(
+    nsIMsgWindow *window, nsIMsgDatabase *db, nsIUrlListener *listener)
+    : nsNewsDownloader(window, db, listener) {
   m_newsDB = db;
 }
 
-DownloadNewsArticlesToOfflineStore::~DownloadNewsArticlesToOfflineStore()
-{
-}
+DownloadNewsArticlesToOfflineStore::~DownloadNewsArticlesToOfflineStore() {}
 
-DownloadMatchingNewsArticlesToNewsDB::DownloadMatchingNewsArticlesToNewsDB
-  (nsIMsgWindow *window, nsIMsgFolder *folder, nsIMsgDatabase *newsDB,
-   nsIUrlListener *listener) :
-   DownloadNewsArticlesToOfflineStore(window, newsDB, listener)
-{
+DownloadMatchingNewsArticlesToNewsDB::DownloadMatchingNewsArticlesToNewsDB(
+    nsIMsgWindow *window, nsIMsgFolder *folder, nsIMsgDatabase *newsDB,
+    nsIUrlListener *listener)
+    : DownloadNewsArticlesToOfflineStore(window, newsDB, listener) {
   m_window = window;
   m_folder = folder;
   m_newsDB = newsDB;
   m_downloadFromKeys = true;  // search term matching means downloadFromKeys.
 }
 
-DownloadMatchingNewsArticlesToNewsDB::~DownloadMatchingNewsArticlesToNewsDB()
-{
-}
-
+DownloadMatchingNewsArticlesToNewsDB::~DownloadMatchingNewsArticlesToNewsDB() {}
 
 NS_IMPL_ISUPPORTS(nsMsgDownloadAllNewsgroups, nsIUrlListener)
 
-
-nsMsgDownloadAllNewsgroups::nsMsgDownloadAllNewsgroups(nsIMsgWindow *window, nsIUrlListener *listener)
-{
+nsMsgDownloadAllNewsgroups::nsMsgDownloadAllNewsgroups(
+    nsIMsgWindow *window, nsIUrlListener *listener) {
   m_window = window;
   m_listener = listener;
-  m_downloaderForGroup = new DownloadMatchingNewsArticlesToNewsDB(window, nullptr, nullptr, this);
+  m_downloaderForGroup =
+      new DownloadMatchingNewsArticlesToNewsDB(window, nullptr, nullptr, this);
   m_downloadedHdrsForCurGroup = false;
 }
 
-nsMsgDownloadAllNewsgroups::~nsMsgDownloadAllNewsgroups()
-{
-}
+nsMsgDownloadAllNewsgroups::~nsMsgDownloadAllNewsgroups() {}
 
-NS_IMETHODIMP nsMsgDownloadAllNewsgroups::OnStartRunningUrl(nsIURI* url)
-{
-    return NS_OK;
+NS_IMETHODIMP nsMsgDownloadAllNewsgroups::OnStartRunningUrl(nsIURI *url) {
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgDownloadAllNewsgroups::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
-{
+nsMsgDownloadAllNewsgroups::OnStopRunningUrl(nsIURI *url, nsresult exitCode) {
   nsresult rv = exitCode;
-  if (NS_SUCCEEDED(exitCode) || exitCode == NS_MSG_NEWS_ARTICLE_NOT_FOUND)
-  {
-    if (m_downloadedHdrsForCurGroup)
-    {
+  if (NS_SUCCEEDED(exitCode) || exitCode == NS_MSG_NEWS_ARTICLE_NOT_FOUND) {
+    if (m_downloadedHdrsForCurGroup) {
       bool savingArticlesOffline = false;
-      nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
-      if (newsFolder)
-        newsFolder->GetSaveArticleOffline(&savingArticlesOffline);
+      nsCOMPtr<nsIMsgNewsFolder> newsFolder =
+          do_QueryInterface(m_currentFolder);
+      if (newsFolder) newsFolder->GetSaveArticleOffline(&savingArticlesOffline);
 
       m_downloadedHdrsForCurGroup = false;
-      if (savingArticlesOffline) // skip this group - we're saving to it already
+      if (savingArticlesOffline)  // skip this group - we're saving to it
+                                  // already
         rv = ProcessNextGroup();
       else
         rv = DownloadMsgsForCurrentGroup();
-    }
-    else
-    {
+    } else {
       rv = ProcessNextGroup();
     }
-  }
-  else if (m_listener)  // notify main observer.
+  } else if (m_listener)  // notify main observer.
     m_listener->OnStopRunningUrl(url, exitCode);
 
   return rv;
 }
 
 /**
  * Leaves m_currentServer at the next nntp "server" that
  * might have folders to download for offline use. If no more servers,
  * m_currentServer will be left at nullptr and the function returns false.
  * Also, sets up m_serverEnumerator to enumerate over the server.
  * If no servers found, m_serverEnumerator will be left at null.
  */
-bool nsMsgDownloadAllNewsgroups::AdvanceToNextServer()
-{
+bool nsMsgDownloadAllNewsgroups::AdvanceToNextServer() {
   nsresult rv;
 
-  if (!m_allServers)
-  {
+  if (!m_allServers) {
     nsCOMPtr<nsIMsgAccountManager> accountManager =
-             do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
-    NS_ASSERTION(accountManager && NS_SUCCEEDED(rv), "couldn't get account mgr");
-    if (!accountManager || NS_FAILED(rv))
-      return false;
+        do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
+    NS_ASSERTION(accountManager && NS_SUCCEEDED(rv),
+                 "couldn't get account mgr");
+    if (!accountManager || NS_FAILED(rv)) return false;
 
     rv = accountManager->GetAllServers(getter_AddRefs(m_allServers));
     NS_ENSURE_SUCCESS(rv, false);
   }
   uint32_t serverIndex = 0;
-  if (m_currentServer)
-  {
+  if (m_currentServer) {
     rv = m_allServers->IndexOf(0, m_currentServer, &serverIndex);
-    if (NS_FAILED(rv))
-      serverIndex = -1;
+    if (NS_FAILED(rv)) serverIndex = -1;
 
     ++serverIndex;
   }
   m_currentServer = nullptr;
   uint32_t numServers;
   m_allServers->GetLength(&numServers);
-  nsCOMPtr <nsIMsgFolder> rootFolder;
+  nsCOMPtr<nsIMsgFolder> rootFolder;
 
-  while (serverIndex < numServers)
-  {
-    nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(m_allServers, serverIndex);
+  while (serverIndex < numServers) {
+    nsCOMPtr<nsIMsgIncomingServer> server =
+        do_QueryElementAt(m_allServers, serverIndex);
     serverIndex++;
 
-    nsCOMPtr <nsINntpIncomingServer> newsServer = do_QueryInterface(server);
-    if (!newsServer) // we're only looking for news servers
+    nsCOMPtr<nsINntpIncomingServer> newsServer = do_QueryInterface(server);
+    if (!newsServer)  // we're only looking for news servers
       continue;
 
-    if (server)
-    {
+    if (server) {
       m_currentServer = server;
       server->GetRootFolder(getter_AddRefs(rootFolder));
-      if (rootFolder)
-      {
+      if (rootFolder) {
         rv = rootFolder->GetDescendants(getter_AddRefs(m_allFolders));
-        if (NS_SUCCEEDED(rv))
-        {
+        if (NS_SUCCEEDED(rv)) {
           rv = m_allFolders->Enumerate(getter_AddRefs(m_serverEnumerator));
-          if (NS_SUCCEEDED(rv) && m_serverEnumerator)
-          {
+          if (NS_SUCCEEDED(rv) && m_serverEnumerator) {
             bool hasMore = false;
             rv = m_serverEnumerator->HasMoreElements(&hasMore);
-            if (NS_SUCCEEDED(rv) && hasMore)
-              return true;
+            if (NS_SUCCEEDED(rv) && hasMore) return true;
           }
         }
       }
     }
   }
   return false;
 }
 
 /**
  * Sets m_currentFolder to the next usable folder.
  *
  * @return  False if no more folders found, otherwise true.
  */
-bool nsMsgDownloadAllNewsgroups::AdvanceToNextGroup()
-{
+bool nsMsgDownloadAllNewsgroups::AdvanceToNextGroup() {
   nsresult rv = NS_OK;
 
-  if (m_currentFolder)
-  {
-    nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
-    if (newsFolder)
-      newsFolder->SetSaveArticleOffline(false);
+  if (m_currentFolder) {
+    nsCOMPtr<nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
+    if (newsFolder) newsFolder->SetSaveArticleOffline(false);
 
     nsCOMPtr<nsIMsgMailSession> session =
-             do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
-    if (NS_SUCCEEDED(rv) && session)
-    {
+        do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
+    if (NS_SUCCEEDED(rv) && session) {
       bool folderOpen;
       uint32_t folderFlags;
       m_currentFolder->GetFlags(&folderFlags);
       session->IsFolderOpenInWindow(m_currentFolder, &folderOpen);
-      if (!folderOpen && ! (folderFlags & (nsMsgFolderFlags::Trash | nsMsgFolderFlags::Inbox)))
+      if (!folderOpen &&
+          !(folderFlags & (nsMsgFolderFlags::Trash | nsMsgFolderFlags::Inbox)))
         m_currentFolder->SetMsgDatabase(nullptr);
     }
     m_currentFolder = nullptr;
   }
 
   bool hasMore = false;
-  if (m_currentServer)
-    m_serverEnumerator->HasMoreElements(&hasMore);
-  if (!hasMore)
-    hasMore = AdvanceToNextServer();
+  if (m_currentServer) m_serverEnumerator->HasMoreElements(&hasMore);
+  if (!hasMore) hasMore = AdvanceToNextServer();
 
-  if (hasMore)
-  {
+  if (hasMore) {
     nsCOMPtr<nsISupports> supports;
     rv = m_serverEnumerator->GetNext(getter_AddRefs(supports));
-    if (NS_SUCCEEDED(rv))
-      m_currentFolder = do_QueryInterface(supports);
+    if (NS_SUCCEEDED(rv)) m_currentFolder = do_QueryInterface(supports);
   }
   return m_currentFolder;
 }
 
-nsresult DownloadMatchingNewsArticlesToNewsDB::RunSearch(nsIMsgFolder *folder, nsIMsgDatabase *newsDB, nsIMsgSearchSession *searchSession)
-{
+nsresult DownloadMatchingNewsArticlesToNewsDB::RunSearch(
+    nsIMsgFolder *folder, nsIMsgDatabase *newsDB,
+    nsIMsgSearchSession *searchSession) {
   m_folder = folder;
   m_newsDB = newsDB;
   m_searchSession = searchSession;
 
   m_keysToDownload.Clear();
 
   NS_ENSURE_ARG(searchSession);
   NS_ENSURE_ARG(folder);
 
-  searchSession->RegisterListener(this,
-                                  nsIMsgSearchSession::allNotifications);
-  nsresult rv = searchSession->AddScopeTerm(nsMsgSearchScope::localNews, folder);
+  searchSession->RegisterListener(this, nsIMsgSearchSession::allNotifications);
+  nsresult rv =
+      searchSession->AddScopeTerm(nsMsgSearchScope::localNews, folder);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return searchSession->Search(m_window);
 }
 
-nsresult nsMsgDownloadAllNewsgroups::ProcessNextGroup()
-{
+nsresult nsMsgDownloadAllNewsgroups::ProcessNextGroup() {
   bool done = false;
 
-  while (!done)
-  {
+  while (!done) {
     done = !AdvanceToNextGroup();
-    if (!done && m_currentFolder)
-    {
+    if (!done && m_currentFolder) {
       uint32_t folderFlags;
       m_currentFolder->GetFlags(&folderFlags);
-      if (folderFlags & nsMsgFolderFlags::Offline)
-        break;
+      if (folderFlags & nsMsgFolderFlags::Offline) break;
     }
   }
-  if (done)
-  {
-    if (m_listener)
-      return m_listener->OnStopRunningUrl(nullptr, NS_OK);
+  if (done) {
+    if (m_listener) return m_listener->OnStopRunningUrl(nullptr, NS_OK);
   }
   m_downloadedHdrsForCurGroup = true;
-  return m_currentFolder ? m_currentFolder->GetNewMessages(m_window, this) : NS_ERROR_NOT_INITIALIZED;
+  return m_currentFolder ? m_currentFolder->GetNewMessages(m_window, this)
+                         : NS_ERROR_NOT_INITIALIZED;
 }
 
-nsresult nsMsgDownloadAllNewsgroups::DownloadMsgsForCurrentGroup()
-{
+nsresult nsMsgDownloadAllNewsgroups::DownloadMsgsForCurrentGroup() {
   NS_ENSURE_TRUE(m_downloaderForGroup, NS_ERROR_OUT_OF_MEMORY);
-  nsCOMPtr <nsIMsgDatabase> db;
-  nsCOMPtr <nsIMsgDownloadSettings> downloadSettings;
+  nsCOMPtr<nsIMsgDatabase> db;
+  nsCOMPtr<nsIMsgDownloadSettings> downloadSettings;
   m_currentFolder->GetMsgDatabase(getter_AddRefs(db));
-  nsresult rv = m_currentFolder->GetDownloadSettings(getter_AddRefs(downloadSettings));
+  nsresult rv =
+      m_currentFolder->GetDownloadSettings(getter_AddRefs(downloadSettings));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
-  if (newsFolder)
-    newsFolder->SetSaveArticleOffline(true);
+  nsCOMPtr<nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_currentFolder);
+  if (newsFolder) newsFolder->SetSaveArticleOffline(true);
 
-  nsCOMPtr <nsIMsgSearchSession> searchSession = do_CreateInstance(NS_MSGSEARCHSESSION_CONTRACTID, &rv);
+  nsCOMPtr<nsIMsgSearchSession> searchSession =
+      do_CreateInstance(NS_MSGSEARCHSESSION_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   bool downloadByDate, downloadUnreadOnly;
   uint32_t ageLimitOfMsgsToDownload;
 
   downloadSettings->GetDownloadByDate(&downloadByDate);
   downloadSettings->GetDownloadUnreadOnly(&downloadUnreadOnly);
   downloadSettings->GetAgeLimitOfMsgsToDownload(&ageLimitOfMsgsToDownload);
 
-  nsCOMPtr <nsIMsgSearchTerm> term;
-  nsCOMPtr <nsIMsgSearchValue>    value;
+  nsCOMPtr<nsIMsgSearchTerm> term;
+  nsCOMPtr<nsIMsgSearchValue> value;
 
   rv = searchSession->CreateTerm(getter_AddRefs(term));
   NS_ENSURE_SUCCESS(rv, rv);
   term->GetValue(getter_AddRefs(value));
 
-  if (downloadUnreadOnly)
-  {
+  if (downloadUnreadOnly) {
     value->SetAttrib(nsMsgSearchAttrib::MsgStatus);
     value->SetStatus(nsMsgMessageFlags::Read);
-    searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus, nsMsgSearchOp::Isnt, value, true, nullptr);
+    searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus,
+                                 nsMsgSearchOp::Isnt, value, true, nullptr);
   }
-  if (downloadByDate)
-  {
+  if (downloadByDate) {
     value->SetAttrib(nsMsgSearchAttrib::AgeInDays);
     value->SetAge(ageLimitOfMsgsToDownload);
-    searchSession->AddSearchTerm(nsMsgSearchAttrib::AgeInDays, nsMsgSearchOp::IsLessThan, value, nsMsgSearchBooleanOp::BooleanAND, nullptr);
+    searchSession->AddSearchTerm(nsMsgSearchAttrib::AgeInDays,
+                                 nsMsgSearchOp::IsLessThan, value,
+                                 nsMsgSearchBooleanOp::BooleanAND, nullptr);
   }
   value->SetAttrib(nsMsgSearchAttrib::MsgStatus);
   value->SetStatus(nsMsgMessageFlags::Offline);
-  searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus, nsMsgSearchOp::Isnt, value, nsMsgSearchBooleanOp::BooleanAND, nullptr);
+  searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus,
+                               nsMsgSearchOp::Isnt, value,
+                               nsMsgSearchBooleanOp::BooleanAND, nullptr);
 
   m_downloaderForGroup->RunSearch(m_currentFolder, db, searchSession);
   return rv;
 }
--- a/mailnews/news/src/nsNewsDownloader.h
+++ b/mailnews/news/src/nsNewsDownloader.h
@@ -1,128 +1,136 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _nsNewsDownloader_H_
 #define _nsNewsDownloader_H_
 
-
 #include "nsIMsgDatabase.h"
 #include "nsIUrlListener.h"
 #include "nsIMsgFolder.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgWindow.h"
 #include "nsIMsgSearchNotify.h"
 #include "nsIMsgSearchSession.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsTArray.h"
 
-// base class for downloading articles in a single newsgroup. Keys to download are passed in
-// to DownloadArticles method.
-class nsNewsDownloader : public nsIUrlListener, public nsIMsgSearchNotify
-{
-public:
-  nsNewsDownloader(nsIMsgWindow *window, nsIMsgDatabase *db, nsIUrlListener *listener);
+// base class for downloading articles in a single newsgroup. Keys to download
+// are passed in to DownloadArticles method.
+class nsNewsDownloader : public nsIUrlListener, public nsIMsgSearchNotify {
+ public:
+  nsNewsDownloader(nsIMsgWindow *window, nsIMsgDatabase *db,
+                   nsIUrlListener *listener);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIURLLISTENER
   NS_DECL_NSIMSGSEARCHNOTIFY
 
-  virtual nsresult DownloadArticles(nsIMsgWindow *window, nsIMsgFolder *folder, nsTArray<nsMsgKey> *pKeyArray);
+  virtual nsresult DownloadArticles(nsIMsgWindow *window, nsIMsgFolder *folder,
+                                    nsTArray<nsMsgKey> *pKeyArray);
 
   bool ShouldAbort() const { return m_abort; }
 
-protected:
+ protected:
   virtual ~nsNewsDownloader();
 
-  virtual int32_t Write(const char * /*block*/, int32_t length) {return length;}
+  virtual int32_t Write(const char * /*block*/, int32_t length) {
+    return length;
+  }
   virtual void Abort();
   virtual void Complete();
   virtual bool GetNextHdrToRetrieve();
   virtual nsresult DownloadNext(bool firstTimeP);
-  virtual int32_t FinishDownload() {return 0;}
-  virtual int32_t  StartDownload() {return 0;}
-  virtual nsresult ShowProgress(const char16_t *progressString, int32_t percent);
+  virtual int32_t FinishDownload() { return 0; }
+  virtual int32_t StartDownload() { return 0; }
+  virtual nsresult ShowProgress(const char16_t *progressString,
+                                int32_t percent);
 
-  nsTArray<nsMsgKey>      m_keysToDownload;
-  nsCOMPtr <nsIMsgFolder>  m_folder;
-  nsCOMPtr <nsIMsgDatabase> m_newsDB;
-  nsCOMPtr <nsIUrlListener> m_listener;
+  nsTArray<nsMsgKey> m_keysToDownload;
+  nsCOMPtr<nsIMsgFolder> m_folder;
+  nsCOMPtr<nsIMsgDatabase> m_newsDB;
+  nsCOMPtr<nsIUrlListener> m_listener;
   bool m_downloadFromKeys;
   bool m_existedP;
   bool m_wroteAnyP;
   bool m_summaryValidP;
   bool m_abort;
-  int32_t     m_numwrote;
-  nsMsgKey    m_keyToDownload;
-  nsCOMPtr <nsIMsgWindow> m_window;
-  nsCOMPtr <nsIMsgStatusFeedback> m_statusFeedback;
-  nsCOMPtr <nsIMsgSearchSession> m_searchSession;
+  int32_t m_numwrote;
+  nsMsgKey m_keyToDownload;
+  nsCOMPtr<nsIMsgWindow> m_window;
+  nsCOMPtr<nsIMsgStatusFeedback> m_statusFeedback;
+  nsCOMPtr<nsIMsgSearchSession> m_searchSession;
   int32_t m_lastPercent;
   int64_t m_lastProgressTime;
-  nsresult  m_status;
+  nsresult m_status;
 };
 
-
 // class for downloading articles in a single newsgroup to the offline store.
-class DownloadNewsArticlesToOfflineStore : public nsNewsDownloader
-{
-public:
-  DownloadNewsArticlesToOfflineStore(nsIMsgWindow *window, nsIMsgDatabase *db, nsIUrlListener *listener);
+class DownloadNewsArticlesToOfflineStore : public nsNewsDownloader {
+ public:
+  DownloadNewsArticlesToOfflineStore(nsIMsgWindow *window, nsIMsgDatabase *db,
+                                     nsIUrlListener *listener);
   virtual ~DownloadNewsArticlesToOfflineStore();
 
-  NS_IMETHOD OnStartRunningUrl(nsIURI* url);
-  NS_IMETHOD OnStopRunningUrl(nsIURI* url, nsresult exitCode);
-protected:
-  virtual int32_t  StartDownload();
+  NS_IMETHOD OnStartRunningUrl(nsIURI *url);
+  NS_IMETHOD OnStopRunningUrl(nsIURI *url, nsresult exitCode);
+
+ protected:
+  virtual int32_t StartDownload();
   virtual int32_t FinishDownload();
   virtual bool GetNextHdrToRetrieve();
 
-  nsCOMPtr <nsISimpleEnumerator>  m_headerEnumerator;
-  nsCOMPtr <nsIMsgDBHdr>  m_newsHeader;
+  nsCOMPtr<nsISimpleEnumerator> m_headerEnumerator;
+  nsCOMPtr<nsIMsgDBHdr> m_newsHeader;
 };
 
-// class for downloading all the articles that match the passed in search criteria
-// for a single newsgroup.
-class DownloadMatchingNewsArticlesToNewsDB : public DownloadNewsArticlesToOfflineStore
-{
-public:
-  DownloadMatchingNewsArticlesToNewsDB(nsIMsgWindow *window, nsIMsgFolder *folder, nsIMsgDatabase *newsDB,  nsIUrlListener *listener);
+// class for downloading all the articles that match the passed in search
+// criteria for a single newsgroup.
+class DownloadMatchingNewsArticlesToNewsDB
+    : public DownloadNewsArticlesToOfflineStore {
+ public:
+  DownloadMatchingNewsArticlesToNewsDB(nsIMsgWindow *window,
+                                       nsIMsgFolder *folder,
+                                       nsIMsgDatabase *newsDB,
+                                       nsIUrlListener *listener);
   virtual ~DownloadMatchingNewsArticlesToNewsDB();
-  nsresult RunSearch(nsIMsgFolder *folder, nsIMsgDatabase *newsDB, nsIMsgSearchSession *searchSession);
-protected:
+  nsresult RunSearch(nsIMsgFolder *folder, nsIMsgDatabase *newsDB,
+                     nsIMsgSearchSession *searchSession);
+
+ protected:
 };
 
-// this class iterates all the news servers for each group on the server that's configured for
-// offline use, downloads the messages that meet the download criteria for that newsgroup/server
-class nsMsgDownloadAllNewsgroups : public nsIUrlListener
-{
-public:
+// this class iterates all the news servers for each group on the server that's
+// configured for offline use, downloads the messages that meet the download
+// criteria for that newsgroup/server
+class nsMsgDownloadAllNewsgroups : public nsIUrlListener {
+ public:
   nsMsgDownloadAllNewsgroups(nsIMsgWindow *window, nsIUrlListener *listener);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIURLLISTENER
 
   nsresult ProcessNextGroup();
 
-protected:
+ protected:
   virtual ~nsMsgDownloadAllNewsgroups();
 
-  bool     AdvanceToNextServer();
-  bool     AdvanceToNextGroup();
+  bool AdvanceToNextServer();
+  bool AdvanceToNextGroup();
   nsresult DownloadMsgsForCurrentGroup();
 
   RefPtr<DownloadMatchingNewsArticlesToNewsDB> m_downloaderForGroup;
 
-  nsCOMPtr <nsIMsgFolder> m_currentFolder;
-  nsCOMPtr <nsIMsgWindow> m_window;
-  nsCOMPtr <nsIArray> m_allServers;
-  nsCOMPtr <nsIArray> m_allFolders;
-  nsCOMPtr <nsIMsgIncomingServer> m_currentServer;
-  nsCOMPtr <nsISimpleEnumerator> m_serverEnumerator;
-  nsCOMPtr <nsIUrlListener> m_listener;
+  nsCOMPtr<nsIMsgFolder> m_currentFolder;
+  nsCOMPtr<nsIMsgWindow> m_window;
+  nsCOMPtr<nsIArray> m_allServers;
+  nsCOMPtr<nsIArray> m_allFolders;
+  nsCOMPtr<nsIMsgIncomingServer> m_currentServer;
+  nsCOMPtr<nsISimpleEnumerator> m_serverEnumerator;
+  nsCOMPtr<nsIUrlListener> m_listener;
 
   bool m_downloadedHdrsForCurGroup;
 };
 
 #endif
--- a/mailnews/news/src/nsNewsFolder.cpp
+++ b/mailnews/news/src/nsNewsFolder.cpp
@@ -2,17 +2,17 @@
 /* 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 "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "prlog.h"
 
-#include "msgCore.h"    // precompiled header...
+#include "msgCore.h"  // precompiled header...
 #include "nntpCore.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsNewsFolder.h"
 #include "nsMsgFolderFlags.h"
 #include "MailNewsTypes.h"
 #include "prprf.h"
 #include "prsystem.h"
 #include "nsIArray.h"
@@ -54,92 +54,83 @@
 #include "nsILoginManager.h"
 #include "nsEmbedCID.h"
 #include "mozilla/Services.h"
 #include "nsAutoPtr.h"
 #include "nsIInputStream.h"
 #include "nsMemory.h"
 #include "nsIURIMutator.h"
 
-
 #define kNewsSortOffset 9000
 
 #define NEWS_SCHEME "news:"
 #define SNEWS_SCHEME "snews:"
 
 ////////////////////////////////////////////////////////////////////////////////
 
-nsMsgNewsFolder::nsMsgNewsFolder(void) :
-