Backed out changeset 59943cb43b16 (bug 722187) due to test bustage.
authorMike Conley <mconley@mozilla.com>
Tue, 14 Feb 2012 13:51:48 -0500
changeset 10836 de184df942a78b0192bbed1176841abf1a5dd64c
parent 10835 650205a133cd5425294cdc62ad0bbf7200dcb4bc
child 10837 8f6ef3a01d419cacaf029d430d6f147fe931247b
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs722187
backs out59943cb43b167bbf343d0dfd53dfee5bb7404d30
Backed out changeset 59943cb43b16 (bug 722187) due to test bustage.
mailnews/addrbook/content/abAddressBookNameDialog.js
mailnews/addrbook/content/abDragDrop.js
mailnews/addrbook/content/abMailListDialog.js
mailnews/addrbook/content/addrbookWidgets.xml
mailnews/addrbook/prefs/content/pref-directory-add.js
mailnews/addrbook/prefs/content/pref-editdirectories.js
mailnews/addrbook/src/nsAbAutoCompleteMyDomain.js
mailnews/addrbook/src/nsAbAutoCompleteSearch.js
mailnews/addrbook/src/nsAbLDAPAttributeMap.js
--- a/mailnews/addrbook/content/abAddressBookNameDialog.js
+++ b/mailnews/addrbook/content/abAddressBookNameDialog.js
@@ -31,41 +31,42 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Components.utils.import("resource:///modules/mailServices.js");
-
 var gOkButton;
 var gNameInput;
 var gDirectory = null;
 
 const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab";
 const kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab";
 const kPABDirectory = 2; // defined in nsDirPrefs.h
 
 function abNameOnLoad()
 {
-  // Get the document elements.
+  // Get the document elements.  
   gOkButton = document.documentElement.getButton('accept');
   gNameInput = document.getElementById('name');
 
   // look in arguments[0] for parameters to see if we have a directory or not
   if ("arguments" in window && window.arguments[0] &&
       "selectedDirectory" in window.arguments[0]) {
     gDirectory = window.arguments[0].selectedDirectory;
     gNameInput.value = gDirectory.dirName;
   }
 
   // Work out the window title (if we have a directory specified, then it's a
   // rename).
+  var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
+    .getService(Components.interfaces.nsIStringBundleService);
+
   var bundle = document.getElementById("bundle_addressBook");
 
   document.title = bundle.getString(gDirectory ?
     'renameAddressBookTitle' : 'newAddressBookTitle');
 
   if (gDirectory &&
      (gDirectory.URI == kCollectedAddressbookURI ||
        gDirectory.URI == kPersonalAddressbookURI)) {
@@ -84,17 +85,19 @@ function abNameOKButton()
 {
   var newName = gNameInput.value.trim();
 
   // Either create a new directory or update an existing one depending on what
   // we were given when we started.
   if (gDirectory)
     gDirectory.dirName = newName;
   else
-    MailServices.ab.newAddressBook(newName, "", kPABDirectory);
+    Components.classes["@mozilla.org/abmanager;1"]
+              .getService(Components.interfaces.nsIAbManager)
+              .newAddressBook(newName, "", kPABDirectory);
 
   return true;
 }
 
 function abNameDoOkEnabling()
 {
   gOkButton.disabled = !/\S/.test(gNameInput.value);
 }
--- a/mailnews/addrbook/content/abDragDrop.js
+++ b/mailnews/addrbook/content/abDragDrop.js
@@ -76,21 +76,21 @@ var abResultsPaneObserver = {
 
   onDragExit: function (aEvent, aDragSession)
     {
     },
 
   onDragOver: function (aEvent, aFlavour, aDragSession)
     {
     },
-
+ 
   getSupportedFlavours: function ()
-    {
-      return null;
-    }
+	{
+     return null;
+  }
 };
 
 
 var dragService = Components.classes["@mozilla.org/widget/dragservice;1"]
                             .getService().QueryInterface(Components.interfaces.nsIDragService);
 
 var abDirTreeObserver = {
   /**
@@ -131,17 +131,17 @@ var abDirTreeObserver = {
     if (targetURI == srcURI)
       return false;
 
     // determine if we dragging from a mailing list on a directory x to the parent (directory x).
     // if so, don't allow the drop
     if (srcURI.substring(0, targetURI.length) == targetURI)
       return false
 
-    // check if we can write to the target directory
+    // check if we can write to the target directory 
     // e.g. LDAP is readonly currently
     var targetDirectory = GetDirectoryFromURI(targetURI);
 
     if (targetDirectory.readOnly)
       return false;
 
     var dragSession = dragService.getCurrentSession();
     if (!dragSession)
@@ -378,17 +378,17 @@ function DragAddressOverTargetControl(ev
     }
   }
   dragSession.canDrop = canDrop;
 }
 
 function DropAddressOverTargetControl(event)
 {
   var dragSession = gDragService.getCurrentSession();
-
+  
   var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
   trans.addDataFlavor("text/x-moz-address");
 
   for ( var i = 0; i < dragSession.numDropItems; ++i )
   {
     dragSession.getData ( trans, i );
     var dataObj = new Object();
     var bestFlavor = new Object();
@@ -398,20 +398,20 @@ function DropAddressOverTargetControl(ev
     try
     {
       trans.getAnyTransferData ( bestFlavor, dataObj, len);
     }
     catch (ex)
     {
       continue;
     }
-
-    if ( dataObj )
+ 
+    if ( dataObj )  
       dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
-    if ( !dataObj )
+    if ( !dataObj ) 
       continue;
 
     // pull the address out of the data object
     var address = dataObj.data.substring(0, len.value);
     if (!address)
       continue;
 
     DropRecipient(address);
--- a/mailnews/addrbook/content/abMailListDialog.js
+++ b/mailnews/addrbook/content/abMailListDialog.js
@@ -36,16 +36,18 @@
  * ***** END LICENSE BLOCK ***** */
 
 top.MAX_RECIPIENTS = 1;
 var inputElementType = "";
 
 var gListCard;
 var gEditList;
 var oldListName = "";
+var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+var gHeaderParser = Components.classes["@mozilla.org/messenger/headerparser;1"].getService(Components.interfaces.nsIMsgHeaderParser);
 var gLoadListeners = [];
 var gSaveListeners = [];
 
 try
 {
   var gDragService = Components.classes["@mozilla.org/widget/dragservice;1"]
                                .getService(Components.interfaces.nsIDragService);
 }
@@ -59,19 +61,22 @@ function handleKeyPress(element, event)
   if (element.value != "" && event.keyCode == 13) {
     event.stopPropagation();
     event.preventDefault();
   }
 }
 
 function mailingListExists(listname)
 {
-  if (MailServices.ab.mailListNameExists(listname))
+  var addressbook = Components.classes["@mozilla.org/abmanager;1"]
+                              .getService(Components.interfaces.nsIAbManager);
+
+  if (addressbook.mailListNameExists(listname))
   {
-    Services.prompt.alert(window,
+    gPromptService.alert(window, 
       gAddressBookBundle.getString("mailListNameExistsTitle"),
       gAddressBookBundle.getString("mailListNameExistsMessage"));
     return true;
   }
   return false;
 }
 
 function GetListValue(mailList, doAdd)
@@ -108,17 +113,17 @@ function GetListValue(mailList, doAdd)
   var oldTotal = mailList.addressLists.length;
   var i = 1;
   var pos = 0;
   var inputField, fieldValue, cardproperty;
   while ((inputField = awGetInputElement(i)))
   {
 
     fieldValue = inputField.value;
-
+    
     if (doAdd || (!doAdd && pos >= oldTotal))
       cardproperty = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance();
     else
       cardproperty = mailList.addressLists.queryElementAt(pos, Components.interfaces.nsIAbCard);
 
     if (fieldValue == "")
     {
       if (!doAdd && cardproperty)
@@ -136,17 +141,17 @@ function GetListValue(mailList, doAdd)
     else if (cardproperty)
     {
       cardproperty = cardproperty.QueryInterface(Components.interfaces.nsIAbCard);
       if (cardproperty)
       {
         var addresses = {};
         var names = {};
         var fullNames = {};
-        var numAddresses = MailServices.headerParser.parseHeadersWithArray(fieldValue, addresses, names, fullNames);
+        var numAddresses = gHeaderParser.parseHeadersWithArray(fieldValue, addresses, names, fullNames);
         for (var j = 0; j < numAddresses; j++)
         {
           if (j > 0)
           {
             cardproperty = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance();
             cardproperty = cardproperty.QueryInterface(Components.interfaces.nsIAbCard);
           }
           cardproperty.primaryEmail = addresses.value[j];
@@ -291,18 +296,18 @@ function OnLoadEditList()
       var listbox = document.getElementById('addressingWidget');
       var newListBoxNode = listbox.cloneNode(false);
       var templateNode = listbox.getElementsByTagName("listitem")[0];
 
       top.MAX_RECIPIENTS = 0;
       for ( var i = 0;  i < total; i++ )
       {
         var card = gEditList.addressLists.queryElementAt(i, Components.interfaces.nsIAbCard);
-        let address = MailServices.headerParser.makeFullAddress(card.displayName,
-                                                                card.primaryEmail);
+        var address = gHeaderParser.makeFullAddress(card.displayName,
+                                                    card.primaryEmail);
         SetInputValue(address, newListBoxNode, templateNode);
       }
       var parent = listbox.parentNode;
       parent.replaceChild(newListBoxNode, listbox);
     }
   }
 
   // Is this directory read-only? If so, we now need to set all the fields to
@@ -620,8 +625,9 @@ function NotifyLoadListeners(aMailingLis
 
 /* Notifies all save listeners.
  */
 function NotifySaveListeners(aMailingList)
 {
   for (let i = 0; i < gSaveListeners.length; i++)
     gSaveListeners[i](aMailingList, document);
 }
+
--- a/mailnews/addrbook/content/addrbookWidgets.xml
+++ b/mailnews/addrbook/content/addrbookWidgets.xml
@@ -50,18 +50,21 @@
 
       <!-- Represents the nsIAbDirectory attribute used as the value of the
            parent menulist. Defaults to URI but can be e.g. dirPrefId -->
       <field name="_value">this.getAttribute("value") || "URI"</field>
 
       <constructor>
         <![CDATA[
           // Init the address book cache.
+          const nsIAbManager = Components.interfaces.nsIAbManager;
           const nsIAbDirectory = Components.interfaces.nsIAbDirectory;
-          let directories = MailServices.ab.directories;
+          var abManager = Components.classes["@mozilla.org/abmanager;1"]
+                                    .getService(nsIAbManager);
+          var directories = abManager.directories;
           while (directories && directories.hasMoreElements()) {
             var ab = directories.getNext();
             if (ab instanceof nsIAbDirectory && this._matches(ab))
               this._directories.push(ab);
           }
 
           this._directories.sort(this._compare);
 
@@ -79,26 +82,28 @@
 
           // Attempt to select the persisted or otherwise first directory.
           menulist.value = menulist.value;
           if (!menulist.selectedItem && this.hasChildNodes())
             menulist.selectedIndex = 0;
 
           const nsIAbListener = Components.interfaces.nsIAbListener;
           // Add a listener so we can update correctly if the list should change
-          MailServices.ab.addAddressBookListener(this,
-                                                 nsIAbListener.itemAdded |
-                                                 nsIAbListener.directoryRemoved |
-                                                 nsIAbListener.itemChanged);
+          abManager.addAddressBookListener(this,
+                                           nsIAbListener.itemAdded |
+                                           nsIAbListener.directoryRemoved |
+                                           nsIAbListener.itemChanged);
         ]]>
       </constructor>
 
       <destructor>
         <![CDATA[
-          MailServices.ab.removeAddressBookListener(this);
+          Components.classes["@mozilla.org/abmanager;1"]
+                    .getService(Components.interfaces.nsIAbManager)
+                    .removeAddressBookListener(this);
 
           // Empty out anything in the list.
           while (this.hasChildNodes())
             this.removeChild(this.lastChild);
         ]]>
       </destructor>
 
       <!-- nsIAbListener methods -->
--- a/mailnews/addrbook/prefs/content/pref-directory-add.js
+++ b/mailnews/addrbook/prefs/content/pref-directory-add.js
@@ -1,13 +1,12 @@
 /* -*- Mode: Java; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-
-Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 
+var gPrefInt = null;
 var gCurrentDirectory = null;
 var gReplicationBundle = null;
 var gReplicationService =
   Components.classes["@mozilla.org/addressbook/ldap-replication-service;1"].
              getService(Components.interfaces.nsIAbLDAPReplicationService);
 var gReplicationCancelled = false;
 var gProgressText;
 var gProgressMeter;
@@ -24,16 +23,18 @@ var ldapOfflineObserver = {
     // sanity checks
     if (topic != "network:offline-status-changed") return;
     setDownloadOfflineOnlineState(state == "offline");
   }
 }
 
 function Startup()
 {
+  gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]
+    .getService(Components.interfaces.nsIPrefBranch);
   gReplicationBundle = document.getElementById("bundle_replication");
 
   document.getElementById("download").label =
     gReplicationBundle.getString("downloadButton");
   document.getElementById("download").accessKey =
     gReplicationBundle.getString("downloadButton.accesskey");
 
   if ( "arguments" in window && window.arguments[0] ) {
@@ -42,40 +43,47 @@ function Startup()
       fillSettings();
     } catch (ex) {
       dump("pref-directory-add.js:Startup(): fillSettings() exception: " 
            + ex + "\n");
     }
 
     // Only set up the download button for online/offline status toggling
     // if the pref isn't locked to disable the button.
-    if (!Services.prefs.prefIsLocked(gCurrentDirectory.dirPrefId +
-                                     ".disable_button_download")) {
+    if (!gPrefInt.prefIsLocked(gCurrentDirectory.dirPrefId +
+                               ".disable_button_download")) {
       // Now connect to the offline/online observer
-      Services.obs.addObserver(ldapOfflineObserver,
-                               "network:offline-status-changed", false);
+      var observerService = Components.classes["@mozilla.org/observer-service;1"]
+                                      .getService(Components.interfaces.nsIObserverService);
+      observerService.addObserver(ldapOfflineObserver,
+                                  "network:offline-status-changed", false);
 
-      // Now set the initial offline/online state and update the state
-      setDownloadOfflineOnlineState(Services.io.offline);
+      // Now set the initial offline/online state.
+      var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+                                .getService(Components.interfaces.nsIIOService);
+      // And update the state
+      setDownloadOfflineOnlineState(ioService.offline);
     }
   } else {
     fillDefaultSettings();
     // Don't add observer here as it doesn't make any sense.
   }
 }
 
 function onUnload()
 {
   if ("arguments" in window && 
       window.arguments[0] &&
-      !Services.prefs.prefIsLocked(gCurrentDirectory.dirPrefId +
-                                   ".disable_button_download")) {
+      !gPrefInt.prefIsLocked(gCurrentDirectory.dirPrefId +
+                             ".disable_button_download")) {
     // Remove the observer that we put in on dialog startup
-    Services.obs.removeObserver(ldapOfflineObserver,
-                                "network:offline-status-changed");
+    var observerService = Components.classes["@mozilla.org/observer-service;1"]
+                                    .getService(Components.interfaces.nsIObserverService);
+    observerService.removeObserver(ldapOfflineObserver,
+                                   "network:offline-status-changed");
   }
 }
 
 var progressListener = {
   onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
   {
     if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_START) {
       // start the spinning
@@ -222,24 +230,24 @@ function fillSettings()
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".description", "description");
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".disable_button_download", "download");
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".maxHits", "results");
   DisableElementIfPrefIsLocked(gCurrentDirectory.dirPrefId + ".auth.dn", "login");
 }
 
 function DisableElementIfPrefIsLocked(aPrefName, aElementId)
 {
-  if (Services.prefs.prefIsLocked(aPrefName))
+  if (gPrefInt.prefIsLocked(aPrefName))
     document.getElementById(aElementId).setAttribute('disabled', true);
 }
 
 // disables all the text fields corresponding to the .uri pref.
 function DisableUriFields(aPrefName)
 {
-  if (Services.prefs.prefIsLocked(aPrefName)) {
+  if (gPrefInt.prefIsLocked(aPrefName)) {
     var lockedElements = document.getElementsByAttribute("disableiflocked", "true");
     for (var i=0; i<lockedElements.length; i++)
       lockedElements[i].setAttribute('disabled', 'true');
   }
 }
 
 function onSecure()
 {
@@ -306,20 +314,22 @@ function onAccept()
     // XXX write isValidDn and call it on the dn string here?
     else if (port && hasCharacters(port))
       errorValue = "invalidPortNumber";
     else if (results && hasCharacters(results))
       errorValue = "invalidResults";
     if (!errorValue) {
       // XXX Due to the LDAP c-sdk pass a dummy url to the IO service, then
       // update the parts (bug 473351).
-      let ldapUrl = Services.io.newURI(
-        (secure.checked ? "ldaps://" : "ldap://") + "localhost/dc=???", null, null)
+      var ldapUrl = Components.classes["@mozilla.org/network/io-service;1"]
+        .getService(Components.interfaces.nsIIOService)
+        .newURI((secure.checked ? "ldaps://" : "ldap://") + "localhost/dc=???",
+                null, null)
         .QueryInterface(Components.interfaces.nsILDAPURL);
-
+      
       ldapUrl.host = hostname;
       ldapUrl.port = port ? port :
                             (secure.checked ? kDefaultSecureLDAPPort :
                                               kDefaultLDAPPort);
       ldapUrl.dn = document.getElementById("basedn").value;
       ldapUrl.scope = document.getElementById("one").selected ?
                       Components.interfaces.nsILDAPURL.SCOPE_ONELEVEL :
                       Components.interfaces.nsILDAPURL.SCOPE_SUBTREE;
@@ -354,19 +364,23 @@ function onAccept()
 
       window.opener.gNewServer = description;
       // set window.opener.gUpdate to true so that LDAP Directory Servers
       // dialog gets updated
       window.opener.gUpdate = true; 
     } else {
       var addressBookBundle = document.getElementById("bundle_addressBook");
 
-      Services.prompt.alert(window,
-                            document.title,
-                            addressBookBundle.getString(errorValue));
+      var promptService = Components.
+                          classes["@mozilla.org/embedcomp/prompt-service;1"].
+                          getService(Components.interfaces.nsIPromptService);
+
+      promptService.alert(window,
+                          document.title,
+                          addressBookBundle.getString(errorValue));
       return false;
     }
   } catch (outer) {
     dump("Internal error in pref-directory-add.js:onAccept() " + outer + "\n");
   }
   return true;
 }
 
--- a/mailnews/addrbook/prefs/content/pref-editdirectories.js
+++ b/mailnews/addrbook/prefs/content/pref-editdirectories.js
@@ -31,19 +31,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource:///modules/mailServices.js");
-
 // Listener to refresh the list items if something changes. In all these
 // cases we just rebuild the list as it is easier than searching/adding in the
 // correct places an would be an infrequent operation.
 var gAddressBookAbListener = {
   onItemAdded: function(parentDir, item) {
     if (item instanceof Components.interfaces.nsIAbDirectory) {
       fillDirectoryList();
     }
@@ -61,48 +58,58 @@ var gAddressBookAbListener = {
 };
 
 function onInitEditDirectories()
 {
   // For AbDeleteDirectory in abCommon.js
   gAddressBookBundle = document.getElementById("bundle_addressBook");
 
   // If the pref is locked disable the "Add" button
-  if (Services.prefs.prefIsLocked("ldap_2.disable_button_add"))
+  var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                        .getService(Components.interfaces.nsIPrefBranch);
+
+  if (prefs.prefIsLocked("ldap_2.disable_button_add"))
     document.getElementById("addButton").setAttribute('disabled', true);
 
   // Fill out the directory list
   fillDirectoryList();
 
   const nsIAbListener = Components.interfaces.nsIAbListener;
   // Add a listener so we can update correctly if the list should change
-  MailServices.ab.addAddressBookListener(gAddressBookAbListener,
-                                         nsIAbListener.itemAdded |
-                                         nsIAbListener.directoryRemoved |
-                                         nsIAbListener.itemChanged);
+  Components.classes["@mozilla.org/abmanager;1"]
+            .getService(Components.interfaces.nsIAbManager)
+            .addAddressBookListener(gAddressBookAbListener,
+                                    nsIAbListener.itemAdded |
+                                    nsIAbListener.directoryRemoved |
+                                    nsIAbListener.itemChanged);
 }
 
 function onUninitEditDirectories()
 {
-  MailServices.ab.removeAddressBookListener(gAddressBookAbListener);
+  Components.classes["@mozilla.org/abmanager;1"]
+            .getService(Components.interfaces.nsIAbManager)
+            .removeAddressBookListener(gAddressBookAbListener);
 }
 
 function fillDirectoryList()
 {
   var abList = document.getElementById("directoriesList");
 
   // Empty out anything in the list
   while (abList.hasChildNodes())
     abList.removeChild(abList.lastChild);
 
   // Init the address book list
-  let directories = MailServices.ab.directories;
-  let holdingArray = [];
-  while (directories && directories.hasMoreElements()) {
-    let ab = directories.getNext();
+  var addressBooks = Components.classes["@mozilla.org/abmanager;1"]
+                               .getService(Components.interfaces.nsIAbManager)
+                               .directories;
+  var holdingArray = [];
+
+  while (addressBooks && addressBooks.hasMoreElements()) {
+    var ab = addressBooks.getNext();
     if (ab instanceof Components.interfaces.nsIAbDirectory && ab.isRemote)
       holdingArray.push(ab);
   }
 
   holdingArray.sort(function (a, b) { return a.dirName.localeCompare(b.dirName); });
 
   holdingArray.forEach(function (ab) {
     var item = document.createElement('listitem');
@@ -119,20 +126,24 @@ function selectDirectory()
   var editButton = document.getElementById("editButton");
   var removeButton = document.getElementById("removeButton");
 
   if (abList && abList.selectedItem) {
     editButton.removeAttribute("disabled");
 
     // If the disable delete button pref for the selected directory is set,
     // disable the delete button for that directory.
-    let disable = false;
-    let ab = MailServices.ab.getDirectory(abList.value);
+    var disable = false;
+    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                          .getService(Components.interfaces.nsIPrefBranch);
+    var ab = Components.classes["@mozilla.org/abmanager;1"]
+                       .getService(Components.interfaces.nsIAbManager)
+                       .getDirectory(abList.value);
     try {
-      disable = Services.prefs.getBoolPref(ab.dirPrefId + ".disable_delete");
+      disable = prefs.getBoolPref(ab.dirPrefId + ".disable_delete");
     }
     catch(ex){
       // If this preference is not set, it's ok.
     }
     if (disable)
       removeButton.setAttribute("disabled", true);
     else
       removeButton.removeAttribute("disabled");
@@ -152,18 +163,20 @@ function dblClickDirectory(event)
   editDirectory();
 }
 
 function editDirectory()
 {
   var abList = document.getElementById("directoriesList");
 
   if (abList && abList.selectedItem) {
-    let abURI = abList.value;
-    let ab = MailServices.ab.getDirectory(abURI);
+    var abURI = abList.value;
+    var ab = Components.classes["@mozilla.org/abmanager;1"]
+                       .getService(Components.interfaces.nsIAbManager)
+                       .getDirectory(abURI);
 
     window.openDialog(ab.propertiesChromeURI, "editDirectory",
                       "chrome,modal=yes,resizable=no",
                       { selectedDirectory: ab });
   }
 }
 
 function removeDirectory()
--- a/mailnews/addrbook/src/nsAbAutoCompleteMyDomain.js
+++ b/mailnews/addrbook/src/nsAbAutoCompleteMyDomain.js
@@ -29,17 +29,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function nsAbAutoCompleteMyDomain() {}
 
 nsAbAutoCompleteMyDomain.prototype = {
   classID: Components.ID("{5b259db2-e451-4de9-8a6f-cfba91402973}"),
   QueryInterface: XPCOMUtils.generateQI([
       Components.interfaces.nsIAutoCompleteSearch]),
@@ -47,17 +46,20 @@ nsAbAutoCompleteMyDomain.prototype = {
   cachedParam: "",
   cachedIdentity: null,
 
   startSearch: function(aString, aParam, aResult, aListener) {
     const ACR = Components.interfaces.nsIAutoCompleteResult;
     var address = null;
     if (aString && !/,/.test(aString)) {
       if (aParam != this.cachedParam) {
-        this.cachedIdentity = MailServices.accounts.getIdentity(aParam);
+        this.cachedIdentity =
+            Components.classes['@mozilla.org/messenger/account-manager;1']
+                      .getService(Components.interfaces.nsIMsgAccountManager)
+                      .getIdentity(aParam);
         this.cachedParam = aParam;
       }
       if (this.cachedIdentity.autocompleteToMyDomain)
         address = /@/.test(aString) ? aString :
                   this.cachedIdentity.email.replace(/[^@]*/, aString);
     }
 
     var result = {
--- a/mailnews/addrbook/src/nsAbAutoCompleteSearch.js
+++ b/mailnews/addrbook/src/nsAbAutoCompleteSearch.js
@@ -30,20 +30,19 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
+
 const ACR = Components.interfaces.nsIAutoCompleteResult;
 const nsIAbAutoCompleteResult = Components.interfaces.nsIAbAutoCompleteResult;
 
 function nsAbAutoCompleteResult(aSearchString) {
   // Can't create this in the prototype as we'd get the same array for
   // all instances
   this._searchResults = new Array();
   this.searchString = aSearchString;
@@ -106,18 +105,20 @@ function nsAbAutoCompleteSearch() {}
 nsAbAutoCompleteSearch.prototype = {
   // For component registration
   classID: Components.ID("2f946df9-114c-41fe-8899-81f10daf4f0c"),
 
   // This is set from a preference,
   // 0 = no comment column, 1 = name of address book this card came from
   // Other numbers currently unused (hence default to zero)
   _commentColumn: 0,
-  _parser: MailServices.headerParser,
-  _abManager: MailServices.ab,
+  _parser: Components.classes["@mozilla.org/messenger/headerparser;1"]
+                     .getService(Components.interfaces.nsIMsgHeaderParser),
+  _abManager: Components.classes["@mozilla.org/abmanager;1"]
+                        .getService(Components.interfaces.nsIAbManager),
 
   // Private methods
 
   /**
    * Returns the popularity index for a given card. This takes account of a
    * translation bug whereby Thunderbird 2 stores its values in mork as
    * hexadecimal, and Thunderbird 3 stores as decimal.
    *
@@ -387,19 +388,22 @@ nsAbAutoCompleteSearch.prototype = {
     // The comma check is so that we don't autocomplete against the user
     // entering multiple addresses.
     if (!aSearchString || /,/.test(aSearchString)) {
       result.searchResult = ACR.RESULT_IGNORED;
       aListener.onSearchResult(this, result);
       return;
     }
 
+    var prefSvc = Components.classes["@mozilla.org/preferences-service;1"]
+                            .getService(Components.interfaces.nsIPrefBranch);
+
     // Find out about the comment column
     try {
-      this._commentColumn = Services.prefs.getIntPref("mail.autoComplete.commentColumn");
+      this._commentColumn = prefSvc.getIntPref("mail.autoComplete.commentColumn");
     } catch(e) { }
 
     // Craft this by hand - we want the first item to contain the full string,
     // the second item with just the first word, and the third item with
     // anything after the first word.
     var fullString = aSearchString.toLocaleLowerCase();
     var firstWord = "";
     var rest = "";
--- a/mailnews/addrbook/src/nsAbLDAPAttributeMap.js
+++ b/mailnews/addrbook/src/nsAbLDAPAttributeMap.js
@@ -31,17 +31,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const NS_ABLDAPATTRIBUTEMAP_CID = Components.ID(
   "{127b341a-bdda-4270-85e1-edff569a9b85}");
 const NS_ABLDAPATTRIBUTEMAPSERVICE_CID = Components.ID(
   "{4ed7d5e1-8800-40da-9e78-c4f509d7ac5e}");
 
 function nsAbLDAPAttributeMap() {
@@ -144,18 +143,21 @@ nsAbLDAPAttributeMap.prototype = {
       props.push(prop);
     }
 
     aCount.value = props.length;
     return props;
   },
 
   setFromPrefs: function setFromPrefs(aPrefBranchName) {
+    var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].
+      getService(Components.interfaces.nsIPrefService);
+
     // get the right pref branch
-    let branch = Services.prefs.getBranch(aPrefBranchName + ".");
+    var branch = prefSvc.getBranch(aPrefBranchName + ".");
 
     // get the list of children
     var childCount = {};
     var children = branch.getChildList("", childCount);
 
     // do the actual sets
     for each (var child in children) {
       this.setAttributeList(child, branch.getCharPref(child), true);