From 2cdba2028cf34153a5a4fcc0f6a2d42e78beb000 Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.demon.co.uk" Date: Thu, 1 Mar 2007 19:13:39 +0000 Subject: [PATCH] Bug 371542 Tidy up nsIImportABDescriptor.idl and associated code. r=Neil,sr=bienvenu git-svn-id: svn://10.0.0.236/trunk@221167 18797224-902f-48f8-a5cc-f745e15eee43 --- .../import/eudora/src/nsEudoraImport.cpp | 24 ++-- .../import/eudora/src/nsEudoraMac.cpp | 36 +++--- .../import/eudora/src/nsEudoraWin32.cpp | 18 +-- .../mailnews/import/oexpress/nsOEImport.cpp | 6 +- .../import/outlook/src/nsOutlookImport.cpp | 11 +- .../import/outlook/src/nsOutlookMail.cpp | 2 +- .../import/public/nsIImportABDescriptor.idl | 104 ++++++++--------- .../import/src/nsImportABDescriptor.cpp | 16 +-- .../import/src/nsImportABDescriptor.h | 106 ++++++++++++------ .../import/src/nsImportAddressBooks.cpp | 17 +-- .../mailnews/import/text/src/nsTextImport.cpp | 44 ++------ 11 files changed, 201 insertions(+), 183 deletions(-) diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp index d2b86e3a7a1..4e69d4ff1ce 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp @@ -708,11 +708,7 @@ NS_IMETHODIMP ImportEudoraAddressImpl::ImportAddressBook( nsIImportABDescriptor PRBool abort = PR_FALSE; nsString name; - PRUnichar * pName; - if (NS_SUCCEEDED( pSource->GetPreferredName( &pName))) { - name = pName; - nsCRT::free( pName); - } + pSource->GetPreferredName(name); PRUint32 addressSize = 0; pSource->GetSize( &addressSize); @@ -724,16 +720,24 @@ NS_IMETHODIMP ImportEudoraAddressImpl::ImportAddressBook( nsIImportABDescriptor } - nsIFileSpec * inFile; - if (NS_FAILED( pSource->GetFileSpec( &inFile))) { + nsCOMPtr inFile; + if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) { ImportEudoraMailImpl::ReportError( EUDORAIMPORT_ADDRESS_BADSOURCEFILE, name, &error); ImportEudoraMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog); return( NS_ERROR_FAILURE); } + nsIFileSpec *inFileSpec; + if (NS_FAILED(NS_NewFileSpecFromIFile(inFile, &inFileSpec))) { + ImportEudoraMailImpl::ReportError( EUDORAIMPORT_ADDRESS_BADSOURCEFILE, name, &error); + ImportEudoraMailImpl::SetLogs( success, error, pErrorLog, pSuccessLog); + return( NS_ERROR_FAILURE); + } + + #ifdef IMPORT_DEBUG char *pPath; - inFile->GetNativePath( &pPath); + inFile->GetNativePath(&pPath); IMPORT_LOG1( "Import address book: %s\n", pPath); nsCRT::free( pPath); #endif @@ -742,9 +746,9 @@ NS_IMETHODIMP ImportEudoraAddressImpl::ImportAddressBook( nsIImportABDescriptor nsresult rv = NS_OK; m_bytes = 0; - rv = m_eudora.ImportAddresses( &m_bytes, &abort, name.get(), inFile, pDestination, error); + rv = m_eudora.ImportAddresses( &m_bytes, &abort, name.get(), inFileSpec, pDestination, error); - inFile->Release(); + inFileSpec->Release(); diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp index 5f931e41a6f..6c8c2f5d71b 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp @@ -1269,6 +1269,15 @@ nsresult nsEudoraMac::FindAddressBooks( nsIFileSpec *pRoot, nsISupportsArray **p if (NS_SUCCEEDED( rv) && exists) rv = spec->IsFile( &isFile); + // XXX this should be fixed by implementing bug 323211 + nsFileSpec fileSpec; + rv = spec->GetFileSpec(&fileSpec); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr fileLoc; + rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(fileLoc)); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr desc; nsISupports * pInterface; @@ -1277,14 +1286,9 @@ nsresult nsEudoraMac::FindAddressBooks( nsIFileSpec *pRoot, nsISupportsArray **p if (NS_SUCCEEDED( rv)) { sz = 0; spec->GetFileSize( &sz); - desc->SetPreferredName( displayName.get()); + desc->SetPreferredName(displayName); desc->SetSize( sz); - nsIFileSpec *pSpec = nsnull; - desc->GetFileSpec( &pSpec); - if (pSpec) { - pSpec->FromFileSpec( spec); - NS_RELEASE( pSpec); - } + desc->SetAbFile(fileLoc); rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface); (*ppArray)->AppendElement( pInterface); pInterface->Release(); @@ -1359,18 +1363,22 @@ nsresult nsEudoraMac::FindAddressBooks( nsIFileSpec *pRoot, nsISupportsArray **p fSpec.GetFileTypeAndCreator( &type, &creator); #endif if (type == 'TEXT') { + + // XXX this should be fixed by implementing bug 323211 + rv = spec->GetFileSpec(&fileSpec); + NS_ENSURE_SUCCESS(rv, rv); + + rv = NS_FileSpecToIFile(&fileSpec, + getter_AddRefs(fileLoc)); + NS_ENSURE_SUCCESS(rv, rv); + rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc)); if (NS_SUCCEEDED( rv)) { sz = 0; spec->GetFileSize( &sz); - desc->SetPreferredName( displayName.get()); + desc->SetPreferredName(displayName); desc->SetSize( sz); - nsIFileSpec *pSpec = nsnull; - desc->GetFileSpec( &pSpec); - if (pSpec) { - pSpec->FromFileSpec( spec); - NS_RELEASE( pSpec); - } + desc->SetAbFile(fileLoc); rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface); (*ppArray)->AppendElement( pInterface); pInterface->Release(); diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp index d9f3fbfba64..f97de3bf779 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp @@ -1394,18 +1394,22 @@ nsresult nsEudoraWin32::FoundAddressBook( nsIFileSpec *spec, const PRUnichar *pN } } + // XXX this should be fixed by implementing bug 323211 + nsFileSpec fileSpec; + rv = spec->GetFileSpec(&fileSpec); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr fileLoc; + rv = NS_FileSpecToIFile(fileSpec, getter_AddRefs(fileLoc)); + NS_ENSURE_SUCCESS(rv, rv); + rv = impSvc->CreateNewABDescriptor( getter_AddRefs( desc)); if (NS_SUCCEEDED( rv)) { PRUint32 sz = 0; spec->GetFileSize( &sz); - desc->SetPreferredName( name.get()); + desc->SetPreferredName(name); desc->SetSize( sz); - nsIFileSpec *pSpec = nsnull; - desc->GetFileSpec( &pSpec); - if (pSpec) { - pSpec->FromFileSpec( spec); - NS_RELEASE( pSpec); - } + desc->SetAbFile(fileLoc); rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface); pArray->AppendElement( pInterface); pInterface->Release(); diff --git a/mozilla/mailnews/import/oexpress/nsOEImport.cpp b/mozilla/mailnews/import/oexpress/nsOEImport.cpp index 68eb0795e0d..4a50a5cfe5f 100644 --- a/mozilla/mailnews/import/oexpress/nsOEImport.cpp +++ b/mozilla/mailnews/import/oexpress/nsOEImport.cpp @@ -627,7 +627,7 @@ NS_IMETHODIMP ImportOEAddressImpl::FindAddressBooks(nsIFileSpec *location, nsISu pID->SetIdentifier( 0x4F453334); pID->SetRef( 1); pID->SetSize( 100); - pID->SetPreferredName( str.get()); + pID->SetPreferredName(str); rv = pID->QueryInterface( kISupportsIID, (void **) &pInterface); (*_retval)->AppendElement( pInterface); pInterface->Release(); @@ -690,10 +690,8 @@ NS_IMETHODIMP ImportOEAddressImpl::ImportAddressBook( nsIImportABDescriptor *sou nsString name; if (SUCCEEDED(hr)) { - nsXPIDLString pName; - if (NS_SUCCEEDED( source->GetPreferredName(getter_Copies(pName)))) + if (NS_SUCCEEDED(source->GetPreferredName(name))) { - name = pName; ReportSuccess( name, &success); } } diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp index 4362f190c21..2659e76f26e 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp @@ -619,14 +619,9 @@ NS_IMETHODIMP ImportOutlookAddressImpl::ImportAddressBook( nsIImportABDescriptor return NS_ERROR_NULL_POINTER; } - nsString name; - PRUnichar * pName; - if (NS_SUCCEEDED( source->GetPreferredName( &pName))) { - name = pName; - nsCRT::free( pName); - } - - + nsString name; + source->GetPreferredName(name); + PRUint32 id; if (NS_FAILED( source->GetIdentifier( &id))) { ImportOutlookMailImpl::ReportError( OUTLOOKIMPORT_ADDRESS_BADSOURCEFILE, name, &error); diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp index f8fbd00b18b..d17ae655030 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp @@ -305,7 +305,7 @@ nsresult nsOutlookMail::GetAddressBooks( nsISupportsArray **pArray) pID->SetIdentifier( i); pFolder->GetDisplayName( name); MakeAddressBookNameUnique( name, list); - pID->SetPreferredName(name.get()); + pID->SetPreferredName(name); pID->SetSize( 100); rv = pID->QueryInterface( kISupportsIID, (void **) &pInterface); (*pArray)->AppendElement( pInterface); diff --git a/mozilla/mailnews/import/public/nsIImportABDescriptor.idl b/mozilla/mailnews/import/public/nsIImportABDescriptor.idl index 0760cf4e67e..dab0f006a91 100644 --- a/mozilla/mailnews/import/public/nsIImportABDescriptor.idl +++ b/mozilla/mailnews/import/public/nsIImportABDescriptor.idl @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -20,6 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Mark Banner * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -47,63 +48,56 @@ #include "nsISupports.idl" -interface nsIFileSpec; +interface nsIFile; -[scriptable, uuid(9c1774e0-3538-11d3-a206-00a0cc26da63)] +/** + * Implementation Note: + * + * The default implementation can be obtained from + * nsIImportService::CreateNewABDescriptor(); + * + * You should only be interested in using this class if you implement + * the nsIImportAddressBooks interface in which case, just using the service to + * create new ones should work fine for you. If not, implement your + * own. + */ +[scriptable, uuid(2d8983b2-cea6-4ae2-9145-eb772481fa18)] interface nsIImportABDescriptor : nsISupports { - /* - use the following 2 attributes however you'd like to - refer to a specific address book - */ - attribute unsigned long identifier; - attribute unsigned long ref; + /** + * use the following 2 attributes however you'd like to + * refer to a specific address book + */ + attribute unsigned long identifier; + attribute unsigned long ref; + + /** + * Doesn't have to be accurate, this is merely used to report progress. + * If you're importing a file, using file size and reporting progress + * as the number of bytes processed so far makes sense. For other formats + * returning the number of records may make more sense. + */ + attribute unsigned long size; - /* - Doesn't have to be accurate, this is merely used to report progress. - If you're importing a file, using file size and reporting progress - as the number of bytes processed so far makes sense. For other formats - returning the number of records may make more sense. - */ - attribute unsigned long size; + /** + * The preferred name for this address book. Depending upon how the + * user selected import, the caller of the nsIImportAddressBooks interface + * may use this name to create the destination address book or it may + * ignore it. However, this must be provided in all cases as it is + * also displayed in the UI to the user. + */ + attribute AString preferredName; - /* - The preferred name for this address book. Depending upon how the - user selected import, the caller of the nsIImportAddressBooks interface - may use this name to create the destination address book or it may - ignore it. However, this must be provided in all cases as it is - also displayed in the UI to the user. - */ - wstring GetPreferredName(); - void SetPreferredName( [const] in wstring name); - - /* - For address books that want a file descriptor to locate the address book. - For formats that do not, use identifier & ref to refer to the address book - OR implement your own nsIImportABDescriptor that contains additional data - necessary to identify specific address books, - */ - - readonly attribute nsIFileSpec fileSpec; - - /* - Set by the UI to indicate whether or not this address book should be imported. - */ - attribute boolean import; + /** + * For address books that want a file descriptor to locate the address book. + * For formats that do not, use identifier & ref to refer to the address book + * OR implement your own nsIImportABDescriptor that contains additional data + * necessary to identify specific address books, + */ + attribute nsIFile abFile; + + /** + * Set by the UI to indicate whether or not this address book should be imported. + */ + attribute boolean import; }; - - - -%{ C++ - -/* - The default implementation can be obtained from - nsIImportService::CreateNewABDescriptor(); - - You should only be interested in using this class if you implement - the nsIImportAddressBooks interface in which case, just using the service to - create new ones should work fine for you. If not, implement your - own. -*/ - -%} diff --git a/mozilla/mailnews/import/src/nsImportABDescriptor.cpp b/mozilla/mailnews/import/src/nsImportABDescriptor.cpp index 2812a65daf8..cc6fdac9115 100644 --- a/mozilla/mailnews/import/src/nsImportABDescriptor.cpp +++ b/mozilla/mailnews/import/src/nsImportABDescriptor.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -21,6 +21,7 @@ * * Contributor(s): * Pierre Phaneuf + * Mark Banner * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -42,8 +43,6 @@ //////////////////////////////////////////////////////////////////////// - - NS_METHOD nsImportABDescriptor::Create( nsISupports *aOuter, REFNSIID aIID, void **aResult) { if (aOuter) @@ -61,12 +60,7 @@ NS_METHOD nsImportABDescriptor::Create( nsISupports *aOuter, REFNSIID aIID, void NS_IMPL_THREADSAFE_ISUPPORTS1(nsImportABDescriptor, nsIImportABDescriptor) -nsImportABDescriptor::nsImportABDescriptor() -{ - m_ref = 0; - m_id = 0; - m_size = 0; - m_import = PR_TRUE; - m_pFileSpec = nsnull; - NS_NewFileSpec( &m_pFileSpec); +nsImportABDescriptor::nsImportABDescriptor() + : mId(0), mRef(0), mSize(0), mImport(PR_TRUE) +{ } diff --git a/mozilla/mailnews/import/src/nsImportABDescriptor.h b/mozilla/mailnews/import/src/nsImportABDescriptor.h index 5a2d362caa1..afc3771617b 100644 --- a/mozilla/mailnews/import/src/nsImportABDescriptor.h +++ b/mozilla/mailnews/import/src/nsImportABDescriptor.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -20,6 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Mark Banner * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -42,51 +43,92 @@ #include "nsString.h" #include "nsReadableUtils.h" #include "nsIImportABDescriptor.h" -#include "nsIFileSpec.h" +#include "nsIFile.h" //////////////////////////////////////////////////////////////////////// - class nsImportABDescriptor : public nsIImportABDescriptor { public: - NS_DECL_ISUPPORTS + NS_DECL_ISUPPORTS - NS_IMETHOD GetIdentifier( PRUint32 *pIdentifier) { *pIdentifier = m_id; return( NS_OK);} - NS_IMETHOD SetIdentifier( PRUint32 ident) { m_id = ident; return( NS_OK);} - - /* attribute unsigned long ref; */ - NS_IMETHOD GetRef( PRUint32 *pRef) { *pRef = m_ref; return( NS_OK);} - NS_IMETHOD SetRef( PRUint32 ref) { m_ref = ref; return( NS_OK);} + NS_IMETHOD GetIdentifier(PRUint32 *pIdentifier) { + *pIdentifier = mId; + return NS_OK; + } + NS_IMETHOD SetIdentifier(PRUint32 ident) { + mId = ident; + return NS_OK; + } + + NS_IMETHOD GetRef(PRUint32 *pRef) { + *pRef = mRef; + return NS_OK; + } + NS_IMETHOD SetRef(PRUint32 ref) { + mRef = ref; + return NS_OK; + } /* attribute unsigned long size; */ - NS_IMETHOD GetSize( PRUint32 *pSize) { *pSize = m_size; return( NS_OK);} - NS_IMETHOD SetSize( PRUint32 theSize) { m_size = theSize; return( NS_OK);} - - /* attribute wstring displayName; */ - NS_IMETHOD GetPreferredName( PRUnichar **pName) { *pName = ToNewUnicode(m_displayName); return( NS_OK);} - NS_IMETHOD SetPreferredName( const PRUnichar * pName) { m_displayName = pName; return( NS_OK);} - - /* readonly attribute nsIFileSpec fileSpec; */ - NS_IMETHOD GetFileSpec(nsIFileSpec * *aFileSpec) { if (m_pFileSpec) { m_pFileSpec->AddRef(); *aFileSpec = m_pFileSpec; return( NS_OK);} else return( NS_ERROR_FAILURE); } - - /* attribute boolean import; */ - NS_IMETHOD GetImport( PRBool *pImport) { *pImport = m_import; return( NS_OK);} - NS_IMETHOD SetImport( PRBool doImport) { m_import = doImport; return( NS_OK);} + NS_IMETHOD GetSize(PRUint32 *pSize) { + *pSize = mSize; + return NS_OK; + } + NS_IMETHOD SetSize(PRUint32 theSize) { + mSize = theSize; + return NS_OK; + } + /* attribute AString displayName; */ + NS_IMETHOD GetPreferredName(nsAString &aName) { + aName = mDisplayName; + return NS_OK; + } + NS_IMETHOD SetPreferredName(const nsAString &aName) { + mDisplayName = aName; + return NS_OK; + } + + /* readonly attribute nsIFile fileSpec; */ + NS_IMETHOD GetAbFile(nsIFile **aFile) { + if (!mFile) + return NS_ERROR_NULL_POINTER; + + return mFile->Clone(aFile); + } + + NS_IMETHOD SetAbFile(nsIFile *aFile) { + if (!aFile) { + mFile = nsnull; + return NS_OK; + } + + return aFile->Clone(getter_AddRefs(mFile)); + } + + /* attribute boolean import; */ + NS_IMETHOD GetImport(PRBool *pImport) { + *pImport = mImport; + return NS_OK; + } + NS_IMETHOD SetImport(PRBool doImport) { + mImport = doImport; + return NS_OK; + } nsImportABDescriptor(); - virtual ~nsImportABDescriptor() { if (m_pFileSpec) m_pFileSpec->Release();} + virtual ~nsImportABDescriptor() {} + + static NS_METHOD Create( nsISupports *aOuter, REFNSIID aIID, void **aResult); - static NS_METHOD Create( nsISupports *aOuter, REFNSIID aIID, void **aResult); - private: - PRUint32 m_id; // used by creator of the structure - PRUint32 m_ref; // depth in the heirarchy - nsString m_displayName; // name of this mailbox - nsIFileSpec * m_pFileSpec; // source file (if applicable) - PRUint32 m_size; // size - PRBool m_import; // import it or not? + PRUint32 mId; // used by creator of the structure + PRUint32 mRef; // depth in the heirarchy + nsString mDisplayName; // name of this mailbox + nsCOMPtr mFile; // source file (if applicable) + PRUint32 mSize; // size + PRBool mImport; // import it or not? }; diff --git a/mozilla/mailnews/import/src/nsImportAddressBooks.cpp b/mozilla/mailnews/import/src/nsImportAddressBooks.cpp index 9453b8584b0..aa3cb9374db 100644 --- a/mozilla/mailnews/import/src/nsImportAddressBooks.cpp +++ b/mozilla/mailnews/import/src/nsImportAddressBooks.cpp @@ -115,7 +115,8 @@ private: public: static void SetLogs( nsString& success, nsString& error, nsISupportsString *pSuccess, nsISupportsString *pError); - static void ReportError(PRUnichar *pName, nsString *pStream, nsIStringBundle *aBundle); + static void ReportError(const PRUnichar *pName, nsString *pStream, + nsIStringBundle *aBundle); private: nsIImportAddressBooks * m_pInterface; @@ -862,7 +863,9 @@ nsIAddrDatabase *GetAddressBook( const PRUnichar *name, PRBool makeNew) return( pDatabase); } -void nsImportGenericAddressBooks::ReportError( PRUnichar *pName, nsString *pStream, nsIStringBundle* aBundle) +void nsImportGenericAddressBooks::ReportError(const PRUnichar *pName, + nsString *pStream, + nsIStringBundle* aBundle) { if (!pStream) return; @@ -911,13 +914,13 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff) rv = book->GetSize( &size); if (size && import) { - PRUnichar *pName; - book->GetPreferredName( &pName); + nsXPIDLString name; + book->GetPreferredName(name); if (destDB) { pDestDB = destDB; } else { - pDestDB = GetAddressBook( pName, PR_TRUE); + pDestDB = GetAddressBook(name, PR_TRUE); } nsCOMPtr proxyAddrDatabase; @@ -967,11 +970,9 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff) } } else { - nsImportGenericAddressBooks::ReportError(pName, &error, pBundle); + nsImportGenericAddressBooks::ReportError(name, &error, pBundle); } - nsCRT::free( pName); - pData->currentSize = 0; pData->currentTotal += size; diff --git a/mozilla/mailnews/import/text/src/nsTextImport.cpp b/mozilla/mailnews/import/text/src/nsTextImport.cpp index f25b2183e31..dc3053ed95a 100644 --- a/mozilla/mailnews/import/text/src/nsTextImport.cpp +++ b/mozilla/mailnews/import/text/src/nsTextImport.cpp @@ -392,14 +392,9 @@ NS_IMETHODIMP ImportAddressImpl::FindAddressBooks(nsIFileSpec *pLoc, nsISupports if (NS_SUCCEEDED( rv)) { PRUint32 sz = 0; pLoc->GetFileSize( &sz); - desc->SetPreferredName( name.get()); + desc->SetPreferredName(name); desc->SetSize( sz); - nsIFileSpec *pSpec = nsnull; - desc->GetFileSpec( &pSpec); - if (pSpec) { - pSpec->FromFileSpec( pLoc); - NS_RELEASE( pSpec); - } + desc->SetAbFile(m_fileLoc); rv = desc->QueryInterface( kISupportsIID, (void **) &pInterface); array->AppendElement( pInterface); pInterface->Release(); @@ -483,13 +478,9 @@ NS_IMETHODIMP ImportAddressImpl::ImportAddressBook( nsIImportABDescriptor *pSour ClearSampleFile(); - PRBool addrAbort = PR_FALSE; - nsString name; - PRUnichar * pName; - if (NS_SUCCEEDED( pSource->GetPreferredName( &pName))) { - name = pName; - nsCRT::free( pName); - } + PRBool addrAbort = PR_FALSE; + nsString name; + pSource->GetPreferredName(name); PRUint32 addressSize = 0; pSource->GetSize( &addressSize); @@ -497,31 +488,18 @@ NS_IMETHODIMP ImportAddressImpl::ImportAddressBook( nsIImportABDescriptor *pSour IMPORT_LOG0( "Address book size is 0, skipping import.\n"); ReportSuccess( name, &success); SetLogs( success, error, pErrorLog, pSuccessLog); - return( NS_OK); + return NS_OK; } - - nsIFileSpec * inFileSpec; - if (NS_FAILED( pSource->GetFileSpec( &inFileSpec))) { + nsCOMPtr inFile; + if (NS_FAILED(pSource->GetAbFile(getter_AddRefs(inFile)))) { ReportError( TEXTIMPORT_ADDRESS_BADSOURCEFILE, name, &error); SetLogs( success, error, pErrorLog, pSuccessLog); - return( NS_ERROR_FAILURE); - } - - nsXPIDLCString pPath; - inFileSpec->GetNativePath(getter_Copies(pPath)); - IMPORT_LOG1( "Importing address book: %s\n", pPath.get()); - - inFileSpec->Release(); - - nsresult rv = NS_OK; - - nsCOMPtr inFile; - rv = NS_NewNativeLocalFile(pPath, PR_TRUE, getter_AddRefs(inFile)); - NS_ENSURE_SUCCESS(rv, rv); + return NS_ERROR_FAILURE; + } PRBool isLDIF = PR_FALSE; - + nsresult rv; nsCOMPtr ldifService = do_GetService(NS_ABLDIFSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) {