From 85df3a5c782cf876f2b0c135e04173855d7bb8fc Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 28 Nov 2013 07:12:07 +0900 Subject: [PATCH] Bug 945045 - Remove nsISupportsArray in mailnews/import. r=Standard8 CLOSED TREE --- .../applemail/src/nsAppleMailImport.cpp | 18 +++---- .../import/applemail/src/nsAppleMailImport.h | 8 +-- mailnews/import/eudora/src/nsEudoraAddress.h | 4 +- .../import/eudora/src/nsEudoraCompose.cpp | 2 +- mailnews/import/eudora/src/nsEudoraEditor.cpp | 9 ++-- mailnews/import/eudora/src/nsEudoraEditor.h | 5 +- .../import/eudora/src/nsEudoraFilters.cpp | 18 +++---- mailnews/import/eudora/src/nsEudoraFilters.h | 5 +- mailnews/import/eudora/src/nsEudoraImport.cpp | 43 +++++++++++----- mailnews/import/eudora/src/nsEudoraMac.cpp | 37 +++++--------- mailnews/import/eudora/src/nsEudoraMac.h | 14 ++--- mailnews/import/eudora/src/nsEudoraMailbox.h | 4 +- mailnews/import/eudora/src/nsEudoraWin32.cpp | 51 +++++++------------ mailnews/import/eudora/src/nsEudoraWin32.h | 20 ++++---- mailnews/import/oexpress/nsOEImport.cpp | 17 ++++--- mailnews/import/oexpress/nsOEScanBoxes.cpp | 16 +++--- mailnews/import/oexpress/nsOEScanBoxes.h | 9 ++-- .../import/outlook/src/nsOutlookCompose.cpp | 7 +-- .../import/outlook/src/nsOutlookImport.cpp | 10 ++-- mailnews/import/outlook/src/nsOutlookMail.cpp | 23 +++++---- mailnews/import/outlook/src/nsOutlookMail.h | 6 +-- .../import/public/nsIImportAddressBooks.idl | 8 +-- mailnews/import/public/nsIImportGeneric.idl | 6 +-- mailnews/import/public/nsIImportMail.idl | 8 +-- mailnews/import/public/nsIImportService.idl | 6 +-- mailnews/import/src/nsImportAddressBooks.cpp | 39 +++++++------- mailnews/import/src/nsImportMail.cpp | 15 +++--- mailnews/import/src/nsImportService.cpp | 24 +++++++-- .../test/unit/resources/TestMailImporter.js | 4 +- mailnews/import/text/src/nsTextImport.cpp | 20 ++++---- mailnews/import/vcard/src/nsVCardImport.cpp | 18 +++---- mailnews/import/winlivemail/nsWMImport.cpp | 6 +-- 32 files changed, 248 insertions(+), 232 deletions(-) diff --git a/mailnews/import/applemail/src/nsAppleMailImport.cpp b/mailnews/import/applemail/src/nsAppleMailImport.cpp index 21262ac891..a101274e8c 100644 --- a/mailnews/import/applemail/src/nsAppleMailImport.cpp +++ b/mailnews/import/applemail/src/nsAppleMailImport.cpp @@ -19,6 +19,7 @@ #include "nsIMsgFolder.h" #include "nsIMsgHdr.h" #include "nsIMsgPluggableStore.h" +#include "nsIMutableArray.h" #include "nsNetUtil.h" #include "nsMsgUtils.h" #include "mozilla/Services.h" @@ -180,7 +181,7 @@ NS_IMETHODIMP nsAppleMailImportMail::GetDefaultLocation(nsIFile **aLocation, boo // this is the method that initiates all searching for mailboxes. // it will assume that it has a directory like ~/Library/Mail/ -NS_IMETHODIMP nsAppleMailImportMail::FindMailboxes(nsIFile *aMailboxFile, nsISupportsArray **aResult) +NS_IMETHODIMP nsAppleMailImportMail::FindMailboxes(nsIFile *aMailboxFile, nsIArray **aResult) { NS_ENSURE_ARG_POINTER(aMailboxFile); NS_ENSURE_ARG_POINTER(aResult); @@ -195,8 +196,7 @@ NS_IMETHODIMP nsAppleMailImportMail::FindMailboxes(nsIFile *aMailboxFile, nsISup nsCOMPtr importService(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr resultsArray; - NS_NewISupportsArray(getter_AddRefs(resultsArray)); + nsCOMPtr resultsArray(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); if (!resultsArray) return NS_ERROR_OUT_OF_MEMORY; @@ -224,14 +224,14 @@ NS_IMETHODIMP nsAppleMailImportMail::FindMailboxes(nsIFile *aMailboxFile, nsISup } if (NS_SUCCEEDED(rv) && resultsArray) - resultsArray.swap(*aResult); + resultsArray.forget(aResult); return rv; } // operates on the Mail/ directory root, trying to find accounts (which are folders named something like "POP-hwaara@gmail.com") // and add their .mbox dirs -void nsAppleMailImportMail::FindAccountMailDirs(nsIFile *aRoot, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService) +void nsAppleMailImportMail::FindAccountMailDirs(nsIFile *aRoot, nsIMutableArray *aMailboxDescs, nsIImportService *aImportService) { nsCOMPtr directoryEnumerator; nsresult rv = aRoot->GetDirectoryEntries(getter_AddRefs(directoryEnumerator)); @@ -293,7 +293,7 @@ void nsAppleMailImportMail::FindAccountMailDirs(nsIFile *aRoot, nsISupportsArray mailboxDescFile->InitWithFile(currentEntry); // add this mailbox descriptor to the list - aMailboxDescs->AppendElement(desc); + aMailboxDescs->AppendElement(desc, false); // now add all the children mailboxes mCurDepth++; @@ -305,7 +305,7 @@ void nsAppleMailImportMail::FindAccountMailDirs(nsIFile *aRoot, nsISupportsArray } // adds the specified file as a mailboxdescriptor to the array -nsresult nsAppleMailImportMail::AddMboxDir(nsIFile *aFolder, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService) +nsresult nsAppleMailImportMail::AddMboxDir(nsIFile *aFolder, nsIMutableArray *aMailboxDescs, nsIImportService *aImportService) { nsAutoString folderName; aFolder->GetLeafName(folderName); @@ -370,7 +370,7 @@ nsresult nsAppleMailImportMail::AddMboxDir(nsIFile *aFolder, nsISupportsArray *a mailboxDescFile->InitWithFile(aFolder); // add this mailbox descriptor to the list - aMailboxDescs->AppendElement(desc); + aMailboxDescs->AppendElement(desc, false); } return NS_OK; @@ -386,7 +386,7 @@ nsresult nsAppleMailImportMail::AddMboxDir(nsIFile *aFolder, nsISupportsArray *a // MyChildMailbox.mbox/ // MyOtherChildMailbox.mbox/ // -nsresult nsAppleMailImportMail::FindMboxDirs(nsIFile *aFolder, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService) +nsresult nsAppleMailImportMail::FindMboxDirs(nsIFile *aFolder, nsIMutableArray *aMailboxDescs, nsIImportService *aImportService) { NS_ENSURE_ARG_POINTER(aFolder); NS_ENSURE_ARG_POINTER(aMailboxDescs); diff --git a/mailnews/import/applemail/src/nsAppleMailImport.h b/mailnews/import/applemail/src/nsAppleMailImport.h index c334e40c75..deb2cf434f 100644 --- a/mailnews/import/applemail/src/nsAppleMailImport.h +++ b/mailnews/import/applemail/src/nsAppleMailImport.h @@ -11,7 +11,6 @@ #include "nsCOMPtr.h" #include "nsIStringBundle.h" #include "nsIImportMail.h" -#include "nsISupportsArray.h" // logging facilities extern PRLogModuleInfo *APPLEMAILLOGMODULE; @@ -32,6 +31,7 @@ extern PRLogModuleInfo *APPLEMAILLOGMODULE; #define kAppleMailSupportsString "mail" class nsIImportService; +class nsIMutableArray; class nsAppleMailImportModule : public nsIImportModule { @@ -62,9 +62,9 @@ class nsAppleMailImportMail : public nsIImportMail private: - void FindAccountMailDirs(nsIFile *aRoot, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService); - nsresult FindMboxDirs(nsIFile *aFolder, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService); - nsresult AddMboxDir(nsIFile *aFolder, nsISupportsArray *aMailboxDescs, nsIImportService *aImportService); + void FindAccountMailDirs(nsIFile *aRoot, nsIMutableArray *aMailboxDescs, nsIImportService *aImportService); + nsresult FindMboxDirs(nsIFile *aFolder, nsIMutableArray *aMailboxDescs, nsIImportService *aImportService); + nsresult AddMboxDir(nsIFile *aFolder, nsIMutableArray *aMailboxDescs, nsIImportService *aImportService); // aInfoString is the format to a "foo %s" string. It may be NULL if the error string needs no such format. void ReportStatus(int32_t aErrorNum, nsString &aName, nsAString &aStream); diff --git a/mailnews/import/eudora/src/nsEudoraAddress.h b/mailnews/import/eudora/src/nsEudoraAddress.h index 19838384ae..0df1d9df6a 100644 --- a/mailnews/import/eudora/src/nsEudoraAddress.h +++ b/mailnews/import/eudora/src/nsEudoraAddress.h @@ -11,7 +11,6 @@ #include "nsStringGlue.h" #include "nsVoidArray.h" #include "nsIFile.h" -#include "nsISupportsArray.h" #include "nsCOMPtr.h" #include "nsIImportService.h" @@ -20,6 +19,7 @@ class nsIAddrDatabase; class CAliasEntry; class CAliasData; class nsIStringBundle; +class nsIMutableArray; ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// @@ -34,7 +34,7 @@ public: // retrieve the mail folder virtual bool FindAddressFolder(nsIFile **pFolder) { return false;} // get the list of mailboxes - virtual nsresult FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray) { return NS_ERROR_FAILURE;} + virtual nsresult FindAddressBooks(nsIFile *pRoot, nsIMutableArray *pArray) { return NS_ERROR_FAILURE;} // Non-platform specific common stuff // import a mailbox diff --git a/mailnews/import/eudora/src/nsEudoraCompose.cpp b/mailnews/import/eudora/src/nsEudoraCompose.cpp index f72641c31d..234ef82f77 100644 --- a/mailnews/import/eudora/src/nsEudoraCompose.cpp +++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp @@ -612,7 +612,7 @@ nsresult nsEudoraCompose::SendTheMessage(nsIFile *pMailImportLocation, nsIFile * nsCOMPtr pAttach; GetLocalAttachments(getter_AddRefs(pAttach)); nsEudoraEditor eudoraEditor(m_pBody, pMailImportLocation); - nsCOMPtr embeddedObjects; + nsCOMPtr embeddedObjects; if (eudoraEditor.HasEmbeddedContent()) eudoraEditor.GetEmbeddedObjects(getter_AddRefs(embeddedObjects)); diff --git a/mailnews/import/eudora/src/nsEudoraEditor.cpp b/mailnews/import/eudora/src/nsEudoraEditor.cpp index 2d3e54691d..e317479162 100644 --- a/mailnews/import/eudora/src/nsEudoraEditor.cpp +++ b/mailnews/import/eudora/src/nsEudoraEditor.cpp @@ -5,7 +5,7 @@ #include "nsEudoraEditor.h" -#include "nsISupportsArray.h" +#include "nsIArray.h" #include "nsComponentManagerUtils.h" #include "nsStringGlue.h" #include "nsMsgUtils.h" @@ -57,7 +57,7 @@ nsEudoraEditor::~nsEudoraEditor() { } -nsresult nsEudoraEditor::GetEmbeddedObjects(nsISupportsArray ** aNodeList) +nsresult nsEudoraEditor::GetEmbeddedObjects(nsIArray ** aNodeList) { NS_ENSURE_ARG_POINTER(aNodeList); @@ -69,7 +69,8 @@ nsresult nsEudoraEditor::GetEmbeddedObjects(nsISupportsArray ** aNodeList) } // Create array in m_EmbeddedObjectList - nsresult rv = NS_NewISupportsArray(getter_AddRefs(m_EmbeddedObjectList)); + nsresult rv; + m_EmbeddedObjectList = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); // Return m_EmbeddedObjectList in aNodeList and increment ref count - caller @@ -173,7 +174,7 @@ nsresult nsEudoraEditor::GetEmbeddedObjects(nsISupportsArray ** aNodeList) new nsImportEmbeddedImageData(embeddedFileURI, NS_LossyConvertUTF16toASCII(cid)); // Append the embedded image node to the list - m_EmbeddedObjectList->AppendElement(imageData); + m_EmbeddedObjectList->AppendElement(imageData, false); int32_t endEmbeddedContentLine = m_body.Find("\r\n", true, startEmbeddedContentLine+1); if (endEmbeddedContentLine != kNotFound) diff --git a/mailnews/import/eudora/src/nsEudoraEditor.h b/mailnews/import/eudora/src/nsEudoraEditor.h index f5f8b393b6..e9c98effc4 100644 --- a/mailnews/import/eudora/src/nsEudoraEditor.h +++ b/mailnews/import/eudora/src/nsEudoraEditor.h @@ -9,6 +9,7 @@ #include "nsCOMPtr.h" #include "nsStringGlue.h" #include "nsIFile.h" +#include "nsIMutableArray.h" class nsEudoraEditor @@ -19,11 +20,11 @@ class nsEudoraEditor bool GetEmbeddedImageCID(uint32_t aCIDHash, const nsAString & aOldRef, nsString &aCID); bool HasEmbeddedContent(); - nsresult GetEmbeddedObjects(nsISupportsArray ** aNodeList); + nsresult GetEmbeddedObjects(nsIArray ** aNodeList); nsresult GetBody(nsAString & _retval) {_retval = m_body; return NS_OK;} protected: NS_ConvertASCIItoUTF16 m_body; nsCOMPtr m_pMailImportLocation; - nsCOMPtr m_EmbeddedObjectList; // Initialized when GetEmbeddedObjects is called + nsCOMPtr m_EmbeddedObjectList; // Initialized when GetEmbeddedObjects is called }; diff --git a/mailnews/import/eudora/src/nsEudoraFilters.cpp b/mailnews/import/eudora/src/nsEudoraFilters.cpp index 8c6f82eeed..b7d1e11617 100644 --- a/mailnews/import/eudora/src/nsEudoraFilters.cpp +++ b/mailnews/import/eudora/src/nsEudoraFilters.cpp @@ -391,11 +391,11 @@ nsresult nsEudoraFilters::LoadServers() if (m_pServerArray) rv = m_pServerArray->Clear(); else - rv = NS_NewISupportsArray(getter_AddRefs(m_pServerArray)); + m_pServerArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); if (!m_pFilterArray) - rv = NS_NewISupportsArray(getter_AddRefs(m_pFilterArray)); + m_pFilterArray = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr accountMgr = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); @@ -431,7 +431,7 @@ nsresult nsEudoraFilters::LoadServers() rv = server->GetFilterList(nullptr, getter_AddRefs(filterList)); NS_ENSURE_SUCCESS(rv, rv); - m_pServerArray->AppendElement(server); + m_pServerArray->AppendElement(server, false); } } } @@ -446,7 +446,7 @@ nsresult nsEudoraFilters::SaveFilters() nsresult rv; uint32_t numServers; - rv = m_pServerArray->Count(&numServers); + rv = m_pServerArray->GetLength(&numServers); NS_ENSURE_SUCCESS(rv, rv); for (uint32_t serverIndex = 0; serverIndex < numServers; serverIndex++) { @@ -474,7 +474,7 @@ nsresult nsEudoraFilters::CreateNewFilter(const char* pName) nsAutoString unicodeName; NS_CopyNativeToUnicode(nsCString(pName), unicodeName); uint32_t numServers; - rv = m_pServerArray->Count(&numServers); + rv = m_pServerArray->GetLength(&numServers); NS_ENSURE_SUCCESS(rv, rv); for (uint32_t serverIndex = 0; serverIndex < numServers; serverIndex++) { @@ -499,7 +499,7 @@ nsresult nsEudoraFilters::CreateNewFilter(const char* pName) rv = filterList->InsertFilterAt(count, newFilter); NS_ENSURE_SUCCESS(rv, rv); - m_pFilterArray->AppendElement(newFilter); + m_pFilterArray->AppendElement(newFilter, false); } m_isAnd = false; @@ -539,7 +539,7 @@ nsresult nsEudoraFilters::EnableFilter(bool enable) nsresult rv; uint32_t numFilters; - rv = m_pFilterArray->Count(&numFilters); + rv = m_pFilterArray->GetLength(&numFilters); NS_ENSURE_SUCCESS(rv, rv); for (uint32_t filterIndex = 0; filterIndex < numFilters; filterIndex++) { @@ -744,7 +744,7 @@ nsresult nsEudoraFilters::AddTerm(const char* pHeader, const char* pVerb, const } uint32_t numFilters; - rv = m_pFilterArray->Count(&numFilters); + rv = m_pFilterArray->GetLength(&numFilters); NS_ENSURE_SUCCESS(rv, rv); for (uint32_t filterIndex = 0; filterIndex < numFilters; filterIndex++) { @@ -793,7 +793,7 @@ nsresult nsEudoraFilters::AddAction(nsMsgRuleActionType actionType, int32_t junk nsresult rv; uint32_t numFilters; - rv = m_pFilterArray->Count(&numFilters); + rv = m_pFilterArray->GetLength(&numFilters); NS_ENSURE_SUCCESS(rv, rv); for (uint32_t filterIndex = 0; filterIndex < numFilters; filterIndex++) { diff --git a/mailnews/import/eudora/src/nsEudoraFilters.h b/mailnews/import/eudora/src/nsEudoraFilters.h index 7ba5299486..41461f9edd 100644 --- a/mailnews/import/eudora/src/nsEudoraFilters.h +++ b/mailnews/import/eudora/src/nsEudoraFilters.h @@ -8,6 +8,7 @@ #include "nsIImportFilters.h" #include "nsIFile.h" +#include "nsIMutableArray.h" #include "nsCOMPtr.h" #include "nsMsgFilterCore.h" @@ -28,8 +29,8 @@ public: private: nsCOMPtr m_pLocation; - nsCOMPtr m_pServerArray; - nsCOMPtr m_pFilterArray; + nsCOMPtr m_pServerArray; + nsCOMPtr m_pFilterArray; nsCOMPtr m_pMailboxesRoot; nsString m_errorLog; diff --git a/mailnews/import/eudora/src/nsEudoraImport.cpp b/mailnews/import/eudora/src/nsEudoraImport.cpp index 0e10a3918c..dc32a637d8 100644 --- a/mailnews/import/eudora/src/nsEudoraImport.cpp +++ b/mailnews/import/eudora/src/nsEudoraImport.cpp @@ -23,6 +23,7 @@ #include "nsComponentManagerUtils.h" #include "nsEudoraImport.h" #include "nsIMemory.h" +#include "nsIMutableArray.h" #include "nsIImportService.h" #include "nsIImportMail.h" #include "nsIImportMailboxDescriptor.h" @@ -75,8 +76,8 @@ public: /* void GetDefaultLocation (out nsIFile location, out boolean found, out boolean userVerify); */ NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify); - /* nsISupportsArray FindMailboxes (in nsIFile location); */ - NS_IMETHOD FindMailboxes(nsIFile *location, nsISupportsArray **_retval); + /* nsIArray FindMailboxes (in nsIFile location); */ + NS_IMETHOD FindMailboxes(nsIFile *location, nsIArray **_retval); NS_IMETHOD ImportMailbox(nsIImportMailboxDescriptor *source, nsIMsgFolder *dstFolder, @@ -129,7 +130,7 @@ public: NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify); - NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval); + NS_IMETHOD FindAddressBooks(nsIFile *location, nsIArray **_retval); NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap) { return NS_ERROR_FAILURE; } @@ -423,7 +424,7 @@ NS_IMETHODIMP ImportEudoraMailImpl::GetDefaultLocation(nsIFile **ppLoc, bool *fo } -NS_IMETHODIMP ImportEudoraMailImpl::FindMailboxes(nsIFile *pLoc, nsISupportsArray **ppArray) +NS_IMETHODIMP ImportEudoraMailImpl::FindMailboxes(nsIFile *pLoc, nsIArray **ppArray) { NS_PRECONDITION(pLoc != nullptr, "null ptr"); NS_PRECONDITION(ppArray != nullptr, "null ptr"); @@ -435,11 +436,19 @@ NS_IMETHODIMP ImportEudoraMailImpl::FindMailboxes(nsIFile *pLoc, nsISupportsArra if (NS_FAILED(rv) || !exists) return NS_ERROR_FAILURE; - rv = m_eudora.FindMailboxes(pLoc, ppArray); - if (NS_FAILED(rv) && *ppArray) - NS_RELEASE(*ppArray); + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); + if (NS_FAILED(rv)) + { + IMPORT_LOG0("FAILED to allocate the nsIMutableArray\n"); + return rv; + } + rv = m_eudora.FindMailboxes(pLoc, array); + if (NS_FAILED(rv)) + return rv; - return rv; + array.forget(ppArray); + + return NS_OK; } void ImportEudoraMailImpl::AddLinebreak(nsString *pStream) @@ -632,7 +641,7 @@ NS_IMETHODIMP ImportEudoraAddressImpl::GetDefaultLocation(nsIFile **ppLoc, bool -NS_IMETHODIMP ImportEudoraAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISupportsArray **ppArray) +NS_IMETHODIMP ImportEudoraAddressImpl::FindAddressBooks(nsIFile *pLoc, nsIArray **ppArray) { NS_PRECONDITION(pLoc != nullptr, "null ptr"); NS_PRECONDITION(ppArray != nullptr, "null ptr"); @@ -644,11 +653,19 @@ NS_IMETHODIMP ImportEudoraAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISuppor if (NS_FAILED(rv) || !exists) return NS_ERROR_FAILURE; - rv = m_eudora.FindAddressBooks(pLoc, ppArray); - if (NS_FAILED(rv) && *ppArray) - NS_RELEASE(*ppArray); + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); + if (NS_FAILED(rv)) + { + IMPORT_LOG0("FAILED to allocate the nsIMutableArray\n"); + return rv; + } + rv = m_eudora.FindAddressBooks(pLoc, array); + if (NS_FAILED(rv)) + return rv; - return rv; + array.forget(ppArray); + + return NS_OK; } diff --git a/mailnews/import/eudora/src/nsEudoraMac.cpp b/mailnews/import/eudora/src/nsEudoraMac.cpp index fb7ff27143..4a895ce5da 100644 --- a/mailnews/import/eudora/src/nsEudoraMac.cpp +++ b/mailnews/import/eudora/src/nsEudoraMac.cpp @@ -9,6 +9,7 @@ #include "nsIServiceManager.h" #include "nsIMsgAccountManager.h" #include "nsIMsgAccount.h" +#include "nsIMutableArray.h" #include "nsMsgBaseCID.h" #include "nsMsgCompCID.h" #include "nsISmtpService.h" @@ -212,15 +213,9 @@ bool nsEudoraMac::VerifyEudoraLocation(nsIFile **pFolder, bool findIni) } -nsresult nsEudoraMac::FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray) +nsresult nsEudoraMac::FindMailboxes(nsIFile *pRoot, nsIMutableArray *pArray) { - nsresult rv = NS_NewISupportsArray(ppArray); - if (NS_FAILED(rv)) - { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); - return rv; - } - + nsresult rv; nsCOMPtr impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; @@ -228,11 +223,11 @@ nsresult nsEudoraMac::FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray) m_depth = 0; m_mailImportLocation = do_QueryInterface(pRoot); - return ScanMailDir(pRoot, *ppArray, impSvc); + return ScanMailDir(pRoot, pArray, impSvc); } -nsresult nsEudoraMac::ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraMac::ScanMailDir(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport) { // On Windows, we look for a descmap file but on Mac we just iterate @@ -247,7 +242,7 @@ nsresult nsEudoraMac::ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, ns return rv; } -nsresult nsEudoraMac::IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraMac::IterateMailDir(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport) { bool hasMore; nsCOMPtr directoryEnumerator; @@ -312,7 +307,7 @@ nsresult nsEudoraMac::IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArray, } -nsresult nsEudoraMac::FoundMailbox(nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraMac::FoundMailbox(nsIFile *mailFile, const char *pName, nsIMutableArray *pArray, nsIImportService *pImport) { nsAutoString displayName; nsCOMPtr desc; @@ -344,7 +339,7 @@ nsresult nsEudoraMac::FoundMailbox(nsIFile *mailFile, const char *pName, nsISupp pLocalFile->InitWithFile(mailFile); } rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - pArray->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); } @@ -352,7 +347,7 @@ nsresult nsEudoraMac::FoundMailbox(nsIFile *mailFile, const char *pName, nsISupp } -nsresult nsEudoraMac::FoundMailFolder(nsIFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraMac::FoundMailFolder(nsIFile *mailFolder, const char *pName, nsIMutableArray *pArray, nsIImportService *pImport) { nsAutoString displayName; nsCOMPtr desc; @@ -382,7 +377,7 @@ nsresult nsEudoraMac::FoundMailFolder(nsIFile *mailFolder, const char *pName, ns if (pFile) pFile->InitWithFile(mailFolder); rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - pArray->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); } @@ -1102,7 +1097,7 @@ bool nsEudoraMac::FindAddressFolder(nsIFile **pFolder) return FindEudoraLocation(pFolder); } -nsresult nsEudoraMac::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray) +nsresult nsEudoraMac::FindAddressBooks(nsIFile *pRoot, nsIMutableArray *pArray) { // Look for the nicknames file in this folder and then // additional files in the Nicknames folder @@ -1113,12 +1108,6 @@ nsresult nsEudoraMac::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArra rv = file->InitWithFile(pRoot); if (NS_FAILED(rv)) return rv; - rv = NS_NewISupportsArray(ppArray); - if (NS_FAILED(rv)) - { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); - return rv; - } nsCOMPtr impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) @@ -1153,7 +1142,7 @@ nsresult nsEudoraMac::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArra // SetAbFile will clone the file we pass to it. desc->SetAbFile(file); rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - (*ppArray)->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); } if (NS_FAILED(rv)) @@ -1227,7 +1216,7 @@ nsresult nsEudoraMac::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArra // SetAbFile will clone the file we pass to it. desc->SetAbFile(entry); rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - (*ppArray)->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); } if (NS_FAILED(rv)) diff --git a/mailnews/import/eudora/src/nsEudoraMac.h b/mailnews/import/eudora/src/nsEudoraMac.h index 0cda0fe117..a83803009e 100644 --- a/mailnews/import/eudora/src/nsEudoraMac.h +++ b/mailnews/import/eudora/src/nsEudoraMac.h @@ -11,7 +11,6 @@ #include "nscore.h" #include "nsStringGlue.h" #include "nsIFile.h" -#include "nsISupportsArray.h" #include "nsEudoraMailbox.h" #include "nsEudoraAddress.h" @@ -20,6 +19,7 @@ class nsIImportService; class nsIMsgAccountManager; class nsIMsgAccount; +class nsIMutableArray; class nsEudoraMac : public nsEudoraMailbox, public nsEudoraAddress { @@ -31,7 +31,7 @@ public: virtual bool FindMailFolder(nsIFile **pFolder) MOZ_OVERRIDE; // get the list of mailboxes virtual nsresult FindMailboxes(nsIFile *pRoot, - nsISupportsArray **ppArray) MOZ_OVERRIDE; + nsIMutableArray *pArray) MOZ_OVERRIDE; // get a TOC file from a mailbox file virtual nsresult FindTOCFile(nsIFile *pMailFile, nsIFile **pTOCFile, @@ -46,7 +46,7 @@ public: virtual bool FindAddressFolder(nsIFile **pFolder) MOZ_OVERRIDE; // get the list of mailboxes virtual nsresult FindAddressBooks(nsIFile *pRoot, - nsISupportsArray **ppArray) MOZ_OVERRIDE; + nsIMutableArray *pArray) MOZ_OVERRIDE; // import settings static bool ImportSettings(nsIFile *pIniFile, @@ -66,18 +66,18 @@ private: nsresult ScanMailDir(nsIFile *pFolder, - nsISupportsArray *pArray, + nsIMutableArray *pArray, nsIImportService *pImport); nsresult IterateMailDir(nsIFile *pFolder, - nsISupportsArray *pArray, + nsIMutableArray *pArray, nsIImportService *pImport); nsresult FoundMailFolder(nsIFile *mailFolder, const char *pName, - nsISupportsArray *pArray, + nsIMutableArray *pArray, nsIImportService *pImport); nsresult FoundMailbox(nsIFile *mailFile, const char *pName, - nsISupportsArray *pArray, + nsIMutableArray *pArray, nsIImportService *pImport); bool IsValidMailFolderName(nsCString& name); diff --git a/mailnews/import/eudora/src/nsEudoraMailbox.h b/mailnews/import/eudora/src/nsEudoraMailbox.h index 7796adf8d1..0a8a35bed4 100644 --- a/mailnews/import/eudora/src/nsEudoraMailbox.h +++ b/mailnews/import/eudora/src/nsEudoraMailbox.h @@ -11,10 +11,10 @@ #include "nsStringGlue.h" #include "nsVoidArray.h" #include "nsIFile.h" -#include "nsISupportsArray.h" #include "nsEudoraCompose.h" class nsIOutputStream; +class nsIMutableArray; ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// @@ -141,7 +141,7 @@ public: // retrieve the mail folder virtual bool FindMailFolder(nsIFile **pFolder) { return false;} // get the list of mailboxes - virtual nsresult FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray) { return NS_ERROR_FAILURE;} + virtual nsresult FindMailboxes(nsIFile *pRoot, nsIMutableArray *pArray) { return NS_ERROR_FAILURE;} // get the toc file corresponding to this mailbox virtual nsresult FindTOCFile(nsIFile *pMailFile, nsIFile **pTOCFile, bool *pDeleteToc) { return NS_ERROR_FAILURE;} // interpret the attachment line and return the attached file diff --git a/mailnews/import/eudora/src/nsEudoraWin32.cpp b/mailnews/import/eudora/src/nsEudoraWin32.cpp index 11ed636d27..e6172927d1 100644 --- a/mailnews/import/eudora/src/nsEudoraWin32.cpp +++ b/mailnews/import/eudora/src/nsEudoraWin32.cpp @@ -10,6 +10,7 @@ #include "nsIServiceManager.h" #include "nsIMsgAccountManager.h" #include "nsIMsgAccount.h" +#include "nsIMutableArray.h" #include "nsIPop3IncomingServer.h" #include "nsMsgBaseCID.h" #include "nsMsgCompCID.h" @@ -150,26 +151,20 @@ bool nsEudoraWin32::FindEudoraLocation(nsIFile **pFolder, bool findIni) return result; } -nsresult nsEudoraWin32::FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray) +nsresult nsEudoraWin32::FindMailboxes(nsIFile *pRoot, nsIMutableArray *pArray) { - nsresult rv = NS_NewISupportsArray(ppArray); - if (NS_FAILED(rv)) - { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); - return rv; - } - + nsresult rv; nsCOMPtr impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; m_depth = 0; m_mailImportLocation = do_QueryInterface(pRoot); - return ScanMailDir(pRoot, *ppArray, impSvc); + return ScanMailDir(pRoot, pArray, impSvc); } -nsresult nsEudoraWin32::ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraWin32::ScanMailDir(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport) { bool exists = false; bool isFile = false; @@ -231,7 +226,7 @@ nsresult nsEudoraWin32::ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, return rv; } -nsresult nsEudoraWin32::IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraWin32::IterateMailDir(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport) { bool hasMore; nsCOMPtr directoryEnumerator; @@ -298,7 +293,7 @@ nsresult nsEudoraWin32::IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArra return rv; } -nsresult nsEudoraWin32::ScanDescmap(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, int32_t len) +nsresult nsEudoraWin32::ScanDescmap(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport, const char *pData, int32_t len) { // use this to find stuff in the directory. @@ -425,7 +420,7 @@ nsresult nsEudoraWin32::ScanDescmap(nsIFile *pFolder, nsISupportsArray *pArray, } -nsresult nsEudoraWin32::FoundMailbox(nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraWin32::FoundMailbox(nsIFile *mailFile, const char *pName, nsIMutableArray *pArray, nsIImportService *pImport) { nsString displayName; nsCOMPtr desc; @@ -458,7 +453,7 @@ nsresult nsEudoraWin32::FoundMailbox(nsIFile *mailFile, const char *pName, nsISu pFile->InitWithFile(mailFile); } rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - pArray->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); } @@ -466,7 +461,7 @@ nsresult nsEudoraWin32::FoundMailbox(nsIFile *mailFile, const char *pName, nsISu } -nsresult nsEudoraWin32::FoundMailFolder(nsIFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport) +nsresult nsEudoraWin32::FoundMailFolder(nsIFile *mailFolder, const char *pName, nsIMutableArray *pArray, nsIImportService *pImport) { nsString displayName; nsCOMPtr desc; @@ -498,7 +493,7 @@ nsresult nsEudoraWin32::FoundMailFolder(nsIFile *mailFolder, const char *pName, pFile->InitWithFile(mailFolder); } rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - pArray->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); } @@ -1316,7 +1311,7 @@ bool nsEudoraWin32::FindAddressFolder(nsIFile **pFolder) return FindEudoraLocation(pFolder); } -nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray) +nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsIMutableArray *pArray) { nsresult rv; nsCOMPtr file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv); @@ -1324,13 +1319,6 @@ nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppAr rv = file->InitWithFile(pRoot); NS_ENSURE_SUCCESS(rv, rv); - rv = NS_NewISupportsArray(ppArray); - if (NS_FAILED(rv)) - { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); - return rv; - } - nsCOMPtr impSvc(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; @@ -1365,7 +1353,7 @@ nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppAr if (exists && isFile) { - if (NS_FAILED(rv = FoundAddressBook(file, displayName.get(), *ppArray, impSvc))) + if (NS_FAILED(rv = FoundAddressBook(file, displayName.get(), pArray, impSvc))) return rv; } @@ -1382,7 +1370,7 @@ nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppAr rv = file->IsDirectory(&isDir); if (exists && isDir) { - if (NS_FAILED(rv = ScanAddressDir(file, *ppArray, impSvc))) + if (NS_FAILED(rv = ScanAddressDir(file, pArray, impSvc))) return rv; } @@ -1440,7 +1428,7 @@ nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppAr rv = file->IsDirectory(&isDir); if (exists && isDir) { - if (NS_FAILED(rv = ScanAddressDir(file, *ppArray, impSvc))) + if (NS_FAILED(rv = ScanAddressDir(file, pArray, impSvc))) return rv; } } @@ -1458,16 +1446,15 @@ nsresult nsEudoraWin32::FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppAr rv = file->IsDirectory(&isDir); if (exists && isDir) { - if (NS_FAILED(rv = ScanAddressDir(file, *ppArray, impSvc))) + if (NS_FAILED(rv = ScanAddressDir(file, pArray, impSvc))) return rv; } } - return NS_OK; } -nsresult nsEudoraWin32::ScanAddressDir(nsIFile *pDir, nsISupportsArray *pArray, nsIImportService *impSvc) +nsresult nsEudoraWin32::ScanAddressDir(nsIFile *pDir, nsIMutableArray *pArray, nsIImportService *impSvc) { bool hasMore; nsCOMPtr directoryEnumerator; @@ -1525,7 +1512,7 @@ nsresult nsEudoraWin32::ScanAddressDir(nsIFile *pDir, nsISupportsArray *pArray, } -nsresult nsEudoraWin32::FoundAddressBook(nsIFile *file, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc) +nsresult nsEudoraWin32::FoundAddressBook(nsIFile *file, const PRUnichar *pName, nsIMutableArray *pArray, nsIImportService *impSvc) { nsCOMPtr desc; nsISupports * pInterface; @@ -1556,7 +1543,7 @@ nsresult nsEudoraWin32::FoundAddressBook(nsIFile *file, const PRUnichar *pName, desc->SetSize((uint32_t) sz); desc->SetAbFile(file); rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - pArray->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); } if (NS_FAILED(rv)) diff --git a/mailnews/import/eudora/src/nsEudoraWin32.h b/mailnews/import/eudora/src/nsEudoraWin32.h index 6881a1ec46..63cb50cadc 100644 --- a/mailnews/import/eudora/src/nsEudoraWin32.h +++ b/mailnews/import/eudora/src/nsEudoraWin32.h @@ -11,7 +11,6 @@ #include "nscore.h" #include "nsStringGlue.h" #include "nsIFile.h" -#include "nsISupportsArray.h" #include "nsEudoraMailbox.h" #include "nsEudoraAddress.h" @@ -20,6 +19,7 @@ class nsIImportService; class nsIMsgAccountManager; class nsIMsgAccount; +class nsIMutableArray; class nsEudoraWin32 : public nsEudoraMailbox, public nsEudoraAddress { @@ -30,7 +30,7 @@ public: // retrieve the mail folder virtual bool FindMailFolder(nsIFile **pFolder) MOZ_OVERRIDE; // get the list of mailboxes - virtual nsresult FindMailboxes(nsIFile *pRoot, nsISupportsArray **ppArray) MOZ_OVERRIDE; + virtual nsresult FindMailboxes(nsIFile *pRoot, nsIMutableArray *pArray) MOZ_OVERRIDE; // get a TOC file from a mailbox file virtual nsresult FindTOCFile(nsIFile *pMailFile, nsIFile **pTOCFile, bool *pDeleteToc) MOZ_OVERRIDE; @@ -40,7 +40,7 @@ public: // retrieve the address book folder virtual bool FindAddressFolder(nsIFile **pFolder) MOZ_OVERRIDE; // get the list of address books - virtual nsresult FindAddressBooks(nsIFile *pRoot, nsISupportsArray **ppArray) MOZ_OVERRIDE; + virtual nsresult FindAddressBooks(nsIFile *pRoot, nsIMutableArray *pArray) MOZ_OVERRIDE; // import settings from Win32 ini file static bool ImportSettings(nsIFile *pIniFile, nsIMsgAccount **localMailAccount); @@ -51,15 +51,15 @@ public: static bool GetMailboxNameHierarchy(const nsACString& pEudoraLocation, const char* pEudoraFilePath, nsCString& nameHierarchy); private: - nsresult ScanMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport); - nsresult IterateMailDir(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport); - nsresult ScanDescmap(nsIFile *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, int32_t len); - nsresult FoundMailFolder(nsIFile *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport); - nsresult FoundMailbox(nsIFile *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport); + nsresult ScanMailDir(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport); + nsresult IterateMailDir(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport); + nsresult ScanDescmap(nsIFile *pFolder, nsIMutableArray *pArray, nsIImportService *pImport, const char *pData, int32_t len); + nsresult FoundMailFolder(nsIFile *mailFolder, const char *pName, nsIMutableArray *pArray, nsIImportService *pImport); + nsresult FoundMailbox(nsIFile *mailFile, const char *pName, nsIMutableArray *pArray, nsIImportService *pImport); bool FindMimeIniFile(nsIFile *pFile); void GetMimeTypeFromExtension(nsCString& ext, nsCString& mimeType); - nsresult FoundAddressBook(nsIFile *file, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc); - nsresult ScanAddressDir(nsIFile *pDir, nsISupportsArray *pArray, nsIImportService *impSvc); + nsresult FoundAddressBook(nsIFile *file, const PRUnichar *pName, nsIMutableArray *pArray, nsIImportService *impSvc); + nsresult ScanAddressDir(nsIFile *pDir, nsIMutableArray *pArray, nsIImportService *impSvc); static bool FindEudoraLocation(nsIFile **pFolder, bool findIni = false); diff --git a/mailnews/import/oexpress/nsOEImport.cpp b/mailnews/import/oexpress/nsOEImport.cpp index 11f5e05e87..82ef1aa59f 100644 --- a/mailnews/import/oexpress/nsOEImport.cpp +++ b/mailnews/import/oexpress/nsOEImport.cpp @@ -30,6 +30,7 @@ #include "nsIImportAddressBooks.h" #include "nsIImportABDescriptor.h" #include "nsIImportFieldMap.h" +#include "nsIMutableArray.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" #include "WabObject.h" @@ -66,8 +67,8 @@ public: /* void GetDefaultLocation (out nsIFile location, out boolean found, out boolean userVerify); */ NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify); - /* nsISupportsArray FindMailboxes (in nsIFile location); */ - NS_IMETHOD FindMailboxes(nsIFile *location, nsISupportsArray **_retval); + /* nsIArray FindMailboxes (in nsIFile location); */ + NS_IMETHOD FindMailboxes(nsIFile *location, nsIArray **_retval); NS_IMETHOD ImportMailbox(nsIImportMailboxDescriptor *source, nsIMsgFolder *dstFolder, @@ -111,7 +112,7 @@ public: NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify); - NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval); + NS_IMETHOD FindAddressBooks(nsIFile *location, nsIArray **_retval); NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap) { return NS_ERROR_FAILURE; } @@ -327,7 +328,7 @@ NS_IMETHODIMP ImportOEMailImpl::GetDefaultLocation(nsIFile **ppLoc, bool *found, } -NS_IMETHODIMP ImportOEMailImpl::FindMailboxes(nsIFile *pLoc, nsISupportsArray **ppArray) +NS_IMETHODIMP ImportOEMailImpl::FindMailboxes(nsIFile *pLoc, nsIArray **ppArray) { NS_PRECONDITION(pLoc != nullptr, "null ptr"); NS_PRECONDITION(ppArray != nullptr, "null ptr"); @@ -521,13 +522,14 @@ NS_IMETHODIMP ImportOEAddressImpl::GetAutoFind(PRUnichar **description, bool *_r -NS_IMETHODIMP ImportOEAddressImpl::FindAddressBooks(nsIFile *location, nsISupportsArray **_retval) +NS_IMETHODIMP ImportOEAddressImpl::FindAddressBooks(nsIFile *location, nsIArray **_retval) { NS_PRECONDITION(_retval != nullptr, "null ptr"); if (!_retval) return NS_ERROR_NULL_POINTER; - nsresult rv = NS_NewISupportsArray(_retval); + nsresult rv; + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; @@ -567,7 +569,7 @@ NS_IMETHODIMP ImportOEAddressImpl::FindAddressBooks(nsIFile *location, nsISuppor pID->SetSize(100); pID->SetPreferredName(str); rv = pID->QueryInterface(kISupportsIID, (void **) &pInterface); - (*_retval)->AppendElement(pInterface); + array->AppendElement(pInterface, false); pInterface->Release(); pID->Release(); } @@ -578,6 +580,7 @@ NS_IMETHODIMP ImportOEAddressImpl::FindAddressBooks(nsIFile *location, nsISuppor delete m_pWab; m_pWab = nullptr; } + array.forget(_retval); return NS_OK; } diff --git a/mailnews/import/oexpress/nsOEScanBoxes.cpp b/mailnews/import/oexpress/nsOEScanBoxes.cpp index e3e35fb579..dde1ebd476 100644 --- a/mailnews/import/oexpress/nsOEScanBoxes.cpp +++ b/mailnews/import/oexpress/nsOEScanBoxes.cpp @@ -133,7 +133,7 @@ bool nsOEScanBoxes::FindMail(nsIFile *pWhere) return isDir; } -bool nsOEScanBoxes::GetMailboxes(nsIFile *pWhere, nsISupportsArray **pArray) +bool nsOEScanBoxes::GetMailboxes(nsIFile *pWhere, nsIArray **pArray) { nsCString path; pWhere->GetNativePath(path); @@ -680,20 +680,22 @@ uint32_t nsOEScanBoxes::CountMailboxes(MailboxEntry *pBox) return count; } -bool nsOEScanBoxes::GetMailboxList(nsIFile * root, nsISupportsArray **pArray) +bool nsOEScanBoxes::GetMailboxList(nsIFile * root, nsIArray **pArray) { - nsresult rv = NS_NewISupportsArray(pArray); + nsresult rv; + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); if (NS_FAILED(rv)) { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); + IMPORT_LOG0("FAILED to allocate the nsIArray\n"); return false; } - BuildMailboxList(nullptr, root, 1, *pArray); + BuildMailboxList(nullptr, root, 1, array); + array.forget(pArray); return true; } -void nsOEScanBoxes::BuildMailboxList(MailboxEntry *pBox, nsIFile * root, int32_t depth, nsISupportsArray *pArray) +void nsOEScanBoxes::BuildMailboxList(MailboxEntry *pBox, nsIFile * root, int32_t depth, nsIMutableArray *pArray) { if (pBox == nullptr) { if (m_pFirst != nullptr) { @@ -740,7 +742,7 @@ void nsOEScanBoxes::BuildMailboxList(MailboxEntry *pBox, nsIFile * root, int32_t pID->SetSize(size); } rv = pID->QueryInterface(kISupportsIID, (void **) &pInterface); - pArray->AppendElement(pInterface); + pArray->AppendElement(pInterface, false); pInterface->Release(); pID->Release(); } diff --git a/mailnews/import/oexpress/nsOEScanBoxes.h b/mailnews/import/oexpress/nsOEScanBoxes.h index 6fffd2b1ef..e40eab8f2d 100644 --- a/mailnews/import/oexpress/nsOEScanBoxes.h +++ b/mailnews/import/oexpress/nsOEScanBoxes.h @@ -9,7 +9,8 @@ #include "nsStringGlue.h" #include "nsIImportModule.h" #include "nsVoidArray.h" -#include "nsISupportsArray.h" +#include "nsIArray.h" +#include "nsIMutableArray.h" #include "nsIFile.h" #include "nsIImportService.h" @@ -22,7 +23,7 @@ public: static bool FindMail(nsIFile *pWhere); - bool GetMailboxes(nsIFile *pWhere, nsISupportsArray **pArray); + bool GetMailboxes(nsIFile *pWhere, nsIArray **pArray); private: @@ -60,8 +61,8 @@ private: bool ReadString(nsIInputStream * stream, nsCString& str, uint32_t offset); uint32_t CountMailboxes(MailboxEntry *pBox); - void BuildMailboxList(MailboxEntry *pBox, nsIFile * root, int32_t depth, nsISupportsArray *pArray); - bool GetMailboxList(nsIFile * root, nsISupportsArray **pArray); + void BuildMailboxList(MailboxEntry *pBox, nsIFile * root, int32_t depth, nsIMutableArray *pArray); + bool GetMailboxList(nsIFile * root, nsIArray **pArray); private: MailboxEntry * m_pFirst; diff --git a/mailnews/import/outlook/src/nsOutlookCompose.cpp b/mailnews/import/outlook/src/nsOutlookCompose.cpp index 343cc981c3..0dd6058e6f 100644 --- a/mailnews/import/outlook/src/nsOutlookCompose.cpp +++ b/mailnews/import/outlook/src/nsOutlookCompose.cpp @@ -25,6 +25,7 @@ #include "nsIMsgCompFields.h" #include "nsIMsgAccountManager.h" #include "nsIMsgSend.h" +#include "nsIMutableArray.h" #include "nsImportEmbeddedImageData.h" #include "nsNetCID.h" #include "nsCRT.h" @@ -294,7 +295,7 @@ nsresult nsOutlookCompose::ComposeTheMessage(nsMsgDeliverMode mode, CMapiMessage bodyW = msg.GetBody(); // End Bug 593907 - nsCOMPtr embeddedObjects; + nsCOMPtr embeddedObjects; if (msg.BodyIsHtml()) { for (unsigned int i = 0; i imageData = new nsImportEmbeddedImageData(uri, nsDependentCString(cid), nsDependentCString(name)); - embeddedObjects->AppendElement(imageData); + embeddedObjects->AppendElement(imageData, false); } } } diff --git a/mailnews/import/outlook/src/nsOutlookImport.cpp b/mailnews/import/outlook/src/nsOutlookImport.cpp index 5722bb15ca..bfd23ed82c 100644 --- a/mailnews/import/outlook/src/nsOutlookImport.cpp +++ b/mailnews/import/outlook/src/nsOutlookImport.cpp @@ -60,8 +60,8 @@ public: /* void GetDefaultLocation (out nsIFile location, out boolean found, out boolean userVerify); */ NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify); - /* nsISupportsArray FindMailboxes (in nsIFile location); */ - NS_IMETHOD FindMailboxes(nsIFile *location, nsISupportsArray **_retval); + /* nsIArray FindMailboxes (in nsIFile location); */ + NS_IMETHOD FindMailboxes(nsIFile *location, nsIArray **_retval); NS_IMETHOD ImportMailbox(nsIImportMailboxDescriptor *source, nsIMsgFolder *dstFolder, @@ -107,7 +107,7 @@ public: NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify) { return NS_ERROR_FAILURE;} - NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval); + NS_IMETHOD FindAddressBooks(nsIFile *location, nsIArray **_retval); NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap) { return NS_ERROR_FAILURE; } @@ -338,7 +338,7 @@ NS_IMETHODIMP ImportOutlookMailImpl::GetDefaultLocation(nsIFile **ppLoc, bool *f } -NS_IMETHODIMP ImportOutlookMailImpl::FindMailboxes(nsIFile *pLoc, nsISupportsArray **ppArray) +NS_IMETHODIMP ImportOutlookMailImpl::FindMailboxes(nsIFile *pLoc, nsIArray **ppArray) { NS_PRECONDITION(pLoc != nullptr, "null ptr"); NS_PRECONDITION(ppArray != nullptr, "null ptr"); @@ -501,7 +501,7 @@ NS_IMETHODIMP ImportOutlookAddressImpl::GetAutoFind(PRUnichar **description, boo return NS_OK; } -NS_IMETHODIMP ImportOutlookAddressImpl::FindAddressBooks(nsIFile *location, nsISupportsArray **_retval) +NS_IMETHODIMP ImportOutlookAddressImpl::FindAddressBooks(nsIFile *location, nsIArray **_retval) { NS_PRECONDITION(_retval != nullptr, "null ptr"); if (!_retval) diff --git a/mailnews/import/outlook/src/nsOutlookMail.cpp b/mailnews/import/outlook/src/nsOutlookMail.cpp index 017742c231..8ca2916785 100644 --- a/mailnews/import/outlook/src/nsOutlookMail.cpp +++ b/mailnews/import/outlook/src/nsOutlookMail.cpp @@ -15,6 +15,7 @@ #include "nsIImportFieldMap.h" #include "nsIImportMailboxDescriptor.h" #include "nsIImportABDescriptor.h" +#include "nsIMutableArray.h" #include "nsOutlookStringBundle.h" #include "nsABBaseCID.h" #include "nsIAbCard.h" @@ -108,16 +109,17 @@ nsOutlookMail::~nsOutlookMail() // EmptyAttachments(); } -nsresult nsOutlookMail::GetMailFolders(nsISupportsArray **pArray) +nsresult nsOutlookMail::GetMailFolders(nsIArray **pArray) { if (!m_haveMapi) { IMPORT_LOG0("GetMailFolders called before Mapi is initialized\n"); return NS_ERROR_FAILURE; } - nsresult rv = NS_NewISupportsArray(pArray); + nsresult rv; + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); if (NS_FAILED(rv)) { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray for the mail folder list\n"); + IMPORT_LOG0("FAILED to allocate the nsIMutableArray for the mail folder list\n"); return rv; } @@ -174,12 +176,12 @@ nsresult nsOutlookMail::GetMailFolders(nsISupportsArray **pArray) pID->SetSize(1000); rv = pID->QueryInterface(kISupportsIID, (void **) &pInterface); - (*pArray)->AppendElement(pInterface); + array->AppendElement(pInterface, false); pInterface->Release(); pID->Release(); } } - + array.forget(pArray); return NS_OK; } @@ -212,16 +214,17 @@ void nsOutlookMail::MakeAddressBookNameUnique(nsString& name, nsString& list) list.AppendLiteral("],"); } -nsresult nsOutlookMail::GetAddressBooks(nsISupportsArray **pArray) +nsresult nsOutlookMail::GetAddressBooks(nsIArray **pArray) { if (!m_haveMapi) { IMPORT_LOG0("GetAddressBooks called before Mapi is initialized\n"); return NS_ERROR_FAILURE; } - nsresult rv = NS_NewISupportsArray(pArray); + nsresult rv; + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); if (NS_FAILED(rv)) { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray for the address book list\n"); + IMPORT_LOG0("FAILED to allocate the nsIMutableArray for the address book list\n"); return rv; } @@ -275,13 +278,13 @@ nsresult nsOutlookMail::GetAddressBooks(nsISupportsArray **pArray) pID->SetPreferredName(name); pID->SetSize(100); rv = pID->QueryInterface(kISupportsIID, (void **) &pInterface); - (*pArray)->AppendElement(pInterface); + array->AppendElement(pInterface, false); pInterface->Release(); pID->Release(); } } } - + array.forget(pArray); return NS_OK; } diff --git a/mailnews/import/outlook/src/nsOutlookMail.h b/mailnews/import/outlook/src/nsOutlookMail.h index 961eafea14..47ef160e09 100644 --- a/mailnews/import/outlook/src/nsOutlookMail.h +++ b/mailnews/import/outlook/src/nsOutlookMail.h @@ -6,7 +6,7 @@ #ifndef nsOutlookMail_h___ #define nsOutlookMail_h___ -#include "nsISupportsArray.h" +#include "nsIArray.h" #include "nsStringGlue.h" #include "nsOutlookCompose.h" #include "nsIFile.h" @@ -22,8 +22,8 @@ public: nsOutlookMail(); ~nsOutlookMail(); - nsresult GetMailFolders(nsISupportsArray **pArray); - nsresult GetAddressBooks(nsISupportsArray **pArray); + nsresult GetMailFolders(nsIArray **pArray); + nsresult GetAddressBooks(nsIArray **pArray); nsresult ImportMailbox(uint32_t *pDoneSoFar, bool *pAbort, int32_t index, const PRUnichar *pName, nsIMsgFolder *pDest, int32_t *pMsgCount); diff --git a/mailnews/import/public/nsIImportAddressBooks.idl b/mailnews/import/public/nsIImportAddressBooks.idl index 6aa26310ed..b956a937b6 100644 --- a/mailnews/import/public/nsIImportAddressBooks.idl +++ b/mailnews/import/public/nsIImportAddressBooks.idl @@ -35,13 +35,13 @@ #include "nsISupports.idl" interface nsIFile; -interface nsISupportsArray; +interface nsIArray; interface nsIImportABDescriptor; interface nsIOutputStream; interface nsIAddrDatabase; interface nsIImportFieldMap; -[scriptable, uuid(d64a87ba-f87b-6378-5ed1-4025a7474334)] +[scriptable, uuid(6bba48be-331c-41e3-bc9f-c2ea3754d977)] interface nsIImportAddressBooks : nsISupports { @@ -80,11 +80,11 @@ interface nsIImportAddressBooks : nsISupports out boolean found, out boolean userVerify); /* - Returns an nsISupportsArray which contains an nsIImportABDescriptor for each + Returns an nsIArray which contains an nsIImportABDescriptor for each address book. The array is not sorted before display to the user. location is null if GetAutoFind returned true. */ - nsISupportsArray FindAddressBooks( in nsIFile location); + nsIArray FindAddressBooks(in nsIFile location); /* Fill in defaults (if any) for a field map for importing address diff --git a/mailnews/import/public/nsIImportGeneric.idl b/mailnews/import/public/nsIImportGeneric.idl index c292f38ec0..1496bac651 100644 --- a/mailnews/import/public/nsIImportGeneric.idl +++ b/mailnews/import/public/nsIImportGeneric.idl @@ -13,17 +13,17 @@ interface nsISupportsString; -[scriptable, uuid(d64a87b8-aeb4-da40-fe28-57df1e50c64f)] +[scriptable, uuid(469d7d5f-144c-4f07-9661-e49e40156348)] interface nsIImportGeneric : nsISupports { /* Use these to prepare for the import */ /* "mailInterface" - nsIImportMail interface - "mailBoxes" - nsISupportsArray of nsIImportMailboxDescriptors + "mailBoxes" - nsIArray of nsIImportMailboxDescriptors "mailLocation" - nsIFile, source location for mail "addressInterface" - nsIImportAddressBooks interface - "addressBooks" - nsISupportsArray of nsIImportABDescriptors + "addressBooks" - nsIArray of nsIImportABDescriptors "addressLocation" - src location of address books (if needed!) "addressDestination" - uri of destination address book or null if new address books will be created. diff --git a/mailnews/import/public/nsIImportMail.idl b/mailnews/import/public/nsIImportMail.idl index ab5602a967..1158f2dc1f 100644 --- a/mailnews/import/public/nsIImportMail.idl +++ b/mailnews/import/public/nsIImportMail.idl @@ -36,12 +36,12 @@ #include "nsISupports.idl" interface nsIFile; -interface nsISupportsArray; +interface nsIArray; interface nsIImportMailboxDescriptor; interface nsIOutputStream; interface nsIMsgFolder; -[scriptable, uuid(306561d3-ed2f-425d-87ee-eb129a84a6af)] +[scriptable, uuid(a14a3308-0849-420b-86d3-13a2948b5504)] interface nsIImportMail : nsISupports { @@ -55,10 +55,10 @@ interface nsIImportMail : nsISupports out boolean found, out boolean userVerify); /* - Returns an nsISupportsArray which contains an nsIImportMailboxID for each + Returns an nsIArray which contains an nsIImportMailboxID for each mailbox. The array is not sorted before display to the user. */ - nsISupportsArray FindMailboxes( in nsIFile location); + nsIArray FindMailboxes(in nsIFile location); /* Import a specific mailbox into the destination folder supplied. If an error diff --git a/mailnews/import/public/nsIImportService.idl b/mailnews/import/public/nsIImportService.idl index a65395093b..a6e1e6dcaf 100644 --- a/mailnews/import/public/nsIImportService.idl +++ b/mailnews/import/public/nsIImportService.idl @@ -22,9 +22,9 @@ interface nsIMsgSendListener; interface nsIArray; interface nsIMsgIdentity; interface nsIMsgCompFields; -interface nsISupportsArray; +interface nsIArray; -[scriptable, uuid(16359964-66e3-4412-84f8-2a8d58be8be0)] +[scriptable, uuid(d0ed4c50-5997-49c9-8a6a-045f0680ed29)] interface nsIImportService : nsISupports { void DiscoverModules(); @@ -47,7 +47,7 @@ interface nsIImportService : nsISupports in ACString aBody, in boolean aCreateAsDraft, in nsIArray aLoadedAttachments, - in nsISupportsArray aEmbeddedObjects, + in nsIArray aEmbeddedObjects, in nsIMsgSendListener aListener); }; diff --git a/mailnews/import/src/nsImportAddressBooks.cpp b/mailnews/import/src/nsImportAddressBooks.cpp index 71dd08c171..fc5a85a075 100644 --- a/mailnews/import/src/nsImportAddressBooks.cpp +++ b/mailnews/import/src/nsImportAddressBooks.cpp @@ -27,8 +27,9 @@ #include "ImportDebug.h" #include "nsIAbMDBDirectory.h" #include "nsComponentManagerUtils.h" -#include "nsISupportsArray.h" +#include "nsIArray.h" #include "nsCOMArray.h" +#include "nsArrayUtils.h" static void ImportAddressThread(void *stuff); @@ -72,7 +73,7 @@ public: private: nsIImportAddressBooks * m_pInterface; - nsISupportsArray *m_pBooks; + nsCOMPtr m_Books; nsCOMArray m_DBs; nsCOMPtr m_pLocation; nsIImportFieldMap * m_pFieldMap; @@ -98,7 +99,7 @@ public: bool fatalError; uint32_t currentTotal; uint32_t currentSize; - nsISupportsArray * books; + nsIArray *books; nsCOMArray* dBs; nsCOMPtr ldifService; nsIImportAddressBooks * addressImport; @@ -134,7 +135,6 @@ nsresult NS_NewGenericAddressBooks(nsIImportGeneric** aImportGeneric) nsImportGenericAddressBooks::nsImportGenericAddressBooks() { m_pInterface = nullptr; - m_pBooks = nullptr; m_pSuccessLog = nullptr; m_pErrorLog = nullptr; m_totalSize = 0; @@ -163,7 +163,6 @@ nsImportGenericAddressBooks::~nsImportGenericAddressBooks() NS_IF_RELEASE(m_pFieldMap); NS_IF_RELEASE(m_pInterface); - NS_IF_RELEASE(m_pBooks); NS_IF_RELEASE(m_pSuccessLog); NS_IF_RELEASE(m_pErrorLog); } @@ -195,10 +194,9 @@ NS_IMETHODIMP nsImportGenericAddressBooks::GetData(const char *dataId, nsISuppor if (!PL_strcasecmp(dataId, "addressBooks")) { if (!m_pLocation) GetDefaultLocation(); - if (!m_pBooks) + if (!m_Books) GetDefaultBooks(); - *_retval = m_pBooks; - NS_IF_ADDREF(m_pBooks); + *_retval = m_Books; } if (!PL_strcasecmp(dataId, "addressDestination")) { @@ -274,9 +272,8 @@ NS_IMETHODIMP nsImportGenericAddressBooks::SetData(const char *dataId, nsISuppor item->QueryInterface(NS_GET_IID(nsIImportAddressBooks), (void **) &m_pInterface); } if (!PL_strcasecmp(dataId, "addressBooks")) { - NS_IF_RELEASE(m_pBooks); if (item) - item->QueryInterface(NS_GET_IID(nsISupportsArray), (void **) &m_pBooks); + item->QueryInterface(NS_GET_IID(nsIArray), (void **) &m_Books); } if (!PL_strcasecmp(dataId, "addressLocation")) { @@ -384,13 +381,13 @@ void nsImportGenericAddressBooks::GetDefaultLocation(void) void nsImportGenericAddressBooks::GetDefaultBooks(void) { - if (!m_pInterface || m_pBooks) + if (!m_pInterface || m_Books) return; if (!m_pLocation && !m_autoFind) return; - nsresult rv = m_pInterface->FindAddressBooks(m_pLocation, &m_pBooks); + nsresult rv = m_pInterface->FindAddressBooks(m_pLocation, getter_AddRefs(m_Books)); if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error: FindAddressBooks failed\n"); } @@ -437,17 +434,17 @@ NS_IMETHODIMP nsImportGenericAddressBooks::WantsProgress(bool *_retval) bool result = false; - if (m_pBooks) { + if (m_Books) { uint32_t count = 0; uint32_t i; bool import; uint32_t size; uint32_t totalSize = 0; - (void) m_pBooks->Count(&count); + m_Books->GetLength(&count); for (i = 0; i < count; i++) { - nsCOMPtr book = do_QueryElementAt(m_pBooks, i); + nsCOMPtr book = do_QueryElementAt(m_Books, i); if (book) { import = false; size = 0; @@ -609,7 +606,7 @@ NS_IMETHODIMP nsImportGenericAddressBooks::BeginImport(nsISupportsString *succes return NS_OK; } - if (!m_pInterface || !m_pBooks) { + if (!m_pInterface || !m_Books) { nsImportStringBundle::GetStringByID(IMPORT_ERROR_AB_NOTINITIALIZED, m_stringBundle, error); SetLogs(success, error, successLog, errorLog); @@ -640,8 +637,8 @@ NS_IMETHODIMP nsImportGenericAddressBooks::BeginImport(nsISupportsString *succes // not going to create a new thread for this since address books // don't tend to be large, and import is rare. m_pThreadData = new AddressThreadData(); - m_pThreadData->books = m_pBooks; - NS_ADDREF(m_pBooks); + m_pThreadData->books = m_Books; + NS_ADDREF(m_Books); m_pThreadData->addressImport = m_pInterface; NS_ADDREF(m_pInterface); m_pThreadData->fieldMap = m_pFieldMap; @@ -654,14 +651,14 @@ NS_IMETHODIMP nsImportGenericAddressBooks::BeginImport(nsISupportsString *succes m_pThreadData->pDestinationUri = strdup(m_pDestinationUri); uint32_t count = 0; - m_pBooks->Count(&count); + m_Books->GetLength(&count); // Create/obtain any address books that we need here, so that we don't need // to do so inside the import thread which would just proxy the create // operations back to the main thread anyway. nsCOMPtr db = GetAddressBookFromUri(m_pDestinationUri); for (uint32_t i = 0; i < count; ++i) { - nsCOMPtr book = do_QueryElementAt(m_pBooks, i); + nsCOMPtr book = do_QueryElementAt(m_Books, i); if (book) { if (!db) @@ -811,7 +808,7 @@ static void ImportAddressThread(void *stuff) nsString success; nsString error; - (void) pData->books->Count(&count); + (void) pData->books->GetLength(&count); for (i = 0; (i < count) && !(pData->abort); i++) { nsCOMPtr book = diff --git a/mailnews/import/src/nsImportMail.cpp b/mailnews/import/src/nsImportMail.cpp index 0386589855..3ff2d5952f 100644 --- a/mailnews/import/src/nsImportMail.cpp +++ b/mailnews/import/src/nsImportMail.cpp @@ -15,7 +15,8 @@ #include "prprf.h" #include "nscore.h" #include "nsCOMPtr.h" -#include "nsISupportsArray.h" +#include "nsIArray.h" +#include "nsArrayUtils.h" #include "nsIImportMail.h" #include "nsIImportGeneric.h" @@ -96,8 +97,8 @@ private: bool m_gotLocation; bool m_found; bool m_userVerify; - nsIImportMail * m_pInterface; - nsISupportsArray * m_pMailboxes; + nsIImportMail *m_pInterface; + nsIArray * m_pMailboxes; nsISupportsString *m_pSuccessLog; nsISupportsString *m_pErrorLog; uint32_t m_totalSize; @@ -117,7 +118,7 @@ public: uint32_t currentSize; nsIMsgFolder * destRoot; bool ownsDestRoot; - nsISupportsArray * boxes; + nsIArray *boxes; nsIImportMail * mailImport; nsISupportsString * successLog; nsISupportsString * errorLog; @@ -282,7 +283,7 @@ NS_IMETHODIMP nsImportGenericMail::SetData(const char *dataId, nsISupports *item if (!PL_strcasecmp(dataId, "mailBoxes")) { NS_IF_RELEASE(m_pMailboxes); if (item) - item->QueryInterface(NS_GET_IID(nsISupportsArray), (void **) &m_pMailboxes); + item->QueryInterface(NS_GET_IID(nsIArray), (void **) &m_pMailboxes); } if (!PL_strcasecmp(dataId, "mailLocation")) { @@ -415,7 +416,7 @@ NS_IMETHODIMP nsImportGenericMail::WantsProgress(bool *_retval) uint32_t size; uint32_t totalSize = 0; - (void) m_pMailboxes->Count(&count); + (void) m_pMailboxes->GetLength(&count); for (i = 0; i < count; i++) { nsCOMPtr box = do_QueryElementAt(m_pMailboxes, i); @@ -714,7 +715,7 @@ ImportMailThread(void *stuff) nsCOMPtr destRoot(pData->destRoot); uint32_t count = 0; - rv = pData->boxes->Count(&count); + rv = pData->boxes->GetLength(&count); uint32_t i; bool import; diff --git a/mailnews/import/src/nsImportService.cpp b/mailnews/import/src/nsImportService.cpp index 5f51b40dc7..1661cb6399 100644 --- a/mailnews/import/src/nsImportService.cpp +++ b/mailnews/import/src/nsImportService.cpp @@ -37,6 +37,7 @@ #include "nsServiceManagerUtils.h" #include "nsComponentManagerUtils.h" #include "nsIMutableArray.h" +#include "nsIArray.h" #include "nsISupportsArray.h" #include "nsIMsgSend.h" @@ -295,7 +296,7 @@ public: const nsACString &attachment1_body, bool aIsDraft, nsIArray *aLoadedAttachments, - nsISupportsArray *aEmbeddedAttachments, + nsIArray *aEmbeddedAttachments, nsIMsgSendListener *aListener); NS_DECL_NSIRUNNABLE private: @@ -305,7 +306,7 @@ private: nsCString m_bodyType; nsCString m_body; nsCOMPtr m_loadedAttachments; - nsCOMPtr m_embeddedAttachments; + nsCOMPtr m_embeddedAttachments; nsCOMPtr m_listener; }; @@ -316,7 +317,7 @@ nsProxySendRunnable::nsProxySendRunnable(nsIMsgIdentity *aIdentity, const nsACString &aBody, bool aIsDraft, nsIArray *aLoadedAttachments, - nsISupportsArray *aEmbeddedAttachments, + nsIArray *aEmbeddedAttachments, nsIMsgSendListener *aListener) : m_identity(aIdentity), m_compFields(aMsgFields), m_isDraft(aIsDraft), m_bodyType(aBodyType), @@ -332,10 +333,23 @@ NS_IMETHODIMP nsProxySendRunnable::Run() nsCOMPtr msgSend = do_CreateInstance(NS_MSGSEND_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr supportsArray; + NS_NewISupportsArray(getter_AddRefs(supportsArray)); + + nsCOMPtr enumerator; + m_embeddedAttachments->Enumerate(getter_AddRefs(enumerator)); + + bool hasMore; + while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) { + nsCOMPtr item; + enumerator->GetNext(getter_AddRefs(item)); + supportsArray->AppendElement(item); + } + return msgSend->CreateRFC822Message(m_identity, m_compFields, m_bodyType.get(), m_body, m_isDraft, m_loadedAttachments, - m_embeddedAttachments, + supportsArray, m_listener); } @@ -347,7 +361,7 @@ nsImportService::CreateRFC822Message(nsIMsgIdentity *aIdentity, const nsACString &aBody, bool aIsDraft, nsIArray *aLoadedAttachments, - nsISupportsArray *aEmbeddedAttachments, + nsIArray *aEmbeddedAttachments, nsIMsgSendListener *aListener) { nsRefPtr runnable = diff --git a/mailnews/import/test/unit/resources/TestMailImporter.js b/mailnews/import/test/unit/resources/TestMailImporter.js index dfbb070c58..62f1e71d0e 100644 --- a/mailnews/import/test/unit/resources/TestMailImporter.js +++ b/mailnews/import/test/unit/resources/TestMailImporter.js @@ -63,7 +63,7 @@ TestMailImpoter.prototype = { let descriptor = this._createMailboxDescriptor(directory.path, directory.leafName, depth); - result.AppendElement(descriptor); + result.AppendElement(descriptor, false); let entries = directory.directoryEntries; while (entries.hasMoreElements()) { let entry = entries.getNext().QueryInterface(Ci.nsIFile); @@ -75,7 +75,7 @@ TestMailImpoter.prototype = { FindMailboxes: function(location) { let result; result = Cc["@mozilla.org/supports-array;1"] - .createInstance(Ci.nsISupportsArray); + .createInstance(Ci.nsIArray); this._collectMailboxesInDirectory(location, 0, result); return result; diff --git a/mailnews/import/text/src/nsTextImport.cpp b/mailnews/import/text/src/nsTextImport.cpp index fdbb25e28d..6d3d838c42 100644 --- a/mailnews/import/text/src/nsTextImport.cpp +++ b/mailnews/import/text/src/nsTextImport.cpp @@ -23,6 +23,7 @@ #include "nsIComponentManager.h" #include "nsTextImport.h" #include "nsIMemory.h" +#include "nsIMutableArray.h" #include "nsIImportGeneric.h" #include "nsIImportAddressBooks.h" #include "nsIImportABDescriptor.h" @@ -73,7 +74,7 @@ public: NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify); - NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval); + NS_IMETHOD FindAddressBooks(nsIFile *location, nsIArray **_retval); NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap); @@ -256,7 +257,7 @@ NS_IMETHODIMP ImportAddressImpl::GetDefaultLocation(nsIFile **ppLoc, bool *found -NS_IMETHODIMP ImportAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISupportsArray **ppArray) +NS_IMETHODIMP ImportAddressImpl::FindAddressBooks(nsIFile *pLoc, nsIArray **ppArray) { NS_PRECONDITION(pLoc != nullptr, "null ptr"); NS_PRECONDITION(ppArray != nullptr, "null ptr"); @@ -288,10 +289,9 @@ NS_IMETHODIMP ImportAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISupportsArra m_fileLoc = do_QueryInterface(pLoc); /* Build an address book descriptor based on the file passed in! */ - nsCOMPtr array; - rv = NS_NewISupportsArray(getter_AddRefs(array)); + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); if (NS_FAILED(rv)) { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); + IMPORT_LOG0("FAILED to allocate the nsIMutableArray\n"); return rv; } @@ -324,17 +324,15 @@ NS_IMETHODIMP ImportAddressImpl::FindAddressBooks(nsIFile *pLoc, nsISupportsArra desc->SetSize((uint32_t) sz); desc->SetAbFile(m_fileLoc); rv = desc->QueryInterface(kISupportsIID, (void **) &pInterface); - array->AppendElement(pInterface); + array->AppendElement(pInterface, false); pInterface->Release(); } if (NS_FAILED(rv)) { IMPORT_LOG0("*** Error creating address book descriptor for text import\n"); + return rv; } - else { - rv = array->QueryInterface(NS_GET_IID(nsISupportsArray), (void **) ppArray); - } - - return rv; + array.forget(ppArray); + return NS_OK; } void ImportAddressImpl::ReportSuccess(nsString& name, nsString *pStream, diff --git a/mailnews/import/vcard/src/nsVCardImport.cpp b/mailnews/import/vcard/src/nsVCardImport.cpp index df4fdb73bb..9786beeab7 100644 --- a/mailnews/import/vcard/src/nsVCardImport.cpp +++ b/mailnews/import/vcard/src/nsVCardImport.cpp @@ -17,6 +17,7 @@ #include "nsIImportAddressBooks.h" #include "nsIImportFieldMap.h" #include "nsIImportGeneric.h" +#include "nsIMutableArray.h" #include "nsCOMPtr.h" #include "nsIImportService.h" #include "nsIFile.h" @@ -58,7 +59,7 @@ public: NS_IMETHOD GetDefaultLocation( nsIFile **location, bool *found, bool *userVerify); - NS_IMETHOD FindAddressBooks(nsIFile *location, nsISupportsArray **_retval); + NS_IMETHOD FindAddressBooks(nsIFile *location, nsIArray **_retval); NS_IMETHOD InitFieldMap(nsIImportFieldMap *fieldMap) { return NS_ERROR_FAILURE;} @@ -227,7 +228,7 @@ NS_IMETHODIMP ImportVCardAddressImpl::GetDefaultLocation( } NS_IMETHODIMP ImportVCardAddressImpl::FindAddressBooks( - nsIFile *pLoc, nsISupportsArray **ppArray) + nsIFile *pLoc, nsIArray **ppArray) { NS_ENSURE_ARG_POINTER(pLoc); NS_ENSURE_ARG_POINTER(ppArray); @@ -246,10 +247,9 @@ NS_IMETHODIMP ImportVCardAddressImpl::FindAddressBooks( m_fileLoc = do_QueryInterface(pLoc); /* Build an address book descriptor based on the file passed in! */ - nsCOMPtr array; - rv = NS_NewISupportsArray(getter_AddRefs(array)); + nsCOMPtr array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv)); if (NS_FAILED(rv)) { - IMPORT_LOG0("FAILED to allocate the nsISupportsArray\n"); + IMPORT_LOG0("FAILED to allocate the nsIMutableArray\n"); return rv; } @@ -281,16 +281,16 @@ NS_IMETHODIMP ImportVCardAddressImpl::FindAddressBooks( desc->SetSize((uint32_t) sz); desc->SetAbFile(m_fileLoc); nsCOMPtr pInterface(do_QueryInterface(desc, &rv)); - array->AppendElement(pInterface); + array->AppendElement(pInterface, false); } if (NS_FAILED(rv)) { IMPORT_LOG0( "*** Error creating address book descriptor for vCard import\n"); - } else { - array.swap(*ppArray); + return rv; } - return rv; + array.forget(ppArray); + return NS_OK; } void ImportVCardAddressImpl::ReportSuccess( diff --git a/mailnews/import/winlivemail/nsWMImport.cpp b/mailnews/import/winlivemail/nsWMImport.cpp index 88bdeacbf8..d9fe86e3f7 100644 --- a/mailnews/import/winlivemail/nsWMImport.cpp +++ b/mailnews/import/winlivemail/nsWMImport.cpp @@ -59,8 +59,8 @@ public: /* void GetDefaultLocation (out nsIFile location, out boolean found, out boolean userVerify); */ NS_IMETHOD GetDefaultLocation(nsIFile **location, bool *found, bool *userVerify); - /* nsISupportsArray FindMailboxes (in nsIFile location); */ - NS_IMETHOD FindMailboxes(nsIFile *location, nsISupportsArray **_retval); + /* nsIArray FindMailboxes (in nsIFile location); */ + NS_IMETHOD FindMailboxes(nsIFile *location, nsIArray **_retval); NS_IMETHOD ImportMailbox(nsIImportMailboxDescriptor *source, nsIMsgFolder *dstFolder, @@ -192,7 +192,7 @@ NS_IMETHODIMP ImportWMMailImpl::GetDefaultLocation(nsIFile **ppLoc, bool *found, } NS_IMETHODIMP ImportWMMailImpl::FindMailboxes(nsIFile *pLoc, - nsISupportsArray **ppArray) + nsIArray **ppArray) { return NS_ERROR_NOT_IMPLEMENTED; }