First part of Bug 142123 thread safety assertions when doing import into address books (ASSERTION: morkObject not thread-safe). r/sr=bienvenu

This commit is contained in:
Mark Banner 2008-07-29 10:47:32 -07:00
Родитель 668a00efab
Коммит fd85b334e5
6 изменённых файлов: 132 добавлений и 89 удалений

Просмотреть файл

@ -177,6 +177,7 @@ public:
NS_IMETHOD ImportAddressBook(nsIImportABDescriptor *source,
nsIAddrDatabase *destination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar **errorLog,
PRUnichar **successLog,
@ -734,9 +735,11 @@ void ImportEudoraAddressImpl::ReportSuccess( nsString& name, nsString *pStream)
}
NS_IMETHODIMP ImportEudoraAddressImpl::ImportAddressBook( nsIImportABDescriptor *pSource,
NS_IMETHODIMP
ImportEudoraAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
nsIAddrDatabase *pDestination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar **pErrorLog,
PRUnichar **pSuccessLog,

Просмотреть файл

@ -153,10 +153,10 @@ public:
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,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar **errorLog,
PRUnichar **successLog,
@ -607,6 +607,7 @@ NS_IMETHODIMP ImportOEAddressImpl::FindAddressBooks(nsIFile *location, nsISuppor
NS_IMETHODIMP ImportOEAddressImpl::ImportAddressBook(nsIImportABDescriptor *source,
nsIAddrDatabase *destination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar **errorLog,
PRUnichar **successLog,

Просмотреть файл

@ -150,10 +150,10 @@ public:
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,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar **errorLog,
PRUnichar **successLog,
@ -567,6 +567,7 @@ NS_IMETHODIMP ImportOutlookAddressImpl::FindAddressBooks(nsIFile *location, nsIS
NS_IMETHODIMP ImportOutlookAddressImpl::ImportAddressBook(nsIImportABDescriptor *source,
nsIAddrDatabase *destination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar **pErrorLog,
PRUnichar **pSuccessLog,

Просмотреть файл

@ -62,15 +62,6 @@
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"
@ -82,7 +73,7 @@ interface nsIOutputStream;
interface nsIAddrDatabase;
interface nsIImportFieldMap;
[scriptable, uuid(d415da06-5d77-468d-aae4-9baaf5b3b6cc)]
[scriptable, uuid(49e2bdf8-c5c3-4425-8c67-f20d15d45a71)]
interface nsIImportAddressBooks : nsISupports
{
@ -133,19 +124,34 @@ interface nsIImportAddressBooks : nsISupports
*/
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.
/**
* 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 source,
in nsIAddrDatabase destination,
in nsIImportFieldMap fieldMap,
in boolean isAddrLocHome,
out wstring errorLog,
out wstring successLog,
out boolean fatalError);
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

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsILocalFile.h"
#include "nsIAddrDatabase.h"
#include "nsIAbManager.h"
#include "nsIAbLDIFService.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "nsAbBaseCID.h"
@ -137,6 +138,7 @@ public:
PRUint32 currentTotal;
PRUint32 currentSize;
nsISupportsArray * books;
nsIAbLDIFService *ldifService;
nsIImportAddressBooks * addressImport;
nsIImportFieldMap * fieldMap;
nsISupportsString * successLog;
@ -603,6 +605,24 @@ NS_IMETHODIMP nsImportGenericAddressBooks::BeginImport(nsISupportsString *succes
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,
@ -705,6 +725,7 @@ AddressThreadData::AddressThreadData()
pDestinationUri = nsnull;
fieldMap = nsnull;
stringBundle = nsnull;
ldifService = nsnull;
}
AddressThreadData::~AddressThreadData()
@ -718,6 +739,7 @@ AddressThreadData::~AddressThreadData()
NS_IF_RELEASE(successLog);
NS_IF_RELEASE(fieldMap);
NS_IF_RELEASE(stringBundle);
NS_IF_RELEASE(ldifService);
}
void AddressThreadData::DriverDelete( void)
@ -988,6 +1010,7 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff)
if (NS_FAILED(rv))
return;
PRBool fatalError = PR_FALSE;
pData->currentSize = size;
if (proxyAddrDatabase) {
@ -1010,8 +1033,9 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff)
*/
rv = pData->addressImport->ImportAddressBook(book,
proxyAddrDatabase, // destination
pData->fieldMap, // fieldmap
proxyAddrDatabase,
pData->fieldMap,
pData->ldifService,
pData->bAddrLocInput,
&pError,
&pSuccess,

Просмотреть файл

@ -120,6 +120,7 @@ public:
NS_IMETHOD ImportAddressBook(nsIImportABDescriptor *source,
nsIAddrDatabase *destination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar **errorLog,
PRUnichar **successLog,
@ -425,9 +426,11 @@ void ImportAddressImpl::SetLogs( nsString& success, nsString& error, PRUnichar *
}
NS_IMETHODIMP ImportAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
NS_IMETHODIMP
ImportAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSource,
nsIAddrDatabase *pDestination,
nsIImportFieldMap *fieldMap,
nsISupports *aSupportService,
PRBool isAddrLocHome,
PRUnichar ** pErrorLog,
PRUnichar ** pSuccessLog,
@ -482,8 +485,13 @@ NS_IMETHODIMP ImportAddressImpl::ImportAddressBook(nsIImportABDescriptor *pSourc
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);