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
This commit is contained in:
@@ -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<nsIFile> 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();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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<nsILocalFile> fileLoc;
|
||||
rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(fileLoc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIImportABDescriptor> 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();
|
||||
|
||||
@@ -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<nsILocalFile> 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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <bugzilla@standard8.demon.co.uk>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
%}
|
||||
|
||||
@@ -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 <pp@ludusdesign.com>
|
||||
* Mark Banner <bugzilla@standard8.demon.co.uk>
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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 <bugzilla@standard8.demon.co.uk>
|
||||
*
|
||||
* 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<nsIFile> mFile; // source file (if applicable)
|
||||
PRUint32 mSize; // size
|
||||
PRBool mImport; // import it or not?
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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<nsIAddrDatabase> 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;
|
||||
|
||||
|
||||
@@ -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<nsIFile> 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<nsILocalFile> 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<nsIAbLDIFService> ldifService = do_GetService(NS_ABLDIFSERVICE_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
Reference in New Issue
Block a user