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 удалений

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

@ -174,13 +174,14 @@ public:
{ 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);
@ -734,13 +735,15 @@ void ImportEudoraAddressImpl::ReportSuccess( nsString& name, nsString *pStream)
}
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");

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

@ -153,14 +153,14 @@ 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,
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);
@ -605,12 +605,13 @@ NS_IMETHODIMP ImportOEAddressImpl::FindAddressBooks(nsIFile *location, nsISuppor
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");

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

@ -150,14 +150,14 @@ 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,
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);
@ -564,13 +564,14 @@ NS_IMETHODIMP ImportOutlookAddressImpl::FindAddressBooks(nsIFile *location, nsIS
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;

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

@ -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.
*/
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

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

@ -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;
@ -601,7 +603,25 @@ NS_IMETHODIMP nsImportGenericAddressBooks::BeginImport(nsISupportsString *succes
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,
@ -704,7 +724,8 @@ AddressThreadData::AddressThreadData()
errorLog = nsnull;
pDestinationUri = nsnull;
fieldMap = nsnull;
stringBundle = 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) {
@ -1009,13 +1032,14 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff)
}
*/
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);

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

@ -97,7 +97,7 @@ public:
NS_DECL_ISUPPORTS
// nsIImportAddressBooks interface
/* PRBool GetSupportsMultiple (); */
NS_IMETHOD GetSupportsMultiple(PRBool *_retval) { *_retval = PR_FALSE; return( NS_OK);}
@ -118,12 +118,13 @@ public:
/* 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);
@ -425,13 +426,15 @@ void ImportAddressImpl::SetLogs( nsString& success, nsString& error, PRUnichar *
}
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");
@ -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);