Bug 560772 - Make use of mozilla::services for comm-central. r=Standard8 a=Standard8 for CLOSED TREE
authorJustin Wood <Callek@gmail.com>
Mon, 02 Jan 2012 01:21:21 -0500
changeset 10818 23367078802034b888f2137483a4c356a2c7cb9e
parent 10817 fb4163ac866a1ea8918c61b760e354b70e142719
child 10819 465ce21de933b568b949cfa3f6561d4494b08cba
push idunknown
push userunknown
push dateunknown
reviewersStandard8, Standard8
bugs560772
Bug 560772 - Make use of mozilla::services for comm-central. r=Standard8 a=Standard8 for CLOSED TREE
mail/components/shell/nsMailGNOMEIntegration.cpp
mailnews/addrbook/src/nsAbCardProperty.cpp
mailnews/addrbook/src/nsAbDirFactoryService.cpp
mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp
mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
mailnews/addrbook/src/nsAbLDAPDirectory.cpp
mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
mailnews/addrbook/src/nsAbManager.cpp
mailnews/addrbook/src/nsAbView.cpp
mailnews/addrbook/src/nsAddbookProtocolHandler.cpp
mailnews/addrbook/src/nsAddrDatabase.cpp
mailnews/base/search/src/nsMsgFilter.cpp
mailnews/base/search/src/nsMsgFilterService.cpp
mailnews/base/src/nsMailDirProvider.cpp
mailnews/base/src/nsMessenger.cpp
mailnews/base/src/nsMessengerUnixIntegration.cpp
mailnews/base/src/nsMessengerWinIntegration.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgAccountManagerDS.cpp
mailnews/base/src/nsMsgBiffManager.cpp
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgFolderDataSource.cpp
mailnews/base/src/nsMsgMailSession.cpp
mailnews/base/src/nsMsgOfflineManager.cpp
mailnews/base/src/nsMsgPrintEngine.cpp
mailnews/base/src/nsMsgProgress.cpp
mailnews/base/src/nsMsgRDFDataSource.cpp
mailnews/base/src/nsMsgStatusFeedback.cpp
mailnews/base/src/nsSpamSettings.cpp
mailnews/base/src/nsStatusBarBiffManager.cpp
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/base/util/nsMsgIncomingServer.cpp
mailnews/base/util/nsMsgMailNewsUrl.cpp
mailnews/base/util/nsMsgProtocol.cpp
mailnews/base/util/nsMsgUtils.cpp
mailnews/compose/src/nsMsgAttachmentHandler.cpp
mailnews/compose/src/nsMsgCompUtils.cpp
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgComposeService.cpp
mailnews/compose/src/nsMsgPrompts.cpp
mailnews/compose/src/nsMsgQuote.cpp
mailnews/compose/src/nsMsgSend.cpp
mailnews/compose/src/nsMsgSendLater.cpp
mailnews/compose/src/nsMsgSendReport.cpp
mailnews/compose/src/nsSmtpProtocol.cpp
mailnews/db/msgdb/src/nsDBFolderInfo.cpp
mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp
mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
mailnews/imap/src/nsAutoSyncManager.cpp
mailnews/imap/src/nsIMAPHostSessionList.cpp
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapStringBundle.cpp
mailnews/import/applemail/src/nsAppleMailImport.cpp
mailnews/import/eudora/src/nsEudoraFilters.cpp
mailnews/import/eudora/src/nsEudoraStringBundle.cpp
mailnews/import/oexpress/nsOEStringBundle.cpp
mailnews/import/outlook/src/nsOutlookStringBundle.cpp
mailnews/import/src/nsImportMail.cpp
mailnews/import/src/nsImportStringBundle.cpp
mailnews/import/winlivemail/nsWMStringBundle.cpp
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsMailboxUrl.cpp
mailnews/local/src/nsMovemailService.cpp
mailnews/local/src/nsParseMailbox.cpp
mailnews/local/src/nsPop3Protocol.cpp
mailnews/local/src/nsPop3Service.cpp
mailnews/local/src/nsPop3Sink.cpp
mailnews/mapi/mapihook/src/msgMapiHook.cpp
mailnews/mapi/mapihook/src/msgMapiSupport.cpp
mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp
mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
mailnews/mime/src/mimemoz2.cpp
mailnews/news/src/nsNNTPNewsgroupList.cpp
mailnews/news/src/nsNNTPProtocol.cpp
mailnews/news/src/nsNewsDownloader.cpp
mailnews/news/src/nsNewsFolder.cpp
mailnews/news/src/nsNntpIncomingServer.cpp
suite/shell/src/nsWindowsShellService.cpp
--- a/mail/components/shell/nsMailGNOMEIntegration.cpp
+++ b/mail/components/shell/nsMailGNOMEIntegration.cpp
@@ -47,16 +47,17 @@
 #include "nsIPromptService.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsEmbedCID.h"
 #include "nsMemory.h"
 #include "nsIStringBundle.h"
+#include "mozilla/Services.h"
 
 #include <glib.h>
 #include <limits.h>
 #include <stdlib.h>
 
 static const char* const sMailProtocols[] = {
   "mailto"
 };
@@ -296,18 +297,18 @@ nsMailGNOMEIntegration::MakeDefault(cons
       rv = gconf->SetAppForProtocol(nsDependentCString(aProtocols[i]),
                                     appKeyValue);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   if (giovfs) {
     nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     nsCOMPtr<nsIStringBundle> brandBundle;
     rv = bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsString brandShortName;
     brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
                                    getter_Copies(brandShortName));
--- a/mailnews/addrbook/src/nsAbCardProperty.cpp
+++ b/mailnews/addrbook/src/nsAbCardProperty.cpp
@@ -56,16 +56,17 @@
 #include "nsArrayUtils.h"
 #include "mozITXTToHTMLConv.h"
 #include "nsIAbManager.h"
 
 #include "nsIProperty.h"
 #include "nsCOMArray.h"
 #include "nsArrayEnumerator.h"
 #include "prmem.h"
+#include "mozilla/Services.h"
 
 #define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
 
 const char sAddrbookProperties[] = "chrome://messenger/locale/addressbook/addressBook.properties";
 
 enum EAppendType {
   eAppendLine,
   eAppendLabel,
@@ -719,18 +720,19 @@ nsresult nsAbCardProperty::ConvertToBase
   nsString xmlStr;
 
   xmlStr.AppendLiteral("<?xml version=\"1.0\"?>\n"
                        "<?xml-stylesheet type=\"text/css\" href=\"chrome://messagebody/content/addressbook/print.css\"?>\n"
                        "<directory>\n");
 
   // Get Address Book string and set it as title of XML document
   nsCOMPtr<nsIStringBundle> bundle;
-  nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv)) {
+  nsCOMPtr<nsIStringBundleService> stringBundleService =
+    mozilla::services::GetStringBundleService();
+  if (stringBundleService) {
     rv = stringBundleService->CreateBundle(sAddrbookProperties, getter_AddRefs(bundle));
     if (NS_SUCCEEDED(rv)) {
       nsString addrBook;
       rv = bundle->GetStringFromName(NS_LITERAL_STRING("addressBook").get(), getter_Copies(addrBook));
       if (NS_SUCCEEDED(rv)) {
         xmlStr.AppendLiteral("<title xmlns=\"http://www.w3.org/1999/xhtml\">");
         xmlStr.Append(addrBook);
         xmlStr.AppendLiteral("</title>\n");
@@ -756,18 +758,19 @@ nsresult nsAbCardProperty::ConvertToXMLP
   nsresult rv;
   nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   PRInt32 generatedNameFormat;
   rv = prefBranch->GetIntPref(PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST, &generatedNameFormat);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIStringBundleService> stringBundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(stringBundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = stringBundleService->CreateBundle(sAddrbookProperties, getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsString generatedName;
   rv = GenerateName(generatedNameFormat, bundle, generatedName);
   NS_ENSURE_SUCCESS(rv,rv);
@@ -1086,18 +1089,18 @@ NS_IMETHODIMP nsAbCardProperty::Generate
     aResult = firstName;
   else if (firstName.IsEmpty())
     aResult = lastName;
   else {
     nsresult rv;
     nsCOMPtr<nsIStringBundle> bundle(aBundle);
     if (!bundle) {
       nsCOMPtr<nsIStringBundleService> stringBundleService =
-        do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); 
-      NS_ENSURE_SUCCESS(rv, rv);
+        mozilla::services::GetStringBundleService();
+      NS_ENSURE_TRUE(stringBundleService, NS_ERROR_UNEXPECTED);
         
       rv = stringBundleService->CreateBundle(sAddrbookProperties,
                                              getter_AddRefs(bundle));
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     nsString result;
 
--- a/mailnews/addrbook/src/nsAbDirFactoryService.cpp
+++ b/mailnews/addrbook/src/nsAbDirFactoryService.cpp
@@ -44,16 +44,17 @@
 #include "nsNetCID.h"
 #include "nsMemory.h"
 #include "nsStringGlue.h"
 #include "plstr.h"
 
 #include "nsAbBaseCID.h"
 #include "nsAbDirFactoryService.h"
 #include "nsIAbDirFactory.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS1(nsAbDirFactoryService, nsIAbDirFactoryService)
 
 nsAbDirFactoryService::nsAbDirFactoryService()
 {
 }
 
 nsAbDirFactoryService::~nsAbDirFactoryService()
@@ -65,18 +66,19 @@ NS_IMETHODIMP
 nsAbDirFactoryService::GetDirFactory(const nsACString &aURI,
                                      nsIAbDirFactory** aDirFactory)
 {
   NS_ENSURE_ARG_POINTER(aDirFactory);
 
   nsresult rv;
 
   // Obtain the network IO service
-  nsCOMPtr<nsIIOService> nsService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIIOService> nsService =
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(nsService, NS_ERROR_UNEXPECTED);
     
   // Extract the scheme
   nsCAutoString scheme;
   rv = nsService->ExtractScheme(aURI, scheme);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Try to find a factory using the component manager.
   nsCAutoString contractID;
--- a/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp
@@ -45,16 +45,17 @@
 #include "nsILDAPMessage.h"
 #include "nsIStringBundle.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsNetError.h"
 #include "nsMemory.h"
 #include "nsILDAPErrors.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 #define LDAP_ERROR_BUNDLE "chrome://mozldap/locale/ldap.properties"
 #define LDAP_AUTOCOMPLETE_ERROR_BUNDLE "chrome://messenger/locale/addressbook/ldapAutoCompErrs.properties"
 
 NS_IMPL_ISUPPORTS2(nsAbLDAPAutoCompFormatter, 
 		   nsILDAPAutoCompFormatter, 
 		   nsIAbLDAPAutoCompFormatter)
 
@@ -176,22 +177,22 @@ nsAbLDAPAutoCompFormatter::FormatExcepti
         return NS_ERROR_NOT_AVAILABLE;
     }
 
     // get the string bundle service
     //
     nsString errMsg, ldapErrMsg, alertMsg, ldapHint;
     nsString errCodeNum;
 
-    nsCOMPtr<nsIStringBundleService> stringBundleSvc(do_GetService(
-                                            NS_STRINGBUNDLE_CONTRACTID, &rv)); 
-    if (NS_FAILED(rv)) {
+    nsCOMPtr<nsIStringBundleService> stringBundleSvc =
+        mozilla::services::GetStringBundleService();
+    if (stringBundleSvc) {
         NS_ERROR("nsAbLDAPAutoCompleteFormatter::FormatException():"
                  " error getting string bundle service");
-        return rv;
+        return NS_ERROR_UNEXPECTED;
     }
 
     // get the string bundles relevant here: the main LDAP bundle,
     // and the ldap AutoCompletion-specific bundle
     //
     nsCOMPtr<nsIStringBundle> ldapBundle, ldapACBundle;
 
     rv = stringBundleSvc->CreateBundle(
--- a/mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPChangeLogData.cpp
@@ -50,16 +50,17 @@
 #include "nsAbLDAPCard.h"
 #include "nsIAuthPrompt.h"
 #include "nsIStringBundle.h"
 #include "nsIWindowWatcher.h"
 #include "nsUnicharUtils.h"
 #include "plstr.h"
 #include "nsILDAPErrors.h"
 #include "prmem.h"
+#include "mozilla/Services.h"
 
 // Defined here since to be used
 // only locally to this file.
 enum UpdateOp {
  NO_OP,
  ENTRY_ADD,
  ENTRY_DELETE,
  ENTRY_MODIFY
@@ -281,19 +282,19 @@ nsresult nsAbLDAPProcessChangeLogData::G
     if (NS_FAILED(rv))
         return rv;
 
     nsCAutoString serverUri;
     rv = url->GetSpec(serverUri);
     if (NS_FAILED(rv)) 
         return rv;
 
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    if (NS_FAILED (rv)) 
-        return rv ;
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(bundle));
     if (NS_FAILED (rv)) 
         return rv ;
 
     nsString title;
     rv = bundle->GetStringFromName(NS_LITERAL_STRING("AuthDlgTitle").get(), getter_Copies(title));
     if (NS_FAILED (rv)) 
--- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
@@ -65,16 +65,17 @@
 #include "nsILDAPService.h"
 #include "nsIAbLDAPCard.h"
 #include "nsAbUtils.h"
 #include "nsArrayUtils.h"
 #include "nsIPrefService.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 #define kDefaultMaxHits 100
 
 using namespace mozilla;
 
 nsAbLDAPDirectory::nsAbLDAPDirectory() :
   nsAbDirProperty(),
   mPerformingQuery(false),
@@ -142,18 +143,19 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetChil
 }
 
 NS_IMETHODIMP nsAbLDAPDirectory::GetChildCards(nsISimpleEnumerator** result)
 {
     nsresult rv;
     
     // when offline, we need to get the child cards for the local, replicated mdb directory 
     bool offline;
-    nsCOMPtr <nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv,rv);
+    nsCOMPtr <nsIIOService> ioService =
+      mozilla::services::GetIOService();
+    NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
     rv = ioService->GetOffline(&offline);
     NS_ENSURE_SUCCESS(rv,rv);
     
     if (offline) {
       nsCString fileName;
       rv = GetReplicationFileName(fileName);
       NS_ENSURE_SUCCESS(rv,rv);
       
@@ -244,18 +246,19 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetLDAP
      * case where it is not a preference, we need to replace the
      * "moz-abldapdirectory".
      */
     URI = mURINoQuery;
     if (StringBeginsWith(URI, NS_LITERAL_CSTRING(kLDAPDirectoryRoot)))
       URI.Replace(0, kLDAPDirectoryRootLen, NS_LITERAL_CSTRING("ldap://"));
   }
 
-  nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIIOService> ioService =
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIURI> result;
   rv = ioService->NewURI(URI, nsnull, nsnull, getter_AddRefs(result));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return CallQueryInterface(result, aResult);
 }
 
@@ -441,18 +444,18 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetRead
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (readOnly)
     return NS_OK;
 
   // when online, we'll allow writing as well
   bool offline;
   nsCOMPtr <nsIIOService> ioService =
-    do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
 
   rv = ioService->GetOffline(&offline);
   NS_ENSURE_SUCCESS(rv,rv);
 
   if (!offline)
     *aReadOnly = false;
 #endif
 
@@ -485,18 +488,18 @@ NS_IMETHODIMP nsAbLDAPDirectory::UseForA
   NS_ENSURE_ARG_POINTER(aResult);
 
   // Set this to false by default to make the code easier below.
   *aResult = false;
 
   nsresult rv;
   bool offline = false;
   nsCOMPtr <nsIIOService> ioService =
-    do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
 
   rv = ioService->GetOffline(&offline);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If we're online, then don't allow search during local autocomplete - must
   // use the separate LDAP autocomplete session due to the current interfaces
   if (!offline)
     return NS_OK;
--- a/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
@@ -46,16 +46,17 @@
 #include "nsIStringBundle.h"
 #include "nsILDAPMessage.h"
 #include "nsILDAPErrors.h"
 #include "nsILoginManager.h"
 #include "nsILoginInfo.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMemory.h"
+#include "mozilla/Services.h"
 
 using namespace mozilla;
 
 nsAbLDAPListenerBase::nsAbLDAPListenerBase(nsILDAPURL* url,
                                            nsILDAPConnection* connection,
                                            const nsACString &login,
                                            const PRInt32 timeOut) :
   mDirectoryUrl(url), mConnection(connection), mLogin(login),
@@ -104,23 +105,23 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
 
   // If mLogin is set, we're expected to use it to get a password.
   //
   if (!mLogin.IsEmpty() && !mSaslMechanism.EqualsLiteral("GSSAPI"))
   {
     // get the string bundle service
     //
     nsCOMPtr<nsIStringBundleService> stringBundleSvc = 
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    if (NS_FAILED(rv))
+      mozilla::services::GetStringBundleService();
+    if (!stringBundleSvc)
     {
       NS_ERROR("nsAbLDAPListenerBase::OnLDAPInit():"
                " error getting string bundle service");
       InitFailed();
-      return rv;
+      return NS_ERROR_UNEXPECTED;
     }
 
     // get the LDAP string bundle
     //
     nsCOMPtr<nsIStringBundle> ldapBundle;
     rv = stringBundleSvc->CreateBundle("chrome://mozldap/locale/ldap.properties",
                                        getter_AddRefs(ldapBundle));
     if (NS_FAILED(rv))
--- a/mailnews/addrbook/src/nsAbManager.cpp
+++ b/mailnews/addrbook/src/nsAbManager.cpp
@@ -66,16 +66,17 @@
 #include "nsDirectoryServiceUtils.h"
 #include "nsIObserverService.h"
 #include "nsDirPrefs.h"
 #include "nsThreadUtils.h"
 #include "nsIAbDirFactory.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIIOService.h"
 #include "nsAbQueryStringToExpression.h"
+#include "mozilla/Services.h"
 
 struct ExportAttributesTableStruct
 {
   const char* abPropertyName;
   PRUint32 plainTextStringID;
 };
 
 // our schema is not fixed yet, but we still want some sort of objectclass
@@ -167,22 +168,21 @@ NS_IMPL_QUERY_INTERFACE3(nsAbManager,
                          nsIAbManager,
                          nsICommandLineHandler,
                          nsIObserver)
 
 nsresult nsAbManager::Init()
 {
   NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_FAILURE);
 
-  nsresult rv;
   nsCOMPtr<nsIObserverService> observerService =
-    do_GetService("@mozilla.org/observer-service;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetObserverService();
+  NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
 
-  rv = observerService->AddObserver(this, "profile-do-change", false);
+  nsresult rv = observerService->AddObserver(this, "profile-do-change", false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
                                     false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
@@ -201,22 +201,21 @@ NS_IMETHODIMP nsAbManager::Observe(nsISu
     DIR_ShutDown();
     return NS_OK;
   }
 
   if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
   {
     DIR_ShutDown();
 
-    nsresult rv;
     nsCOMPtr<nsIObserverService> observerService =
-      do_GetService("@mozilla.org/observer-service;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+      mozilla::services::GetObserverService();
+    NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
 
-    rv = observerService->RemoveObserver(this, "profile-do-change");
+    nsresult rv = observerService->RemoveObserver(this, "profile-do-change");
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
@@ -535,18 +534,19 @@ enum ADDRESSBOOK_EXPORT_FILE_TYPE
 NS_IMETHODIMP nsAbManager::ExportAddressBook(nsIDOMWindow *aParentWin, nsIAbDirectory *aDirectory)
 {
   NS_ENSURE_ARG_POINTER(aParentWin);
 
   nsresult rv;
   nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString title;
   rv = bundle->GetStringFromName(NS_LITERAL_STRING("ExportAddressBookTitle").get(), getter_Copies(title));
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -661,18 +661,19 @@ nsAbManager::ExportDirectoryToDelimitedT
   // the desired file may be read only
   if (NS_FAILED(rv))
     return rv;
 
   PRUint32 i;
   PRUint32 writeCount;
   PRUint32 length;
 
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/importMsgs.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCString revisedName;
   nsString columnName;
 
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -55,16 +55,17 @@
 #include "nsIMutableArray.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch2.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
 #define ALL_ROWS -1
 
 #define PREF_MAIL_ADDR_BOOK_LASTNAMEFIRST "mail.addr_book.lastnamefirst"
 #define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_AUTOGENERATION "mail.addr_book.displayName.autoGeneration"
 #define PREF_MAIL_ADDR_BOOK_DISPLAYNAME_LASTNAMEFIRST "mail.addr_book.displayName.lastnamefirst"
 
@@ -175,18 +176,18 @@ nsresult nsAbView::Initialize()
   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 =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); 
-    NS_ENSURE_SUCCESS(rv, rv);
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(stringBundleService, NS_ERROR_UNEXPECTED);
 
     rv = stringBundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(mABBundle));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return SetGeneratedNameFormatFromPrefs();
 }
 
@@ -1192,18 +1193,19 @@ NS_IMETHODIMP nsAbView::SwapFirstNameLas
     nsCOMPtr<nsIPrefLocalizedString> pls;
     rv = pPrefBranchInt->GetComplexValue(PREF_MAIL_ADDR_BOOK_DISPLAYNAME_LASTNAMEFIRST,
                                          NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(pls));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsString str;
     pls->ToString(getter_Copies(str));
     displayNameLastnamefirst = str.EqualsLiteral("true");
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     rv = bundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", 
                                      getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   for (PRInt32 i = 0; i < selectionCount; i++)
   {
--- a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp
+++ b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp
@@ -51,16 +51,17 @@
 #include "nsStringStream.h"
 #include "nsIAbDirectory.h"
 #include "nsIAbManager.h"
 #include "prmem.h"
 #include "nsIAbView.h"
 #include "nsITreeView.h"
 #include "nsIStringBundle.h"
 #include "nsIServiceManager.h"
+#include "mozilla/Services.h"
 
 nsAddbookProtocolHandler::nsAddbookProtocolHandler()
 {
   mAddbookOperation = nsIAddbookUrlOperation::InvalidUrl;
 }
 
 nsAddbookProtocolHandler::~nsAddbookProtocolHandler()
 {
@@ -260,18 +261,19 @@ nsAddbookProtocolHandler::BuildDirectory
   nsCOMPtr<nsIAbCard> card;
 
   aOutput.AppendLiteral("<?xml version=\"1.0\"?>\n"
                         "<?xml-stylesheet type=\"text/css\" href=\"chrome://messagebody/content/addressbook/print.css\"?>\n"
                         "<directory>\n");
 
   // Get Address Book string and set it as title of XML document
   nsCOMPtr<nsIStringBundle> bundle;
-  nsCOMPtr<nsIStringBundleService> stringBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); 
-  if (NS_SUCCEEDED(rv)) {
+  nsCOMPtr<nsIStringBundleService> stringBundleService =
+    mozilla::services::GetStringBundleService();
+  if (stringBundleService) {
     rv = stringBundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(bundle));
     if (NS_SUCCEEDED(rv)) {
       nsString addrBook;
       rv = bundle->GetStringFromName(NS_LITERAL_STRING("addressBook").get(), getter_Copies(addrBook));
       if (NS_SUCCEEDED(rv)) {
         aOutput.AppendLiteral("<title xmlns=\"http://www.w3.org/1999/xhtml\">");
         aOutput.Append(addrBook);
         aOutput.AppendLiteral("</title>\n");
--- a/mailnews/addrbook/src/nsAddrDatabase.cpp
+++ b/mailnews/addrbook/src/nsAddrDatabase.cpp
@@ -60,16 +60,17 @@
 #include "nsEmbedCID.h"
 #include "nsIProperty.h"
 #include "nsIVariant.h"
 #include "nsCOMArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIAbManager.h"
+#include "mozilla/Services.h"
 
 #define ID_PAB_TABLE            1
 #define ID_DELETEDCARDS_TABLE           2
 
 // There's two books by default, although Mac may have one more, so set this
 // to three. Its not going to affect much, but will save us a few reallocations
 // when the cache is allocated.
 const PRUint32 kInitialAddrDBCacheSize = 3;
@@ -465,18 +466,19 @@ NS_IMETHODIMP nsAddrDatabase::Open
     }
   }
   return rv;
 }
 
 nsresult nsAddrDatabase::DisplayAlert(const PRUnichar *titleName, const PRUnichar *alertStringName, const PRUnichar **formatStrings, PRInt32 numFormatStrings)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/addressbook/addressBook.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString alertMessage;
   rv = bundle->FormatStringFromName(alertStringName, formatStrings, numFormatStrings,
     getter_Copies(alertMessage));
--- a/mailnews/base/search/src/nsMsgFilter.cpp
+++ b/mailnews/base/search/src/nsMsgFilter.cpp
@@ -57,16 +57,17 @@
 #include "nsIOutputStream.h"
 #include "nsIStringBundle.h"
 #include "nsDateTimeFormatCID.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIMsgFilterService.h"
 #include "nsMemory.h"
 #include "prmem.h"
+#include "mozilla/Services.h"
 
 static const char *kImapPrefix = "//imap:";
 static const char *kWhitespace = "\b\t\r\n ";
 
 nsMsgRuleAction::nsMsgRuleAction()
 {
 }
 
@@ -535,18 +536,18 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(ns
     nsCString buffer;
 #ifdef MOZILLA_INTERNAL_API
     // this is big enough to hold a log entry.
     // do this so we avoid growing and copying as we append to the log.
     buffer.SetCapacity(512);
 #endif
 
     nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle("chrome://messenger/locale/filter.properties",
       getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, rv);
 
     const PRUnichar *filterLogDetectFormatStrings[4] = { filterName.get(), authorValue.get(), subjectValue.get(), dateValue.get() };
     nsString filterLogDetectStr;
--- a/mailnews/base/search/src/nsMsgFilterService.cpp
+++ b/mailnews/base/search/src/nsMsgFilterService.cpp
@@ -224,25 +224,25 @@ nsMsgFilterService::GetStringFromBundle(
 
 }
 
 nsresult
 nsMsgFilterService::GetFilterStringBundle(nsIStringBundle **aBundle)
 {
   NS_ENSURE_ARG_POINTER(aBundle);
 
-  nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService =
-         do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+         mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
-  if (bundleService && NS_SUCCEEDED(rv))
+  if (bundleService)
     bundleService->CreateBundle("chrome://messenger/locale/filter.properties",
                                  getter_AddRefs(bundle));
   NS_IF_ADDREF(*aBundle = bundle);
-  return rv;
+  return NS_OK;
 }
 
 nsresult
 nsMsgFilterService::ThrowAlertMsg(const char*aMsgName, nsIMsgWindow *aMsgWindow)
 {
   nsString alertString;
   nsresult rv = GetStringFromBundle(aMsgName, getter_Copies(alertString));
   if (NS_SUCCEEDED(rv) && !alertString.IsEmpty() && aMsgWindow)
@@ -1072,17 +1072,18 @@ NS_IMETHODIMP nsMsgFilterAfterTheFact::O
   return RunNextFilter();
 }
 
 bool nsMsgFilterAfterTheFact::ContinueExecutionPrompt()
 {
   if (!m_curFilter)
     return false;
   nsCOMPtr<nsIStringBundle> bundle;
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
   if (!bundleService)
     return false;
   bundleService->CreateBundle("chrome://messenger/locale/filter.properties",
                               getter_AddRefs(bundle));
   if (!bundle)
     return false;
   nsString filterName;
   m_curFilter->GetFilterName(filterName);
--- a/mailnews/base/src/nsMailDirProvider.cpp
+++ b/mailnews/base/src/nsMailDirProvider.cpp
@@ -43,16 +43,17 @@
 #include "nsCOMArray.h"
 #include "nsEnumeratorUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIChromeRegistry.h"
 #include "nsICategoryManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsDirectoryServiceUtils.h"
+#include "mozilla/Services.h"
 
 #define MAIL_DIR_50_NAME             "Mail"
 #define IMAP_MAIL_DIR_50_NAME        "ImapMail"
 #define NEWS_DIR_50_NAME             "News"
 #define MSG_FOLDER_CACHE_DIR_50_NAME "panacea.dat"
 
 nsresult
 nsMailDirProvider::EnsureDirectory(nsIFile *aDirectory)
@@ -223,14 +224,15 @@ nsMailDirProvider::AppendingEnumerator::
 
   return NS_OK;
 }
 
 nsMailDirProvider::AppendingEnumerator::AppendingEnumerator
     (nsISimpleEnumerator* aBase) :
   mBase(aBase)
 {
-  nsCOMPtr<nsIXULChromeRegistry> packageRegistry = do_GetService("@mozilla.org/chrome/chrome-registry;1");
+  nsCOMPtr<nsIXULChromeRegistry> packageRegistry =
+    mozilla::services::GetXULChromeRegistryService();
   if (packageRegistry)
     packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global"), mLocale);
   // Initialize mNext to begin
   GetNext(nsnull);
 }
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -52,16 +52,17 @@
 #include "nsQuickSort.h"
 #include "nsAutoPtr.h"
 #if defined(XP_MACOSX) && !defined(__LP64__)
 #include "nsIAppleFileDecoder.h"
 #include "nsILocalFileMac.h"
 #endif
 #include "nsNativeCharsetUtils.h"
 #include "nsIMutableArray.h"
+#include "mozilla/Services.h"
 
 // necko
 #include "nsMimeTypes.h"
 #include "nsIURL.h"
 #include "nsIPrompt.h"
 #include "nsIStreamListener.h"
 #include "nsIStreamConverterService.h"
 #include "nsNetUtil.h"
@@ -1979,27 +1980,25 @@ nsSaveMsgListener::OnDataAvailable(nsIRe
   return rv;
 }
 
 #define MESSENGER_STRING_URL       "chrome://messenger/locale/messenger.properties"
 
 nsresult
 nsMessenger::InitStringBundle()
 {
-  nsresult res = NS_OK;
-  if (!mStringBundle)
-  {
-    const char propertyURL[] = MESSENGER_STRING_URL;
-    nsCOMPtr<nsIStringBundleService> sBundleService =
-             do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
-      res = sBundleService->CreateBundle(propertyURL,
-                                               getter_AddRefs(mStringBundle));
-  }
-  return res;
+  if (mStringBundle)
+    return NS_OK;
+
+  const char propertyURL[] = MESSENGER_STRING_URL;
+  nsCOMPtr<nsIStringBundleService> sBundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
+  return sBundleService->CreateBundle(propertyURL,
+                                      getter_AddRefs(mStringBundle));
 }
 
 void
 nsMessenger::GetString(const nsString& aStringName, nsString& aValue)
 {
   nsresult rv;
   aValue.Truncate();
 
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -79,16 +79,17 @@
 
 #include "nsNativeCharsetUtils.h"
 #include "nsToolkitCompsCID.h"
 #include "nsMsgUtils.h"
 #include "msgCore.h"
 #include "nsCOMArray.h"
 #include "nsIMutableArray.h"
 #include "nsMemory.h"
+#include "mozilla/Services.h"
 
 #define ALERT_CHROME_URL "chrome://messenger/content/newmailalert.xul"
 #define NEW_MAIL_ALERT_ICON "chrome://messenger/skin/icons/new-mail-alert.png"
 #define SHOW_ALERT_PREF "mail.biff.show_alert"
 #define SHOW_ALERT_PREVIEW_LENGTH "mail.biff.alert.preview_length"
 #define SHOW_ALERT_PREVIEW_LENGTH_DEFAULT 40
 #define SHOW_ALERT_PREVIEW "mail.biff.alert.show_preview"
 #define SHOW_ALERT_SENDER  "mail.biff.alert.show_sender"
@@ -168,24 +169,25 @@ nsMessengerUnixIntegration::OnItemUnicha
 NS_IMETHODIMP
 nsMessengerUnixIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *)
 {
   return NS_OK;
 }
 
 nsresult nsMessengerUnixIntegration::GetStringBundle(nsIStringBundle **aBundle)
 {
-  nsresult rv = NS_OK;
   NS_ENSURE_ARG_POINTER(aBundle);
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
-  if (bundleService && NS_SUCCEEDED(rv))
-    bundleService->CreateBundle("chrome://messenger/locale/messenger.properties", getter_AddRefs(bundle));
+  bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
+                              getter_AddRefs(bundle));
   bundle.swap(*aBundle);
-  return rv;
+  return NS_OK;
 }
 
 #ifdef MOZ_THUNDERBIRD
 bool
 nsMessengerUnixIntegration::BuildNotificationTitle(nsIMsgFolder *aFolder, nsIStringBundle *aBundle, nsString &aTitle)
 {
   nsString accountName;
   aFolder->GetPrettiestName(accountName);
--- a/mailnews/base/src/nsMessengerWinIntegration.cpp
+++ b/mailnews/base/src/nsMessengerWinIntegration.cpp
@@ -77,16 +77,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIWeakReferenceUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsMsgUtils.h"
 #ifdef MOZ_THUNDERBIRD
 #include "mozilla/LookAndFeel.h"
 #endif
+#include "mozilla/Services.h"
 
 #include "nsToolkitCompsCID.h"
 #include <stdlib.h>
 #define PROFILE_COMMANDLINE_ARG " -profile "
 
 #define XP_SHSetUnreadMailCounts "SHSetUnreadMailCountW"
 #define XP_SHEnumerateUnreadMailAccounts "SHEnumerateUnreadMailAccountsW"
 #define NOTIFICATIONCLASSNAME "MailBiffNotificationMessageWindow"
@@ -455,24 +456,25 @@ nsMessengerWinIntegration::OnItemUnichar
 NS_IMETHODIMP
 nsMessengerWinIntegration::OnItemRemoved(nsIMsgFolder *, nsISupports *)
 {
   return NS_OK;
 }
 
 nsresult nsMessengerWinIntegration::GetStringBundle(nsIStringBundle **aBundle)
 {
-  nsresult rv = NS_OK;
   NS_ENSURE_ARG_POINTER(aBundle);
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
-  if (bundleService && NS_SUCCEEDED(rv))
-    bundleService->CreateBundle("chrome://messenger/locale/messenger.properties", getter_AddRefs(bundle));
+  bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
+                              getter_AddRefs(bundle));
   NS_IF_ADDREF(*aBundle = bundle);
-  return rv;
+  return NS_OK;
 }
 
 #ifndef MOZ_THUNDERBIRD
 nsresult nsMessengerWinIntegration::ShowAlertMessage(const nsString& aAlertTitle,
                                                      const nsString& aAlertText,
                                                      const nsACString& aFolderURI)
 {
   nsresult rv;
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -93,16 +93,17 @@
 #include "nsIMsgHdr.h"
 #include "nsILineInputStream.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsIStringBundle.h"
 #include "nsMsgMessageFlags.h"
 #include "nsIMsgFilterList.h"
 #include "nsDirectoryServiceUtils.h"
+#include "mozilla/Services.h"
 
 #define PREF_MAIL_ACCOUNTMANAGER_ACCOUNTS "mail.accountmanager.accounts"
 #define PREF_MAIL_ACCOUNTMANAGER_DEFAULTACCOUNT "mail.accountmanager.defaultaccount"
 #define PREF_MAIL_ACCOUNTMANAGER_LOCALFOLDERSSERVER "mail.accountmanager.localfoldersserver"
 #define PREF_MAIL_SERVER_PREFIX "mail.server."
 #define ACCOUNT_PREFIX "account"
 #define SERVER_PREFIX "server"
 #define ID_PREFIX "id"
@@ -183,26 +184,24 @@ nsMsgAccountManager::nsMsgAccountManager
   m_userAuthenticated(false),
   m_loadingVirtualFolders(false),
   m_virtualFoldersLoaded(false)
 {
 }
 
 nsMsgAccountManager::~nsMsgAccountManager()
 {
-  nsresult rv;
-
   if(!m_haveShutdown)
   {
     Shutdown();
     //Don't remove from Observer service in Shutdown because Shutdown also gets called
     //from xpcom shutdown observer.  And we don't want to remove from the service in that case.
     nsCOMPtr<nsIObserverService> observerService =
-         do_GetService("@mozilla.org/observer-service;1", &rv);
-    if (NS_SUCCEEDED(rv))
+      mozilla::services::GetObserverService();
+    if (observerService)
     {
       observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       observerService->RemoveObserver(this, "quit-application-granted");
       observerService->RemoveObserver(this, ABOUT_TO_GO_OFFLINE_TOPIC);
       observerService->RemoveObserver(this, "sleep_notification");
     }
   }
 }
@@ -218,18 +217,18 @@ nsresult nsMsgAccountManager::Init()
   m_incomingServers.Init();
 
   rv = NS_NewISupportsArray(getter_AddRefs(m_accounts));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = NS_NewISupportsArray(getter_AddRefs(mFolderListeners));
 
   nsCOMPtr<nsIObserverService> observerService =
-           do_GetService("@mozilla.org/observer-service;1", &rv);
-  if (NS_SUCCEEDED(rv))
+           mozilla::services::GetObserverService();
+  if (NS_SUCCEEDED(rv) && observerService)
   {
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
     observerService->AddObserver(this, "quit-application-granted" , true);
     observerService->AddObserver(this, ABOUT_TO_GO_OFFLINE_TOPIC, true);
     observerService->AddObserver(this, "profile-before-change", true);
     observerService->AddObserver(this, "sleep_notification", true);
   }
 
@@ -834,19 +833,19 @@ nsMsgAccountManager::notifyDefaultServer
         rootFolder->NotifyBoolPropertyChanged(kDefaultServerAtom,
                                               false, true);
     }
   }
 
   if (aOldAccount && aNewAccount)  //only notify if the user goes and changes default account
   {
     nsCOMPtr<nsIObserverService> observerService =
-      do_GetService("@mozilla.org/observer-service;1", &rv);
-
-    if (NS_SUCCEEDED(rv))
+      mozilla::services::GetObserverService();
+
+    if (observerService)
       observerService->NotifyObservers(nsnull,"mailDefaultAccountChanged",nsnull);
   }
 
   return NS_OK;
 }
 
 nsresult
 nsMsgAccountManager::setDefaultAccountPref(nsIMsgAccount* aDefaultAccount)
@@ -2369,18 +2368,18 @@ NS_IMETHODIMP nsMsgAccountManager::GetLo
 
 nsresult nsMsgAccountManager::GetLocalFoldersPrettyName(nsString &localFoldersName)
 {
   // we don't want "nobody at Local Folders" to show up in the
   // folder pane, so we set the pretty name to a localized "Local Folders"
   nsCOMPtr<nsIStringBundle> bundle;
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> sBundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
 
   if (sBundleService)
     rv = sBundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
                                       getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return bundle->GetStringFromName(NS_LITERAL_STRING("localFolders").get(), getter_Copies(localFoldersName));
 }
--- a/mailnews/base/src/nsMsgAccountManagerDS.cpp
+++ b/mailnews/base/src/nsMsgAccountManagerDS.cpp
@@ -53,16 +53,17 @@
 
 #include "nsICategoryManager.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsArrayEnumerator.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 // turn this on to see useful output
 #undef DEBUG_amds
 
 #define NC_RDF_PAGETITLE_PREFIX               NC_NAMESPACE_URI "PageTitle"
 #define NC_RDF_PAGETITLE_MAIN                 NC_RDF_PAGETITLE_PREFIX "Main"
 #define NC_RDF_PAGETITLE_SERVER               NC_RDF_PAGETITLE_PREFIX "Server"
 #define NC_RDF_PAGETITLE_COPIES               NC_RDF_PAGETITLE_PREFIX "Copies"
@@ -353,18 +354,18 @@ nsMsgAccountManagerDataSource::GetTarget
         rv = folder->GetIsServer(&isServer);
         if (NS_SUCCEEDED(rv) && isServer)
           rv = folder->GetPrettyName(pageTitle);
       }
       else {
         // allow for the accountmanager to be dynamically extended.
 
         nsCOMPtr<nsIStringBundleService> strBundleService =
-          do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-        NS_ENSURE_SUCCESS(rv,rv);
+          mozilla::services::GetStringBundleService();
+        NS_ENSURE_TRUE(strBundleService, NS_ERROR_UNEXPECTED);
 
         const char *sourceValue;
         rv = source->GetValueConst(&sourceValue);
         NS_ENSURE_SUCCESS(rv,rv);
 
         // make sure the pointer math we're about to do is safe.
         NS_ENSURE_TRUE(sourceValue && (strlen(sourceValue) > strlen(NC_RDF_PAGETITLE_PREFIX)), NS_ERROR_UNEXPECTED);
 
@@ -1152,21 +1153,19 @@ nsMsgAccountManagerDataSource::findServe
   return true;
 }
 
 nsresult
 nsMsgAccountManagerDataSource::getStringBundle()
 {
   if (mStringBundle) return NS_OK;
 
-  nsresult rv;
-
   nsCOMPtr<nsIStringBundleService> strBundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) return rv;
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(strBundleService, NS_ERROR_UNEXPECTED);
 
   return strBundleService->CreateBundle("chrome://messenger/locale/prefs.properties",
                                       getter_AddRefs(mStringBundle));
 }
 
 NS_IMETHODIMP
 nsMsgAccountManagerDataSource::OnServerLoaded(nsIMsgIncomingServer* aServer)
 {
--- a/mailnews/base/src/nsMsgBiffManager.cpp
+++ b/mailnews/base/src/nsMsgBiffManager.cpp
@@ -47,16 +47,17 @@
 #include "prlog.h"
 #include "nspr.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIObserverService.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 #define PREF_BIFF_JITTER "mail.biff.add_interval_jitter"
 
 static NS_DEFINE_CID(kStatusBarBiffManagerCID, NS_STATUSBARBIFFMANAGER_CID);
 
 static PRLogModuleInfo *MsgBiffLogModule = nsnull;
 
 NS_IMPL_ISUPPORTS4(nsMsgBiffManager, nsIMsgBiffManager,
@@ -78,20 +79,19 @@ nsMsgBiffManager::nsMsgBiffManager()
 nsMsgBiffManager::~nsMsgBiffManager()
 {
   if (mBiffTimer)
     mBiffTimer->Cancel();
 
   if (!mHaveShutdown)
     Shutdown();
 
-  nsresult rv;
   nsCOMPtr<nsIObserverService> observerService =
-       do_GetService("@mozilla.org/observer-service;1", &rv);
-  if (NS_SUCCEEDED(rv))
+    mozilla::services::GetObserverService();
+  if (observerService)
   {
     observerService->RemoveObserver(this, "wake_notification");
     observerService->RemoveObserver(this, "sleep_notification");
   }
 }
 
 NS_IMETHODIMP nsMsgBiffManager::Init()
 {
@@ -116,18 +116,18 @@ NS_IMETHODIMP nsMsgBiffManager::Init()
   // Ensure status bar biff service has started
   nsCOMPtr<nsIFolderListener> statusBarBiffService = 
     do_GetService(kStatusBarBiffManagerCID, &rv);
 
   if (!MsgBiffLogModule)
     MsgBiffLogModule = PR_NewLogModule("MsgBiff");
 
   nsCOMPtr<nsIObserverService> observerService =
-           do_GetService("@mozilla.org/observer-service;1", &rv);
-  if (NS_SUCCEEDED(rv))
+    mozilla::services::GetObserverService();
+  if (observerService)
   {
     observerService->AddObserver(this, "sleep_notification", true);
     observerService->AddObserver(this, "wake_notification", true);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgBiffManager::Shutdown()
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -78,16 +78,17 @@
 #include "nsIMsgFolderNotificationService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMemory.h"
 #include "nsAlgorithm.h"
 #include "nsIAbManager.h"
 #include "nsIAbDirectory.h"
 #include "nsIAbCard.h"
+#include "mozilla/Services.h"
 
 nsrefcnt nsMsgDBView::gInstanceCount  = 0;
 
 #ifdef SUPPORT_PRIORITY_COLORS
 nsIAtom * nsMsgDBView::kHighestPriorityAtom = nsnull;
 nsIAtom * nsMsgDBView::kHighPriorityAtom = nsnull;
 nsIAtom * nsMsgDBView::kLowestPriorityAtom = nsnull;
 nsIAtom * nsMsgDBView::kLowPriorityAtom = nsnull;
@@ -309,24 +310,25 @@ nsresult nsMsgDBView::InitLabelStrings()
     rv = GetPrefLocalizedString(prefString.get(), mLabelPrefDescriptions[i]);
   }
   return rv;
 }
 
 // helper function used to fetch strings from the messenger string bundle
 PRUnichar * nsMsgDBView::GetString(const PRUnichar *aStringName)
 {
-  nsresult    res = NS_OK;
+  nsresult    res = NS_ERROR_UNEXPECTED;
   PRUnichar   *ptrv = nsnull;
 
   if (!mMessengerStringBundle)
   {
     static const char propertyURL[] = MESSENGER_STRING_URL;
-    nsCOMPtr<nsIStringBundleService> sBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res) && sBundleService)
+    nsCOMPtr<nsIStringBundleService> sBundleService =
+      mozilla::services::GetStringBundleService();
+    if (sBundleService)
       res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mMessengerStringBundle));
   }
 
   if (mMessengerStringBundle)
     res = mMessengerStringBundle->GetStringFromName(aStringName, &ptrv);
 
   if ( NS_SUCCEEDED(res) && (ptrv) )
     return ptrv;
--- a/mailnews/base/src/nsMsgFolderDataSource.cpp
+++ b/mailnews/base/src/nsMsgFolderDataSource.cpp
@@ -71,16 +71,17 @@
 #include "nsIPrompt.h"
 #include "nsIMsgAccountManager.h"
 #include "nsArrayEnumerator.h"
 #include "nsArrayUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMemory.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 #define MESSENGER_STRING_URL       "chrome://messenger/locale/messenger.properties"
 
 nsIRDFResource* nsMsgFolderDataSource::kNC_Child = nsnull;
 nsIRDFResource* nsMsgFolderDataSource::kNC_Folder= nsnull;
 nsIRDFResource* nsMsgFolderDataSource::kNC_Name= nsnull;
 nsIRDFResource* nsMsgFolderDataSource::kNC_Open = nsnull;
 nsIRDFResource* nsMsgFolderDataSource::kNC_FolderTreeName= nsnull;
@@ -1990,21 +1991,22 @@ nsresult nsMsgFolderDataSource::DoDelete
     nsCOMPtr<nsIMsgFolder> folderToDelete = do_QueryElementAt(folderArray, 0);
     PRUint32 folderFlags = 0;
     if (folderToDelete)
     {
       folderToDelete->GetFlags(&folderFlags);
       if (folderFlags & nsMsgFolderFlags::Virtual)
       {
         NS_ENSURE_ARG_POINTER(msgWindow);
-        nsCOMPtr<nsIStringBundleService> sBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+        nsCOMPtr<nsIStringBundleService> sBundleService =
+          mozilla::services::GetStringBundleService();
+        NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
         nsCOMPtr<nsIStringBundle> sMessengerStringBundle;
         nsString confirmMsg;
-        if (NS_SUCCEEDED(rv) && sBundleService)
-          rv = sBundleService->CreateBundle(MESSENGER_STRING_URL, getter_AddRefs(sMessengerStringBundle));
+        rv = sBundleService->CreateBundle(MESSENGER_STRING_URL, getter_AddRefs(sMessengerStringBundle));
         NS_ENSURE_SUCCESS(rv, rv);
         sMessengerStringBundle->GetStringFromName(NS_LITERAL_STRING("confirmSavedSearchDeleteMessage").get(), getter_Copies(confirmMsg));
 
         nsCOMPtr<nsIPrompt> dialog;
         rv = msgWindow->GetPromptDialog(getter_AddRefs(dialog));
         if (NS_SUCCEEDED(rv))
         {
           bool dialogResult;
--- a/mailnews/base/src/nsMsgMailSession.cpp
+++ b/mailnews/base/src/nsMsgMailSession.cpp
@@ -55,16 +55,17 @@
 #include "nsIWindowMediator.h"
 #include "nsIWindowWatcher.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "prcmon.h"
 #include "nsThreadUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIProperties.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_THREADSAFE_ADDREF(nsMsgMailSession)
 NS_IMPL_THREADSAFE_RELEASE(nsMsgMailSession)
 NS_INTERFACE_MAP_BEGIN(nsMsgMailSession)
   NS_INTERFACE_MAP_ENTRY(nsIMsgMailSession)
   NS_INTERFACE_MAP_ENTRY(nsIFolderListener)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMsgMailSession)
 NS_INTERFACE_MAP_END_THREADSAFE
@@ -475,18 +476,18 @@ nsMsgMailSession::GetSelectedLocaleDataD
 
   nsresult rv;                                                                
   bool baseDirExists = false;                                            
   rv = defaultsDir->Exists(&baseDirExists);                               
   NS_ENSURE_SUCCESS(rv,rv);                                                   
 
   if (baseDirExists) {                                                        
     nsCOMPtr<nsIXULChromeRegistry> packageRegistry =
-      do_GetService("@mozilla.org/chrome/chrome-registry;1", &rv);
-    if (NS_SUCCEEDED(rv)) {                                                 
+      mozilla::services::GetXULChromeRegistryService();
+    if (packageRegistry) {                                                 
       nsCAutoString localeName;                                           
       rv = packageRegistry->GetSelectedLocale(NS_LITERAL_CSTRING("global-region"), localeName);
 
       if (NS_SUCCEEDED(rv) && !localeName.IsEmpty()) {
         bool localeDirExists = false;                              
         nsCOMPtr<nsIFile> localeDataDir;                                
         
         rv = defaultsDir->Clone(getter_AddRefs(localeDataDir));     
@@ -544,28 +545,30 @@ nsMsgMailSession::GetDataFilesDir(const 
 NS_IMPL_ISUPPORTS3(nsMsgShutdownService, nsIMsgShutdownService, nsIUrlListener, nsIObserver)
 
 nsMsgShutdownService::nsMsgShutdownService()
 : mQuitMode(nsIAppStartup::eAttemptQuit),
   mProcessedShutdown(false),
   mQuitForced(false),
   mReadyToQuit(false)
 {
-  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
   if (observerService)
   {
     observerService->AddObserver(this, "quit-application-requested", false);
     observerService->AddObserver(this, "quit-application-granted", false);
     observerService->AddObserver(this, "quit-application", false);
   }
 }
 
 nsMsgShutdownService::~nsMsgShutdownService()
 {
-  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
   if (observerService)
   {  
     observerService->RemoveObserver(this, "quit-application-requested");
     observerService->RemoveObserver(this, "quit-application-granted");
     observerService->RemoveObserver(this, "quit-application");
   }
 }
 
@@ -654,17 +657,18 @@ NS_IMETHODIMP nsMsgShutdownService::Obse
   if (!strcmp(aTopic, "quit-application"))
   {
     if (mProcessedShutdown)
       return NS_OK;
     else
       mQuitForced = true;
   }
 
-  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
   NS_ENSURE_STATE(observerService);
   
   nsCOMPtr<nsISimpleEnumerator> listenerEnum;
   nsresult rv = observerService->EnumerateObservers("msg-shutdown", getter_AddRefs(listenerEnum));
   if (NS_SUCCEEDED(rv) && listenerEnum)
   {
     bool hasMore;
     listenerEnum->HasMoreElements(&hasMore);
--- a/mailnews/base/src/nsMsgOfflineManager.cpp
+++ b/mailnews/base/src/nsMsgOfflineManager.cpp
@@ -50,16 +50,17 @@
 #include "nsIMsgAccountManager.h"
 #include "nsMsgCompCID.h"
 #include "nsIIOService.h"
 #include "nsNetCID.h"
 #include "nsMsgNewsCID.h"
 #include "nsINntpService.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 
 static NS_DEFINE_CID(kMsgSendLaterCID, NS_MSGSENDLATER_CID); 
 
 NS_IMPL_THREADSAFE_ISUPPORTS5(nsMsgOfflineManager,
                               nsIMsgOfflineManager,
                               nsIMsgSendLaterListener,
                               nsIObserver,
                               nsISupportsWeakReference,
@@ -270,36 +271,32 @@ nsresult nsMsgOfflineManager::SendUnsent
   return AdvanceToNextState(rv);
 
 }
 
 #define MESSENGER_STRING_URL       "chrome://messenger/locale/messenger.properties"
 
 nsresult nsMsgOfflineManager::ShowStatus(const char *statusMsgName)
 {
-  nsresult res = NS_OK;
   if (!mStringBundle)
   {
-    static const char propertyURL[] = MESSENGER_STRING_URL;
-
     nsCOMPtr<nsIStringBundleService> sBundleService = 
-             do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) 
-    {
-      res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
-    }
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
+    sBundleService->CreateBundle(MESSENGER_STRING_URL, getter_AddRefs(mStringBundle));
+    return NS_OK;
   }
-  if (mStringBundle)
-  {
-    nsString statusString;
-    res = mStringBundle->GetStringFromName(NS_ConvertASCIItoUTF16(statusMsgName).get(), getter_Copies(statusString));
 
-    if (NS_SUCCEEDED(res) && m_statusFeedback)
-      m_statusFeedback->ShowStatusString(statusString);
-  }
+  nsString statusString;
+  nsresult res = mStringBundle->GetStringFromName(NS_ConvertASCIItoUTF16(statusMsgName).get(),
+						  getter_Copies(statusString));
+
+  if (NS_SUCCEEDED(res) && m_statusFeedback)
+    m_statusFeedback->ShowStatusString(statusString);
+
   return res;
 }
 
 nsresult nsMsgOfflineManager::DownloadOfflineNewsgroups()
 {
 	nsresult rv;
   ShowStatus("downloadingNewsgroups");
   nsCOMPtr<nsINntpService> nntpService(do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv));
@@ -354,23 +351,20 @@ NS_IMETHODIMP nsMsgOfflineManager::Synch
   }
   else
     return AdvanceToNextState(NS_OK);
   return NS_OK;
 }
 
 nsresult nsMsgOfflineManager::SetOnlineState(bool online)
 {
-  nsresult rv;
-  nsCOMPtr<nsIIOService> netService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
-  if (NS_SUCCEEDED(rv) && netService)
-  {
-    rv = netService->SetOffline(!online);
-  }
-  return rv;
+  nsCOMPtr<nsIIOService> netService =
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(netService, NS_ERROR_UNEXPECTED);
+  return netService->SetOffline(!online);
 }
 
   // nsIUrlListener methods
 
 NS_IMETHODIMP
 nsMsgOfflineManager::OnStartRunningUrl(nsIURI * aUrl)
 {
     return NS_OK;
--- a/mailnews/base/src/nsMsgPrintEngine.cpp
+++ b/mailnews/base/src/nsMsgPrintEngine.cpp
@@ -59,16 +59,17 @@
 #include "nsMsgBaseCID.h"
 #include "nsIDocumentLoader.h"
 #include "nsIWidget.h"
 #include "nsIXULWindow.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsThreadUtils.h"
 #include "nsAutoPtr.h"
+#include "mozilla/Services.h"
 
 // Interfaces Needed
 #include "nsIBaseWindow.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeNode.h"
 #include "nsIWebNavigation.h"
 #include "nsIChannel.h"
@@ -594,31 +595,30 @@ nsMsgPrintEngine::SetStatusMessage(const
   return NS_OK;
 }
 
 #define MESSENGER_STRING_URL       "chrome://messenger/locale/messenger.properties"
 
 void
 nsMsgPrintEngine::GetString(const PRUnichar *aStringName, nsString& outStr)
 {
-  nsresult    res = NS_OK;
   outStr.Truncate();
 
   if (!mStringBundle)
   {
     static const char propertyURL[] = MESSENGER_STRING_URL;
 
     nsCOMPtr<nsIStringBundleService> sBundleService = 
-             do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res); 
-    if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) 
-      res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
+      mozilla::services::GetStringBundleService();
+    if (sBundleService)
+      sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
   }
 
   if (mStringBundle)
-    res = mStringBundle->GetStringFromName(aStringName, getter_Copies(outStr));
+    mStringBundle->GetStringFromName(aStringName, getter_Copies(outStr));
   return;
 }
 
 //-----------------------------------------------------------
 void
 nsMsgPrintEngine::PrintMsgWindow()
 {
   const char* kMsgKeys[] = {"PrintingMessage",  "PrintPreviewMessage",
--- a/mailnews/base/src/nsMsgProgress.cpp
+++ b/mailnews/base/src/nsMsgProgress.cpp
@@ -43,16 +43,17 @@
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsNetError.h"
 #include "nsIWindowWatcher.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_THREADSAFE_ADDREF(nsMsgProgress)
 NS_IMPL_THREADSAFE_RELEASE(nsMsgProgress)
 
 NS_INTERFACE_MAP_BEGIN(nsMsgProgress)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMsgStatusFeedback)
   NS_INTERFACE_MAP_ENTRY(nsIMsgProgress)
   NS_INTERFACE_MAP_ENTRY(nsIMsgStatusFeedback)
@@ -284,15 +285,16 @@ NS_IMETHODIMP nsMsgProgress::OnProgress(
   return OnProgressChange(nsnull, request, PRInt32(aProgress), PRInt32(aProgressMax),
                           PRInt32(aProgress) /* current total progress */, PRInt32(aProgressMax) /* max total progress */);
 }
 
 NS_IMETHODIMP nsMsgProgress::OnStatus(nsIRequest *request, nsISupports* ctxt,
                                       nsresult aStatus, const PRUnichar* aStatusArg)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> sbs =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(sbs, NS_ERROR_UNEXPECTED);
   nsString str;
   rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(str));
   NS_ENSURE_SUCCESS(rv, rv);
   return ShowStatusString(str);
 }
--- a/mailnews/base/src/nsMsgRDFDataSource.cpp
+++ b/mailnews/base/src/nsMsgRDFDataSource.cpp
@@ -39,16 +39,17 @@
 #include "nsRDFCID.h"
 #include "rdf.h"
 #include "plstr.h"
 #include "nsMsgRDFUtils.h"
 #include "nsEnumeratorUtils.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 nsMsgRDFDataSource::nsMsgRDFDataSource():
     m_shuttingDown(false),
     mInitialized(false)
 {
 }
@@ -65,18 +66,19 @@ nsMsgRDFDataSource::~nsMsgRDFDataSource(
 */
 nsresult
 nsMsgRDFDataSource::Init()
 {
   NS_ENSURE_TRUE(!mInitialized, NS_ERROR_ALREADY_INITIALIZED);
 
   nsresult rv;
   /* Add an observer to XPCOM shutdown */
-  nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIObserverService> obs =
+    mozilla::services::GetObserverService();
+  NS_ENSURE_TRUE(obs, NS_ERROR_UNEXPECTED);
   rv = obs->AddObserver(static_cast<nsIObserver*>(this), NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
   NS_ENSURE_SUCCESS(rv, rv);
 
   getRDFService();
 
   mInitialized=true;
   return rv;
 }
--- a/mailnews/base/src/nsMsgStatusFeedback.cpp
+++ b/mailnews/base/src/nsMsgStatusFeedback.cpp
@@ -48,29 +48,30 @@
 #include "prinrval.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMimeMiscStatus.h"
 #include "nsIMsgWindow.h"
 #include "nsMsgUtils.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgFolder.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 
 #define MSGFEEDBACK_TIMER_INTERVAL 500
 
 nsMsgStatusFeedback::nsMsgStatusFeedback() :
   m_lastPercent(0)
 {
   LL_I2L(m_lastProgressTime, 0);
 
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+    mozilla::services::GetStringBundleService();
 
-  if (NS_SUCCEEDED(rv))
+  if (bundleService)
     bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
                                 getter_AddRefs(mBundle));
 
   m_msgLoadedAtom = MsgGetAtom("msgLoaded");
 }
 
 nsMsgStatusFeedback::~nsMsgStatusFeedback()
 {
@@ -301,15 +302,16 @@ NS_IMETHODIMP nsMsgStatusFeedback::OnPro
   return OnProgressChange(nsnull, request, PRInt32(aProgress), PRInt32(aProgressMax), 
                           PRInt32(aProgress) /* current total progress */, PRInt32(aProgressMax) /* max total progress */);
 }
 
 NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIRequest *request, nsISupports* ctxt, 
                                             nsresult aStatus, const PRUnichar* aStatusArg)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> sbs =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(sbs, NS_ERROR_UNEXPECTED);
   nsString str;
   rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(str));
   NS_ENSURE_SUCCESS(rv, rv);
   return ShowStatusString(str);
 }
--- a/mailnews/base/src/nsSpamSettings.cpp
+++ b/mailnews/base/src/nsSpamSettings.cpp
@@ -52,16 +52,17 @@
 #include "nsIImapIncomingServer.h"
 #include "nsIRDFService.h"
 #include "nsIRDFResource.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIStringBundle.h"
 #include "nsDateTimeFormatCID.h"
+#include "mozilla/Services.h"
 
 #include "nsMailDirServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsIMsgHeaderParser.h"
 #include "nsAbBaseCID.h"
@@ -704,18 +705,18 @@ NS_IMETHODIMP nsSpamSettings::LogJunkHit
   nsCString buffer;
   // this is big enough to hold a log entry.
   // do this so we avoid growing and copying as we append to the log.
 #ifdef MOZILLA_INTERNAL_API
   buffer.SetCapacity(512);
 #endif
 
   nsCOMPtr<nsIStringBundleService> bundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/filter.properties",
     getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   const PRUnichar *junkLogDetectFormatStrings[3] = { authorValue.get(), subjectValue.get(), dateValue.get() };
   nsString junkLogDetectStr;
--- a/mailnews/base/src/nsStatusBarBiffManager.cpp
+++ b/mailnews/base/src/nsStatusBarBiffManager.cpp
@@ -49,16 +49,17 @@
 #include "nsIFileChannel.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsIFileURL.h"
 #include "nsIFile.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 // QueryInterface, AddRef, and Release
 //
 NS_IMPL_ISUPPORTS2(nsStatusBarBiffManager, nsIStatusBarBiffManager, nsIFolderListener)
 
 nsIAtom * nsStatusBarBiffManager::kBiffStateAtom = nsnull;
 
 nsStatusBarBiffManager::nsStatusBarBiffManager()
@@ -193,18 +194,18 @@ nsStatusBarBiffManager::OnItemIntPropert
     // we still need to update the UI.    
     if (newValue == nsIMsgFolder::nsMsgBiffState_NewMail) {
       // if we fail to play the biff sound, keep going.
       (void)PlayBiffSound();
     }
     mCurrentBiffState = newValue;
 
     // don't care if notification fails
-    nsCOMPtr<nsIObserverService>
-      observerService(do_GetService("@mozilla.org/observer-service;1"));
+    nsCOMPtr<nsIObserverService> observerService =
+      mozilla::services::GetObserverService();
       
     if (observerService)
       observerService->NotifyObservers(this, "mail:biff-state-changed", nsnull);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP 
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -98,16 +98,17 @@
 #include "nsAutoPtr.h"
 #include "nsIPK11TokenDB.h"
 #include "nsIPK11Token.h"
 #include "nsMsgLocalFolderHdrs.h"
 #define oneHour 3600000000U
 #include "nsMsgUtils.h"
 #include "nsIMsgFilterService.h"
 #include "nsDirectoryServiceUtils.h"
+#include "mozilla/Services.h"
 
 static PRTime gtimeOfLastPurgeCheck;    //variable to know when to check for purge_threshhold
 
 #define PREF_MAIL_PROMPT_PURGE_THRESHOLD "mail.prompt_purge_threshhold"
 #define PREF_MAIL_PURGE_THRESHOLD "mail.purge_threshhold"
 #define PREF_MAIL_PURGE_THRESHOLD_MB "mail.purge_threshhold_mb"
 #define PREF_MAIL_PURGE_MIGRATED "mail.purge_threshold_migrated"
 #define PREF_MAIL_PURGE_ASK "mail.purge.ask"
@@ -2906,18 +2907,18 @@ nsresult nsMsgDBFolder::PerformBiffNotif
   return NS_OK;
 }
 
 nsresult
 nsMsgDBFolder::initializeStrings()
 {
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService =
-      do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
                                    getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   bundle->GetStringFromName(NS_LITERAL_STRING("inboxFolderName").get(),
                             &kLocalizedInboxName);
   bundle->GetStringFromName(NS_LITERAL_STRING("trashFolderName").get(),
@@ -5155,25 +5156,24 @@ NS_IMETHODIMP nsMsgDBFolder::GenerateMes
   aURI = uri;
   return NS_OK;
 }
 
 nsresult
 nsMsgDBFolder::GetBaseStringBundle(nsIStringBundle **aBundle)
 {
   NS_ENSURE_ARG_POINTER(aBundle);
-  nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleService =
-         do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
-  if (bundleService && NS_SUCCEEDED(rv))
-    bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
+  bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
                                  getter_AddRefs(bundle));
   bundle.swap(*aBundle);
-  return rv;
+  return NS_OK;
 }
 
 nsresult //Do not use this routine if you have to call it very often because it creates a new bundle each time
 nsMsgDBFolder::GetStringFromBundle(const char *msgName, nsString& aResult)
 {
   nsresult rv;
   nsCOMPtr <nsIStringBundle> bundle;
   rv = GetBaseStringBundle(getter_AddRefs(bundle));
--- a/mailnews/base/util/nsMsgIncomingServer.cpp
+++ b/mailnews/base/util/nsMsgIncomingServer.cpp
@@ -72,16 +72,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsILoginInfo.h"
 #include "nsILoginManager.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIMsgMdnGenerator.h"
 #include "nsMsgFolderFlags.h"
 #include "nsMsgUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
+#include "mozilla/Services.h"
 
 #define PORT_NOT_SET -1
 
 nsMsgIncomingServer::nsMsgIncomingServer():
     m_rootFolder(0),
     m_numMsgsDownloaded(0),
     m_biffState(nsIMsgFolder::nsMsgBiffState_Unknown),
     m_serverBusy(false),
@@ -1614,22 +1615,22 @@ nsMsgIncomingServer::SetOfflineSupportLe
   return NS_OK;
 }
 #define BASE_MSGS_URL       "chrome://messenger/locale/messenger.properties"
 
 NS_IMETHODIMP nsMsgIncomingServer::DisplayOfflineMsg(nsIMsgWindow *aMsgWindow)
 {
   NS_ENSURE_ARG_POINTER(aMsgWindow);
 
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
-  rv = bundleService->CreateBundle(BASE_MSGS_URL, getter_AddRefs(bundle));
+  nsresult rv = bundleService->CreateBundle(BASE_MSGS_URL, getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
   if (bundle)
   {
     nsString errorMsgTitle;
     nsString errorMsgBody;
     bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodybody").get(), getter_Copies(errorMsgBody));
     bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodytitle").get(),  getter_Copies(errorMsgTitle));
     aMsgWindow->DisplayHTMLInMessagePane(errorMsgTitle, errorMsgBody, true);
--- a/mailnews/base/util/nsMsgMailNewsUrl.cpp
+++ b/mailnews/base/util/nsMsgMailNewsUrl.cpp
@@ -51,16 +51,17 @@
 #include "nsIStreamListener.h"
 #include "nsIOutputStream.h"
 #include "nsIInputStream.h"
 #include "nsNetUtil.h"
 #include "nsIFile.h"
 #include "prmem.h"
 #include <time.h>
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 nsMsgMailNewsUrl::nsMsgMailNewsUrl()
 {
   // nsIURI specific state
   m_errorMessage = nsnull;
   m_runningUrl = false;
   m_updatingFolder = false;
   m_addContentToCache = false;
@@ -565,18 +566,19 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SchemeIs
 {
   return m_baseURL->SchemeIs(aScheme, _retval);
 }
 
 NS_IMETHODIMP nsMsgMailNewsUrl::Clone(nsIURI **_retval)
 {
   nsresult rv;
   nsCAutoString urlSpec;
-  nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIIOService> ioService =
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
   rv = GetSpec(urlSpec);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = ioService->NewURI(urlSpec, nsnull, nsnull, _retval);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // add the msg window to the cloned url
   nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(m_msgWindowWeak));
   if (msgWindow)
@@ -595,18 +597,19 @@ NS_IMETHODIMP nsMsgMailNewsUrl::Resolve(
   // everything else shouldn't be resolved against mailnews urls.
   nsresult rv = NS_OK;
 
   if (!relativePath.IsEmpty() && relativePath.First() == '#') // an anchor
     return m_baseURL->Resolve(relativePath, result);
   else
   {
     // if relativePath is a complete url with it's own scheme then allow it...
-    nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIIOService> ioService =
+      mozilla::services::GetIOService();
+    NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
     nsCAutoString scheme;
 
     rv = ioService->ExtractScheme(relativePath, scheme);
     // if we have a fully qualified scheme then pass the relative path back as the result
     if (NS_SUCCEEDED(rv) && !scheme.IsEmpty())
     {
       result = relativePath;
       rv = NS_OK;
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -61,16 +61,17 @@
 #include "nsThreadUtils.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsMsgUtils.h"
 #include "nsILineInputStream.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsAlgorithm.h"
+#include "mozilla/Services.h"
 
 using namespace mozilla;
 
 NS_IMPL_THREADSAFE_ADDREF(nsMsgProtocol)
 NS_IMPL_THREADSAFE_RELEASE(nsMsgProtocol)
 
 NS_INTERFACE_MAP_BEGIN(nsMsgProtocol)
    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChannel)
@@ -1565,18 +1566,18 @@ PRInt32 nsMsgAsyncWriteProtocol::SendDat
 PRUnichar *FormatStringWithHostNameByID(PRInt32 stringID, nsIMsgMailNewsUrl *msgUri)
 {
   if (!msgUri)
     return nsnull;
 
   nsresult rv;
 
   nsCOMPtr<nsIStringBundleService> sBundleService =
-          do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, nsnull);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(sBundleService, nsnull);
 
   nsCOMPtr<nsIStringBundle> sBundle;
   rv = sBundleService->CreateBundle(MSGS_URL, getter_AddRefs(sBundle));
   NS_ENSURE_SUCCESS(rv, nsnull);
 
   PRUnichar *ptrv = nsnull;
   nsCOMPtr<nsIMsgIncomingServer> server;
   rv = msgUri->GetServer(getter_AddRefs(server));
--- a/mailnews/base/util/nsMsgUtils.cpp
+++ b/mailnews/base/util/nsMsgUtils.cpp
@@ -99,16 +99,17 @@
 #include "nsILineInputStream.h"
 #include "nsIPlatformCharset.h"
 #include "nsIParser.h"
 #include "nsParserCIID.h"
 #include "nsIHTMLToTextSink.h"
 #include "nsIContentSink.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIDocumentEncoder.h"
+#include "mozilla/Services.h"
 
 static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
 static NS_DEFINE_CID(kImapUrlCID, NS_IMAPURL_CID);
 static NS_DEFINE_CID(kCMailboxUrl, NS_MAILBOXURL_CID);
 static NS_DEFINE_CID(kCNntpUrlCID, NS_NNTPURL_CID);
 
 #define ILLEGAL_FOLDER_CHARS ";#"
 #define ILLEGAL_FOLDER_CHARS_AS_FIRST_LETTER "."
@@ -512,18 +513,18 @@ nsresult FormatFileSize(PRUint64 size, b
 
   const PRUnichar *sizeAbbrNames[] = {
     byteAbbr.get(), kbAbbr.get(), mbAbbr.get(), gbAbbr.get()
   };
 
   nsresult rv;
 
   nsCOMPtr<nsIStringBundleService> bundleSvc =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleSvc, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleSvc->CreateBundle("chrome://messenger/locale/messenger.properties",
                                getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   float unitSize = size;
   PRUint32 unitIndex = 0;
@@ -816,21 +817,21 @@ nsresult NS_MsgDecodeUnescapeURLPath(con
   MsgUnescapeString(aPath, nsINetUtil::ESCAPE_URL_FILE_BASENAME |
                  nsINetUtil::ESCAPE_URL_FORCED, unescapedName);
   CopyUTF8toUTF16(unescapedName, aResult);
   return NS_OK;
 }
 
 bool WeAreOffline()
 {
-  nsresult rv = NS_OK;
   bool offline = false;
 
-  nsCOMPtr <nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && ioService)
+  nsCOMPtr <nsIIOService> ioService =
+    mozilla::services::GetIOService();
+  if (ioService)
     ioService->GetOffline(&offline);
 
   return offline;
 }
 
 nsresult GetExistingFolder(const nsCString& aFolderURI, nsIMsgFolder **aFolder)
 {
   NS_ENSURE_ARG_POINTER(aFolder);
@@ -2089,18 +2090,18 @@ NS_MSG_BASE nsresult MsgPromptLoginFaile
       do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = wwatch->GetNewPrompter(0, getter_AddRefs(dialog));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCOMPtr<nsIStringBundleService> bundleSvc =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleSvc, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleSvc->CreateBundle("chrome://messenger/locale/messenger.properties",
                                getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString message;
   NS_ConvertUTF8toUTF16 hostNameUTF16(aHostname);
--- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp
+++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp
@@ -60,16 +60,17 @@
 #include "nsNetCID.h"
 #include "nsIMimeStreamConverter.h"
 #include "nsMsgMimeCID.h"
 #include "nsNetUtil.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsComposeStrings.h"
 #include "nsIZipWriter.h"
 #include "nsIDirectoryEnumerator.h"
+#include "mozilla/Services.h"
 
 ///////////////////////////////////////////////////////////////////////////
 // Mac Specific Attachment Handling for AppleDouble Encoded Files
 ///////////////////////////////////////////////////////////////////////////
 #ifdef XP_MACOSX
 
 #define AD_WORKING_BUFF_SIZE                  8192
 
@@ -1051,18 +1052,19 @@ nsMsgAttachmentHandler::UrlExit(nsresult
     // At this point, we should probably ask a question to the user
     // if we should continue without this attachment.
     //
     bool              keepOnGoing = true;
     nsCString    turl;
     nsString     msg;
     PRUnichar         *printfString = nsnull;
     nsresult rv;
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, rv);
     nsMsgDeliverMode mode = nsIMsgSend::nsMsgDeliverNow;
     m_mime_delivery_state->GetDeliveryMode(&mode);
     if (mode == nsIMsgSend::nsMsgSaveAsDraft || mode == nsIMsgSend::nsMsgSaveAsTemplate)
       bundle->GetStringFromID(NS_MSG_FAILURE_ON_OBJ_EMBED_WHILE_SAVING, getter_Copies(msg));
     else
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -58,16 +58,17 @@
 #include "nsComposeStrings.h"
 #include "nsIMsgCompUtils.h"
 #include "nsIMsgMdnGenerator.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMemory.h"
 #include "nsCRTGlue.h"
 #include <ctype.h>
+#include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS1(nsMsgCompUtils, nsIMsgCompUtils)
 
 nsMsgCompUtils::nsMsgCompUtils()
 {
 }
 
 nsMsgCompUtils::~nsMsgCompUtils()
@@ -624,18 +625,19 @@ mime_generate_headers (nsMsgCompFields *
   {
     bool bAddUndisclosedRecipients = true;
     prefs->GetBoolPref("mail.compose.add_undisclosed_recipients", &bAddUndisclosedRecipients);
     if (bAddUndisclosedRecipients)
     {
       const char* pBcc = fields->GetBcc(); //Do not free me!
       if (pBcc && *pBcc)
       {
-        nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-        if (NS_SUCCEEDED(rv))
+        nsCOMPtr<nsIStringBundleService> stringService =
+          mozilla::services::GetStringBundleService();
+        if (stringService)
         {
           nsCOMPtr<nsIStringBundle> composeStringBundle;
           rv = stringService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(composeStringBundle));
           if (NS_SUCCEEDED(rv))
           {
             nsString undisclosedRecipients;
             rv = composeStringBundle->GetStringFromID(NS_MSG_UNDISCLOSED_RECIPIENTS, getter_Copies(undisclosedRecipients));
             if (NS_SUCCEEDED(rv) && !undisclosedRecipients.IsEmpty())
@@ -1734,29 +1736,28 @@ msg_pick_real_name (nsMsgAttachmentHandl
 
 // Utility to create a nsIURI object...
 nsresult
 nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec)
 {
   nsresult rv = NS_OK;
   if (nsnull == aInstancePtrResult)
     return NS_ERROR_NULL_POINTER;
-  nsCOMPtr<nsIIOService> pNetService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
-  if (NS_SUCCEEDED(rv) && pNetService)
+  nsCOMPtr<nsIIOService> pNetService =
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(pNetService, NS_ERROR_UNEXPECTED);
+  if (PL_strstr(aSpec, "://") == nsnull && strncmp(aSpec, "data:", 5))
   {
-    if (PL_strstr(aSpec, "://") == nsnull && strncmp(aSpec, "data:", 5))
-    {
-      //XXXjag Temporary fix for bug 139362 until the real problem(bug 70083) get fixed
-      nsCAutoString uri(NS_LITERAL_CSTRING("http://"));
-      uri.Append(aSpec);
-      rv = pNetService->NewURI(uri, nsnull, nsnull, aInstancePtrResult);
-    }
-    else
-      rv = pNetService->NewURI(nsDependentCString(aSpec), nsnull, nsnull, aInstancePtrResult);
+    //XXXjag Temporary fix for bug 139362 until the real problem(bug 70083) get fixed
+    nsCAutoString uri(NS_LITERAL_CSTRING("http://"));
+    uri.Append(aSpec);
+    rv = pNetService->NewURI(uri, nsnull, nsnull, aInstancePtrResult);
   }
+  else
+    rv = pNetService->NewURI(nsDependentCString(aSpec), nsnull, nsnull, aInstancePtrResult);
   return rv;
 }
 
 bool
 nsMsgIsLocalFile(const char *url)
 {
   /*
     A url is considered as a local file if it's start with file://
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -109,16 +109,17 @@
 #include "nsMsgFolderFlags.h"
 #include "nsIMsgDatabase.h"
 #include "nsStringStream.h"
 #include "nsIMutableArray.h"
 #include "nsArrayUtils.h"
 #include "nsIMsgWindow.h"
 #include "nsITextToSubURI.h"
 #include "nsIAbManager.h"
+#include "mozilla/Services.h"
 
 static void GetReplyHeaderInfo(PRInt32* reply_header_type,
                                nsString& reply_header_locale,
                                nsString& reply_header_authorwrote,
                                nsString& reply_header_ondate,
                                nsString& reply_header_separator,
                                nsString& reply_header_colon,
                                nsString& reply_header_originalmessage)
@@ -2103,18 +2104,19 @@ nsresult nsMsgCompose::CreateMessage(con
               bool addExtension = true;
               nsString sanitizedSubj;
               prefs->GetBoolPref("mail.forward_add_extension", &addExtension);
 
               // copy subject string to sanitizedSubj, use default if empty
               if (subject.IsEmpty())
               {
                 nsresult rv;
-                nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-                NS_ENSURE_SUCCESS(rv, rv);
+                nsCOMPtr<nsIStringBundleService> bundleService =
+                  mozilla::services::GetStringBundleService();
+                NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
                 nsCOMPtr<nsIStringBundle> composeBundle;
                 rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties",
                                                  getter_AddRefs(composeBundle));
                 NS_ENSURE_SUCCESS(rv, rv);
                 composeBundle->GetStringFromName(NS_LITERAL_STRING("messageAttachmentSafeName").get(),
                                                  getter_Copies(sanitizedSubj));
               }
               else
@@ -3901,18 +3903,19 @@ NS_IMETHODIMP nsMsgComposeSendListener::
         // Unregister ourself from msg compose progress
         progress->UnregisterListener(this);
 
         bool bCanceled = false;
         progress->GetProcessCanceledByUser(&bCanceled);
         if (bCanceled)
         {
           nsresult rv;
-          nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-          NS_ENSURE_SUCCESS(rv, rv);
+          nsCOMPtr<nsIStringBundleService> bundleService =
+            mozilla::services::GetStringBundleService();
+          NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
           nsCOMPtr<nsIStringBundle> bundle;
           rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
           NS_ENSURE_SUCCESS(rv, rv);
           nsString msg;
           bundle->GetStringFromID(NS_ERROR_GET_CODE(NS_MSG_CANCELLING), getter_Copies(msg));
           progress->OnStatusChange(nsnull, nsnull, 0, msg.get());
         }
       }
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -83,16 +83,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIMsgDatabase.h"
 #include "nsIDocumentEncoder.h"
 #include "nsContentCID.h"
 #include "nsISelection.h"
 #include "nsUTF8Utils.h"
 #include "nsILineBreaker.h"
 #include "nsLWBrkCIID.h"
+#include "mozilla/Services.h"
 
 #ifdef MSGCOMP_TRACE_PERFORMANCE
 #include "prlog.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgMessageService.h"
 #include "nsMsgUtils.h"
 #endif
 
@@ -186,18 +187,19 @@ nsMsgComposeService::~nsMsgComposeServic
 }
 
 nsresult nsMsgComposeService::Init()
 {
   nsresult rv = NS_OK;
   // Register observers
 
   // Register for quit application and profile change, we will need to clear the cache.
-  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
-  if (NS_SUCCEEDED(rv))
+  nsCOMPtr<nsIObserverService> observerService =
+    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);
   if (pbi)
@@ -1295,19 +1297,19 @@ nsMsgComposeService::ForwardMessage(cons
   // Therefore, let's just mark it here instead.
   return folder->AddMessageDispositionState(aMsgHdr, nsIMsgFolder::nsMsgDispositionState_Forwarded);
 }
 
 nsresult nsMsgComposeService::ShowCachedComposeWindow(nsIDOMWindow *aComposeWindow, bool aShow)
 {
   nsresult rv = NS_OK;
 
-  nsCOMPtr<nsIObserverService> obs
-    (do_GetService("@mozilla.org/observer-service;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIObserverService> obs =
+    mozilla::services::GetObserverService();
+  NS_ENSURE_TRUE(obs, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr <nsPIDOMWindow> window = do_QueryInterface(aComposeWindow, &rv);
 
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsIDocShell *docShell = window->GetDocShell();
 
   nsCOMPtr <nsIDocShellTreeItem> treeItem = do_QueryInterface(docShell, &rv);
--- a/mailnews/compose/src/nsMsgPrompts.cpp
+++ b/mailnews/compose/src/nsMsgPrompts.cpp
@@ -39,40 +39,43 @@
 #include "nsMsgCopy.h"
 #include "nsIPrompt.h"
 #include "nsIWindowWatcher.h"
 #include "nsMsgCompCID.h"
 #include "nsComposeStrings.h"
 #include "nsIStringBundle.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 nsresult
 nsMsgGetMessageByID(PRInt32 aMsgID, nsString& aResult)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (NS_IS_MSG_ERROR(aMsgID))
     aMsgID = NS_ERROR_GET_CODE(aMsgID);
 
   return bundle->GetStringFromID(aMsgID, getter_Copies(aResult));
 }
 
 static nsresult
 nsMsgBuildMessageByName(const PRUnichar *aName, nsIFile *aFile, nsString& aResult)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString path;
   aFile->GetPath(path);
 
@@ -91,18 +94,19 @@ nsMsgBuildMessageWithTmpFile(nsIFile *aF
 {
   return nsMsgBuildMessageByName(NS_LITERAL_STRING("unableToOpenTmpFile").get(), aFile, aResult);
 }
 
 nsresult
 nsMsgDisplayMessageByID(nsIPrompt * aPrompt, PRInt32 msgID, const PRUnichar * windowTitle)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString msg;
   bundle->GetStringFromID(NS_IS_MSG_ERROR(msgID) ? NS_ERROR_GET_CODE(msgID) : msgID, getter_Copies(msg));
   return nsMsgDisplayMessageByString(aPrompt, msg.get(), windowTitle);
 }
--- a/mailnews/compose/src/nsMsgQuote.cpp
+++ b/mailnews/compose/src/nsMsgQuote.cpp
@@ -51,16 +51,17 @@
 #include "nsMsgCompUtils.h"
 #include "nsIMsgMessageService.h"
 #include "nsMsgUtils.h"
 #include "nsNetUtil.h"
 #include "nsMsgMimeCID.h"
 #include "nsMsgCompCID.h"
 #include "nsMsgCompose.h"
 #include "nsMsgMailNewsUrl.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_THREADSAFE_ADDREF(nsMsgQuoteListener)
 NS_IMPL_THREADSAFE_RELEASE(nsMsgQuoteListener)
 
 NS_INTERFACE_MAP_BEGIN(nsMsgQuoteListener)
    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMsgQuoteListener)
    NS_INTERFACE_MAP_ENTRY(nsIMimeStreamConverterListener)
    NS_INTERFACE_MAP_ENTRY(nsIMsgQuoteListener)
@@ -213,18 +214,19 @@ nsMsgQuote::QuoteMessage(const char *msg
   // funky magic go get the isupports for this class which inherits from multiple interfaces.
   nsISupports * supports;
   QueryInterface(NS_GET_IID(nsISupports), (void **) &supports);
   nsCOMPtr<nsISupports> quoteSupport = supports;
   NS_IF_RELEASE(supports);
 
   // now we want to create a necko channel for this url and we want to open it
   mQuoteChannel = nsnull;
-  nsCOMPtr<nsIIOService> netService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
-  if (NS_FAILED(rv)) return rv;
+  nsCOMPtr<nsIIOService> netService =
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(netService, NS_ERROR_UNEXPECTED);
   rv = netService->NewChannelFromURI(aURL, getter_AddRefs(mQuoteChannel));
   if (NS_FAILED(rv)) return rv;
   nsCOMPtr<nsISupports> ctxt = do_QueryInterface(aURL);
 
   nsCOMPtr<nsIStreamConverterService> streamConverterService = 
            do_GetService("@mozilla.org/streamConverters;1", &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -105,16 +105,17 @@
 #include "nsIMsgMessageService.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgFolder.h"
 #include "nsComposeStrings.h"
 #include "nsStringGlue.h"
 #include "nsMsgUtils.h"
 #include "nsIArray.h"
 #include "nsArrayUtils.h"
+#include "mozilla/Services.h"
 
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 #define PREF_MAIL_SEND_STRUCT "mail.send_struct"
 #define PREF_MAIL_STRICTLY_MIME "mail.strictly_mime"
 #define PREF_MAIL_MESSAGE_WARNING_SIZE "mailnews.message_warning_size"
 #define PREF_MAIL_COLLECT_EMAIL_ADDRESS_OUTGOING "mail.collect_email_address_outgoing"
 #define PREF_MAIL_DONT_ATTACH_SOURCE "mail.compose.dont_attach_source_of_local_network_links"
@@ -2124,18 +2125,19 @@ nsMsgComposeAndSend::AddCompFieldLocalAt
 
           if (m_attachments[newLoc].mTmpFile)
           {
             if (m_attachments[newLoc].mDeleteFile)
               m_attachments[newLoc].mTmpFile->Remove(false);
             m_attachments[newLoc].mTmpFile =nsnull;
           }
           nsresult rv;
-          nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-          NS_ENSURE_SUCCESS(rv, rv);
+          nsCOMPtr<nsIIOService> ioService =
+            mozilla::services::GetIOService();
+          NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
           nsCOMPtr <nsIURI> uri;
           rv = ioService->NewURI(url, nsnull, nsnull, getter_AddRefs(uri));
           NS_ENSURE_SUCCESS(rv, rv);
           nsCOMPtr <nsIFileURL> fileURL = do_QueryInterface(uri);
           NS_ENSURE_SUCCESS(rv, rv);
           nsCOMPtr <nsIFile> fileURLFile;
           fileURL->GetFile(getter_AddRefs(fileURLFile));
           m_attachments[newLoc].mTmpFile = do_QueryInterface(fileURLFile);
@@ -3210,18 +3212,19 @@ nsMsgComposeAndSend::Init(
   mLastErrorReported = NS_OK;
 
   //Let make sure we retreive the correct number of related parts. It may have changed since last time
   GetMultipartRelatedCount(true);
 
   nsString msg;
   if (!mComposeBundle)
   {
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(mComposeBundle));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Tell the user we are assembling the message...
   mComposeBundle->GetStringFromID(NS_MSG_ASSEMBLING_MESSAGE, getter_Copies(msg));
   SetStatusMessage(msg);
@@ -4011,18 +4014,19 @@ nsMsgComposeAndSend::NotifyListenerOnSto
   SetStatusMessage(msg);
   nsCOMPtr<nsIPrompt> prompt;
   GetDefaultPrompt(getter_AddRefs(prompt));
 
   if (NS_FAILED(aStatus))
   {
     bool retry = false;
     nsresult rv;
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsString msg;
     const PRUnichar *formatStrings[] = { mSavedToFolderName.get() };
 
     rv = bundle->FormatStringFromName(NS_LITERAL_STRING("errorSavingMsg").get(),
--- a/mailnews/compose/src/nsMsgSendLater.cpp
+++ b/mailnews/compose/src/nsMsgSendLater.cpp
@@ -57,16 +57,17 @@
 #include "nsIMimeConverter.h"
 #include "nsMsgMimeCID.h"
 #include "nsComposeStrings.h"
 #include "nsIMutableArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsIObserverService.h"
 #include "nsIMsgLocalMailFolder.h"
 #include "nsIMsgDatabase.h"
+#include "mozilla/Services.h"
 
 // Consts for checking and sending mail in milliseconds
 
 // 1 second from mail into the unsent messages folder to initially trying to
 // send it.
 const PRUint32 kInitialMessageSendTime = 1000;
 
 NS_IMPL_ISUPPORTS7(nsMsgSendLater,
@@ -129,18 +130,18 @@ nsMsgSendLater::Init()
   bool sendInBackground;
   rv = prefs->GetBoolPref("mailnews.sendInBackground", &sendInBackground);
   // If we're not sending in the background, don't do anything else
   if (NS_FAILED(rv) || !sendInBackground)
     return NS_OK;
 
   // We need to know when we're shutting down.
   nsCOMPtr<nsIObserverService> observerService =
-    do_GetService("@mozilla.org/observer-service;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetObserverService();
+  NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
 
   rv = observerService->AddObserver(this, "xpcom-shutdown", false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = observerService->AddObserver(this, "quit-application", false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = observerService->AddObserver(this, "msg-shutdown", false);
@@ -195,18 +196,18 @@ nsMsgSendLater::Observe(nsISupports *aSu
     if (mMessageFolder)
     {
       rv = mMessageFolder->RemoveFolderListener(this);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // Now remove ourselves from the observer service as well.
     nsCOMPtr<nsIObserverService> observerService =
-      do_GetService("@mozilla.org/observer-service;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+      mozilla::services::GetObserverService();
+    NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
 
     rv = observerService->RemoveObserver(this, "xpcom-shutdown");
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = observerService->RemoveObserver(this, "quit-application");
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = observerService->RemoveObserver(this, "msg-shutdown");
--- a/mailnews/compose/src/nsMsgSendReport.cpp
+++ b/mailnews/compose/src/nsMsgSendReport.cpp
@@ -41,16 +41,17 @@
 #include "msgCore.h"
 #include "nsIMsgCompose.h"
 #include "nsMsgCompCID.h"
 #include "nsMsgPrompts.h"
 #include "nsNetError.h"
 #include "nsComposeStrings.h"
 #include "nsIStringBundle.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS1(nsMsgProcessReport, nsIMsgProcessReport)
 
 nsMsgProcessReport::nsMsgProcessReport()
 {
   Reset();
 }
 
@@ -256,18 +257,19 @@ NS_IMETHODIMP nsMsgSendReport::DisplayRe
 
   if (showErrorOnly && NS_SUCCEEDED(currError))
     return NS_OK;
 
   nsString currMessage;
   mProcessReport[mCurrentProcess]->GetMessage(getter_Copies(currMessage));
 
   nsresult rv; // don't step on currError.
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
   if (NS_FAILED(rv))
   {
     //TODO need to display a generic hardcoded message
     mAlreadyDisplayReport = true;
     return NS_OK;  
   }
--- a/mailnews/compose/src/nsSmtpProtocol.cpp
+++ b/mailnews/compose/src/nsSmtpProtocol.cpp
@@ -75,17 +75,17 @@
 #include "nsIPrefService.h"
 #include "nsISignatureVerifier.h"
 #include "nsISSLSocketControl.h"
 #include "nsComposeStrings.h"
 #include "nsIStringBundle.h"
 #include "nsMsgCompUtils.h"
 #include "nsIMsgWindow.h"
 #include "MailNewsTypes2.h" // for nsMsgSocketType and nsMsgAuthMethod
-
+#include "mozilla/Services.h"
 
 #ifndef XP_UNIX
 #include <stdarg.h>
 #endif /* !XP_UNIX */
 
 static PRLogModuleInfo *SMTPLogModule = nsnull;
 
 /* the output_buffer_size must be larger than the largest possible line
@@ -103,29 +103,29 @@ static PRLogModuleInfo *SMTPLogModule = 
 // TEMPORARY HARD CODED FUNCTIONS
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 /* based on in NET_ExplainErrorDetails in mkmessag.c */
 nsresult nsExplainErrorDetails(nsISmtpUrl * aSmtpUrl, int code, ...)
 {
   NS_ENSURE_ARG(aSmtpUrl);
 
-  nsresult rv = NS_OK;
   va_list args;
 
   nsCOMPtr<nsIPrompt> dialog;
   aSmtpUrl->GetPrompt(getter_AddRefs(dialog));
   NS_ENSURE_TRUE(dialog, NS_ERROR_FAILURE);
 
   PRUnichar *  msg;
   nsString eMsg;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
-  rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
+  nsresult rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
   va_start (args, code);
 
   switch (code)
   {
       case NS_ERROR_SMTP_SERVER_ERROR:
       case NS_ERROR_TCP_READ_ERROR:
@@ -446,21 +446,21 @@ NS_IMETHODIMP nsSmtpProtocol::OnStopRequ
 /////////////////////////////////////////////////////////////////////////////////////////////
 // End of nsIStreamListenerSupport
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 void nsSmtpProtocol::UpdateStatus(PRInt32 aStatusID)
 {
   if (m_statusFeedback)
   {
-    nsresult rv;
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-    if (NS_FAILED(rv)) return;
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    if (!bundleService) return;
     nsCOMPtr<nsIStringBundle> bundle;
-    rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
+    nsresult rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
     if (NS_FAILED(rv)) return;
     nsString msg;
     bundle->GetStringFromID(aStatusID, getter_Copies(msg));
     UpdateStatusWithString(msg.get());
   }
 }
 
 void nsSmtpProtocol::UpdateStatusWithString(const PRUnichar * aStatusString)
@@ -2037,22 +2037,22 @@ nsSmtpProtocol::GetPassword(nsCString &a
 
 /**
  * formatStrings is an array for the prompts, item 0 is the hostname, item 1
  * is the username.
  */
 nsresult
 nsSmtpProtocol::PromptForPassword(nsISmtpServer *aSmtpServer, nsISmtpUrl *aSmtpUrl, const PRUnichar **formatStrings, nsACString &aPassword)
 {
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr<nsIStringBundleService> stringService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(stringService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> composeStringBundle;
-  rv = stringService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(composeStringBundle));
+  nsresult rv = stringService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(composeStringBundle));
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsString passwordPromptString;
   if(formatStrings[1])
     rv = composeStringBundle->FormatStringFromName(
       NS_LITERAL_STRING("smtpEnterPasswordPromptWithUsername").get(),
       formatStrings, 2, getter_Copies(passwordPromptString));
   else
--- a/mailnews/db/msgdb/src/nsDBFolderInfo.cpp
+++ b/mailnews/db/msgdb/src/nsDBFolderInfo.cpp
@@ -45,16 +45,17 @@
 #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"
 
 static const char *kDBFolderInfoScope = "ns:msg:db:row:scope:dbfolderinfo:all";
 static const char *kDBFolderInfoTableKind = "ns:msg:db:table:kind:dbfolderinfo";
 
 struct mdbOid gDBFolderInfoOID;
 
 static const char * kNumMessagesColumnName ="numMsgs";
 // have to leave this as numNewMsgs even though it's numUnread Msgs
@@ -232,18 +233,19 @@ nsDBFolderInfo::nsDBFolderInfo(nsMsgData
         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);
         }
 
         // also register for shutdown
-        nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
-        if (NS_SUCCEEDED(rv))
+        nsCOMPtr<nsIObserverService> observerService =
+          mozilla::services::GetObserverService();
+        if (observerService)
         {
           rv = observerService->AddObserver(gFolderCharsetObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
         }
       }
     }
   }
 
   m_mdb = mdb;
--- a/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
+++ b/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
@@ -84,16 +84,17 @@
 #include "nsLayoutCID.h"
 #include "nsIHTMLToTextSink.h"
 #include "nsIDocumentEncoder.h"
 
 #include "nsIncompleteGamma.h"
 #include <math.h>
 #include <prmem.h>
 #include "nsIMsgTraitService.h"
+#include "mozilla/Services.h"
 
 static PRLogModuleInfo *BayesianFilterLogModule = nsnull;
 
 static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
 
 #define kDefaultJunkThreshold .99 // we override this value via a pref
 static const char* kBayesianFilterTokenDelimiters = " \t\n\r\f.";
 static unsigned int kMinLengthForToken = 3; // lower bound on the number of characters in a word before we treat it as a token
@@ -1281,20 +1282,19 @@ nsBayesianFilter::nsBayesianFilter()
     // start from 1
     AnalysisPerToken analysisPT(0, 0.0, 0.0);
     mAnalysisStore.AppendElement(analysisPT);
     mNextAnalysisIndex = 1;
 }
 
 nsresult nsBayesianFilter::Init()
 {
-  nsresult rv;
   nsCOMPtr<nsIObserverService> observerService =
-           do_GetService("@mozilla.org/observer-service;1", &rv);
-  if (NS_SUCCEEDED(rv))
+    mozilla::services::GetObserverService();
+  if (observerService)
     observerService->AddObserver(this, "profile-before-change", true);
   return NS_OK;
 }
 
 void
 nsBayesianFilter::TimerCallback(nsITimer* aTimer, void* aClosure)
 {
     // we will flush the training data to disk after enough time has passed
--- a/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
+++ b/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
@@ -41,16 +41,17 @@
 #include "nsIFileChannel.h"
 #include "nsIMsgFilterService.h"
 #include "nsIMsgMailSession.h"
 #include "nsMsgBaseCID.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsILocalFile.h"
 #include "nsComponentManagerUtils.h"
+#include "mozilla/Services.h"
 
 #define kDefaultViewPeopleIKnow "People I Know"
 #define kDefaultViewRecent "Recent Mail"
 #define kDefaultViewFiveDays "Last 5 Days"
 #define kDefaultViewNotJunk "Not Junk"
 #define kDefaultViewHasAttachments "Has Attachments"
  
 nsMsgMailView::nsMsgMailView()
@@ -80,18 +81,19 @@ NS_IMETHODIMP nsMsgMailView::SetMailView
     return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgMailView::GetPrettyName(PRUnichar ** aMailViewName)
 {
     nsresult rv = NS_OK;
     if (!mBundle)
     {
-        nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-        NS_ENSURE_SUCCESS(rv, rv);
+        nsCOMPtr<nsIStringBundleService> bundleService =
+          mozilla::services::GetStringBundleService();
+        NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
         bundleService->CreateBundle("chrome://messenger/locale/mailviews.properties",
                                     getter_AddRefs(mBundle));
     }
 
     NS_ENSURE_TRUE(mBundle, NS_ERROR_FAILURE);
 
     // see if mName has an associated pretty name inside our string bundle and if so, use that as the pretty name
     // otherwise just return mName
--- a/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp
+++ b/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp
@@ -59,16 +59,17 @@
 #include "nsIMsgCompUtils.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIStringBundle.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsMsgUtils.h"
 #include "nsNetUtil.h"
 #include "nsIMsgDatabase.h"
+#include "mozilla/Services.h"
 
 #define MDN_NOT_IN_TO_CC          ((int) 0x0001)
 #define MDN_OUTSIDE_DOMAIN        ((int) 0x0002)
 
 #define HEADER_RETURN_PATH          "Return-Path"
 #define HEADER_DISPOSITION_NOTIFICATION_TO  "Disposition-Notification-To"
 #define HEADER_APPARENTLY_TO        "Apparently-To"
 #define HEADER_ORIGINAL_RECIPIENT     "Original-Recipient"
@@ -127,47 +128,45 @@ nsMsgMdnGenerator::~nsMsgMdnGenerator()
 {
 }
 
 nsresult nsMsgMdnGenerator::FormatStringFromName(const PRUnichar *aName,
                                                  const PRUnichar *aString,
                                                  PRUnichar **aResultString)
 {
     DEBUG_MDN("nsMsgMdnGenerator::FormatStringFromName");
-    nsresult rv;
 
-    nsCOMPtr<nsIStringBundleService>
-        bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-    NS_ENSURE_SUCCESS(rv,rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     nsCOMPtr <nsIStringBundle> bundle;
-    rv = bundleService->CreateBundle(MDN_STRINGBUNDLE_URL,
-                                     getter_AddRefs(bundle));
+    nsresult rv = bundleService->CreateBundle(MDN_STRINGBUNDLE_URL,
+                                              getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv,rv);
 
     const PRUnichar *formatStrings[1] = { aString };
     rv = bundle->FormatStringFromName(aName,
                     formatStrings, 1, aResultString);
     NS_ENSURE_SUCCESS(rv,rv);
     return rv;
 }
 
 nsresult nsMsgMdnGenerator::GetStringFromName(const PRUnichar *aName,
                                                PRUnichar **aResultString)
 {
     DEBUG_MDN("nsMsgMdnGenerator::GetStringFromName");
-    nsresult rv;
 
-    nsCOMPtr<nsIStringBundleService>
-        bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-    NS_ENSURE_SUCCESS(rv,rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     nsCOMPtr <nsIStringBundle> bundle;
-    rv = bundleService->CreateBundle(MDN_STRINGBUNDLE_URL,
-                                     getter_AddRefs(bundle));
+    nsresult rv = bundleService->CreateBundle(MDN_STRINGBUNDLE_URL,
+                                              getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv,rv);
 
     rv = bundle->GetStringFromName(aName, aResultString);
     NS_ENSURE_SUCCESS(rv,rv);
     return rv;
 }
 
 nsresult nsMsgMdnGenerator::StoreMDNSentFlag(nsIMsgFolder *folder,
@@ -1153,18 +1152,19 @@ NS_IMETHODIMP nsMsgMdnGenerator::OnStopR
     if (NS_SUCCEEDED(rv)) 
       smtpServer->GetHostname(smtpHostName);
      
     nsAutoString hostStr;
     CopyASCIItoUTF16(smtpHostName, hostStr);
     const PRUnichar *params[] = { hostStr.get() };
 
     nsCOMPtr<nsIStringBundle> bundle;
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsString failed_msg, dialogTitle;
 
     bundle->FormatStringFromID(NS_ERROR_GET_CODE(aExitCode), params, 1, getter_Copies(failed_msg));
     bundle->GetStringFromID(NS_MSG_SEND_ERROR_TITLE, getter_Copies(dialogTitle));
--- a/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
+++ b/mailnews/extensions/smime/src/nsMsgComposeSecure.cpp
@@ -48,16 +48,17 @@
 #include "nsIX509CertDB.h"
 #include "nsMimeTypes.h"
 #include "nsMsgMimeCID.h"
 #include "nspr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMemory.h"
 #include "nsAlgorithm.h"
+#include "mozilla/Services.h"
 
 #define MK_MIME_ERROR_WRITING_FILE -1
 
 #define SMIME_STRBUNDLE_URL "chrome://messenger/locale/am-smime.properties"
 
 static void mime_crypto_write_base64 (void *closure, const char *buf,
               unsigned long size);
 static nsresult mime_encoder_output_fn(const char *buf, PRInt32 size, void *closure);
@@ -289,17 +290,17 @@ SMIMEBundleFormatStringFromName(const PR
 }
 
 bool nsMsgComposeSecure::InitializeSMIMEBundle()
 {
   if (mSMIMEBundle)
     return true;
 
   nsCOMPtr<nsIStringBundleService> bundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    mozilla::services::GetStringBundleService();
   nsresult rv = bundleService->CreateBundle(SMIME_STRBUNDLE_URL,
                                             getter_AddRefs(mSMIMEBundle));
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 void nsMsgComposeSecure::SetError(nsIMsgSendReport *sendReport, const PRUnichar *bundle_string)
@@ -540,18 +541,18 @@ nsresult nsMsgComposeSecure::MimeInitMul
  FAIL:
   return rv;
 }
 
 nsresult nsMsgComposeSecure::MimeInitEncryption(bool aSign, nsIMsgSendReport *sendReport)
 {
   nsresult rv;
   nsCOMPtr<nsIStringBundleService> bundleSvc =
-                  do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleSvc, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> sMIMEBundle;
   nsString mime_smime_enc_content_desc;
 
   bundleSvc->CreateBundle(SMIME_STRBUNDLE_URL, getter_AddRefs(sMIMEBundle));
 
   if (!sMIMEBundle)
     return NS_ERROR_FAILURE;
@@ -650,18 +651,18 @@ nsresult nsMsgComposeSecure::MimeFinishM
   nsCOMPtr<nsICMSMessage> cinfo = do_CreateInstance(NS_CMSMESSAGE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsICMSEncoder> encoder = do_CreateInstance(NS_CMSENCODER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   char * header = nsnull;
   nsCOMPtr<nsIStringBundleService> bundleSvc =
-                  do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleSvc, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> sMIMEBundle;
   nsString mime_smime_sig_content_desc;
 
   bundleSvc->CreateBundle(SMIME_STRBUNDLE_URL, getter_AddRefs(sMIMEBundle));
 
   if (!sMIMEBundle)
     return NS_ERROR_FAILURE;
@@ -1057,21 +1058,20 @@ NS_IMETHODIMP nsMsgComposeSecure::MimeCr
  */
 static int
 make_multipart_signed_header_string(bool outer_p,
 									char **header_return,
 									char **boundary_return)
 {
   *header_return = 0;
   *boundary_return = mime_make_separator("ms");
-  nsresult rv;
 
   nsCOMPtr<nsIStringBundleService> bundleSvc =
-                  do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleSvc, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> sMIMEBundle;
   nsString crypto_multipart_blurb;
 
   bundleSvc->CreateBundle(SMIME_STRBUNDLE_URL, getter_AddRefs(sMIMEBundle));
   if (!sMIMEBundle)
     return NS_ERROR_FAILURE;
 
--- a/mailnews/imap/src/nsAutoSyncManager.cpp
+++ b/mailnews/imap/src/nsAutoSyncManager.cpp
@@ -49,16 +49,17 @@
 #include "nsIMsgIncomingServer.h"
 #include "nsIMsgMailSession.h"
 #include "nsMsgFolderFlags.h"
 #include "nsImapIncomingServer.h"
 #include "nsMsgUtils.h"
 #include "nsIIOService.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS1(nsDefaultAutoSyncMsgStrategy, nsIAutoSyncMsgStrategy)
 
 const char* kAppIdleNotification = "mail:appIdle";
 const char* kStartupDoneNotification = "mail-startup-done";
 PRLogModuleInfo *gAutoSyncLog;
 
 // recommended size of each group of messages per download
@@ -256,17 +257,17 @@ nsAutoSyncManager::nsAutoSyncManager()
 
   nsresult rv;
   mIdleService = do_GetService("@mozilla.org/widget/idleservice;1", &rv);
   if (mIdleService)
     mIdleService->AddIdleObserver(this, kIdleTimeInSec);
 
   // Observe xpcom-shutdown event and app-idle changes
   nsCOMPtr<nsIObserverService> observerService =
-         do_GetService("@mozilla.org/observer-service;1", &rv);
+    mozilla::services::GetObserverService();
 
   rv = observerService->AddObserver(this,
                                     NS_XPCOM_SHUTDOWN_OBSERVER_ID,
                                     false);
   observerService->AddObserver(this, kAppIdleNotification, false);
   observerService->AddObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, false);
   observerService->AddObserver(this, NS_IOSERVICE_GOING_OFFLINE_TOPIC, false);
   observerService->AddObserver(this, kStartupDoneNotification, false);
@@ -582,17 +583,17 @@ NS_IMETHODIMP nsAutoSyncManager::Resume(
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAutoSyncManager::Observe(nsISupports*, const char *aTopic, const PRUnichar *aSomeData)
 {
   if (!PL_strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
   {
     nsCOMPtr<nsIObserverService> observerService =
-      do_GetService("@mozilla.org/observer-service;1");
+      mozilla::services::GetObserverService();
     if (observerService)
     {
       observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       observerService->RemoveObserver(this, kAppIdleNotification);
       observerService->RemoveObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
       observerService->RemoveObserver(this, NS_IOSERVICE_GOING_OFFLINE_TOPIC);
       observerService->RemoveObserver(this, kStartupDoneNotification);
     }
--- a/mailnews/imap/src/nsIMAPHostSessionList.cpp
+++ b/mailnews/imap/src/nsIMAPHostSessionList.cpp
@@ -42,16 +42,17 @@
 #include "nsIMAPNamespace.h"
 #include "nsISupportsUtils.h"
 #include "nsIImapIncomingServer.h"
 #include "nsCOMPtr.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 nsIMAPHostInfo::nsIMAPHostInfo(const char *serverKey,
                                nsIImapIncomingServer *server)
 {
   fServerKey = serverKey;
   NS_ASSERTION(server, "*** Fatal null imap incoming server...\n");
   server->GetServerDirectory(fOnlineDir);
   fNextHost = NULL;
@@ -105,40 +106,36 @@ nsIMAPHostSessionList::nsIMAPHostSession
 nsIMAPHostSessionList::~nsIMAPHostSessionList()
 {
   ResetAll();
   PR_DestroyMonitor(gCachedHostInfoMonitor);
 }
 
 nsresult nsIMAPHostSessionList::Init()
 {
-  nsresult rv;
-  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
-  if (NS_SUCCEEDED(rv))
-  {
-    observerService->AddObserver(this, "profile-before-change", true);
-    observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
-  }
-  return rv;
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
+  NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
+  observerService->AddObserver(this, "profile-before-change", true);
+  observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
+  return NS_OK;
 }
 
 
 NS_IMETHODIMP nsIMAPHostSessionList::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
 {
-  nsresult rv;
   if (!strcmp(aTopic, "profile-before-change"))
     ResetAll();
   else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
   {
-    nsCOMPtr<nsIObserverService> observerService =  do_GetService("@mozilla.org/observer-service;1", &rv);
-    if (NS_SUCCEEDED(rv))
-    {
-      observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
-      observerService->RemoveObserver(this, "profile-before-change");
-    }
+    nsCOMPtr<nsIObserverService> observerService =
+      mozilla::services::GetObserverService();
+    NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
+    observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
+    observerService->RemoveObserver(this, "profile-before-change");
   }
   return NS_OK;
 }
 
 nsIMAPHostInfo *nsIMAPHostSessionList::FindHost(const char *serverKey)
 {
   nsIMAPHostInfo *host;
 
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -79,16 +79,17 @@
 #include "nsIMAPNamespace.h"
 #include "nsISignatureVerifier.h"
 #include "nsArrayUtils.h"
 #include "nsITimer.h"
 #include "nsMsgUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCRTGlue.h"
+#include "mozilla/Services.h"
 
 using namespace mozilla;
 
 #define PREF_TRASH_FOLDER_NAME "trash_folder_name"
 #define DEFAULT_TRASH_FOLDER_NAME "Trash"
 
 static NS_DEFINE_CID(kImapProtocolCID, NS_IMAPPROTOCOL_CID);
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@@ -1972,25 +1973,23 @@ NS_IMETHODIMP  nsImapIncomingServer::FEA
 
   return AlertUser(fullMessage, aUrl);
 }
 
 #define IMAP_MSGS_URL       "chrome://messenger/locale/imapMsgs.properties"
 
 nsresult nsImapIncomingServer::GetStringBundle()
 {
-  nsresult res;
-  if (!m_stringBundle)
-  {
-    static const char propertyURL[] = IMAP_MSGS_URL;
-    nsCOMPtr<nsIStringBundleService> sBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
-      res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(m_stringBundle));
-  }
-  return (m_stringBundle) ? NS_OK : res;
+  if (m_stringBundle)
+    return NS_OK;
+
+  nsCOMPtr<nsIStringBundleService> sBundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
+  return sBundleService->CreateBundle(IMAP_MSGS_URL, getter_AddRefs(m_stringBundle));
 }
 
 NS_IMETHODIMP
 nsImapIncomingServer::GetImapStringByID(PRInt32 aMsgId, nsAString& aString)
 {
   nsresult res = NS_OK;
   GetStringBundle();
   if (m_stringBundle)
--- a/mailnews/imap/src/nsImapStringBundle.cpp
+++ b/mailnews/imap/src/nsImapStringBundle.cpp
@@ -38,16 +38,17 @@
 #include "prmem.h"
 #include "nsCOMPtr.h"
 #include "nsStringGlue.h"
 #include "nsIStringBundle.h"
 #include "nsImapStringBundle.h"
 #include "nsIServiceManager.h"
 #include "nsIURI.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 
 #define IMAP_MSGS_URL       "chrome://messenger/locale/imapMsgs.properties"
 
 extern "C" 
 nsresult
 IMAPGetStringByID(PRInt32 stringID, PRUnichar **aString)
 {
   nsresult res=NS_OK;
@@ -57,17 +58,17 @@ IMAPGetStringByID(PRInt32 stringID, PRUn
     res = sBundle->GetStringFromID(stringID, aString);
   return res;
 }
 
 nsresult
 IMAPGetStringBundle(nsIStringBundle **aBundle)
 {
   nsresult rv=NS_OK;
-  nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> stringService =
+    mozilla::services::GetStringBundleService();
   if (!stringService) return NS_ERROR_NULL_POINTER;
   nsCOMPtr<nsIStringBundle> stringBundle;
   rv = stringService->CreateBundle(IMAP_MSGS_URL, getter_AddRefs(stringBundle));
   *aBundle = stringBundle;
   NS_IF_ADDREF(*aBundle);
   return rv;
 }
--- a/mailnews/import/applemail/src/nsAppleMailImport.cpp
+++ b/mailnews/import/applemail/src/nsAppleMailImport.cpp
@@ -45,16 +45,17 @@
 #include "nsISupportsPrimitives.h"
 #include "nsIImportService.h"
 #include "nsIImportMailboxDescriptor.h"
 #include "nsIImportGeneric.h"
 #include "nsILocalFile.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 #include "nsEmlxHelperUtils.h"
 #include "nsAppleMailImport.h"
 
 PRLogModuleInfo *APPLEMAILLOGMODULE = nsnull;
 
 // some hard-coded strings
 #define DEFAULT_MAIL_FOLDER "~/Library/Mail/"
@@ -77,17 +78,18 @@ PRLogModuleInfo *APPLEMAILLOGMODULE = ns
 nsAppleMailImportModule::nsAppleMailImportModule()
 {
   // Init logging module.
   if (!APPLEMAILLOGMODULE)
     APPLEMAILLOGMODULE = PR_NewLogModule("APPLEMAILIMPORTLOG");
 
   IMPORT_LOG0("nsAppleMailImportModule Created");
 
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
   if (bundleService)
     bundleService->CreateBundle(APPLEMAIL_MSGS_URL, getter_AddRefs(mBundle));
 }
 
 
 nsAppleMailImportModule::~nsAppleMailImportModule()
 {
   IMPORT_LOG0("nsAppleMailImportModule Deleted");
@@ -162,19 +164,19 @@ NS_IMETHODIMP nsAppleMailImportModule::G
 
 nsAppleMailImportMail::nsAppleMailImportMail() : mProgress(0), mCurDepth(0)
 {
   IMPORT_LOG0("nsAppleMailImportMail created");
 }
 
 nsresult nsAppleMailImportMail::Initialize()
 {
-  nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   return bundleService->CreateBundle(APPLEMAIL_MSGS_URL, getter_AddRefs(mBundle));
 }
 
 nsAppleMailImportMail::~nsAppleMailImportMail()
 {
   IMPORT_LOG0("nsAppleMailImportMail destroyed");
 }
--- a/mailnews/import/eudora/src/nsEudoraFilters.cpp
+++ b/mailnews/import/eudora/src/nsEudoraFilters.cpp
@@ -47,16 +47,17 @@
 #include "plstr.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgUtils.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsIMsgFilterList.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIStringBundle.h"
+#include "mozilla/Services.h"
 
 #include "nsEudoraFilters.h"
 #include "nsEudoraStringBundle.h"
 
 #include "nsNetUtil.h"
 #include "nsILineInputStream.h"
 #include "EudoraDebugLog.h"
 
@@ -384,30 +385,29 @@ nsresult nsEudoraFilters::Init()
   // we need to call GetSubFolders() so that the folders get initialized
   // if they are not initialized yet.
   nsCOMPtr<nsISimpleEnumerator> enumerator;
   rv = localRootFolder->GetSubFolders(getter_AddRefs(enumerator));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the name of the folder where one-off imported mail is placed
   nsAutoString folderName(NS_LITERAL_STRING("Eudora Import"));
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(
-                                     NS_STRINGBUNDLE_CONTRACTID, &rv));
+  nsCOMPtr<nsIStringBundleService> bundleService = 
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
+
+  nsCOMPtr<nsIStringBundle> bundle;
+  rv = bundleService->CreateBundle("chrome://messenger/locale/importMsgs.properties",
+                                   getter_AddRefs(bundle));
   if (NS_SUCCEEDED(rv))
   {
-    nsCOMPtr<nsIStringBundle> bundle;
-    rv = bundleService->CreateBundle("chrome://messenger/locale/importMsgs.properties",
-                                     getter_AddRefs(bundle));
-    if (NS_SUCCEEDED(rv))
-    {
-      nsAutoString Eudora(NS_LITERAL_STRING("Eudora"));
-      const PRUnichar *moduleName[] = { Eudora.get() };
-      rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImportModuleFolderName").get(),
-                                        moduleName, 1, getter_Copies(folderName));
-    }
+    nsAutoString Eudora(NS_LITERAL_STRING("Eudora"));
+    const PRUnichar *moduleName[] = { Eudora.get() };
+    rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImportModuleFolderName").get(),
+                                      moduleName, 1, getter_Copies(folderName));
   }
   localRootFolder->GetChildNamed(folderName, getter_AddRefs(m_pMailboxesRoot));
   if (!m_pMailboxesRoot)
   {
     // If no "Eudora Import" folder then this is a
     // migration which just puts it in the root
     m_pMailboxesRoot = localRootFolder;
   }
--- a/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
+++ b/mailnews/import/eudora/src/nsEudoraStringBundle.cpp
@@ -40,34 +40,34 @@
 #include "prprf.h"
 #include "prmem.h"
 #include "nsCOMPtr.h"
 #include "nsIStringBundle.h"
 #include "nsEudoraStringBundle.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIURI.h"
 #include "nsTextFormatter.h"
+#include "mozilla/Services.h"
 
 #define EUDORA_MSGS_URL       "chrome://messenger/locale/eudoraImportMsgs.properties"
 
 nsIStringBundle *  nsEudoraStringBundle::m_pBundle = nsnull;
 
 nsIStringBundle *nsEudoraStringBundle::GetStringBundle( void)
 {
   if (m_pBundle)
     return m_pBundle;
 
-  nsresult          rv;
   const char*       propertyURL = EUDORA_MSGS_URL;
   nsIStringBundle*  sBundle = nsnull;
 
   nsCOMPtr<nsIStringBundleService> sBundleService =
-           do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && (nsnull != sBundleService))
-    rv = sBundleService->CreateBundle(propertyURL, &sBundle);
+    mozilla::services::GetStringBundleService();
+  if (sBundleService)
+    sBundleService->CreateBundle(propertyURL, &sBundle);
 
   m_pBundle = sBundle;
   return( sBundle);
 }
 
 void nsEudoraStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
 {
 
--- a/mailnews/import/oexpress/nsOEStringBundle.cpp
+++ b/mailnews/import/oexpress/nsOEStringBundle.cpp
@@ -37,35 +37,34 @@
 #include "prprf.h"
 #include "prmem.h"
 #include "nsCOMPtr.h"
 #include "nsMsgUtils.h"
 #include "nsIStringBundle.h"
 #include "nsOEStringBundle.h"
 #include "nsIServiceManager.h"
 #include "nsIURI.h"
+#include "mozilla/Services.h"
 
 #define OE_MSGS_URL       "chrome://messenger/locale/oeImportMsgs.properties"
 
 nsIStringBundle *  nsOEStringBundle::m_pBundle = nsnull;
 
 nsIStringBundle *nsOEStringBundle::GetStringBundle( void)
 {
   if (m_pBundle)
     return( m_pBundle);
 
-  nsresult      rv;
   char*        propertyURL = OE_MSGS_URL;
   nsIStringBundle*  sBundle = nsnull;
 
-
   nsCOMPtr<nsIStringBundleService> sBundleService =
-           do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && (nsnull != sBundleService)) {
-    rv = sBundleService->CreateBundle(propertyURL, &sBundle);
+    mozilla::services::GetStringBundleService();
+  if (sBundleService) {
+    sBundleService->CreateBundle(propertyURL, &sBundle);
   }
 
   m_pBundle = sBundle;
 
   return( sBundle);
 }
 
 
--- a/mailnews/import/outlook/src/nsOutlookStringBundle.cpp
+++ b/mailnews/import/outlook/src/nsOutlookStringBundle.cpp
@@ -37,35 +37,34 @@
 #include "prprf.h"
 #include "prmem.h"
 #include "nsCOMPtr.h"
 #include "nsMsgUtils.h"
 #include "nsIStringBundle.h"
 #include "nsOutlookStringBundle.h"
 #include "nsIServiceManager.h"
 #include "nsIURI.h"
+#include "mozilla/Services.h"
 
 #define OUTLOOK_MSGS_URL       "chrome://messenger/locale/outlookImportMsgs.properties"
 
 nsIStringBundle *  nsOutlookStringBundle::m_pBundle = nsnull;
 
 nsIStringBundle *nsOutlookStringBundle::GetStringBundle( void)
 {
   if (m_pBundle)
     return m_pBundle;
 
-  nsresult      rv;
   char*        propertyURL = OUTLOOK_MSGS_URL;
   nsIStringBundle*  sBundle = nsnull;
 
-
   nsCOMPtr<nsIStringBundleService> sBundleService =
-           do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && (nsnull != sBundleService)) {
-    rv = sBundleService->CreateBundle(propertyURL, &sBundle);
+    mozilla::services::GetStringBundleService();
+  if (sBundleService) {
+    sBundleService->CreateBundle(propertyURL, &sBundle);
   }
 
   m_pBundle = sBundle;
 
   return( sBundle);
 }
 
 void nsOutlookStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
--- a/mailnews/import/src/nsImportMail.cpp
+++ b/mailnews/import/src/nsImportMail.cpp
@@ -68,16 +68,17 @@
 #include "nsTextFormatter.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIImportService.h"
 #include "ImportDebug.h"
 #include "plstr.h"
 #include "MailNewsTypes.h"
 #include "nsThreadUtils.h"
+#include "mozilla/Services.h"
 
 #define IMPORT_MSGS_URL       "chrome://messenger/locale/importMsgs.properties"
 
 ////////////////////////////////////////////////////////////////////////
 
 static void ImportMailThread( void *stuff);
 
 class ImportThreadData;
@@ -938,19 +939,19 @@ ImportMailThread( void *stuff)
 // Creates a folder in Local Folders with the module name + mail
 // for e.g: Outlook Mail
 bool nsImportGenericMail::CreateFolder( nsIMsgFolder **ppFolder)
 {
   nsresult rv;
   *ppFolder = nsnull;
 
   nsCOMPtr<nsIStringBundle> bundle;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(
-                                     NS_STRINGBUNDLE_CONTRACTID, &rv));
-  if (NS_FAILED(rv) || !bundleService)
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
       return false;
   rv = bundleService->CreateBundle(IMPORT_MSGS_URL, getter_AddRefs(bundle));
   if (NS_FAILED(rv))
       return false;
   nsString folderName;
   if (!m_pName.IsEmpty()) {
     const PRUnichar *moduleName[] = { m_pName.get() };
     rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImportModuleFolderName").get(),
--- a/mailnews/import/src/nsImportStringBundle.cpp
+++ b/mailnews/import/src/nsImportStringBundle.cpp
@@ -38,27 +38,27 @@
 #include "prmem.h"
 #include "nsCOMPtr.h"
 #include "nsIStringBundle.h"
 #include "nsImportStringBundle.h"
 #include "nsIServiceManager.h"
 #include "nsIURI.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
+#include "mozilla/Services.h"
 
 nsresult nsImportStringBundle::GetStringBundle(const char *aPropertyURL,
                                                nsIStringBundle **aBundle)
 {
   nsresult rv;
 
   nsCOMPtr<nsIStringBundleService> sBundleService =
-           do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && (nsnull != sBundleService)) {
-    rv = sBundleService->CreateBundle(aPropertyURL, aBundle);
-  }
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(sBundleService, NS_ERROR_UNEXPECTED);
+  rv = sBundleService->CreateBundle(aPropertyURL, aBundle);
 
   return rv;
 }
 
 void nsImportStringBundle::GetStringByID(PRInt32 aStringID,
                                          nsIStringBundle *aBundle,
                                          nsString &aResult)
 {
--- a/mailnews/import/winlivemail/nsWMStringBundle.cpp
+++ b/mailnews/import/winlivemail/nsWMStringBundle.cpp
@@ -37,34 +37,34 @@
 #include "prprf.h"
 #include "prmem.h"
 #include "nsCOMPtr.h"
 #include "nsMsgUtils.h"
 #include "nsIStringBundle.h"
 #include "nsWMStringBundle.h"
 #include "nsIServiceManager.h"
 #include "nsIURI.h"
+#include "mozilla/Services.h"
 
 #define WM_MSGS_URL       "chrome://messenger/locale/wmImportMsgs.properties"
 
 nsIStringBundle *  nsWMStringBundle::m_pBundle = nsnull;
 
 nsIStringBundle *nsWMStringBundle::GetStringBundle( void)
 {
   if (m_pBundle)
     return( m_pBundle);
 
-  nsresult      rv;
   char*        propertyURL = WM_MSGS_URL;
   nsIStringBundle*  sBundle = nsnull;
 
   nsCOMPtr<nsIStringBundleService> sBundleService =
-           do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (NS_SUCCEEDED(rv) && (nsnull != sBundleService)) {
-    rv = sBundleService->CreateBundle(propertyURL, &sBundle);
+    mozilla::services::GetStringBundleService();
+  if (sBundleService) {
+    sBundleService->CreateBundle(propertyURL, &sBundle);
   }
 
   m_pBundle = sBundle;
 
   return( sBundle);
 }
 
 void nsWMStringBundle::GetStringByID( PRInt32 stringID, nsString& result)
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -105,16 +105,17 @@
 #include "nsIRssIncomingServer.h"
 #include "nsNetUtil.h"
 #include "nsIMsgFolderNotificationService.h"
 #include "nsReadLine.h"
 #include "nsLocalStrings.h"
 #include "nsArrayUtils.h"
 #include "nsIMsgTraitService.h"
 #include "nsIStringEnumerator.h"
+#include "mozilla/Services.h"
 
 //////////////////////////////////////////////////////////////////////////////
 // nsLocal
 /////////////////////////////////////////////////////////////////////////////
 
 nsLocalMailCopyState::nsLocalMailCopyState() :
   m_flags(0),
   m_curDstKey(0xffffffff),
@@ -873,18 +874,19 @@ nsresult nsMsgLocalMailFolder::ConfirmFo
   {
     bool confirmDeletion = true;
     nsresult rv;
     nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
     pPrefBranch->GetBoolPref("mailnews.confirm.moveFoldersToTrash", &confirmDeletion);
     if (confirmDeletion)
     {
-      nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-      NS_ENSURE_SUCCESS(rv, rv);
+      nsCOMPtr<nsIStringBundleService> bundleService =
+        mozilla::services::GetStringBundleService();
+      NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
       nsCOMPtr<nsIStringBundle> bundle;
       rv = bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(bundle));
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsAutoString folderName;
       rv = aFolder->GetName(folderName);
       NS_ENSURE_SUCCESS(rv, rv);
       const PRUnichar *formatStrings[1] = { folderName.get() };
@@ -3190,18 +3192,19 @@ nsresult nsMsgLocalMailFolder::DisplayMo
       if (!msgWindow)
         return NS_OK; // not a fatal error.
 
       msgWindow->GetStatusFeedback(getter_AddRefs(mCopyState->m_statusFeedback));
     }
 
     if (!mCopyState->m_stringBundle)
     {
-      nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-      NS_ENSURE_SUCCESS(rv, rv);
+      nsCOMPtr<nsIStringBundleService> bundleService =
+        mozilla::services::GetStringBundleService();
+      NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
       rv = bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(mCopyState->m_stringBundle));
       NS_ENSURE_SUCCESS(rv, rv);
     }
     if (mCopyState->m_statusFeedback && mCopyState->m_stringBundle)
     {
       nsString folderName;
       GetName(folderName);
       PRInt32 statusMsgId = (mCopyState->m_isMove) ? MOVING_MSGS_STATUS : COPYING_MSGS_STATUS;
--- a/mailnews/local/src/nsMailboxUrl.cpp
+++ b/mailnews/local/src/nsMailboxUrl.cpp
@@ -59,17 +59,17 @@
 
 // this is totally lame and MUST be removed by M6
 // the real fix is to attach the URI to the URL as it runs through netlib
 // then grab it and use it on the other side
 #include "nsCOMPtr.h"
 #include "nsMsgBaseCID.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgUtils.h"
-
+#include "mozilla/Services.h"
 
 // helper function for parsing the search field of a url
 char * extractAttributeValue(const char * searchString, const char * attributeName);
 
 nsMailboxUrl::nsMailboxUrl()
 {
   m_mailboxAction = nsIMailboxUrl::ActionParseMailbox;
   m_filePath = nsnull;
@@ -378,18 +378,19 @@ nsresult nsMailboxUrl::ParseUrl()
   // is creating an empty "mailbox://" uri for every message.
   if (m_file.Length() < 2)
     m_filePath = nsnull;
   else
   {
     nsCString fileUri("file://");
     fileUri.Append(m_file);
     nsresult rv;
-    nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIIOService> ioService =
+      mozilla::services::GetIOService();
+    NS_ENSURE_TRUE(ioService, NS_ERROR_UNEXPECTED);
     nsCOMPtr <nsIURI> uri;
     rv = ioService->NewURI(fileUri, nsnull, nsnull, getter_AddRefs(uri));
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr <nsIFileURL> fileURL = do_QueryInterface(uri);
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr <nsIFile> fileURLFile;
     fileURL->GetFile(getter_AddRefs(fileURLFile));
     m_filePath = do_QueryInterface(fileURLFile, &rv);
--- a/mailnews/local/src/nsMovemailService.cpp
+++ b/mailnews/local/src/nsMovemailService.cpp
@@ -69,16 +69,17 @@
 
 #include "nsILineInputStream.h"
 #include "nsISeekableStream.h"
 #include "nsNetUtil.h"
 #include "nsAutoPtr.h"
 #include "nsIStringBundle.h"
 #include "nsLocalStrings.h"
 #include "nsIMsgPluggableStore.h"
+#include "mozilla/Services.h"
 
 #include "prlog.h"
 #if defined(PR_LOGGING)
 //
 // export NSPR_LOG_MODULES=Movemail:5
 //
 static PRLogModuleInfo *gMovemailLog = nsnull;
 #define LOG(args) PR_LOG(gMovemailLog, PR_LOG_DEBUG, args)
@@ -133,18 +134,19 @@ nsMovemailService::Error(PRInt32 errorCo
 {
   if (!mMsgWindow) return;
 
   nsCOMPtr<nsIPrompt> dialog;
   nsresult rv = mMsgWindow->GetPromptDialog(getter_AddRefs(dialog));
   if (NS_FAILED(rv))
     return;
 
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  if (NS_FAILED(rv))
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
     return;
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(bundle));
   if (NS_FAILED(rv))
     return;
 
   nsString errStr;
   // Format the error string if necessary
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -89,16 +89,17 @@
 #include "nsIStringBundle.h"
 #include "nsLocalStrings.h"
 #include "nsIMsgFilterPlugin.h"
 #include "nsIMutableArray.h"
 #include "nsArrayUtils.h"
 #include "nsIMsgFilterCustomAction.h"
 #include <ctype.h>
 #include "nsIMsgPluggableStore.h"
+#include "mozilla/Services.h"
 
 static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID);
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 /* the following macros actually implement addref, release and query interface for our component. */
 NS_IMPL_ISUPPORTS_INHERITED2(nsMsgMailboxParser,
                              nsParseMailMessageState,
                              nsIStreamListener,
@@ -121,17 +122,19 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStar
     m_startTime = PR_Now();
 
 
     // extract the appropriate event sinks from the url and initialize them in our protocol data
     // the URL should be queried for a nsIMailboxURL. If it doesn't support a mailbox URL interface then
     // we have an error.
     nsresult rv = NS_OK;
 
-    nsCOMPtr<nsIIOService> ioServ(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
+    nsCOMPtr<nsIIOService> ioServ =
+      mozilla::services::GetIOService();
+    NS_ENSURE_TRUE(ioServ, NS_ERROR_UNEXPECTED);
 
     nsCOMPtr<nsIMailboxUrl> runningUrl = do_QueryInterface(ctxt, &rv);
 
     nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(ctxt);
     nsCOMPtr<nsIMsgFolder> folder = do_QueryReferent(m_folder);
 
     if (NS_SUCCEEDED(rv) && runningUrl && folder)
     {
@@ -312,18 +315,19 @@ nsresult nsMsgMailboxParser::Init()
   return AcquireFolderLock();
 }
 
 void nsMsgMailboxParser::UpdateStatusText (PRUint32 stringID)
 {
   if (m_statusFeedback)
   {
     nsresult rv;
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-    if (NS_FAILED(rv))
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    if (!bundleService)
       return;
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(bundle));
     if (NS_FAILED(rv))
       return;
     nsString finalString;
     if (stringID == LOCAL_STATUS_SELECTING_MAILBOX)
     {
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -75,16 +75,17 @@
 #include "nsISignatureVerifier.h"
 #include "nsISocketTransport.h"
 #include "nsISSLSocketControl.h"
 #include "nsILineInputStream.h"
 #include "nsLocalStrings.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsMsgMessageFlags.h"
 #include "nsMsgBaseCID.h"
+#include "mozilla/Services.h"
 
 #define EXTRA_SAFETY_SPACE 3096
 
 PRLogModuleInfo *POP3LOGMODULE = nsnull;
 
 
 static PRIntn
 net_pop3_remove_messages_marked_delete(PLHashEntry* he,
@@ -595,18 +596,19 @@ nsresult nsPop3Protocol::Initialize(nsIU
     if(NS_FAILED(rv))
       return rv;
   } // if we got a url...
 
   m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, true);
   if(!m_lineStreamBuffer)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   return bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(mLocalBundle));
 }
 
 nsPop3Protocol::~nsPop3Protocol()
 {
   Cleanup();
 }
 
--- a/mailnews/local/src/nsPop3Service.cpp
+++ b/mailnews/local/src/nsPop3Service.cpp
@@ -61,16 +61,17 @@
 #include "nsIMsgAccount.h"
 #include "nsLocalMailFolder.h"
 #include "nsIMailboxUrl.h"
 #include "nsIPrompt.h"
 #include "nsLocalStrings.h"
 #include "nsINetUtil.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
+#include "mozilla/Services.h"
 
 #define PREF_MAIL_ROOT_POP3 "mail.root.pop3"        // old - for backward compatibility only
 #define PREF_MAIL_ROOT_POP3_REL "mail.root.pop3-rel"
 
 static NS_DEFINE_CID(kPop3UrlCID, NS_POP3URL_CID);
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 nsPop3Service::nsPop3Service()
@@ -464,19 +465,20 @@ NS_IMETHODIMP nsPop3Service::NewURI(cons
     pop3Sink->SetBuildMessageUri(true);
 
     return NS_OK;
 }
 
 void nsPop3Service::AlertServerBusy(nsIMsgMailNewsUrl *url)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, void(0));
-
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
+    return void(0);
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, void(0));
 
   nsCOMPtr<nsIMsgWindow> msgWindow;
   nsCOMPtr<nsIPrompt> dialog;
   rv = url->GetMsgWindow(getter_AddRefs(msgWindow)); //it is ok to have null msgWindow, for example when biffing
   if (NS_FAILED(rv) || !msgWindow)
--- a/mailnews/local/src/nsPop3Sink.cpp
+++ b/mailnews/local/src/nsPop3Sink.cpp
@@ -70,16 +70,17 @@
 #include "nsIDOMWindow.h"
 #include "nsEmbedCID.h"
 #include "nsMsgUtils.h"
 #include "nsMsgBaseCID.h"
 #include "nsLocalStrings.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIPop3Service.h"
 #include "nsMsgLocalCID.h"
+#include "mozilla/Services.h"
 
 extern PRLogModuleInfo *POP3LOGMODULE;
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsPop3Sink, nsIPop3Sink)
 
 nsPop3Sink::nsPop3Sink()
 {
     m_authed = false;
@@ -756,18 +757,19 @@ nsresult nsPop3Sink::WriteLineToMailbox(
     if ((PRInt32) bytesWritten != bufferLen) return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
 nsresult nsPop3Sink::HandleTempDownloadFailed(nsIMsgWindow *msgWindow)
 {
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(bundle));
   NS_ENSURE_SUCCESS(rv, rv);
   nsString fromStr, subjectStr, confirmString;
 
   m_newMailParser->m_newMsgHdr->GetMime2DecodedSubject(subjectStr);
   m_newMailParser->m_newMsgHdr->GetMime2DecodedAuthor(fromStr);
   const PRUnichar *params[] = { fromStr.get(), subjectStr.get() };
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -74,16 +74,17 @@
 #include "nsIDirectoryService.h"
 #include "nsMsgI18N.h"
 #include "msgMapi.h"
 #include "msgMapiHook.h"
 #include "msgMapiSupport.h"
 #include "msgMapiMain.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
+#include "mozilla/Services.h"
 
 #include "nsEmbedCID.h"
 
 extern PRLogModuleInfo *MAPI;
 
 class nsMAPISendListener : public nsIMsgSendListener
 {
 public:
@@ -160,18 +161,19 @@ bool nsMapiHook::DisplayLoginDialog(bool
                       PRUnichar **aPassword)
 {
   nsresult rv;
   bool btnResult = false;
 
   nsCOMPtr<nsIPromptService> dlgService(do_GetService(NS_PROMPTSERVICE_CONTRACTID, &rv));
   if (NS_SUCCEEDED(rv) && dlgService)
   {
-    nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-    if (NS_FAILED(rv) || !bundleService) return false;
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    if (!bundleService) return false;
 
     nsCOMPtr<nsIStringBundle> bundle;
     rv = bundleService->CreateBundle(MAPI_PROPERTIES_CHROME, getter_AddRefs(bundle));
     if (NS_FAILED(rv) || !bundle) return false;
 
     nsCOMPtr<nsIStringBundle> brandBundle;
     rv = bundleService->CreateBundle(
                     "chrome://branding/locale/brand.properties",
@@ -278,18 +280,19 @@ nsMapiHook::IsBlindSendAllowed()
   }
   if (!enabled)
       return false;
 
   if (!warn)
       return true; // Everything is okay.
 
   nsresult rv;
-  nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-  if (NS_FAILED(rv) || !bundleService) return false;
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  if (!bundleService) return false;
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle(MAPI_PROPERTIES_CHROME, getter_AddRefs(bundle));
   if (NS_FAILED(rv) || !bundle) return false;
 
   nsString warningMsg;
   rv = bundle->GetStringFromName(NS_LITERAL_STRING("mapiBlindSendWarning").get(),
                                       getter_Copies(warningMsg));
--- a/mailnews/mapi/mapihook/src/msgMapiSupport.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiSupport.cpp
@@ -34,16 +34,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #include "nsCOMPtr.h"
 #include "objbase.h"
 #include "nsISupports.h"
 
 #include "mozilla/ModuleUtils.h"
+#include "mozilla/Services.h"
 #include "nsIObserverService.h"
 #include "nsIAppStartupNotifier.h"
 #include "nsIServiceManager.h"
 #include "nsIComponentManager.h"
 #include "nsICategoryManager.h"
 #include "Registry.h"
 #include "msgMapiSupport.h"
 
@@ -61,18 +62,19 @@ nsMapiSupport::Observe(nsISupports *aSub
     nsresult rv = NS_OK ;
 
     if (!strcmp(aTopic, "profile-after-change"))
         return InitializeMAPISupport();
 
     if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
         return ShutdownMAPISupport();
 
-    nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));
-    if (NS_FAILED(rv)) return rv;
+    nsCOMPtr<nsIObserverService> observerService =
+      mozilla::services::GetObserverService();
+    NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
  
     rv = observerService->AddObserver(this,"profile-after-change", false);
     if (NS_FAILED(rv)) return rv;
 
     rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
     if (NS_FAILED(rv))  return rv;
 
     return rv;
--- a/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp
+++ b/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp
@@ -36,24 +36,25 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSMIMEStub.h"
 
 #include "mimecth.h"
 #include "mimexpcom.h"
 #include "nsIStringBundle.h"
 #include "prmem.h"
+#include "mozilla/Services.h"
 
 #define SMIME_PROPERTIES_URL          "chrome://messenger/locale/smime.properties"
 #define SMIME_STR_NOT_SUPPORTED_ID    1000
 
 static char *SMimeGetStringByID(PRInt32 aMsgId)
 {
   nsCOMPtr<nsIStringBundleService> stringBundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    mozilla::services::GetStringBundleService();
 
   nsCOMPtr<nsIStringBundle> stringBundle;
   stringBundleService->CreateBundle(SMIME_PROPERTIES_URL,
                                     getter_AddRefs(stringBundle));
   if (stringBundle)
   {
     nsString v;
     if (NS_SUCCEEDED(stringBundle->GetStringFromID(aMsgId, getter_Copies(v))))
--- a/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
+++ b/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
@@ -61,16 +61,17 @@
 #include "nsIMimeHeaders.h"
 #include "nsIMsgWindow.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsDateTimeFormatCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
 #include "nsTextFormatter.h"
+#include "mozilla/Services.h"
 
 static PRLogModuleInfo * gMimeEmitterLogModule = nsnull;
 
 #define   MIME_HEADER_URL      "chrome://messenger/locale/mimeheader.properties"
 #define   MIME_URL             "chrome://messenger/locale/mime.properties"
 
 NS_IMPL_THREADSAFE_ADDREF(nsMimeBaseEmitter)
 NS_IMPL_THREADSAFE_RELEASE(nsMimeBaseEmitter)
@@ -239,18 +240,18 @@ nsMimeBaseEmitter::MimeGetStringByName(c
 {
   nsresult res = NS_OK;
 
   if (!m_headerStringBundle)
   {
     static const char propertyURL[] = MIME_HEADER_URL;
 
     nsCOMPtr<nsIStringBundleService> sBundleService =
-             do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
+      mozilla::services::GetStringBundleService();
+    if (sBundleService)
     {
       res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(m_headerStringBundle));
     }
   }
 
   if (m_headerStringBundle)
   {
     nsString val;
@@ -278,18 +279,18 @@ nsMimeBaseEmitter::MimeGetStringByID(PRI
 {
   nsresult res = NS_OK;
 
   if (!m_stringBundle)
   {
     static const char propertyURL[] = MIME_URL;
 
     nsCOMPtr<nsIStringBundleService> sBundleService =
-                            do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
-    if (NS_SUCCEEDED(res))
+      mozilla::services::GetStringBundleService();
+    if (sBundleService)
       res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(m_stringBundle));
   }
 
   if (m_stringBundle)
   {
     nsString val;
 
     res = m_stringBundle->GetStringFromID(aID, getter_Copies(val));
--- a/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
+++ b/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp
@@ -57,16 +57,17 @@
 #include "nsINntpUrl.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIMimeConverter.h"
 #include "nsMsgMimeCID.h"
 #include "nsMsgUtils.h"
 #include "nsAutoPtr.h"
 #include "nsINetUtil.h"
 #include "nsMemory.h"
+#include "mozilla/Services.h"
 
 #define VIEW_ALL_HEADERS 2
 
 /**
  * A helper class to implement nsIUTF8StringEnumerator
  */
 
 class nsMimeStringEnumerator : public nsIUTF8StringEnumerator {
@@ -432,18 +433,18 @@ nsMimeHtmlDisplayEmitter::StartAttachmen
   if (mFirst)
   {
     UtilityWrite("<br><fieldset class=\"mimeAttachmentHeader\">");
     if (!name.IsEmpty())
     {
       nsresult rv;
 
       nsCOMPtr<nsIStringBundleService> bundleSvc =
-        do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-      NS_ENSURE_SUCCESS(rv, rv);
+        mozilla::services::GetStringBundleService();
+      NS_ENSURE_TRUE(bundleSvc, NS_ERROR_UNEXPECTED);
 
       nsCOMPtr<nsIStringBundle> bundle;
       rv = bundleSvc->CreateBundle("chrome://messenger/locale/messenger.properties",
                                    getter_AddRefs(bundle));
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsString attachmentsHeader;
       bundle->GetStringFromName(NS_LITERAL_STRING("attachmentsPrintHeader").get(),
--- a/mailnews/mime/src/mimemoz2.cpp
+++ b/mailnews/mime/src/mimemoz2.cpp
@@ -90,16 +90,17 @@
 #include "nsIParser.h"
 #include "nsIHTMLContentSink.h"
 #include "nsIContentSerializer.h"
 #include "nsLayoutCID.h"
 #include "nsIComponentManager.h"
 #include "nsIHTMLToTextSink.h"
 #include "mozISanitizingSerializer.h"
 // </for>
+#include "mozilla/Services.h"
 
 // <for functions="HTML2Plaintext,HTMLSantinize">
 static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
 // </for>
 
 #ifdef HAVE_MIME_DATA_SLOT
 #define LOCK_LAST_CACHED_MESSAGE
 #endif
@@ -713,19 +714,19 @@ NotifyEmittersOfAttachmentList(MimeDispl
 extern "C" nsresult
 nsMimeNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase)
 {
   nsresult  res;
 
   if (nsnull == aInstancePtrResult)
     return NS_ERROR_NULL_POINTER;
 
-  nsCOMPtr<nsIIOService> pService(do_GetService(NS_IOSERVICE_CONTRACTID, &res));
-  if (NS_FAILED(res))
-    return NS_ERROR_FACTORY_NOT_REGISTERED;
+  nsCOMPtr<nsIIOService> pService =
+    mozilla::services::GetIOService();
+  NS_ENSURE_TRUE(pService, NS_ERROR_FACTORY_NOT_REGISTERED);
 
   return pService->NewURI(nsDependentCString(aSpec), nsnull, aBase, aInstancePtrResult);
 }
 
 extern "C" nsresult
 SetMailCharacterSetToMsgWindow(MimeObject *obj, const char *aCharacterSet)
 {
   nsresult rv = NS_OK;
@@ -2051,17 +2052,17 @@ mimeSetNewURL(nsMIMESession *stream, cha
 
 #define     MIME_URL "chrome://messenger/locale/mime.properties"
 
 extern "C"
 char *
 MimeGetStringByID(PRInt32 stringID)
 {
   nsCOMPtr<nsIStringBundleService> stringBundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    mozilla::services::GetStringBundleService();
 
   nsCOMPtr<nsIStringBundle> stringBundle;
   stringBundleService->CreateBundle(MIME_URL, getter_AddRefs(stringBundle));
   if (stringBundle)
   {
     nsString v;
     if (NS_SUCCEEDED(stringBundle->GetStringFromID(stringID, getter_Copies(v))))
       return ToNewUTF8String(v);
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -90,16 +90,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIMsgWindow.h"
 #include "nsIDocShell.h"
 #include "nsIMutableArray.h"
 #include "nsIMsgFolderNotificationService.h"
 #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),
@@ -333,18 +334,19 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDow
     NS_ENSURE_SUCCESS(rv,rv);
     rv = m_newsDB->GetHighWaterArticleNum(&high);
     NS_ENSURE_SUCCESS(rv,rv);
     m_knownArts.set->AddRange(low,high);
   }
 
   if (m_knownArts.set->IsMember(last_possible)) {
     nsString statusString;
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      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(NS_LITERAL_STRING("noNewMessages").get(), getter_Copies(statusString));
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -905,18 +907,19 @@ nsNNTPNewsgroupList::FinishXOVERLINE(int
     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 = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-      NS_ENSURE_SUCCESS(rv, rv);
+      nsCOMPtr<nsIStringBundleService> bundleService =
+        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 PRUnichar *formatStrings[2] = { firstStr.get(), lastStr.get() };
       rv = bundle->FormatStringFromName(NS_LITERAL_STRING("downloadingArticles").get(), formatStrings, 2, getter_Copies(statusString));
       NS_ENSURE_SUCCESS(rv, rv);
@@ -1290,18 +1293,19 @@ nsNNTPNewsgroupList::UpdateStatus(bool f
   totalToDownloadStr.AppendInt(totToDL);
 
   nsAutoString newsgroupName;
   nsresult rv = m_newsFolder->GetUnicodeName(newsgroupName);
   if (!NS_SUCCEEDED(rv))
       return;
 
   nsString statusString;
-  nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-  if (!NS_SUCCEEDED(rv))
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  if (!bundleService)
     return;
 
   nsCOMPtr<nsIStringBundle> bundle;
   rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
   if (!NS_SUCCEEDED(rv))
     return;
 
   if (filtering)
--- a/mailnews/news/src/nsNNTPProtocol.cpp
+++ b/mailnews/news/src/nsNNTPProtocol.cpp
@@ -65,16 +65,17 @@
 #include "nsMsgNewsCID.h"
 
 #include "nsINntpUrl.h"
 #include "prmem.h"
 #include "prtime.h"
 #include "prlog.h"
 #include "prerror.h"
 #include "nsStringGlue.h"
+#include "mozilla/Services.h"
 
 #include "prprf.h"
 
 /* include event sink interfaces for news */
 
 #include "nsIMsgHeaderParser.h"
 #include "nsIMsgSearchSession.h"
 #include "nsIMsgSearchAdapter.h"
@@ -1050,17 +1051,18 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI 
       if (!dialog)
       {
          nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
          wwatch->GetNewPrompter(nsnull, getter_AddRefs(dialog));
       }
 
       nsString statusString, confirmText;
       nsCOMPtr<nsIStringBundle> bundle;
-      nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+      nsCOMPtr<nsIStringBundleService> bundleService =
+        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);
@@ -2862,18 +2864,19 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsI
 
       nsCOMPtr <nsIMsgStatusFeedback> msgStatusFeedback;
 
       rv = m_msgWindow->GetStatusFeedback(getter_AddRefs(msgStatusFeedback));
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsString statusString;
 
-      nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-      NS_ENSURE_SUCCESS(rv, rv);
+      nsCOMPtr<nsIStringBundleService> bundleService =
+        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);
 
@@ -3451,18 +3454,19 @@ PRInt32 nsNNTPProtocol::ReadNewsgroupBod
 
 nsresult nsNNTPProtocol::GetNewsStringByID(PRInt32 stringID, PRUnichar **aString)
 {
   nsresult rv;
   nsAutoString resultString(NS_LITERAL_STRING("???"));
 
   if (!m_stringBundle)
   {
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(m_stringBundle));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   if (m_stringBundle) {
     PRUnichar *ptrv = nsnull;
     rv = m_stringBundle->GetStringFromID(stringID, &ptrv);
@@ -3485,18 +3489,19 @@ nsresult nsNNTPProtocol::GetNewsStringBy
 }
 
 nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName, PRUnichar **aString)
 {
   nsresult rv;
   nsAutoString resultString(NS_LITERAL_STRING("???"));
   if (!m_stringBundle)
   {
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      mozilla::services::GetStringBundleService();
+    NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
     rv = bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(m_stringBundle));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   if (m_stringBundle)
   {
     nsAutoString unicodeName;
@@ -3692,17 +3697,17 @@ PRInt32 nsNNTPProtocol::DoCancel()
   // These shouldn't be set yet, since the headers haven't been "flushed"
   // "Distribution: " doesn't appear to be required, so
   // don't assert on m_cancelDistribution
   NS_ASSERTION (m_cancelID &&
    m_cancelFromHdr &&
    m_cancelNewsgroups, "null ptr");
 
   nsCOMPtr<nsIStringBundleService> bundleService =
-    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
+    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;
--- a/mailnews/news/src/nsNewsDownloader.cpp
+++ b/mailnews/news/src/nsNewsDownloader.cpp
@@ -51,16 +51,17 @@
 #include "nsMsgFolderFlags.h"
 #include "nsIRequestObserver.h"
 #include "nsIMsgMailSession.h"
 #include "nsMsgMessageFlags.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.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)
 {
@@ -210,18 +211,19 @@ bool nsNewsDownloader::GetNextHdrToRetri
       LL_SUB(diffSinceLastProgress, nowMS, m_lastProgressTime); // r = a - b
       LL_SUB(diffSinceLastProgress, diffSinceLastProgress, minIntervalBetweenProgress); // r = a - b
       if (!LL_GE_ZERO(diffSinceLastProgress))
         return true;
     }
 
     m_lastProgressTime = nowMS;
     nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(m_folder);
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, false);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      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(m_keysToDownload.Length());
--- a/mailnews/news/src/nsNewsFolder.cpp
+++ b/mailnews/news/src/nsNewsFolder.cpp
@@ -92,16 +92,17 @@
 #include "nsArrayUtils.h"
 #include "nsIMsgFolderNotificationService.h"
 #include "nsIMutableArray.h"
 #include "nsILoginInfo.h"
 #include "nsILoginManager.h"
 #include "nsIPromptService.h"
 #include "nsEmbedCID.h"
 #include "nsIDOMWindow.h"
+#include "mozilla/Services.h"
 
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 // ###tw  This really ought to be the most
 // efficient file reading size for the current
 // operating system.
 #define NEWSRC_FILE_BUFFER_SIZE 1024
 
@@ -1470,18 +1471,19 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(
     // let us store username-only passwords. So go direct to the dialog and
     // cut out the middle-man.
     nsCOMPtr<nsIPromptService> promptSvc =
       do_GetService(NS_PROMPTSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     bool saveUsername = false;
 
-    nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsIStringBundleService> bundleService =
+      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);
 
     nsString saveUsernameText;
     rv = bundle->GetStringFromName(NS_LITERAL_STRING("saveUsername").get(),
                                    getter_Copies(saveUsernameText));
--- a/mailnews/news/src/nsNntpIncomingServer.cpp
+++ b/mailnews/news/src/nsNntpIncomingServer.cpp
@@ -61,16 +61,17 @@
 #include "nsMsgFolderFlags.h"
 #include "nsMsgI18N.h"
 #include "nsUnicharUtils.h"
 #include "nsISupportsObsolete.h"
 #include "nsILineInputStream.h"
 #include "nsNetUtil.h"
 #include "nsISimpleEnumerator.h"
 #include "nsMsgUtils.h"
+#include "mozilla/Services.h"
 
 #define INVALID_VERSION         0
 #define VALID_VERSION           2
 #define NEW_NEWS_DIR_NAME       "News"
 #define PREF_MAIL_NEWSRC_ROOT   "mail.newsrc_root"
 #define PREF_MAIL_NEWSRC_ROOT_REL "mail.newsrc_root-rel"
 #define PREF_MAILNEWS_VIEW_DEFAULT_CHARSET "mailnews.view_default_charset"
 #define HOSTINFO_FILE_NAME      "hostinfo.dat"
@@ -1593,18 +1594,19 @@ nsNntpIncomingServer::GroupNotFound(nsIM
   }
 
   if (!prompt) {
     nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
     rv = wwatch->GetNewPrompter(nsnull, getter_AddRefs(prompt));
     NS_ENSURE_SUCCESS(rv,rv);
   }
 
-  nsCOMPtr <nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID,&rv);
-  NS_ENSURE_SUCCESS(rv,rv);
+  nsCOMPtr <nsIStringBundleService> bundleService =
+    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);
 
   nsCString hostname;
   rv = GetHostName(hostname);
   NS_ENSURE_SUCCESS(rv,rv);
--- a/suite/shell/src/nsWindowsShellService.cpp
+++ b/suite/shell/src/nsWindowsShellService.cpp
@@ -60,16 +60,17 @@
 #include "nsServiceManagerUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsIWinTaskbar.h"
 #include "nsISupportsPrimitives.h"
 #include <mbstring.h>
 #include "mozilla/ModuleUtils.h"
+#include "mozilla/Services.h"
 
 #ifdef MOZILLA_INTERNAL_API
 #define CaseInsensitiveCompare nsCaseInsensitiveStringComparator()
 #endif
 
 #ifdef _WIN32_WINNT
 #undef _WIN32_WINNT
 #endif
@@ -785,19 +786,19 @@ nsWindowsShellService::SetDesktopBackgro
       return rv;
     rv = request->GetImage(getter_AddRefs(container));
   }
 
   if (!container)
     return NS_ERROR_FAILURE;
 
   // get the file name from localized strings
-  nsCOMPtr<nsIStringBundleService>
-    bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIStringBundleService> bundleService =
+    mozilla::services::GetStringBundleService();
+  NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIStringBundle> shellBundle;
   rv = bundleService->CreateBundle(SHELLSERVICE_PROPERTIES,
                                    getter_AddRefs(shellBundle));
   NS_ENSURE_SUCCESS(rv, rv);
  
   // e.g. "Desktop Background.bmp"
   nsString fileLeafName;