Bug 727408 - Remove nsIPrefBranch2 uses from comm-central, Part C - mailnews/ ; r=Standard8
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 22 Feb 2012 11:46:59 +1300
changeset 10906 b55594e9215d5909421b6c9aee198f44b8d3553d
parent 10905 1568ea5a5309db1274c88558003fdbc2089a2a03
child 10907 8b3d55adf7a63521592c9ebc34dd99e43ecc1e88
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs727408
Bug 727408 - Remove nsIPrefBranch2 uses from comm-central, Part C - mailnews/ ; r=Standard8
mailnews/addrbook/src/nsAbAddressCollector.cpp
mailnews/addrbook/src/nsAbView.cpp
mailnews/addrbook/src/nsDirPrefs.cpp
mailnews/base/src/nsMessenger.cpp
mailnews/base/src/nsMsgContentPolicy.cpp
mailnews/base/src/nsMsgDBView.cpp
mailnews/compose/src/nsMsgComposeService.cpp
mailnews/db/gloda/modules/datastore.js
mailnews/db/msgdb/src/nsDBFolderInfo.cpp
mailnews/import/test/unit/test_winmail.js
--- a/mailnews/addrbook/src/nsAbAddressCollector.cpp
+++ b/mailnews/addrbook/src/nsAbAddressCollector.cpp
@@ -39,17 +39,17 @@
 
 #include "msgCore.h"  // for pre-compiled headers
 #include "nsISimpleEnumerator.h"
 
 #include "nsIAbCard.h"
 #include "nsAbBaseCID.h"
 #include "nsAbAddressCollector.h"
 #include "nsIPrefService.h"
-#include "nsIPrefBranch2.h"
+#include "nsIPrefBranch.h"
 #include "nsIMsgHeaderParser.h"
 #include "nsStringGlue.h"
 #include "prmem.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIAbManager.h"
 
 NS_IMPL_ISUPPORTS2(nsAbAddressCollector, nsIAbAddressCollector, nsIObserver)
@@ -58,17 +58,17 @@ NS_IMPL_ISUPPORTS2(nsAbAddressCollector,
 
 nsAbAddressCollector::nsAbAddressCollector()
 {
 }
 
 nsAbAddressCollector::~nsAbAddressCollector()
 {
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch2> pPrefBranchInt(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> pPrefBranchInt(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   if (NS_SUCCEEDED(rv))
     pPrefBranchInt->RemoveObserver(PREF_MAIL_COLLECT_ADDRESSBOOK, this);
 }
 
 /**
  * Returns the first card found with a given property name/value pair. This
  * returns an already addrefed pointer to the card if the card is found.
  */
@@ -328,33 +328,33 @@ nsAbAddressCollector::SplitFullName(cons
   }
 }
 
 // Observes the collected address book pref in case it changes.
 NS_IMETHODIMP
 nsAbAddressCollector::Observe(nsISupports *aSubject, const char *aTopic,
                               const PRUnichar *aData)
 {
-  nsCOMPtr<nsIPrefBranch2> prefBranch = do_QueryInterface(aSubject);
+  nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(aSubject);
   if (!prefBranch) {
     NS_ASSERTION(prefBranch, "failed to get prefs");
     return NS_OK;
   }
 
   SetUpAbFromPrefs(prefBranch);
   return NS_OK;
 }
 
 // Initialises the collector with the required items.
 nsresult
 nsAbAddressCollector::Init(void)
 {
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch2> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID,
-                                                    &rv));
+  nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID,
+                                                   &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = prefBranch->AddObserver(PREF_MAIL_COLLECT_ADDRESSBOOK, this, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   SetUpAbFromPrefs(prefBranch);
   return NS_OK;
 }
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -49,17 +49,17 @@
 #include "nsIAbManager.h"
 #include "nsAbBaseCID.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsITreeColumns.h"
 #include "nsCRTGlue.h"
 #include "nsIMutableArray.h"
 #include "nsIPrefService.h"
-#include "nsIPrefBranch2.h"
+#include "nsIPrefBranch.h"
 #include "nsIStringBundle.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsArrayUtils.h"
 #include "nsIAddrDatabase.h" // for kPriEmailColumn
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
 
 #define CARD_NOT_FOUND -1
@@ -97,18 +97,18 @@ NS_IMETHODIMP nsAbView::ClearView()
     mTree->SetView(nsnull);
   mTree = nsnull;
   mTreeSelection = nsnull;
 
   if (mInitialized)
   {
     nsresult rv;
     mInitialized = false;
-    nsCOMPtr<nsIPrefBranch2> pbi(do_GetService(NS_PREFSERVICE_CONTRACTID,
-                                               &rv));
+    nsCOMPtr<nsIPrefBranch> pbi(do_GetService(NS_PREFSERVICE_CONTRACTID,
+                                              &rv));
     NS_ENSURE_SUCCESS(rv,rv);
 
     rv = pbi->RemoveObserver(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, this);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIAbManager> abManager(do_GetService(NS_ABMANAGER_CONTRACTID,
                                                    &rv));
     NS_ENSURE_SUCCESS(rv, rv);
@@ -147,17 +147,17 @@ nsresult nsAbView::RemoveCardAt(PRInt32 
     NS_ENSURE_SUCCESS(rv,rv);
   }
   return NS_OK;
 }
 
 nsresult nsAbView::SetGeneratedNameFormatFromPrefs()
 {
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch2> prefBranchInt(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> prefBranchInt(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv,rv);
 
   return prefBranchInt->GetIntPref(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, &mGeneratedNameFormat);
 }
 
 nsresult nsAbView::Initialize()
 {
   if (mInitialized)
@@ -167,17 +167,17 @@ nsresult nsAbView::Initialize()
 
   nsresult rv;
   nsCOMPtr<nsIAbManager> abManager(do_GetService(NS_ABMANAGER_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = abManager->AddAddressBookListener(this, nsIAbListener::all);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIPrefBranch2> pbi(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> pbi(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = pbi->AddObserver(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, this, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!mABBundle)
   {
     nsCOMPtr<nsIStringBundleService> stringBundleService =
@@ -1176,17 +1176,17 @@ NS_IMETHODIMP nsAbView::SwapFirstNameLas
   if (!selectionCount)
     return NS_OK;
   
   // Prepare for displayname generation
   // No cache for pref and bundle since the swap operation is not executed frequently
   bool displayNameAutoGeneration;
   bool displayNameLastnamefirst = false;
 
-  nsCOMPtr<nsIPrefBranch2> pPrefBranchInt(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+  nsCOMPtr<nsIPrefBranch> pPrefBranchInt(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = pPrefBranchInt->GetBoolPref(PREF_MAIL_ADDR_BOOK_DISPLAYNAME_AUTOGENERATION, &displayNameAutoGeneration);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStringBundle> bundle;
   if (displayNameAutoGeneration)
   {
--- a/mailnews/addrbook/src/nsDirPrefs.cpp
+++ b/mailnews/addrbook/src/nsDirPrefs.cpp
@@ -36,17 +36,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* directory server preferences (used to be dirprefs.c in 4.x) */
 
 #include "nsIPrefService.h"
-#include "nsIPrefBranch2.h"
+#include "nsIPrefBranch.h"
 #include "nsDirPrefs.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIObserver.h"
 #include "nsVoidArray.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMemory.h"
 #include "nsIAddrDatabase.h"
 #include "nsAbBaseCID.h"
@@ -186,17 +186,17 @@ static nsresult DIR_GetDirServers()
   if (!dir_ServerList)
   {
     /* we need to build the DIR_Server list */ 
     rv = DIR_GetServerPreferences(&dir_ServerList);
 
     /* Register the preference call back if necessary. */
     if (NS_SUCCEEDED(rv) && !prefObserver)
     {
-      nsCOMPtr<nsIPrefBranch2> pbi(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
+      nsCOMPtr<nsIPrefBranch> pbi(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
       if (NS_FAILED(rv))
         return rv;
       prefObserver = new DirPrefObserver();
 
       if (!prefObserver)
         return NS_ERROR_OUT_OF_MEMORY;
 
       NS_ADDREF(prefObserver);
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -126,17 +126,16 @@
 #include "nsMsgMimeCID.h"
 #include "nsIMimeConverter.h"
 
 // Save As
 #include "nsIFilePicker.h"
 #include "nsIStringBundle.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
-#include "nsIPrefBranch2.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIExternalProtocolService.h"
 #include "nsIMIMEService.h"
 #include "nsITransfer.h"
 
 #include "nsILinkHandler.h"
 
 static NS_DEFINE_CID(kRDFServiceCID,  NS_RDFSERVICE_CID);
--- a/mailnews/base/src/nsMsgContentPolicy.cpp
+++ b/mailnews/base/src/nsMsgContentPolicy.cpp
@@ -34,17 +34,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsMsgContentPolicy.h"
 #include "nsIPrefService.h"
-#include "nsIPrefBranch2.h"
+#include "nsIPrefBranch.h"
 #include "nsIMsgHeaderParser.h"
 #include "nsIAbManager.h"
 #include "nsIAbDirectory.h"
 #include "nsIAbCard.h"
 #include "nsIMsgWindow.h"
 #include "nsIMimeMiscStatus.h"
 #include "nsIMsgHdr.h"
 #include "nsNetUtil.h"
@@ -82,30 +82,30 @@ nsMsgContentPolicy::nsMsgContentPolicy()
   mAllowPlugins = false;
   mBlockRemoteImages = true;
 }
 
 nsMsgContentPolicy::~nsMsgContentPolicy()
 {
   // hey, we are going away...clean up after ourself....unregister our observer
   nsresult rv;
-  nsCOMPtr<nsIPrefBranch2> prefInternal = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  nsCOMPtr<nsIPrefBranch> prefInternal = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv))
   {
     prefInternal->RemoveObserver(kBlockRemoteImages, this);
     prefInternal->RemoveObserver(kAllowPlugins, this);
   }
 }
 
 nsresult nsMsgContentPolicy::Init()
 {
   nsresult rv;
 
   // register ourself as an observer on the mail preference to block remote images
-  nsCOMPtr<nsIPrefBranch2> prefInternal = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+  nsCOMPtr<nsIPrefBranch> prefInternal = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   prefInternal->AddObserver(kBlockRemoteImages, this, true);
   prefInternal->AddObserver(kAllowPlugins, this, true);
 
   prefInternal->GetBoolPref(kAllowPlugins, &mAllowPlugins);
   prefInternal->GetCharPref(kTrustedDomains, getter_Copies(mTrustedMailDomains));
   prefInternal->GetBoolPref(kBlockRemoteImages, &mBlockRemoteImages);
@@ -794,17 +794,17 @@ nsMsgContentPolicy::ShouldProcess(PRUint
 NS_IMETHODIMP nsMsgContentPolicy::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
 {
   if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) 
   {
     NS_LossyConvertUTF16toASCII pref(aData);
 
     nsresult rv;
 
-    nsCOMPtr<nsIPrefBranch2> prefBranchInt = do_QueryInterface(aSubject, &rv);
+    nsCOMPtr<nsIPrefBranch> prefBranchInt = do_QueryInterface(aSubject, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (pref.Equals(kBlockRemoteImages))
       prefBranchInt->GetBoolPref(kBlockRemoteImages, &mBlockRemoteImages);
     if (pref.Equals(kAllowPlugins))
       prefBranchInt->GetBoolPref(kAllowPlugins, &mAllowPlugins);
   }
 
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -55,17 +55,16 @@
 #include "nsImapCore.h"
 #include "nsMsgFolderFlags.h"
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIDOMElement.h"
 #include "nsDateTimeFormatCID.h"
 #include "nsMsgMimeCID.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
-#include "nsIPrefBranch2.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIMsgSearchSession.h"
 #include "nsIMsgCopyService.h"
 #include "nsMsgBaseCID.h"
 #include "nsISpamSettings.h"
 #include "nsIMsgAccountManager.h"
 #include "nsITreeColumns.h"
 #include "nsTextFormatter.h"
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -66,17 +66,16 @@
 #include "nsIDOMElement.h"
 #include "nsIXULWindow.h"
 #include "nsIWindowMediator.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIBaseWindow.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
-#include "nsIPrefBranch2.h"
 #include "nsMsgBaseCID.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIMimeMiscStatus.h"
 #include "nsIStreamConverter.h"
 #include "nsMsgMimeCID.h"
 #include "nsToolkitCompsCID.h"
 #include "nsNetUtil.h"
 #include "nsIMsgMailNewsUrl.h"
@@ -196,17 +195,17 @@ nsresult nsMsgComposeService::Init()
     mozilla::services::GetObserverService();
   if (observerService)
   {
     rv = observerService->AddObserver(this, "quit-application", true);
     rv = observerService->AddObserver(this, "profile-do-change", true);
   }
 
   // Register some pref observer
-  nsCOMPtr<nsIPrefBranch2> pbi = do_GetService(NS_PREFSERVICE_CONTRACTID);
+  nsCOMPtr<nsIPrefBranch> pbi = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (pbi)
     rv = pbi->AddObserver(PREF_MAIL_COMPOSE_MAXRECYCLEDWINDOWS, this, true);
 
   mOpenComposeWindows.Init();
   Reset();
 
   AddGlobalHtmlDomains();
   return rv;
--- a/mailnews/db/gloda/modules/datastore.js
+++ b/mailnews/db/gloda/modules/datastore.js
@@ -956,17 +956,17 @@ var GlodaDatastore = {
     this._log = Log4Moz.repository.getLogger("gloda.datastore");
     this._log.debug("Beginning datastore initialization.");
 
     this._nounIDToDef = aNounIDToDef;
 
     let prefService = Cc["@mozilla.org/preferences-service;1"].
                         getService(Ci.nsIPrefService);
     let branch = prefService.getBranch("mailnews.database.global.datastore.");
-    this._prefBranch = branch.QueryInterface(Ci.nsIPrefBranch2);
+    this._prefBranch = branch;
 
     // Not sure the weak reference really makes a difference given that we are a
     // GC root.
     branch.addObserver("", this, false);
     // claim the pref changed so we can centralize our logic there.
     this.observe(null, "nsPref:changed", "explainToPath");
 
     // Get the path to our global database
--- a/mailnews/db/msgdb/src/nsDBFolderInfo.cpp
+++ b/mailnews/db/msgdb/src/nsDBFolderInfo.cpp
@@ -37,17 +37,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "msgCore.h"
 #include "nsDBFolderInfo.h"
 #include "nsMsgDatabase.h"
 #include "nsMsgFolderFlags.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
-#include "nsIPrefBranch2.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIMsgDBView.h"
 #include "nsISupportsObsolete.h"
 #include "nsServiceManagerUtils.h"
 #include "nsImapCore.h"
 #include "mozilla/Services.h"
@@ -130,22 +129,18 @@ NS_IMETHODIMP nsFolderCharsetObserver::O
     }
     else if (prefName.EqualsLiteral(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE))
     {
       rv = prefBranch->GetBoolPref(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, &gDefaultCharacterOverride);
     }
   }
   else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
   {
-    nsCOMPtr<nsIPrefBranch2> pbi = do_QueryInterface(prefBranch);
-    if (pbi)
-    {
-      rv = pbi->RemoveObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, this);
-      rv = pbi->RemoveObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, this);
-    }
+    rv = prefBranch->RemoveObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, this);
+    rv = prefBranch->RemoveObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, this);
     NS_IF_RELEASE(gFolderCharsetObserver);
     delete gDefaultCharacterSet;
     gDefaultCharacterSet = nsnull;
   }
   return rv;
 }
 
 
@@ -226,21 +221,18 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgData
 
       gFolderCharsetObserver = new nsFolderCharsetObserver();
       NS_ASSERTION(gFolderCharsetObserver, "failed to create observer");
 
       // register prefs callbacks
       if (gFolderCharsetObserver)
       {
         NS_ADDREF(gFolderCharsetObserver);
-        nsCOMPtr<nsIPrefBranch2> pbi = do_QueryInterface(prefBranch);
-        if (pbi) {
-          rv = pbi->AddObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, gFolderCharsetObserver, false);
-          rv = pbi->AddObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, gFolderCharsetObserver, false);
-        }
+        rv = prefBranch->AddObserver(kMAILNEWS_VIEW_DEFAULT_CHARSET, gFolderCharsetObserver, false);
+        rv = prefBranch->AddObserver(kMAILNEWS_DEFAULT_CHARSET_OVERRIDE, gFolderCharsetObserver, false);
 
         // also register for shutdown
         nsCOMPtr<nsIObserverService> observerService =
           mozilla::services::GetObserverService();
         if (observerService)
         {
           rv = observerService->AddObserver(gFolderCharsetObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
         }
--- a/mailnews/import/test/unit/test_winmail.js
+++ b/mailnews/import/test/unit/test_winmail.js
@@ -77,17 +77,17 @@ function run_test()
   Components.manager.QueryInterface(Ci.nsIComponentRegistrar)
             .registerFactory(Components.ID("{0478de5b-0f38-4edb-851d-4c99f1ed8eba}"),
                              "Mock Windows Registry Implementation",
                              "@mozilla.org/windows-registry-key;1", factory);
 //////////////// -- Modified nsIWindowsRegKey implementation ---
 
   var importedPrefs = [];
   var prefS = Cc["@mozilla.org/preferences-service;1"]
-               .getService(Ci.nsIPrefBranch2);
+               .getService(Ci.nsIPrefBranch);
   var obs = {
     QueryInterface: function QueryInterface(aIID) {
       if (aIID.equals(Ci.nsIObserver) || aaIID.equals(Ci.nsISupports))
         return this;
       do_throw(Cr.NS_NOINTERFACE);
     },
     observe: function observe(aSubj, aTopic, aData) {
       let prefSetting = {};