First part of Bug 142123 thread safety assertions when doing import into address books (ASSERTION: morkObject not thread-safe). r/sr=bienvenu
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 29 Jul 2008 10:47:32 -0700
changeset 42 46d3979475c92c72bca135ce2a301c2957ef6e22
parent 41 4cb9ccd2a1ca2a88d630c01adc67517615cfdaf0
child 43 c295f23e75c682276c0683de8d492b1823883ce4
push idunknown
push userunknown
push dateunknown
bugs142123
First part of Bug 142123 thread safety assertions when doing import into address books (ASSERTION: morkObject not thread-safe). r/sr=bienvenu
mailnews/import/eudora/src/nsEudoraImport.cpp
mailnews/import/oexpress/nsOEImport.cpp
mailnews/import/outlook/src/nsOutlookImport.cpp
mailnews/import/public/nsIImportAddressBooks.idl
mailnews/import/src/nsImportAddressBooks.cpp
mailnews/import/text/src/nsTextImport.cpp
--- a/mailnews/import/eudora/src/nsEudoraImport.cpp
+++ b/mailnews/import/eudora/src/nsEudoraImport.cpp
@@ -169,23 +169,24 @@ public:
   /* nsISupportsArray FindAddressBooks (in nsIFile location); */
   NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval);
 
   /* nsISupports GetFieldMap (in nsIImportABDescriptor source); */
   NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap)
     { return( NS_ERROR_FAILURE); }
 
   /* void ImportAddressBook (in nsIImportABDescriptor source, in nsIAddrDatabase destination, in nsIImportFieldMap fieldMap, in boolean isAddrLocHome, out wstring errorLog, out wstring successLog, out boolean fatalError); */
-  NS_IMETHOD ImportAddressBook(  nsIImportABDescriptor *source,
-                  nsIAddrDatabase *  destination,
-                  nsIImportFieldMap *  fieldMap,
-                  PRBool isAddrLocHome,
-                  PRUnichar **    errorLog,
-                  PRUnichar **    successLog,
-                  PRBool *      fatalError);
+  NS_IMETHOD ImportAddressBook(nsIImportABDescriptor *source,
+                               nsIAddrDatabase *destination,
+                               nsIImportFieldMap *fieldMap,
+                               nsISupports *aSupportService,
+                               PRBool isAddrLocHome,
+                               PRUnichar **errorLog,
+                               PRUnichar **successLog,
+                               PRBool *fatalError);
 
   /* unsigned long GetImportProgress (); */
   NS_IMETHOD GetImportProgress(PRUint32 *_retval);
 
   NS_IMETHOD GetSampleData( PRInt32 index, PRBool *pFound, PRUnichar **pStr)
     { return( NS_ERROR_FAILURE);}
 
   NS_IMETHOD SetSampleLocation( nsIFile *) { return( NS_OK); }
@@ -729,23 +730,25 @@ void ImportEudoraAddressImpl::ReportSucc
   pStream->Append( pText);
   nsTextFormatter::smprintf_free( pText);
   nsEudoraStringBundle::FreeString( pFmt);
   ImportEudoraMailImpl::AddLinebreak( pStream);
   NS_IF_RELEASE( pBundle);
 }
 
 
-NS_IMETHODIMP ImportEudoraAddressImpl::ImportAddressBook(  nsIImportABDescriptor *pSource,
-                          nsIAddrDatabase *  pDestination,
-                          nsIImportFieldMap *  fieldMap,
-                PRBool isAddrLocHome,
-                          PRUnichar **    pErrorLog,
-                          PRUnichar **    pSuccessLog,
-                          PRBool *      fatalError)
+NS_IMETHODIMP
+ImportEudoraAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
+                                           nsIAddrDatabase *pDestination,
+                                           nsIImportFieldMap *fieldMap,
+                                           nsISupports *aSupportService,
+                                           PRBool isAddrLocHome,
+                                           PRUnichar **pErrorLog,
+                                           PRUnichar **pSuccessLog,
+                                           PRBool *fatalError)
 {
     NS_PRECONDITION(pSource != nsnull, "null ptr");
     NS_PRECONDITION(pDestination != nsnull, "null ptr");
     NS_PRECONDITION(fatalError != nsnull, "null ptr");
 
   nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsEudoraStringBundle::GetStringBundleProxy()));
 
   nsString  success;
--- a/mailnews/import/oexpress/nsOEImport.cpp
+++ b/mailnews/import/oexpress/nsOEImport.cpp
@@ -148,24 +148,24 @@ public:
 
   /* nsISupportsArray FindAddressBooks (in nsIFileSpec location); */
   NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval);
 
   /* nsISupports InitFieldMap(nsIImportFieldMap *fieldMap); */
   NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap)
     { return( NS_ERROR_FAILURE); }
 
-  /* void ImportAddressBook (in nsIImportABDescriptor source, in nsIAddrDatabase destination, in nsIImportFieldMap fieldMap, in boolean isAddrLocHome, out wstring errorLog, out wstring successLog, out boolean fatalError); */
-  NS_IMETHOD ImportAddressBook(  nsIImportABDescriptor *source,
-                  nsIAddrDatabase *  destination,
-                  nsIImportFieldMap *  fieldMap,
-                  PRBool isAddrLocHome,
-                  PRUnichar **    errorLog,
-                  PRUnichar **    successLog,
-                  PRBool *      fatalError);
+  NS_IMETHOD ImportAddressBook(nsIImportABDescriptor *source,
+                               nsIAddrDatabase *destination,
+                               nsIImportFieldMap *fieldMap,
+                               nsISupports *aSupportService,
+                               PRBool isAddrLocHome,
+                               PRUnichar **errorLog,
+                               PRUnichar **successLog,
+                               PRBool *fatalError);
 
   /* unsigned long GetImportProgress (); */
   NS_IMETHOD GetImportProgress(PRUint32 *_retval);
 
   NS_IMETHOD GetSampleData( PRInt32 index, PRBool *pFound, PRUnichar **pStr)
     { return( NS_ERROR_FAILURE);}
 
   NS_IMETHOD SetSampleLocation( nsIFile *) { return( NS_OK); }
@@ -600,22 +600,23 @@ NS_IMETHODIMP ImportOEAddressImpl::FindA
     m_pWab = nsnull;
   }
   return( NS_OK);
 }
 
 
 
 NS_IMETHODIMP ImportOEAddressImpl::ImportAddressBook(nsIImportABDescriptor *source,
-                                                     nsIAddrDatabase * destination,
-                                                     nsIImportFieldMap * fieldMap,
+                                                     nsIAddrDatabase *destination,
+                                                     nsIImportFieldMap *fieldMap,
+                                                     nsISupports *aSupportService,
                                                      PRBool isAddrLocHome,
-                                                     PRUnichar ** errorLog,
-                                                     PRUnichar ** successLog,
-                                                     PRBool * fatalError)
+                                                     PRUnichar **errorLog,
+                                                     PRUnichar **successLog,
+                                                     PRBool *fatalError)
 {
     NS_PRECONDITION(source != nsnull, "null ptr");
     // NS_PRECONDITION(destination != nsnull, "null ptr");
     // NS_PRECONDITION(fieldMap != nsnull, "null ptr");
     NS_PRECONDITION(fatalError != nsnull, "null ptr");
     if (!source || !fatalError)
         return NS_ERROR_NULL_POINTER;
 
--- a/mailnews/import/outlook/src/nsOutlookImport.cpp
+++ b/mailnews/import/outlook/src/nsOutlookImport.cpp
@@ -145,24 +145,24 @@ public:
 
   /* nsISupportsArray FindAddressBooks (in nsIFile location); */
   NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval);
 
   /* nsISupports GetFieldMap (in nsIImportABDescriptor source); */
   NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap)
     { return( NS_ERROR_FAILURE); }
 
-  /* void ImportAddressBook (in nsIImportABDescriptor source, in nsIAddrDatabase destination, in nsIImportFieldMap fieldMap, in boolean isAddrLocHome, out wstring errorLog, out wstring successLog, out boolean fatalError); */
-  NS_IMETHOD ImportAddressBook(  nsIImportABDescriptor *source,
-                  nsIAddrDatabase *  destination,
-                  nsIImportFieldMap *  fieldMap,
-                  PRBool isAddrLocHome,
-                  PRUnichar **    errorLog,
-                  PRUnichar **    successLog,
-                  PRBool *      fatalError);
+  NS_IMETHOD ImportAddressBook(nsIImportABDescriptor *source,
+                               nsIAddrDatabase *destination,
+                               nsIImportFieldMap *fieldMap,
+                               nsISupports *aSupportService,
+                               PRBool isAddrLocHome,
+                               PRUnichar **errorLog,
+                               PRUnichar **successLog,
+                               PRBool *fatalError);
 
   /* unsigned long GetImportProgress (); */
   NS_IMETHOD GetImportProgress(PRUint32 *_retval);
 
   NS_IMETHOD GetSampleData( PRInt32 index, PRBool *pFound, PRUnichar **pStr)
     { return( NS_ERROR_FAILURE);}
 
   NS_IMETHOD SetSampleLocation( nsIFile *) { return( NS_OK); }
@@ -559,23 +559,24 @@ NS_IMETHODIMP ImportOutlookAddressImpl::
 {
   NS_PRECONDITION(_retval != nsnull, "null ptr");
   if (!_retval)
     return NS_ERROR_NULL_POINTER;
 
   return( m_address.GetAddressBooks( _retval));
 }
 
-NS_IMETHODIMP ImportOutlookAddressImpl::ImportAddressBook(  nsIImportABDescriptor *source,
-                          nsIAddrDatabase *  destination,
-                          nsIImportFieldMap *  fieldMap,
-                          PRBool isAddrLocHome,
-                          PRUnichar **    pErrorLog,
-                          PRUnichar **    pSuccessLog,
-                          PRBool *      fatalError)
+NS_IMETHODIMP ImportOutlookAddressImpl::ImportAddressBook(nsIImportABDescriptor *source,
+                                                          nsIAddrDatabase *destination,
+                                                          nsIImportFieldMap *fieldMap,
+                                                          nsISupports *aSupportService,
+                                                          PRBool isAddrLocHome,
+                                                          PRUnichar **pErrorLog,
+                                                          PRUnichar **pSuccessLog,
+                                                          PRBool *fatalError)
 {
   m_msgCount = 0;
   m_msgTotal = 0;
     NS_PRECONDITION(source != nsnull, "null ptr");
     NS_PRECONDITION(destination != nsnull, "null ptr");
   NS_PRECONDITION(fatalError != nsnull, "null ptr");
 
   nsCOMPtr<nsIStringBundle> bundle( dont_AddRef( nsOutlookStringBundle::GetStringBundleProxy()));
--- a/mailnews/import/public/nsIImportAddressBooks.idl
+++ b/mailnews/import/public/nsIImportAddressBooks.idl
@@ -57,37 +57,28 @@
   if the address book will be imported into an existing address book or new address
   books.  (This could be 2 separate xul UI's?).
   2) The second panel will show field mapping if it is required - if it is required then
   there will be one panel per address book for formats that support multiple
   address books.  If it is not required then there will be no second panel.
   3) Show the progress dialog for the import - this could be per address book if
   mapping is required? what to do, what to doooooo.....
   4) All done, maybe a what was done panel??
-
-
-*/
-
-/*
-*/
-
-/*
-
 */
 
 #include "nsISupports.idl"
 
 interface   nsIFile;
 interface   nsISupportsArray;
 interface  nsIImportABDescriptor;
 interface  nsIOutputStream;
 interface  nsIAddrDatabase;
 interface  nsIImportFieldMap;
 
-[scriptable, uuid(d415da06-5d77-468d-aae4-9baaf5b3b6cc)]
+[scriptable, uuid(49e2bdf8-c5c3-4425-8c67-f20d15d45a71)]
 interface nsIImportAddressBooks : nsISupports
 {
 
   /*
     Does this interface supports 1 or 1..n address books.  You only
     get to choose 1 location so for formats where 1..n address books
     are imported from a directory, then return true.  For a 1 to 1 relationship
     between location and address books return false.
@@ -128,29 +119,44 @@ interface nsIImportAddressBooks : nsISup
   nsISupportsArray FindAddressBooks( in nsIFile location);
 
   /*
     Fill in defaults (if any) for a field map for importing address
     books from this location.
   */
   void InitFieldMap(in nsIImportFieldMap fieldMap);
 
-  /*
-    Import a specific mailbox into the destination file supplied.  If an error
-    occurs that is non-fatal, the destination will be deleted and other mailbox's
-    will be imported.  If a fatal error occurs, the destination will be deleted
-    and the import operation will abort.
-  */
-  void   ImportAddressBook(   in nsIImportABDescriptor source,
-                   in nsIAddrDatabase destination,
-                   in nsIImportFieldMap fieldMap,
-                in boolean isAddrLocHome,
-                out wstring errorLog,
-                out wstring successLog,
-                   out boolean fatalError);
+  /**
+   * Import a specific mailbox into the destination file supplied.  If an error
+   * occurs that is non-fatal, the destination will be deleted and other
+   * mailbox's will be imported.  If a fatal error occurs, the destination will
+   * be deleted and the import operation will abort.
+   *
+   * @param aSource         The source data for the import.
+   * @param aDestination    The proxy database for the destination of the
+   *                        import.
+   * @param aFieldMap       The field map containing the mapping of fields to be
+   *                        used in cvs and tab type imports.
+   * @param aSupportService An optional proxy support service (nsnull is
+   *                        acceptable if it is not required), may be required
+   *                        for certain import types (e.g. nsIAbLDIFService for
+   *                        LDIF import).
+   * @param aIsAddrLocHome  Whether or not an address is the home location.
+   * @param aErrorLog       The error log from the import.
+   * @param aSuccessLog     The success log from the import.
+   * @param aFatalError     True if there was a fatal error doing the import.
+   */
+  void ImportAddressBook(in nsIImportABDescriptor aSource,
+                         in nsIAddrDatabase aDestination,
+                         in nsIImportFieldMap aFieldMap,
+                         in nsISupports aSupportService,
+                         in boolean aIsAddrLocHome,
+                         out wstring aErrorLog,
+                         out wstring aSuccessLog,
+                         out boolean aFatalError);
 
   /*
     Return the amount of the address book that has been imported so far.  This number
     is used to present progress information and must never be larger than the
     size specified in nsIImportABDescriptor.GetSize();  May be called from
     a different thread than ImportAddressBook()
   */
   unsigned long GetImportProgress();
--- a/mailnews/import/src/nsImportAddressBooks.cpp
+++ b/mailnews/import/src/nsImportAddressBooks.cpp
@@ -43,16 +43,17 @@
 #include "nsIImportGeneric.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIImportABDescriptor.h"
 #include "nsIImportFieldMap.h"
 #include "nsStringGlue.h"
 #include "nsILocalFile.h"
 #include "nsIAddrDatabase.h"
 #include "nsIAbManager.h"
+#include "nsIAbLDIFService.h"
 #include "nsIRDFService.h"
 #include "nsRDFCID.h"
 #include "nsAbBaseCID.h"
 #include "nsIStringBundle.h"
 #include "nsImportStringBundle.h"
 #include "nsTextFormatter.h"
 #include "nsIProxyObjectManager.h"
 #include "nsServiceManagerUtils.h"
@@ -132,16 +133,17 @@ class AddressThreadData {
 public:
   PRBool            driverAlive;
   PRBool            threadAlive;
   PRBool            abort;
   PRBool            fatalError;
   PRUint32          currentTotal;
   PRUint32          currentSize;
   nsISupportsArray *      books;
+  nsIAbLDIFService *ldifService;
   nsIImportAddressBooks *    addressImport;
   nsIImportFieldMap *      fieldMap;
   nsISupportsString *    successLog;
   nsISupportsString *    errorLog;
   char *            pDestinationUri;
   PRBool                      bAddrLocInput ;
     nsIStringBundle*            stringBundle;
 
@@ -596,17 +598,35 @@ NS_IMETHODIMP nsImportGenericAddressBook
   m_pThreadData->errorLog = m_pErrorLog;
   NS_IF_ADDREF( m_pErrorLog);
   m_pThreadData->successLog = m_pSuccessLog;
   NS_IF_ADDREF( m_pSuccessLog);
   if (m_pDestinationUri)
     m_pThreadData->pDestinationUri = strdup( m_pDestinationUri);
   m_pThreadData->bAddrLocInput = isAddrLocHome ;
 
-    NS_IF_ADDREF(m_pThreadData->stringBundle = m_stringBundle);
+  NS_IF_ADDREF(m_pThreadData->stringBundle = m_stringBundle);
+
+  nsresult rv;
+  nsCOMPtr<nsIAbLDIFService> ldifService(do_GetService(NS_ABLDIFSERVICE_CONTRACTID, &rv));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsCOMPtr<nsIProxyObjectManager> proxyObjectManager =
+    do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsCOMPtr<nsIAbLDIFService> proxyLDIFService;
+  rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
+                                             NS_GET_IID(nsIAbLDIFService),
+                                             ldifService,
+                                             NS_PROXY_SYNC | NS_PROXY_ALWAYS,
+                                             getter_AddRefs(proxyLDIFService));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  NS_IF_ADDREF(m_pThreadData->ldifService = proxyLDIFService);
 
   PRThread *pThread = PR_CreateThread( PR_USER_THREAD, &ImportAddressThread, m_pThreadData,
                   PR_PRIORITY_NORMAL,
                   PR_LOCAL_THREAD,
                   PR_UNJOINABLE_THREAD,
                   0);
   if (!pThread) {
     m_pThreadData->ThreadDelete();
@@ -699,30 +719,32 @@ AddressThreadData::AddressThreadData()
   currentTotal = 0;
   currentSize = 0;
   books = nsnull;
   addressImport = nsnull;
   successLog = nsnull;
   errorLog = nsnull;
   pDestinationUri = nsnull;
   fieldMap = nsnull;
-    stringBundle = nsnull;
+  stringBundle = nsnull;
+  ldifService = nsnull;
 }
 
 AddressThreadData::~AddressThreadData()
 {
   if (pDestinationUri)
     NS_Free(pDestinationUri);
 
   NS_IF_RELEASE(books);
   NS_IF_RELEASE(addressImport);
   NS_IF_RELEASE(errorLog);
   NS_IF_RELEASE(successLog);
   NS_IF_RELEASE(fieldMap);
   NS_IF_RELEASE(stringBundle);
+  NS_IF_RELEASE(ldifService);
 }
 
 void AddressThreadData::DriverDelete( void)
 {
   driverAlive = PR_FALSE;
   if (!driverAlive && !threadAlive)
     delete this;
 }
@@ -983,16 +1005,17 @@ PR_STATIC_CALLBACK( void) ImportAddressT
         rv = proxyObjectManager->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
                                                    NS_GET_IID(nsIAddrDatabase),
                                                    pDestDB,
                                                    NS_PROXY_SYNC | NS_PROXY_ALWAYS,
                                                    getter_AddRefs(proxyAddrDatabase));
         if (NS_FAILED(rv))
           return;
 
+
         PRBool fatalError = PR_FALSE;
         pData->currentSize = size;
         if (proxyAddrDatabase) {
           PRUnichar *pSuccess = nsnull;
           PRUnichar *pError = nsnull;
 
           /*
           if (pData->fieldMap) {
@@ -1004,23 +1027,24 @@ PR_STATIC_CALLBACK( void) ImportAddressT
             for (PRInt32 i = 0; i < sz; i++) {
               pData->fieldMap->GetFieldMap( i, &mapIndex);
               pData->fieldMap->GetFieldActive( i, &active);
               IMPORT_LOG3( "Field map #%d: index=%d, active=%d\n", (int) i, (int) mapIndex, (int) active);
             }
           }
           */
 
-          rv = pData->addressImport->ImportAddressBook(  book,
-                                proxyAddrDatabase, // destination
-                                pData->fieldMap, // fieldmap
-                                pData->bAddrLocInput,
-                                &pError,
-                                &pSuccess,
-                                &fatalError);
+          rv = pData->addressImport->ImportAddressBook(book,
+                                                       proxyAddrDatabase,
+                                                       pData->fieldMap,
+                                                       pData->ldifService,
+                                                       pData->bAddrLocInput,
+                                                       &pError,
+                                                       &pSuccess,
+                                                       &fatalError);
           if (pSuccess) {
             success.Append( pSuccess);
             NS_Free( pSuccess);
           }
           if (pError) {
             error.Append( pError);
             NS_Free( pError);
           }
--- a/mailnews/import/text/src/nsTextImport.cpp
+++ b/mailnews/import/text/src/nsTextImport.cpp
@@ -92,17 +92,17 @@ public:
 
   static nsresult Create(nsIImportAddressBooks** aImport,
                          nsIStringBundle *aStringBundle);
 
     // nsISupports interface
     NS_DECL_ISUPPORTS
 
     // nsIImportAddressBooks interface
-
+    
   /* PRBool GetSupportsMultiple (); */
   NS_IMETHOD GetSupportsMultiple(PRBool *_retval) { *_retval = PR_FALSE; return( NS_OK);}
 
   /* PRBool GetAutoFind (out wstring description); */
   NS_IMETHOD GetAutoFind(PRUnichar **description, PRBool *_retval);
 
   /* PRBool GetNeedsFieldMap (nsIFile *location); */
   NS_IMETHOD GetNeedsFieldMap(nsIFile *location, PRBool *_retval);
@@ -113,22 +113,23 @@ public:
   /* nsISupportsArray FindAddressBooks (in nsIFile location); */
   NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval);
 
   /* nsISupports InitFieldMap(nsIImportFieldMap fieldMap); */
   NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap);
 
   /* void ImportAddressBook (in nsIImportABDescriptor source, in nsIAddrDatabase destination, in nsIImportFieldMap fieldMap, in boolean isAddrLocHome, out wstring errorLog, out wstring successLog, out boolean fatalError); */
   NS_IMETHOD ImportAddressBook(nsIImportABDescriptor *source,
-                  nsIAddrDatabase * destination,
-                  nsIImportFieldMap * fieldMap,
-                  PRBool isAddrLocHome,
-                  PRUnichar ** errorLog,
-                  PRUnichar ** successLog,
-                  PRBool * fatalError);
+                               nsIAddrDatabase *destination,
+                               nsIImportFieldMap *fieldMap,
+                               nsISupports *aSupportService,
+                               PRBool isAddrLocHome,
+                               PRUnichar **errorLog,
+                               PRUnichar **successLog,
+                               PRBool *fatalError);
 
   /* unsigned long GetImportProgress (); */
   NS_IMETHOD GetImportProgress(PRUint32 *_retval);
 
   NS_IMETHOD GetSampleData( PRInt32 index, PRBool *pFound, PRUnichar **pStr);
 
   NS_IMETHOD SetSampleLocation( nsIFile *);
 
@@ -420,23 +421,25 @@ void ImportAddressImpl::SetLogs( nsStrin
 {
   if (pError)
     *pError = ToNewUnicode(error);
   if (pSuccess)
     *pSuccess = ToNewUnicode(success);
 }
 
 
-NS_IMETHODIMP ImportAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
-                          nsIAddrDatabase * pDestination,
-                          nsIImportFieldMap * fieldMap,
-                          PRBool isAddrLocHome,
-                          PRUnichar ** pErrorLog,
-                          PRUnichar ** pSuccessLog,
-                          PRBool * fatalError)
+NS_IMETHODIMP
+ImportAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
+                                     nsIAddrDatabase *pDestination,
+                                     nsIImportFieldMap *fieldMap,
+                                     nsISupports *aSupportService,
+                                     PRBool isAddrLocHome,
+                                     PRUnichar ** pErrorLog,
+                                     PRUnichar ** pSuccessLog,
+                                     PRBool * fatalError)
 {
   NS_PRECONDITION(pSource != nsnull, "null ptr");
   NS_PRECONDITION(pDestination != nsnull, "null ptr");
   NS_PRECONDITION(fatalError != nsnull, "null ptr");
 
   nsCOMPtr<nsIStringBundle> pBundle;
   nsresult rv =
     nsImportStringBundle::GetStringBundleProxy(m_notProxyBundle,
@@ -477,18 +480,23 @@ NS_IMETHODIMP ImportAddressImpl::ImportA
 
   nsCOMPtr<nsIFile> inFile;
   if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) {
     ReportError(TEXTIMPORT_ADDRESS_BADSOURCEFILE, name, &error, pBundle);
     SetLogs(success, error, pErrorLog, pSuccessLog);
     return NS_ERROR_FAILURE;
   }
 
+  if (!aSupportService) {
+    IMPORT_LOG0("Missing support service to import call");
+    return NS_ERROR_FAILURE;
+  }
+
   PRBool isLDIF = PR_FALSE;
-    nsCOMPtr<nsIAbLDIFService> ldifService = do_GetService(NS_ABLDIFSERVICE_CONTRACTID, &rv);
+  nsCOMPtr<nsIAbLDIFService> ldifService(do_QueryInterface(aSupportService, &rv));
 
     if (NS_SUCCEEDED(rv)) {
       rv = ldifService->IsLDIFFile(inFile, &isLDIF);
       if (NS_FAILED(rv)) {
         IMPORT_LOG0( "*** Error reading address file\n");
       }
     }