Clean up some mailnews array usage, fix some leaks. Bug 175540, r=dmose,

sr=alecf
This commit is contained in:
bzbarsky%mit.edu 2002-11-21 03:49:11 +00:00
Родитель 34fe8ef195
Коммит c0a8aaf4c5
35 изменённых файлов: 460 добавлений и 748 удалений

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

@ -1459,9 +1459,7 @@ NS_IMETHODIMP nsAbCardProperty::ConvertToXMLPrintData(PRUnichar **aXMLSubstr)
nsXPIDLString displayName;
nsXPIDLString primaryEmail;
for (i = 0; i < total; i++) {
nsCOMPtr <nsISupports> item = getter_AddRefs(addresses->ElementAt(i));
nsCOMPtr <nsIAbCard> listCard = do_QueryInterface(item, &rv);
nsCOMPtr <nsIAbCard> listCard = do_QueryElementAt(addresses, i, &rv);
NS_ENSURE_SUCCESS(rv,rv);
xmlStr.Append(NS_LITERAL_STRING("<PrimaryEmail>\n").get());

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

@ -97,10 +97,8 @@ NS_IMETHODIMP nsAbMDBDirProperty::AddMailListToDirectory(nsIAbDirectory *mailLis
for (i = 0; i < count; i++)
{
nsresult err;
nsCOMPtr<nsISupports> pSupport =
getter_AddRefs(m_AddressList->ElementAt(i));
nsCOMPtr<nsIAbDirectory> pList(do_QueryInterface(pSupport, &err));
if (mailList == pList.get())
nsCOMPtr<nsIAbDirectory> pList(do_QueryElementAt(m_AddressList, i, &err));
if (mailList == pList)
return NS_OK;
}
m_AddressList->AppendElement(mailList);
@ -117,10 +115,8 @@ NS_IMETHODIMP nsAbMDBDirProperty::AddAddressToList(nsIAbCard *card)
for (i = 0; i < count; i++)
{
nsresult err;
nsCOMPtr<nsISupports> pSupport =
getter_AddRefs(m_AddressList->ElementAt(i));
nsCOMPtr<nsIAbCard> pCard(do_QueryInterface(pSupport, &err));
if (card == pCard.get())
nsCOMPtr<nsIAbCard> pCard(do_QueryElementAt(m_AddressList, i, &err));
if (card == pCard)
return NS_OK;
}
m_AddressList->AppendElement(card);

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

@ -110,11 +110,7 @@ nsresult nsAbMDBDirectory::RemoveCardFromAddressList(nsIAbCard* card)
for (i = listTotal - 1; i >= 0; i--)
{
nsCOMPtr<nsISupports> pSupport = getter_AddRefs(m_AddressList->ElementAt(i));
if (!pSupport)
continue;
nsCOMPtr<nsIAbDirectory> listDir(do_QueryInterface(pSupport, &rv));
nsCOMPtr<nsIAbDirectory> listDir(do_QueryElementAt(m_AddressList, i, &rv));
if (listDir)
{
nsCOMPtr <nsISupportsArray> pAddressLists;
@ -125,8 +121,7 @@ nsresult nsAbMDBDirectory::RemoveCardFromAddressList(nsIAbCard* card)
rv = pAddressLists->Count(&total);
for (j = total - 1; j >= 0; j--)
{
nsCOMPtr<nsISupports> pSupport = getter_AddRefs(pAddressLists->ElementAt(j));
nsCOMPtr<nsIAbCard> cardInList(do_QueryInterface(pSupport, &rv));
nsCOMPtr<nsIAbCard> cardInList(do_QueryElementAt(pAddressLists, j, &rv));
PRBool equals;
nsresult rv = cardInList->Equals(card, &equals); // should we checking email?
if (NS_SUCCEEDED(rv) && equals) {
@ -468,11 +463,9 @@ NS_IMETHODIMP nsAbMDBDirectory::DeleteCards(nsISupportsArray *cards)
NS_ENSURE_SUCCESS(rv, rv);
for (i = 0; i < cardCount; i++)
{
nsCOMPtr<nsISupports> cardSupports;
nsCOMPtr<nsIAbCard> card;
nsCOMPtr<nsIAbMDBCard> dbcard;
cardSupports = getter_AddRefs(cards->ElementAt(i));
card = do_QueryInterface(cardSupports, &rv);
card = do_QueryElementAt(cards, i, &rv);
NS_ENSURE_SUCCESS(rv, rv);
dbcard = do_QueryInterface(card, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -487,11 +480,7 @@ NS_IMETHODIMP nsAbMDBDirectory::DeleteCards(nsISupportsArray *cards)
rv = m_AddressList->Count(&cardTotal);
for (i = cardTotal - 1; i >= 0; i--)
{
nsCOMPtr<nsISupports> pSupport = getter_AddRefs(m_AddressList->ElementAt(i));
if (!pSupport)
continue;
nsCOMPtr<nsIAbMDBCard> dbarrayCard(do_QueryInterface(pSupport, &rv));
nsCOMPtr<nsIAbMDBCard> dbarrayCard(do_QueryElementAt(m_AddressList, i, &rv));
if (dbarrayCard)
{
PRUint32 tableID, rowID, cardTableID, cardRowID;

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

@ -1074,9 +1074,7 @@ nsresult nsAbView::ReselectCards(nsISupportsArray *cards, nsIAbCard *indexCard)
NS_ENSURE_SUCCESS(rv, rv);
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> cardSupports;
cardSupports = getter_AddRefs(cards->ElementAt(i));
nsCOMPtr <nsIAbCard> card = do_QueryInterface(cardSupports);
nsCOMPtr <nsIAbCard> card = do_QueryElementAt(cards, i);
if (card) {
PRInt32 index = FindIndexForCard(card);
if (index != CARD_NOT_FOUND) {
@ -1198,8 +1196,7 @@ NS_IMETHODIMP nsAbView::GetSelectedAddresses(nsISupportsArray **_retval)
mailListAddresses->Count(&mailListCount);
for (PRUint32 j = 0; j < mailListCount; j++) {
nsCOMPtr<nsISupports> item = getter_AddRefs(mailListAddresses->ElementAt(j));
nsCOMPtr<nsIAbCard> mailListCard = do_QueryInterface(item, &rv);
nsCOMPtr<nsIAbCard> mailListCard = do_QueryElementAt(mailListAddresses, j, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = mailListCard->GetPrimaryEmail(getter_Copies(primaryEmail));

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

@ -1521,8 +1521,7 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewListCardAndAddToDB(nsIAbDirectory *aList,
PRUint32 i;
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> support = getter_AddRefs(addressList->ElementAt(i));
nsCOMPtr<nsIAbCard> currentCard = do_QueryInterface(support, &rv);
nsCOMPtr<nsIAbCard> currentCard = do_QueryElementAt(addressList, i, &rv);
NS_ENSURE_SUCCESS(rv,rv);
PRBool equals;
@ -1668,8 +1667,7 @@ nsresult nsAddrDatabase::AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIM
total = 0;
for (i = 0; i < count; i++)
{
nsCOMPtr<nsISupports> pSupport = getter_AddRefs(pAddressLists->ElementAt(i));
nsCOMPtr<nsIAbCard> pCard(do_QueryInterface(pSupport, &err));
nsCOMPtr<nsIAbCard> pCard(do_QueryElementAt(pAddressLists, i, &err));
if (NS_FAILED(err))
continue;
@ -1684,8 +1682,7 @@ nsresult nsAddrDatabase::AddListAttributeColumnsToRow(nsIAbDirectory *list, nsIM
PRUint32 pos;
for (i = 0; i < count; i++)
{
nsCOMPtr<nsISupports> pSupport = getter_AddRefs(pAddressLists->ElementAt(i));
nsCOMPtr<nsIAbCard> pCard(do_QueryInterface(pSupport, &err));
nsCOMPtr<nsIAbCard> pCard(do_QueryElementAt(pAddressLists, i, &err));
if (NS_FAILED(err))
continue;

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

@ -1664,9 +1664,7 @@ nsresult nsAddressBook::AppendLDIFForMailList(nsIAbCard *aCard, nsACString &aRes
if (total) {
PRUint32 i;
for (i = 0; i < total; i++) {
nsCOMPtr <nsISupports> item = getter_AddRefs(addresses->ElementAt(i));
nsCOMPtr <nsIAbCard> listCard = do_QueryInterface(item, &rv);
nsCOMPtr <nsIAbCard> listCard = do_QueryElementAt(addresses, i, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = AppendDNForCard("member", listCard, aResult);

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

@ -365,8 +365,7 @@ nsAbDirectoryDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/*
PRUint32 i, cnt;
rv = aSources->Count(&cnt);
for (i = 0; i < cnt; i++) {
nsCOMPtr<nsISupports> source = getter_AddRefs(aSources->ElementAt(i));
directory = do_QueryInterface(source, &rv);
directory = do_QueryElementAt(aSources, i, &rv);
if (NS_SUCCEEDED(rv)) {
// we don't care about the arguments -- directory commands are always enabled
if (!((aCommand == kNC_Delete) || (aCommand == kNC_DeleteCards))) {
@ -392,8 +391,7 @@ nsAbDirectoryDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSource
rv = DoDeleteFromDirectory(aSources, aArguments);
else {
for (i = 0; i < cnt; i++) {
nsCOMPtr<nsISupports> supports = getter_AddRefs(aSources->ElementAt(i));
nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIAbDirectory> directory = do_QueryElementAt(aSources, i, &rv);
if (NS_SUCCEEDED(rv)) {
NS_ASSERTION(aCommand == kNC_DeleteCards, "unknown command");
if ((aCommand == kNC_DeleteCards))
@ -561,11 +559,12 @@ nsAbDirectoryDataSource::createDirectoryChildNode(nsIAbDirectory *directory,
}
PRUint32 i;
NS_ASSERTION(total <= 1, "This code probably leaks. Please break out of the loop or something, ok?");
for (i = 0; i < total; i++)
{
nsCOMPtr<nsISupports> mailList = getter_AddRefs(pAddressLists->ElementAt(i));
nsCOMPtr<nsIRDFResource> mailList = do_QueryElementAt(pAddressLists, i);
if (mailList)
mailList->QueryInterface(NS_GET_IID(nsIRDFResource), (void**)target);
NS_ADDREF(*target = mailList);
else
return NS_RDF_NO_VALUE;
}
@ -638,12 +637,10 @@ nsresult nsAbDirectoryDataSource::DoDeleteFromDirectory(nsISupportsArray *parent
for (item = 0; item < itemCount; item++)
{
nsCOMPtr<nsISupports> supports = getter_AddRefs(parentDirs->ElementAt(item));
nsCOMPtr<nsIAbDirectory> parent = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIAbDirectory> parent = do_QueryElementAt(parentDirs, item, &rv);
if (NS_SUCCEEDED(rv))
{
supports = getter_AddRefs(delDirs->ElementAt(item));
nsCOMPtr<nsIAbDirectory> deletedDir(do_QueryInterface(supports));
nsCOMPtr<nsIAbDirectory> deletedDir(do_QueryElementAt(delDirs, item));
if(deletedDir)
{
rv = parent->DeleteDirectory(deletedDir);

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

@ -1018,7 +1018,7 @@ NS_IMETHODIMP nsMsgFilterList::MatchOrChangeFilterTarget(const char *oldFolderUr
nsXPIDLCString folderUri;
for (PRUint32 index = 0; index < numFilters; index++)
{
rv = m_filters->QueryElementAt(index, NS_GET_IID(nsIMsgFilter), (void **)getter_AddRefs(filter));
filter = do_QueryElementAt(m_filters, index, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsArray> filterActionList;
@ -1028,8 +1028,8 @@ NS_IMETHODIMP nsMsgFilterList::MatchOrChangeFilterTarget(const char *oldFolderUr
for (PRUint32 actionIndex =0; actionIndex < numActions; actionIndex++)
{
nsCOMPtr<nsIMsgRuleAction> filterAction;
filterActionList->QueryElementAt(actionIndex, NS_GET_IID(nsIMsgRuleAction), (void **)getter_AddRefs(filterAction));
nsCOMPtr<nsIMsgRuleAction> filterAction =
do_QueryElementAt(filterActionList, actionIndex);
nsMsgRuleActionType actionType;
if (filterAction)
filterAction->GetType(&actionType);
@ -1085,13 +1085,11 @@ nsresult nsMsgFilterList::ComputeArbitraryHeaders()
rv = m_filters->Count(&numFilters);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIMsgFilter> filter;
nsCOMPtr <nsISupports> filterSupports;
nsMsgSearchAttribValue attrib;
nsXPIDLCString arbitraryHeader;
for (PRUint32 index = 0; index < numFilters; index++)
{
filterSupports = getter_AddRefs(m_filters->ElementAt(index));
filter = do_QueryInterface(filterSupports, &rv);
filter = do_QueryElementAt(m_filters, index, &rv);
if (NS_SUCCEEDED(rv) && filter)
{
nsCOMPtr <nsISupportsArray> searchTerms;

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

@ -724,21 +724,13 @@ nsMsgSearchSession::EnableFolderNotifications(PRBool aEnable)
NS_IMETHODIMP
nsMsgSearchSession::AddFolderListener(nsIFolderListener *listener)
{
nsresult rv = NS_OK;
if (!m_folderListenerList)
rv = NS_NewISupportsArray(getter_AddRefs(m_folderListenerList));
if (NS_SUCCEEDED(rv) && m_folderListenerList)
m_folderListenerList->AppendElement(listener);
return rv;
return m_folderListenerList.AppendObject(listener) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMsgSearchSession::RemoveFolderListener(nsIFolderListener *listener)
{
if (m_folderListenerList)
m_folderListenerList->RemoveElement(listener);
m_folderListenerList.RemoveObject(listener);
return NS_OK;
}
@ -748,18 +740,11 @@ NS_IMETHODIMP
nsMsgSearchSession::OnItemEvent(nsIFolder *aFolder,
nsIAtom *aEvent)
{
nsresult rv;
PRUint32 count;
PRInt32 count = m_folderListenerList.Count();
NS_ASSERTION(m_folderListenerList, "no listeners");
if (!m_folderListenerList) return NS_ERROR_FAILURE;
rv = m_folderListenerList->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)m_folderListenerList->ElementAt(i));
nsIFolderListener* listener = m_folderListenerList[i];
if(listener)
listener->OnItemEvent(aFolder, aEvent);
}

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

@ -47,6 +47,7 @@
#include "nsITimer.h"
#include "nsMsgSearchArray.h"
#include "nsISupportsArray.h"
#include "nsCOMArray.h"
#include "nsWeakReference.h"
class nsMsgSearchAdapter;
@ -83,7 +84,7 @@ protected:
nsMsgSearchScopeTermArray m_scopeList;
nsCOMPtr <nsISupportsArray> m_termList;
nsCOMPtr <nsISupportsArray> m_listenerList;
nsCOMPtr <nsISupportsArray> m_folderListenerList;
nsCOMArray<nsIFolderListener> m_folderListenerList;
nsMsgResultArray m_resultList;

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

@ -181,9 +181,6 @@ nsresult nsMsgAccountManager::Init()
rv = NS_NewISupportsArray(getter_AddRefs(m_accounts));
if(NS_FAILED(rv)) return rv;
rv = NS_NewISupportsArray(getter_AddRefs(m_incomingServerListeners));
if(NS_FAILED(rv)) return rv;
rv = NS_NewISupportsArray(getter_AddRefs(mFolderListeners));
nsCOMPtr<nsIObserverService> observerService =
@ -661,8 +658,7 @@ nsMsgAccountManager::RemoveAccount(nsIMsgAccount *aAccount)
NS_ENSURE_SUCCESS(rv,rv);
for (PRUint32 i=0; i< cnt;i++)
{
nsCOMPtr<nsISupports> supports = getter_AddRefs(allDescendents->ElementAt(i));
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(allDescendents, i, &rv);
folder->ForceDBClosed();
}
@ -1753,29 +1749,24 @@ nsMsgAccountManager::findAccountByKey(nsISupports* element, void *aData)
NS_IMETHODIMP nsMsgAccountManager::AddIncomingServerListener(nsIIncomingServerListener *serverListener)
{
m_incomingServerListeners->AppendElement(serverListener);
m_incomingServerListeners.AppendObject(serverListener);
return NS_OK;
}
NS_IMETHODIMP nsMsgAccountManager::RemoveIncomingServerListener(nsIIncomingServerListener *serverListener)
{
m_incomingServerListeners->RemoveElement(serverListener);
m_incomingServerListeners.RemoveObject(serverListener);
return NS_OK;
}
NS_IMETHODIMP nsMsgAccountManager::NotifyServerLoaded(nsIMsgIncomingServer *server)
{
nsresult rv;
PRUint32 count;
rv = m_incomingServerListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
PRInt32 count = m_incomingServerListeners.Count();
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
nsCOMPtr<nsIIncomingServerListener> listener =
getter_AddRefs((nsIIncomingServerListener*)m_incomingServerListeners->ElementAt(i));
nsIIncomingServerListener* listener = m_incomingServerListeners[i];
listener->OnServerLoaded(server);
}
@ -1784,17 +1775,12 @@ NS_IMETHODIMP nsMsgAccountManager::NotifyServerLoaded(nsIMsgIncomingServer *serv
NS_IMETHODIMP nsMsgAccountManager::NotifyServerUnloaded(nsIMsgIncomingServer *server)
{
nsresult rv;
PRUint32 count;
server->SetFilterList(nsnull); // clear this to cut shutdown leaks. we are always passing valid non-null server here.
rv = m_incomingServerListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
PRInt32 count = m_incomingServerListeners.Count();
server->SetFilterList(nsnull); // clear this to cut shutdown leaks. we are always passing valid non-null server here.
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
nsCOMPtr<nsIIncomingServerListener> listener =
getter_AddRefs((nsIIncomingServerListener*)m_incomingServerListeners->ElementAt(i));
nsIIncomingServerListener* listener = m_incomingServerListeners[i];
listener->OnServerUnloaded(server);
}
@ -1803,16 +1789,11 @@ NS_IMETHODIMP nsMsgAccountManager::NotifyServerUnloaded(nsIMsgIncomingServer *se
NS_IMETHODIMP nsMsgAccountManager::NotifyServerChanged(nsIMsgIncomingServer *server)
{
nsresult rv;
PRUint32 count;
rv = m_incomingServerListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
PRInt32 count = m_incomingServerListeners.Count();
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
nsCOMPtr<nsIIncomingServerListener> listener =
getter_AddRefs((nsIIncomingServerListener*)m_incomingServerListeners->ElementAt(i));
nsIIncomingServerListener* listener = m_incomingServerListeners[i];
listener->OnServerChanged(server);
}

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

@ -37,6 +37,7 @@
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsIUrlListener.h"
#include "nsCOMArray.h"
class nsMsgAccountManager
: public nsIMsgAccountManager,
@ -70,7 +71,7 @@ private:
nsHashtable m_identities;
nsHashtable m_incomingServers;
nsCOMPtr<nsIMsgAccount> m_defaultAccount;
nsCOMPtr<nsISupportsArray> m_incomingServerListeners;
nsCOMArray<nsIIncomingServerListener> m_incomingServerListeners;
nsCOMPtr<nsIMsgFolder> m_folderDoingEmptyTrash;
nsCOMPtr<nsIMsgFolder> m_folderDoingCleanupInbox;
PRBool m_emptyTrashInProgress;

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

@ -282,10 +282,8 @@ nsMsgCopyService::DoNextCopy()
nsCOMPtr<nsIMsgDBHdr> aMessage;
if (copySource)
{
nsCOMPtr<nsISupports> aSupport;
aSupport =
getter_AddRefs(copySource->m_messageArray->ElementAt(0));
aMessage = do_QueryInterface(aSupport, &rv);
aMessage = do_QueryElementAt(copySource->m_messageArray,
0, &rv);
copySource->m_processed = PR_TRUE;
}
copyRequest->m_processed = PR_TRUE;
@ -341,7 +339,7 @@ nsMsgCopyService::CopyMessages(nsIMsgFolder* srcFolder, /* UI src folder */
nsCopyRequest* copyRequest;
nsCopySource* copySource = nsnull;
nsCOMPtr<nsISupportsArray> msgArray;
PRUint32 i, cnt;
PRUint32 cnt;
nsCOMPtr<nsIMsgDBHdr> msg;
nsCOMPtr<nsIMsgFolder> curFolder;
nsCOMPtr<nsISupports> aSupport;
@ -366,11 +364,7 @@ nsMsgCopyService::CopyMessages(nsIMsgFolder* srcFolder, /* UI src folder */
// duplicate the message array so we could sort the messages by it's
// folder easily
for (i=0; i<cnt; i++)
{
aSupport = getter_AddRefs(messages->ElementAt(i));
msgArray->AppendElement(aSupport);
}
msgArray->AppendElements(messages);
rv = msgArray->Count(&cnt);
if (NS_FAILED(rv))
@ -378,8 +372,7 @@ nsMsgCopyService::CopyMessages(nsIMsgFolder* srcFolder, /* UI src folder */
while (cnt-- > 0)
{
aSupport = getter_AddRefs(msgArray->ElementAt(cnt));
msg = do_QueryInterface(aSupport, &rv);
msg = do_QueryElementAt(msgArray, cnt, &rv);
if (NS_FAILED(rv))
goto done;

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

@ -2686,9 +2686,9 @@ nsresult nsMsgDBView::ReverseSort()
{
// swap folders --
// needed when search is done across multiple folders
nsCOMPtr <nsISupports> tmpSupports
= getter_AddRefs(folders->ElementAt(i));
folders->SetElementAt(i, folders->ElementAt(end));
nsCOMPtr<nsISupports> tmpSupports = dont_AddRef(folders->ElementAt(i));
nsCOMPtr<nsISupports> endSupports = dont_AddRef(folders->ElementAt(end));
folders->SetElementAt(i, endSupports);
folders->SetElementAt(end, tmpSupports);
}
// no need to swap elements in m_levels,
@ -3227,11 +3227,8 @@ NS_IMETHODIMP nsMsgDBView::Sort(nsMsgViewSortTypeValue sortType, nsMsgViewSortOr
if (folders)
{
nsCOMPtr <nsISupports> tmpSupports
= getter_AddRefs(folders->ElementAt(numSoFar));
nsCOMPtr<nsIMsgFolder> curFolder;
if(tmpSupports) {
curFolder = do_QueryInterface(tmpSupports);
nsCOMPtr<nsIMsgFolder> curFolder = do_QueryElementAt(folders, numSoFar);;
if(curFolder) {
info->folder = curFolder;
}
}

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

@ -172,8 +172,8 @@ NS_IMETHODIMP nsFolderCompactState::CompactAll(nsISupportsArray *aArrayOfFolders
m_offlineFolderArray = do_QueryInterface(aOfflineFolderArray);
m_folderIndex = 0;
nsCOMPtr<nsISupports> supports = getter_AddRefs(m_folderArray->ElementAt(m_folderIndex));
nsCOMPtr<nsIMsgFolder> firstFolder = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIMsgFolder> firstFolder = do_QueryElementAt(m_folderArray,
m_folderIndex, &rv);
if (NS_SUCCEEDED(rv) && firstFolder)
Compact(firstFolder, aMsgWindow); //start with first folder from here.
@ -437,8 +437,8 @@ nsFolderCompactState::CompactNextFolder()
{
if (m_compactOfflineAlso)
{
nsCOMPtr<nsISupports> supports = getter_AddRefs(m_folderArray->ElementAt(m_folderIndex-1));
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(m_folderArray,
m_folderIndex-1, &rv);
if (NS_SUCCEEDED(rv) && folder)
folder->CompactAllOfflineStores(m_window, m_offlineFolderArray);
}
@ -446,8 +446,8 @@ nsFolderCompactState::CompactNextFolder()
return rv;
}
nsCOMPtr<nsISupports> supports = getter_AddRefs(m_folderArray->ElementAt(m_folderIndex));
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(m_folderArray,
m_folderIndex, &rv);
if (NS_SUCCEEDED(rv) && folder)
rv = Compact(folder, m_window);

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

@ -701,8 +701,7 @@ nsMsgFolderDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aS
rv = aSources->Count(&cnt);
if (NS_FAILED(rv)) return rv;
for (PRUint32 i = 0; i < cnt; i++) {
nsCOMPtr<nsISupports> source = getter_AddRefs(aSources->ElementAt(i));
folder = do_QueryInterface(source, &rv);
folder = do_QueryElementAt(aSources, i, &rv);
if (NS_SUCCEEDED(rv)) {
// we don't care about the arguments -- folder commands are always enabled
if (!((aCommand == kNC_Delete) ||
@ -745,8 +744,7 @@ nsMsgFolderDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
if (NS_FAILED(rv)) return rv;
for ( ; i < cnt; i++) {
supports = getter_AddRefs(aSources->ElementAt(i));
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(aSources, i, &rv);
if (NS_SUCCEEDED(rv))
{
if ((aCommand == kNC_Delete))
@ -799,8 +797,7 @@ nsMsgFolderDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
}
else if ((aCommand == kNC_Rename))
{
nsCOMPtr<nsISupports> elem = getter_AddRefs(aArguments->ElementAt(0));
nsCOMPtr<nsIRDFLiteral> literal = do_QueryInterface(elem, &rv);
nsCOMPtr<nsIRDFLiteral> literal = do_QueryElementAt(aArguments, 0, &rv);
if(NS_SUCCEEDED(rv))
{
nsXPIDLString name;
@ -1991,8 +1988,7 @@ nsresult nsMsgFolderDataSource::DoCopyToFolder(nsIMsgFolder *dstFolder, nsISuppo
return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> srcFolderSupports = getter_AddRefs(arguments->ElementAt(0));
nsCOMPtr<nsIMsgFolder> srcFolder(do_QueryInterface(srcFolderSupports));
nsCOMPtr<nsIMsgFolder> srcFolder(do_QueryElementAt(arguments, 0));
if(!srcFolder)
return NS_ERROR_FAILURE;
@ -2052,12 +2048,10 @@ nsresult nsMsgFolderDataSource::DoFolderCopyToFolder(nsIMsgFolder *dstFolder, ns
else //within the same server therefore no need for copy service
{
nsCOMPtr<nsISupports> supports;
nsCOMPtr<nsIMsgFolder> msgFolder;
for (PRUint32 i=0;i< itemCount; i++)
{
supports = getter_AddRefs(arguments->ElementAt(i));
msgFolder = do_QueryInterface(supports,&rv);
msgFolder = do_QueryElementAt(arguments, i, &rv);
if (NS_SUCCEEDED(rv))
{
rv = dstFolder->CopyFolder(msgFolder, isMoveFolder , msgWindow, nsnull);
@ -2116,8 +2110,7 @@ nsresult nsMsgFolderDataSource::DoDeleteFromFolder(
nsresult nsMsgFolderDataSource::DoNewFolder(nsIMsgFolder *folder, nsISupportsArray *arguments)
{
nsresult rv = NS_OK;
nsCOMPtr<nsISupports> elem = getter_AddRefs(arguments->ElementAt(0));
nsCOMPtr<nsIRDFLiteral> literal = do_QueryInterface(elem, &rv);
nsCOMPtr<nsIRDFLiteral> literal = do_QueryElementAt(arguments, 0, &rv);
if(NS_SUCCEEDED(rv))
{
nsXPIDLString name;

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

@ -78,12 +78,7 @@ nsMsgMailSession::~nsMsgMailSession()
nsresult nsMsgMailSession::Init()
{
nsresult rv = NS_NewISupportsArray(getter_AddRefs(mListeners));
if(NS_FAILED(rv))
return rv;
rv = NS_NewISupportsArray(getter_AddRefs(mWindows));
return rv;
return NS_NewISupportsArray(getter_AddRefs(mWindows));
}
nsresult nsMsgMailSession::Shutdown()
@ -93,27 +88,19 @@ nsresult nsMsgMailSession::Shutdown()
NS_IMETHODIMP nsMsgMailSession::AddFolderListener(nsIFolderListener * listener, PRUint32 notifyFlags)
{
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
mListeners->AppendElement(listener);
mListeners.AppendObject(listener);
mListenerNotifyFlags.Add(notifyFlags);
return NS_OK;
}
NS_IMETHODIMP nsMsgMailSession::RemoveFolderListener(nsIFolderListener * listener)
{
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
PRInt32 index;
nsresult rv = mListeners->GetIndexOf(listener, &index);
NS_ENSURE_SUCCESS(rv,rv);
PRInt32 index = mListeners.IndexOf(listener);
NS_ASSERTION(index >= 0, "removing non-existent listener");
if (index >= 0)
{
mListenerNotifyFlags.RemoveAt(index);
mListeners->RemoveElement(listener);
mListeners.RemoveObjectAt(index);
}
return NS_OK;
@ -125,26 +112,18 @@ nsMsgMailSession::OnItemPropertyChanged(nsISupports *item,
const char* oldValue,
const char* newValue)
{
nsresult rv;
PRUint32 count;
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
PRInt32 count = mListeners.Count();
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::propertyChanged) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemPropertyChanged(item, property, oldValue, newValue);
}
if (mListenerNotifyFlags[i] & nsIFolderListener::propertyChanged) {
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemPropertyChanged(item, property, oldValue, newValue);
}
}
return NS_OK;
}
@ -155,24 +134,16 @@ nsMsgMailSession::OnItemUnicharPropertyChanged(nsISupports *item,
const PRUnichar* oldValue,
const PRUnichar* newValue)
{
nsresult rv;
PRUint32 count;
PRInt32 count = mListeners.Count();
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::unicharPropertyChanged) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemUnicharPropertyChanged(item, property, oldValue, newValue);
}
if (mListenerNotifyFlags[i] & nsIFolderListener::unicharPropertyChanged) {
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemUnicharPropertyChanged(item, property, oldValue, newValue);
}
}
return NS_OK;
@ -185,24 +156,16 @@ nsMsgMailSession::OnItemIntPropertyChanged(nsISupports *item,
PRInt32 oldValue,
PRInt32 newValue)
{
nsresult rv;
PRUint32 count;
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
PRInt32 count = mListeners.Count();
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::intPropertyChanged) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemIntPropertyChanged(item, property, oldValue, newValue);
}
if (mListenerNotifyFlags[i] & nsIFolderListener::intPropertyChanged) {
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemIntPropertyChanged(item, property, oldValue, newValue);
}
}
return NS_OK;
@ -215,24 +178,16 @@ nsMsgMailSession::OnItemBoolPropertyChanged(nsISupports *item,
PRBool oldValue,
PRBool newValue)
{
nsresult rv;
PRUint32 count;
PRInt32 count = mListeners.Count();
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::boolPropertyChanged) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemBoolPropertyChanged(item, property, oldValue, newValue);
}
if (mListenerNotifyFlags[i] & nsIFolderListener::boolPropertyChanged) {
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemBoolPropertyChanged(item, property, oldValue, newValue);
}
}
return NS_OK;
@ -244,19 +199,12 @@ nsMsgMailSession::OnItemPropertyFlagChanged(nsISupports *item,
PRUint32 oldValue,
PRUint32 newValue)
{
nsresult rv;
PRUint32 count;
PRInt32 count = mListeners.Count();
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::propertyFlagChanged) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemPropertyFlagChanged(item, property, oldValue, newValue);
@ -268,24 +216,15 @@ nsMsgMailSession::OnItemPropertyFlagChanged(nsISupports *item,
NS_IMETHODIMP nsMsgMailSession::OnItemAdded(nsISupports *parentItem, nsISupports *item, const char* viewString)
{
nsresult rv;
PRUint32 count;
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
PRInt32 count = mListeners.Count();
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::added) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemAdded(parentItem, item, viewString);
}
if (mListenerNotifyFlags[i] & nsIFolderListener::added) {
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemAdded(parentItem, item, viewString);
}
}
return NS_OK;
@ -294,24 +233,16 @@ NS_IMETHODIMP nsMsgMailSession::OnItemAdded(nsISupports *parentItem, nsISupports
NS_IMETHODIMP nsMsgMailSession::OnItemRemoved(nsISupports *parentItem, nsISupports *item, const char* viewString)
{
nsresult rv;
PRUint32 count;
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
PRInt32 count = mListeners.Count();
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::removed) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemRemoved(parentItem, item, viewString);
}
if (mListenerNotifyFlags[i] & nsIFolderListener::removed) {
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
NS_ASSERTION(listener, "listener is null");
if (!listener) return NS_ERROR_FAILURE;
listener->OnItemRemoved(parentItem, item, viewString);
}
}
return NS_OK;
@ -321,22 +252,15 @@ NS_IMETHODIMP nsMsgMailSession::OnItemRemoved(nsISupports *parentItem, nsISuppor
NS_IMETHODIMP nsMsgMailSession::OnItemEvent(nsIFolder *aFolder,
nsIAtom *aEvent)
{
nsresult rv;
PRUint32 count;
PRInt32 count = mListeners.Count();
NS_ASSERTION(mListeners, "no listeners");
if (!mListeners) return NS_ERROR_FAILURE;
rv = mListeners->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIFolderListener::event) {
nsCOMPtr<nsIFolderListener> listener = getter_AddRefs((nsIFolderListener*)mListeners->ElementAt(i));
if(listener)
listener->OnItemEvent(aFolder, aEvent);
}
if (mListenerNotifyFlags[i] & nsIFolderListener::event) {
nsCOMPtr<nsIFolderListener> listener = mListeners[i];
if(listener)
listener->OnItemEvent(aFolder, aEvent);
}
}
return NS_OK;
}
@ -355,13 +279,11 @@ nsresult nsMsgMailSession::GetTopmostMsgWindow(nsIMsgWindow* *aMsgWindow)
rv = mWindows->Count(&count);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupports> windowSupports;
nsCOMPtr<nsIMsgWindow> msgWindow;
if (count == 1)
{
windowSupports = getter_AddRefs(mWindows->ElementAt(0));
msgWindow = do_QueryInterface(windowSupports, &rv);
msgWindow = do_QueryElementAt(mWindows, 0, &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*aMsgWindow = msgWindow);
}
@ -428,8 +350,7 @@ nsresult nsMsgMailSession::GetTopmostMsgWindow(nsIMsgWindow* *aMsgWindow)
nsCOMPtr<nsIDocShell> docShell;
while (count)
{
windowSupports = getter_AddRefs(mWindows->ElementAt(count - 1));
msgWindow = do_QueryInterface(windowSupports, &rv);
msgWindow = do_QueryElementAt(mWindows, count-1, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = msgWindow->GetRootDocShell(getter_AddRefs(docShell));

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

@ -43,7 +43,7 @@
#include "nsCOMPtr.h"
#include "nsIMsgStatusFeedback.h"
#include "nsIMsgWindow.h"
#include "nsISupportsArray.h"
#include "nsCOMArray.h"
///////////////////////////////////////////////////////////////////////////////////
// The mail session is a replacement for the old 4.x MSG_Master object. It contains
@ -69,7 +69,7 @@ public:
nsresult GetSelectedLocaleDataDir(nsIFile *defaultsDir);
protected:
nsCOMPtr<nsISupportsArray> mListeners;
nsCOMArray<nsIFolderListener> mListeners;
nsUInt32Array mListenerNotifyFlags;
nsCOMPtr<nsISupportsArray> mWindows;

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

@ -439,10 +439,7 @@ nsMsgRDFDataSource::GetTransactionManager(nsISupportsArray *aSources, nsITransac
if (cnt > 0)
{
nsCOMPtr<nsISupports> supports;
supports = getter_AddRefs(aSources->ElementAt(0));
transactionManager = do_QueryInterface(supports, &rv);
transactionManager = do_QueryElementAt(aSources, 0, &rv);
if (NS_SUCCEEDED(rv) && transactionManager)
{
aSources->RemoveElementAt(0);

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

@ -69,9 +69,6 @@ NS_IMETHODIMP nsMsgSearchDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeVal
m_folders = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
m_dbToUseList = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsMsgDBView::Open(folder, sortType, sortOrder, viewFlags, aTreatRecipientAsAuthor, pCount);
NS_ENSURE_SUCCESS(rv, rv);
@ -82,18 +79,11 @@ NS_IMETHODIMP nsMsgSearchDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeVal
NS_IMETHODIMP nsMsgSearchDBView::Close()
{
nsresult rv;
PRUint32 count;
PRInt32 count = m_dbToUseList.Count();
NS_ASSERTION(m_dbToUseList, "no db used");
//if (!m_dbToUseList) return NS_ERROR_FAILURE;
rv = m_dbToUseList->Count(&count);
if (NS_FAILED(rv)) return rv;
for(PRUint32 i = 0; i < count; i++)
for(PRInt32 i = 0; i < count; i++)
{
((nsIMsgDatabase*)m_dbToUseList->ElementAt(i))->RemoveListener(this);
m_dbToUseList[i]->RemoveListener(this);
}
return NS_OK;
}
@ -131,11 +121,8 @@ nsresult nsMsgSearchDBView::OnNewHeader(nsMsgKey newKey, nsMsgKey aParentKey, PR
nsresult nsMsgSearchDBView::GetMsgHdrForViewIndex(nsMsgViewIndex index, nsIMsgDBHdr **msgHdr)
{
nsresult rv = NS_MSG_INVALID_DBVIEW_INDEX;
nsCOMPtr <nsISupports> supports = getter_AddRefs(m_folders->ElementAt(index));
if(supports)
{
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports);
if (folder)
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(m_folders, index);
if (folder)
{
nsCOMPtr <nsIMsgDatabase> db;
rv = folder->GetMsgDatabase(mMsgWindow, getter_AddRefs(db));
@ -143,7 +130,6 @@ nsresult nsMsgSearchDBView::GetMsgHdrForViewIndex(nsMsgViewIndex index, nsIMsgDB
if (db)
rv = db->GetMsgHdrForKey(m_keys.GetAt(index), msgHdr);
}
}
return rv;
}
@ -177,8 +163,7 @@ nsMsgSearchDBView::OnSearchHit(nsIMsgDBHdr* aMsgHdr, nsIMsgFolder *folder)
if (dbToUse)
{
dbToUse->AddListener(this);
nsCOMPtr <nsISupports> dbSupports = do_QueryInterface(dbToUse);
m_dbToUseList->AppendElement(dbSupports);
m_dbToUseList.AppendObject(dbToUse);
}
}
@ -205,8 +190,7 @@ nsMsgSearchDBView::OnSearchDone(nsresult status)
//message after deletion will happen before deleting the message and search scope
//can change with every search.
mDeleteModel = nsMsgImapDeleteModels::MoveToTrash; //set to default in case it is non-imap folder
nsCOMPtr <nsISupports> curSupports = getter_AddRefs(m_folders->ElementAt(0));
nsCOMPtr <nsIMsgFolder> curFolder = do_QueryInterface(curSupports);
nsCOMPtr <nsIMsgFolder> curFolder = do_QueryElementAt(m_folders, 0);
if (curFolder)
GetImapDeleteModel(curFolder);
return NS_OK;
@ -219,11 +203,11 @@ nsMsgSearchDBView::OnNewSearch()
{
PRInt32 oldSize = GetSize();
PRUint32 count=0;
m_dbToUseList->Count(&count);
for(PRUint32 j = 0; j < count; j++)
((nsIMsgDatabase*)m_dbToUseList->ElementAt(j))->RemoveListener(this);
m_dbToUseList->Clear();
PRInt32 count = m_dbToUseList.Count();
for(PRInt32 j = 0; j < count; j++) {
m_dbToUseList[j]->RemoveListener(this);
}
m_dbToUseList.Clear();
m_folders->Clear();
m_keys.RemoveAll();
@ -333,14 +317,14 @@ nsMsgSearchDBView::InitializeGlobalsForDeleteAndFile(nsMsgViewIndex *indices, PR
NS_ENSURE_SUCCESS(rv,rv);
for (PRUint32 folderIndex=0; folderIndex < numFolders; folderIndex++)
{
nsCOMPtr <nsISupports> curSupports = getter_AddRefs(m_uniqueFoldersSelected->ElementAt(folderIndex));
nsCOMPtr <nsIMsgFolder> curFolder = do_QueryInterface(curSupports, &rv);
nsCOMPtr <nsIMsgFolder> curFolder =
do_QueryElementAt(m_uniqueFoldersSelected, folderIndex, &rv);
nsCOMPtr <nsISupportsArray> msgHdrsForOneFolder;
NS_NewISupportsArray(getter_AddRefs(msgHdrsForOneFolder));
for (nsMsgViewIndex i = 0; i < (nsMsgViewIndex) numIndices; i++)
{
nsCOMPtr <nsISupports> folderSupports = getter_AddRefs(m_folders->ElementAt(indices[i]));
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(folderSupports, &rv);
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryElementAt(m_folders,
indices[i], &rv);
if (NS_SUCCEEDED(rv) && msgFolder && msgFolder == curFolder)
{
nsCOMPtr<nsIMsgDBHdr> msgHdr;
@ -409,12 +393,12 @@ nsresult nsMsgSearchDBView::ProcessRequestsInOneFolder(nsIMsgWindow *window)
{
nsresult rv = NS_OK;
nsCOMPtr <nsISupports> curSupports = getter_AddRefs(m_uniqueFoldersSelected->ElementAt(mCurIndex));
NS_ASSERTION(curSupports, "curSupports is null");
nsCOMPtr<nsIMsgFolder> curFolder = do_QueryInterface(curSupports);
nsCOMPtr <nsISupports> msgSupports = getter_AddRefs(m_hdrsForEachFolder->ElementAt(mCurIndex));
NS_ASSERTION(msgSupports, "msgSupports is null");
nsCOMPtr <nsISupportsArray> messageArray = do_QueryInterface(msgSupports);
nsCOMPtr<nsIMsgFolder> curFolder =
do_QueryElementAt(m_uniqueFoldersSelected, mCurIndex);
NS_ASSERTION(curFolder, "curFolder is null");
nsCOMPtr <nsISupportsArray> messageArray =
do_QueryElementAt(m_hdrsForEachFolder, mCurIndex);
NS_ASSERTION(messageArray, "messageArray is null");
// called for delete with trash, copy and move
if (mCommand == nsMsgViewCommandType::deleteMsg)
@ -444,13 +428,13 @@ nsresult nsMsgSearchDBView::ProcessRequestsInAllFolders(nsIMsgWindow *window)
NS_ENSURE_SUCCESS(rv,rv);
for (PRUint32 folderIndex=0; folderIndex < numFolders; folderIndex++)
{
nsCOMPtr <nsISupports> curSupports = getter_AddRefs(m_uniqueFoldersSelected->ElementAt(folderIndex));
NS_ASSERTION (curSupports, "curSupports is null");
nsCOMPtr<nsIMsgFolder> curFolder = do_QueryInterface(curSupports);
nsCOMPtr<nsIMsgFolder> curFolder =
do_QueryElementAt(m_uniqueFoldersSelected, folderIndex);
NS_ASSERTION (curFolder, "curFolder is null");
nsCOMPtr <nsISupports> msgSupports = getter_AddRefs(m_hdrsForEachFolder->ElementAt(folderIndex));
NS_ASSERTION(msgSupports, "msgSupports is null");
nsCOMPtr <nsISupportsArray> messageArray = do_QueryInterface(msgSupports);
nsCOMPtr <nsISupportsArray> messageArray =
do_QueryElementAt(m_hdrsForEachFolder, folderIndex);
NS_ASSERTION(messageArray, "messageArray is null");
curFolder->DeleteMessages(messageArray, window, PR_TRUE /* delete storage */, PR_FALSE /* is move*/, nsnull/*copyServListener*/, PR_FALSE /*allowUndo*/ );
}

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

@ -41,6 +41,7 @@
#include "nsMsgDBView.h"
#include "nsIMsgCopyServiceListener.h"
#include "nsIMsgSearchNotify.h"
#include "nsCOMArray.h"
class nsMsgSearchDBView : public nsMsgDBView, public nsIMsgCopyServiceListener, public nsIMsgSearchNotify
{
@ -85,7 +86,7 @@ protected:
nsMsgViewIndex* mIndicesForChainedDeleteAndFile;
nsUInt32Array* mTestIndices;
PRInt32 mTotalIndices;
nsCOMPtr <nsISupportsArray> m_dbToUseList;
nsCOMArray<nsIMsgDatabase> m_dbToUseList;
nsMsgViewCommandTypeValue mCommand;
nsCOMPtr <nsIMsgFolder> mDestFolder;
nsresult ProcessRequestsInOneFolder(nsIMsgWindow *window);

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

@ -128,13 +128,9 @@ NS_IMETHODIMP nsMsgDBFolder::Shutdown(PRBool shutdownChildren)
{
for (PRUint32 i = 0; i < count; i++)
{
nsCOMPtr<nsISupports> childFolderSupports = getter_AddRefs(mSubFolders->ElementAt(i));
if(childFolderSupports)
{
nsCOMPtr<nsIFolder> childFolder = do_QueryInterface(childFolderSupports);
if(childFolder)
childFolder->Shutdown(PR_TRUE);
}
nsCOMPtr<nsIFolder> childFolder = do_QueryElementAt(mSubFolders, i);
if(childFolder)
childFolder->Shutdown(PR_TRUE);
}
}
// Ask base class shutdown itself.
@ -151,14 +147,12 @@ NS_IMETHODIMP nsMsgDBFolder::ForceDBClosed ()
PRUint32 cnt = 0, i;
if (mSubFolders)
{
nsCOMPtr<nsISupports> aSupport;
nsCOMPtr<nsIMsgFolder> child;
mSubFolders->Count(&cnt);
if (cnt > 0)
for (i = 0; i < cnt; i++)
{
aSupport = getter_AddRefs(mSubFolders->ElementAt(i));
child = do_QueryInterface(aSupport);
child = do_QueryElementAt(mSubFolders, i);
if (child)
child->ForceDBClosed();
}
@ -1401,8 +1395,8 @@ nsMsgDBFolder::AutoCompact(nsIMsgWindow *aWindow)
PRInt32 offlineSupportLevel;
if ( numServers > 0 )
{
nsCOMPtr <nsISupports> serverSupports = getter_AddRefs(allServers->ElementAt(serverIndex));
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(serverSupports);
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryElementAt(allServers, serverIndex);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsISupportsArray> folderArray;
nsCOMPtr<nsISupportsArray> offlineFolderArray;
@ -1460,8 +1454,7 @@ nsMsgDBFolder::AutoCompact(nsIMsgWindow *aWindow)
}
}
}
serverSupports = getter_AddRefs(allServers->ElementAt(++serverIndex));
server = do_QueryInterface(serverSupports, &rv);
server = do_QueryElementAt(allServers, ++serverIndex);
}
while (serverIndex < numServers);
totalExpungedBytes = localExpungedBytes + offlineExpungedBytes;
@ -1479,8 +1472,8 @@ nsMsgDBFolder::AutoCompact(nsIMsgWindow *aWindow)
{
if ( localExpungedBytes > 0)
{
nsCOMPtr <nsISupports> aSupports = getter_AddRefs(folderArray->ElementAt(0));
nsCOMPtr <nsIMsgFolder> msgFolder = do_QueryInterface(aSupports, &rv);
nsCOMPtr <nsIMsgFolder> msgFolder =
do_QueryElementAt(folderArray, 0, &rv);
if (msgFolder && NS_SUCCEEDED(rv))
if (offlineExpungedBytes > 0)
msgFolder->CompactAll(nsnull, aWindow, folderArray, PR_TRUE, offlineFolderArray);
@ -1572,8 +1565,8 @@ nsMsgDBFolder::MatchOrChangeFilterDestination(nsIMsgFolder *newFolder, PRBool ca
rv = allServers->Count(&numServers);
for (PRUint32 serverIndex=0; serverIndex < numServers; serverIndex++)
{
nsCOMPtr <nsISupports> serverSupports = getter_AddRefs(allServers->ElementAt(serverIndex));
nsCOMPtr <nsIMsgIncomingServer> server = do_QueryInterface(serverSupports, &rv);
nsCOMPtr <nsIMsgIncomingServer> server =
do_QueryElementAt(allServers, serverIndex, &rv);
if (server && NS_SUCCEEDED(rv))
{
PRBool canHaveFilters;

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

@ -90,6 +90,7 @@
#include "nsIDocShellTreeOwner.h"
#include "nsIWindowMediator.h"
#include "nsISupportsArray.h"
#include "nsCOMArray.h"
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIMsgMailSession.h"
@ -418,7 +419,6 @@ nsresult nsMsgCompose::TagEmbeddedObjects(nsIEditorMailSupport *aEditor)
if (NS_FAILED(aNodeList->Count(&count)))
return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> isupp;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsIURI> originalUrl;
@ -446,17 +446,15 @@ nsresult nsMsgCompose::TagEmbeddedObjects(nsIEditorMailSupport *aEditor)
nsCOMPtr<nsIDOMElement> domElement;
for (i = 0; i < count; i ++)
{
isupp = getter_AddRefs(aNodeList->ElementAt(i));
if (!isupp)
node = do_QueryElementAt(aNodeList, i);
if (!node)
continue;
node = do_QueryInterface(isupp);
if (IsEmbeddedObjectSafe(originalScheme.get(), originalHost.get(),
originalPath.get(), node))
continue; //Don't need to tag this object, it safe to send it.
//The source of this object should not be sent with the message
domElement = do_QueryInterface(isupp);
domElement = do_QueryInterface(node);
if (domElement)
domElement->SetAttribute(NS_LITERAL_STRING("moz-do-not-send"), NS_LITERAL_STRING("true"));
}
@ -3425,8 +3423,8 @@ nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotifica
PRUint32 i;
for (i = 0; i < numListeners;i++)
{
nsCOMPtr<nsISupports> iSupports = getter_AddRefs(mStateListeners->ElementAt(i));
nsCOMPtr<nsIMsgComposeStateListener> thisListener = do_QueryInterface(iSupports);
nsCOMPtr<nsIMsgComposeStateListener> thisListener =
do_QueryElementAt(mStateListeners, i);
if (thisListener)
{
switch (aNotificationType)
@ -3686,7 +3684,7 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
*_retval = nsIAbPreferMailFormat::unknown;
/* First, build an array with original recipients */
nsCOMPtr<nsISupportsArray> recipientsList[MAX_OF_RECIPIENT_ARRAY];
nsCOMArray<nsMsgRecipient> recipientsList[MAX_OF_RECIPIENT_ARRAY];
nsXPIDLString originalRecipients[MAX_OF_RECIPIENT_ARRAY];
m_compFields->GetTo(getter_Copies(originalRecipients[0]));
@ -3707,10 +3705,6 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
nsXPIDLString addr;
addressArray->GetCount(&nbrRecipients);
recipientsList[i] = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
for (j = 0; j < nbrRecipients; j ++)
{
rv = addressArray->StringAt(j, getter_Copies(addr));
@ -3725,12 +3719,11 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
if (!recipient)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(recipient);
rv = recipientsList[i]->AppendElement(recipient);
rv = recipientsList[i].AppendObject(recipient) ? NS_OK : NS_ERROR_FAILURE;
NS_RELEASE(recipient);
if (NS_FAILED(rv))
return rv;
}
}
}
else
return rv;
@ -3753,7 +3746,7 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
{
nsString dirPath;
GetABDirectories(kAllDirectoryRoot, addrbookDirArray, PR_TRUE);
PRUint32 nbrRecipients;
PRInt32 nbrRecipients;
PRUint32 nbrAddressbook;
addrbookDirArray->Count(&nbrAddressbook);
@ -3789,12 +3782,12 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
stillNeedToSearch = PR_FALSE;
for (i = 0; i < MAX_OF_RECIPIENT_ARRAY; i ++)
{
if (!recipientsList[i])
nbrRecipients = recipientsList[i].Count();
if (nbrRecipients == 0)
continue;
recipientsList[i]->Count(&nbrRecipients);
for (j = 0; j < (PRInt32)nbrRecipients; j ++, recipientsList[i]->Count(&nbrRecipients))
for (j = 0; j < nbrRecipients; j++, nbrRecipients = recipientsList[i].Count())
{
nsMsgRecipient* recipient = NS_STATIC_CAST(nsMsgRecipient*, recipientsList[i]->ElementAt(j));
nsMsgRecipient* recipient = recipientsList[i][j];
if (recipient && !recipient->mProcessed)
{
/* First check if it's a mailing list */
@ -3805,8 +3798,8 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
PRUint32 nbrAddresses = 0;
for (mailListAddresses->Count(&nbrAddresses); nbrAddresses > 0; nbrAddresses --)
{
item = getter_AddRefs(mailListAddresses->ElementAt(nbrAddresses - 1));
existingCard = do_QueryInterface(item, &rv);
existingCard = do_QueryElementAt(mailListAddresses,
nbrAddresses - 1, &rv);
if (NS_FAILED(rv))
return rv;
@ -3867,7 +3860,7 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
if (!recipient)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(newRecipient);
if (bIsMailList)
{
//TODO: we must to something to avoid recursivity
@ -3880,18 +3873,18 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
if (NS_SUCCEEDED(rv))
recipient->mProcessed = PR_TRUE;
}
rv = recipientsList[i]->InsertElementAt(newRecipient, j + 1);
rv = recipientsList[i].InsertObjectAt(newRecipient,
j + 1) ? NS_OK : NS_ERROR_FAILURE;
NS_RELEASE(newRecipient);
if (NS_FAILED(rv))
return rv;
}
rv = recipientsList[i]->RemoveElementAt(j);
rv = recipientsList[i].RemoveObjectAt(j) ? NS_OK : NS_ERROR_FAILURE;
j --;
}
else
recipient->mProcessed = PR_TRUE;
NS_RELEASE(recipient);
continue;
}
@ -3909,7 +3902,6 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
}
else
stillNeedToSearch = PR_TRUE;
NS_RELEASE(recipient);
}
}
}
@ -3941,15 +3933,14 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
*_retval = -1;
for (i = 0; i < MAX_OF_RECIPIENT_ARRAY; i ++)
{
if (!recipientsList[i])
PRInt32 nbrRecipients = recipientsList[i].Count();
if (nbrRecipients == 0)
continue;
recipientsStr.SetLength(0);
PRUint32 nbrRecipients;
recipientsList[i]->Count(&nbrRecipients);
for (j = 0; j < (PRInt32)nbrRecipients; j ++)
for (j = 0; j < nbrRecipients; j ++)
{
nsMsgRecipient* recipient = NS_STATIC_CAST(nsMsgRecipient*, recipientsList[i]->ElementAt(j));
nsMsgRecipient* recipient = recipientsList[i][j];
if (recipient)
{
/* if we don't have a prefer format for a recipient, check the domain in case we have a format defined for it */
@ -4000,7 +3991,6 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
nonHtmlRecipientsStr.Append(recipient->mEmail);
}
NS_RELEASE(recipient);
}
}

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

@ -544,10 +544,8 @@ LocateMessageFolder(nsIMsgIdentity *userIdentity,
for (i=0; i<cnt; i++) {
// Now that we have the server...we need to get the named message folder
nsCOMPtr<nsIMsgIncomingServer> inServer;
nsCOMPtr<nsISupports>ptr;
ptr = getter_AddRefs(retval->ElementAt(i));
inServer = do_QueryInterface(ptr, &rv);
inServer = do_QueryElementAt(retval, i, &rv);
if(NS_FAILED(rv) || (!inServer))
continue;

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

@ -481,9 +481,8 @@ nsImapIncomingServer::LoadNextQueuedUrl(PRBool *aResult)
while (cnt > 0 && !urlRun && keepGoing)
{
nsCOMPtr<nsISupports> aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryInterface(aSupport, &rv));
nsCOMPtr<nsIMsgMailNewsUrl> aMailNewsUrl(do_QueryInterface(aSupport, &rv));
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryElementAt(m_urlQueue, 0, &rv));
nsCOMPtr<nsIMsgMailNewsUrl> aMailNewsUrl(do_QueryInterface(aImapUrl, &rv));
PRBool removeUrlFromQueue = PR_FALSE;
if (aImapUrl)
@ -538,8 +537,7 @@ nsImapIncomingServer::AbortQueuedUrls()
while (cnt > 0)
{
nsCOMPtr<nsISupports> aSupport(getter_AddRefs(m_urlQueue->ElementAt(cnt - 1)));
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryInterface(aSupport, &rv));
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryElementAt(m_urlQueue, cnt - 1, &rv));
PRBool removeUrlFromQueue = PR_FALSE;
if (aImapUrl)
@ -691,14 +689,12 @@ nsImapIncomingServer::CreateImapConnection(nsIEventQueue *aEventQueue,
*aImapConnection = nsnull;
// iterate through the connection cache for a connection that can handle this url.
nsCOMPtr<nsISupports> aSupport;
PRBool userCancelled = PR_FALSE;
// loop until we find a connection that can run the url, or doesn't have to wait?
for (PRUint32 i = 0; i < cnt && !canRunUrlImmediately && !canRunButBusy; i++)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, i);
if (connection)
{
if (ConnectionTimeOut(connection))
@ -841,7 +837,6 @@ NS_IMETHODIMP nsImapIncomingServer::CloseConnectionForFolder(nsIMsgFolder *aMsgF
{
nsresult rv = NS_OK;
nsCOMPtr<nsIImapProtocol> connection;
nsCOMPtr<nsISupports> aSupport;
PRBool isBusy = PR_FALSE, isInbox = PR_FALSE;
PRUint32 cnt = 0;
nsXPIDLCString inFolderName;
@ -859,8 +854,7 @@ NS_IMETHODIMP nsImapIncomingServer::CloseConnectionForFolder(nsIMsgFolder *aMsgF
for (PRUint32 i=0; i < cnt; i++)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, i);
if (connection)
{
rv = connection->GetSelectedMailboxName(getter_Copies(connectionFolderName));
@ -882,7 +876,6 @@ NS_IMETHODIMP nsImapIncomingServer::ResetConnection(const char* folderName)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIImapProtocol> connection;
nsCOMPtr<nsISupports> aSupport;
PRBool isBusy = PR_FALSE, isInbox = PR_FALSE;
PRUint32 cnt = 0;
nsXPIDLCString curFolderName;
@ -894,8 +887,7 @@ NS_IMETHODIMP nsImapIncomingServer::ResetConnection(const char* folderName)
for (PRUint32 i=0; i < cnt; i++)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, i);
if (connection)
{
rv = connection->GetSelectedMailboxName(getter_Copies(curFolderName));
@ -976,15 +968,13 @@ nsImapIncomingServer::CloseCachedConnections()
// iterate through the connection cache closing open connections.
PRUint32 cnt;
nsCOMPtr<nsISupports> aSupport;
nsresult rv = m_connectionCache->Count(&cnt);
if (NS_FAILED(rv)) return rv;
for (PRUint32 i = cnt; i>0; i--)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i-1));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, i-1);
if (connection)
connection->TellThreadToDie(PR_TRUE);
}
@ -2488,14 +2478,12 @@ NS_IMETHODIMP nsImapIncomingServer::PseudoInterruptMsgLoad(nsIMsgFolder *aImapFo
// iterate through the connection cache for a connection that is loading
// a message in this folder and should be pseudo-interrupted.
PRUint32 cnt;
nsCOMPtr<nsISupports> aSupport;
rv = m_connectionCache->Count(&cnt);
if (NS_FAILED(rv)) return rv;
for (PRUint32 i = 0; i < cnt; i++)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, i);
if (connection)
rv = connection->PseudoInterruptMsgLoad(aImapFolder, aMsgWindow, interrupted);
}
@ -2738,13 +2726,11 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHo
m_urlQueue->Count(&cnt);
if (cnt > 0)
{
nsCOMPtr<nsISupports> aSupport(getter_AddRefs(m_urlQueue->ElementAt(0)));
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryInterface(aSupport, &rv));
nsCOMPtr<nsIImapUrl> aImapUrl(do_QueryElementAt(m_urlQueue, 0, &rv));
if (aImapUrl)
{
nsISupports *aConsumer = (nsISupports*)m_urlConsumers.ElementAt(0);
NS_IF_ADDREF(aConsumer);
nsCOMPtr<nsISupports> aConsumer = (nsISupports*)m_urlConsumers.ElementAt(0);
nsCOMPtr <nsIImapProtocol> protocolInstance ;
rv = CreateImapConnection(aEventQueue, aImapUrl, getter_AddRefs(protocolInstance));
@ -2762,8 +2748,6 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHo
m_urlQueue->RemoveElementAt(0);
m_urlConsumers.RemoveElementAt(0);
}
NS_IF_RELEASE(aConsumer);
}
}
else
@ -3346,15 +3330,13 @@ nsImapIncomingServer::GetNumIdleConnections(PRInt32 *aNumIdleConnections)
PR_CEnterMonitor(this);
PRUint32 cnt;
nsCOMPtr<nsISupports> aSupport;
rv = m_connectionCache->Count(&cnt);
if (NS_FAILED(rv)) return rv;
// loop counting idle connections
for (PRUint32 i = 0; i < cnt; i++)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, i);
if (connection)
{
rv = connection->IsBusy(&isBusy, &isInboxConnection);

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

@ -1226,9 +1226,8 @@ NS_IMETHODIMP nsImapMailFolder::EmptyTrash(nsIMsgWindow *msgWindow,
aSupportsArray->Count(&cnt);
for (PRInt32 i = cnt-1; i >= 0; i--)
{
aSupport = getter_AddRefs(aSupportsArray->ElementAt(i));
aFolder = do_QueryElementAt(aSupportsArray, i);
aSupportsArray->RemoveElementAt(i);
aFolder = do_QueryInterface(aSupport);
if (aFolder)
trashFolder->PropagateDelete(aFolder, PR_TRUE, msgWindow);
}
@ -1321,15 +1320,13 @@ NS_IMETHODIMP nsImapMailFolder::RecursiveCloseActiveConnections(nsIImapIncomingS
nsresult rv;
if (mSubFolders)
{
nsCOMPtr<nsISupports> aSupport;
nsCOMPtr<nsIMsgImapMailFolder> folder;
mSubFolders->Count(&cnt);
if (cnt > 0)
{
for (i = 0; i < cnt; i++)
{
aSupport = getter_AddRefs(mSubFolders->ElementAt(i));
folder = do_QueryInterface(aSupport);
folder = do_QueryElementAt(mSubFolders, i);
if (folder)
folder->RecursiveCloseActiveConnections(incomingImapServer);
nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(folder, &rv);
@ -1347,15 +1344,13 @@ NS_IMETHODIMP nsImapMailFolder::PrepareToRename()
PRUint32 cnt = 0, i;
if (mSubFolders)
{
nsCOMPtr<nsISupports> aSupport;
nsCOMPtr<nsIMsgImapMailFolder> folder;
mSubFolders->Count(&cnt);
if (cnt > 0)
{
for (i = 0; i < cnt; i++)
{
aSupport = getter_AddRefs(mSubFolders->ElementAt(i));
folder = do_QueryInterface(aSupport);
folder = do_QueryElementAt(mSubFolders, i);
if (folder)
folder->PrepareToRename();
}
@ -1829,7 +1824,6 @@ nsImapMailFolder::BuildIdsAndKeyArray(nsISupportsArray* messages,
nsresult rv = NS_ERROR_NULL_POINTER;
PRUint32 count = 0;
PRUint32 i;
nsCOMPtr<nsISupports> msgSupports;
if (!messages) return rv;
@ -1839,9 +1833,8 @@ nsImapMailFolder::BuildIdsAndKeyArray(nsISupportsArray* messages,
// build up message keys.
for (i = 0; i < count; i++)
{
msgSupports = getter_AddRefs(messages->ElementAt(i));
nsMsgKey key;
nsCOMPtr <nsIMsgDBHdr> msgDBHdr = do_QueryInterface(msgSupports, &rv);
nsCOMPtr <nsIMsgDBHdr> msgDBHdr = do_QueryElementAt(messages, i, &rv);
if (msgDBHdr)
rv = msgDBHdr->GetMessageKey(&key);
if (NS_SUCCEEDED(rv))
@ -1999,8 +1992,7 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
deleteMsgs = PR_FALSE;
for (PRUint32 i=0; i <cnt; i++)
{
nsCOMPtr <nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(i));
nsCOMPtr <nsIMsgDBHdr> msgHdr = do_QueryInterface(msgSupports);
nsCOMPtr <nsIMsgDBHdr> msgHdr = do_QueryElementAt(messages, i);
if (msgHdr)
{
msgHdr->GetFlags(&flags);
@ -2086,7 +2078,6 @@ NS_IMETHODIMP
nsImapMailFolder::DeleteSubFolders(nsISupportsArray* folders, nsIMsgWindow *msgWindow)
{
nsCOMPtr<nsIMsgFolder> curFolder;
nsCOMPtr<nsISupports> folderSupport;
nsCOMPtr<nsIUrlListener> urlListener;
nsCOMPtr<nsIMsgFolder> trashFolder;
PRUint32 i, folderCount = 0;
@ -2157,8 +2148,7 @@ nsImapMailFolder::DeleteSubFolders(nsISupportsArray* folders, nsIMsgWindow *msgW
{
for (i = 0; i < folderCount; i++)
{
folderSupport = getter_AddRefs(folders->ElementAt(i));
curFolder = do_QueryInterface(folderSupport, &rv);
curFolder = do_QueryElementAt(folders, i, &rv);
if (NS_SUCCEEDED(rv))
{
urlListener = do_QueryInterface(curFolder);
@ -4620,11 +4610,8 @@ void nsImapMailFolder::UpdatePendingCounts(PRBool countUnread, PRBool missingAre
if (!m_copyState->m_isCrossServerOp)
for (PRUint32 keyIndex=0; keyIndex < m_copyState->m_totalCount; keyIndex++)
{
nsCOMPtr<nsIMsgDBHdr> message;
nsCOMPtr<nsISupports> aSupport =
getter_AddRefs(m_copyState->m_messages->ElementAt(keyIndex));
message = do_QueryInterface(aSupport, &rv);
nsCOMPtr<nsIMsgDBHdr> message =
do_QueryElementAt(m_copyState->m_messages, keyIndex, &rv);
// if the key is not there, then assume what the caller tells us to.
PRBool isRead = missingAreRead;
PRUint32 flags;
@ -4639,11 +4626,9 @@ void nsImapMailFolder::UpdatePendingCounts(PRBool countUnread, PRBool missingAre
}
else
{
nsCOMPtr<nsIMsgDBHdr> message;
nsCOMPtr<nsISupports> aSupport =
getter_AddRefs(m_copyState->m_messages->ElementAt(m_copyState->m_curIndex));
message = do_QueryInterface(aSupport, &rv);
nsCOMPtr<nsIMsgDBHdr> message =
do_QueryElementAt(m_copyState->m_messages,
m_copyState->m_curIndex, &rv);
// if the key is not there, then assume what the caller tells us to.
PRBool isRead = missingAreRead;
PRUint32 flags;
@ -5616,10 +5601,8 @@ nsImapMailFolder::CopyNextStreamMessage(PRBool copySucceeded, nsISupports *copyS
if (mailCopyState->m_curIndex < mailCopyState->m_totalCount)
{
nsCOMPtr<nsISupports> aSupport =
getter_AddRefs(mailCopyState->m_messages->ElementAt
(mailCopyState->m_curIndex));
mailCopyState->m_message = do_QueryInterface(aSupport,
mailCopyState->m_message = do_QueryElementAt(mailCopyState->m_messages,
mailCopyState->m_curIndex,
&rv);
if (NS_SUCCEEDED(rv))
{
@ -5755,22 +5738,12 @@ nsImapMailFolder::CopyMessagesWithStream(nsIMsgFolder* srcFolder,
NS_GET_IID(nsImapMoveCopyMsgTxn),
getter_AddRefs(m_copyState->m_undoMsgTxn) );
}
nsCOMPtr<nsISupports> msgSupport;
msgSupport = getter_AddRefs(messages->ElementAt(0));
if (msgSupport)
{
nsCOMPtr<nsIMsgDBHdr> aMessage;
aMessage = do_QueryInterface(msgSupport, &rv);
if (NS_SUCCEEDED(rv))
nsCOMPtr<nsIMsgDBHdr> aMessage;
aMessage = do_QueryElementAt(messages, 0, &rv);
if (NS_SUCCEEDED(rv))
CopyStreamMessage(aMessage, this, msgWindow, isMove);
else
return rv; //we are clearing copy state in CopyMessages on failure
}
else
{
rv = NS_ERROR_FAILURE;
}
return rv;
return rv; //we are clearing copy state in CopyMessages on failure
}
nsresult nsImapMailFolder::GetClearedOriginalOp(nsIMsgOfflineImapOperation *op, nsIMsgOfflineImapOperation **originalOp, nsIMsgDatabase **originalDB)
@ -5979,11 +5952,8 @@ nsresult nsImapMailFolder::CopyMessagesOffline(nsIMsgFolder* srcFolder,
nsXPIDLCString originalSrcFolderURI;
if (sourceFolderURI.get())
originalSrcFolderURI.Adopt(nsCRT::strdup(sourceFolderURI.get()));
nsCOMPtr<nsISupports> msgSupports;
nsCOMPtr<nsIMsgDBHdr> message;
msgSupports = getter_AddRefs(messages->ElementAt(sourceKeyIndex));
message = do_QueryInterface(msgSupports);
message = do_QueryElementAt(messages, sourceKeyIndex);
nsMsgKey originalKey;
if (message)
{

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

@ -112,8 +112,7 @@ nsresult nsImapMoveCoalescer::PlaybackMoves()
m_destFolders->Count(&numFolders);
for (PRUint32 i = 0; i < numFolders; i++)
{
nsCOMPtr <nsISupports> destSupports = getter_AddRefs(m_destFolders->ElementAt(i));
nsCOMPtr <nsIMsgFolder> destFolder(do_QueryInterface(destSupports));
nsCOMPtr <nsIMsgFolder> destFolder(do_QueryElementAt(m_destFolders, i));
nsCOMPtr<nsIImapService> imapService =
do_GetService(kCImapService, &rv);
if (NS_SUCCEEDED(rv) && imapService)

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

@ -383,11 +383,9 @@ nsImapMoveCopyMsgTxn::UndoMailboxDelete()
PRUint32 i;
nsCOMPtr<nsIMsgDBHdr> oldHdr;
nsCOMPtr<nsIMsgDBHdr> newHdr;
nsCOMPtr<nsISupports> aSupport;
for (i=0; i<count; i++)
{
aSupport = getter_AddRefs(m_srcHdrs->ElementAt(i));
oldHdr = do_QueryInterface(aSupport);
oldHdr = do_QueryElementAt(m_srcHdrs, i);
NS_ASSERTION(oldHdr, "fatal ... cannot get old msg header\n");
rv = srcDB->CopyHdrFromExistingHdr(m_srcKeyArray.GetAt(i),
oldHdr,PR_TRUE,

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

@ -507,26 +507,22 @@ NS_IMETHODIMP nsImportGenericAddressBooks::WantsProgress(PRBool *_retval)
if (m_pBooks) {
PRUint32 count = 0;
nsresult rv = m_pBooks->Count( &count);
nsISupports * pSupports;
PRUint32 i;
PRBool import;
PRUint32 size;
for (i = 0; i < count; i++) {
pSupports = m_pBooks->ElementAt( i);
if (pSupports) {
nsCOMPtr<nsISupports> interface( dont_AddRef( pSupports));
nsCOMPtr<nsIImportABDescriptor> book( do_QueryInterface( pSupports));
if (book) {
import = PR_FALSE;
size = 0;
rv = book->GetImport( &import);
if (import) {
rv = book->GetSize( &size);
result = PR_TRUE;
}
totalSize += size;
nsCOMPtr<nsIImportABDescriptor> book =
do_QueryElementAt(m_pBooks, i);
if (book) {
import = PR_FALSE;
size = 0;
rv = book->GetImport( &import);
if (import) {
rv = book->GetSize( &size);
result = PR_TRUE;
}
totalSize += size;
}
}
@ -860,7 +856,6 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff)
PRUint32 count = 0;
nsresult rv = pData->books->Count( &count);
nsISupports * pSupports;
PRUint32 i;
PRBool import;
PRUint32 size;
@ -871,90 +866,87 @@ PR_STATIC_CALLBACK( void) ImportAddressThread( void *stuff)
nsString error;
for (i = 0; (i < count) && !(pData->abort); i++) {
pSupports = pData->books->ElementAt( i);
if (pSupports) {
nsCOMPtr<nsISupports> interface( dont_AddRef( pSupports));
nsCOMPtr<nsIImportABDescriptor> book( do_QueryInterface( pSupports));
if (book) {
import = PR_FALSE;
size = 0;
rv = book->GetImport( &import);
if (import)
rv = book->GetSize( &size);
if (size && import) {
PRUnichar *pName;
book->GetPreferredName( &pName);
if (destDB) {
pDestDB = destDB;
}
else {
pDestDB = GetAddressBook( pName, PR_TRUE);
}
nsCOMPtr<nsIImportABDescriptor> book =
do_QueryElementAt(pData->books, i);
if (book) {
import = PR_FALSE;
size = 0;
rv = book->GetImport( &import);
if (import)
rv = book->GetSize( &size);
if (size && import) {
PRUnichar *pName;
book->GetPreferredName( &pName);
if (destDB) {
pDestDB = destDB;
}
else {
pDestDB = GetAddressBook( pName, PR_TRUE);
}
nsCOMPtr<nsIAddrDatabase> proxyAddrDatabase;
rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
NS_GET_IID(nsIAddrDatabase),
pDestDB,
PROXY_SYNC | PROXY_ALWAYS,
getter_AddRefs(proxyAddrDatabase));
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIAddrDatabase> proxyAddrDatabase;
rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
NS_GET_IID(nsIAddrDatabase),
pDestDB,
PROXY_SYNC | PROXY_ALWAYS,
getter_AddRefs(proxyAddrDatabase));
if (NS_FAILED(rv))
return;
PRBool fatalError = PR_FALSE;
pData->currentSize = size;
if (proxyAddrDatabase) {
PRUnichar *pSuccess = nsnull;
PRUnichar *pError = nsnull;
PRBool fatalError = PR_FALSE;
pData->currentSize = size;
if (proxyAddrDatabase) {
PRUnichar *pSuccess = nsnull;
PRUnichar *pError = nsnull;
/*
if (pData->fieldMap) {
PRInt32 sz = 0;
PRInt32 mapIndex;
PRBool active;
pData->fieldMap->GetMapSize( &sz);
IMPORT_LOG1( "**** Field Map Size: %d\n", (int) sz);
for (PRInt32 i = 0; i < sz; i++) {
pData->fieldMap->GetFieldMap( i, &mapIndex);
pData->fieldMap->GetFieldActive( i, &active);
IMPORT_LOG3( "Field map #%d: index=%d, active=%d\n", (int) i, (int) mapIndex, (int) active);
}
}
*/
rv = pData->addressImport->ImportAddressBook( book,
proxyAddrDatabase, // destination
pData->fieldMap, // fieldmap
pData->bAddrLocInput,
&pError,
&pSuccess,
&fatalError);
if (pSuccess) {
success.Append( pSuccess);
nsCRT::free( pSuccess);
}
if (pError) {
error.Append( pError);
nsCRT::free( pError);
/*
if (pData->fieldMap) {
PRInt32 sz = 0;
PRInt32 mapIndex;
PRBool active;
pData->fieldMap->GetMapSize( &sz);
IMPORT_LOG1( "**** Field Map Size: %d\n", (int) sz);
for (PRInt32 i = 0; i < sz; i++) {
pData->fieldMap->GetFieldMap( i, &mapIndex);
pData->fieldMap->GetFieldActive( i, &active);
IMPORT_LOG3( "Field map #%d: index=%d, active=%d\n", (int) i, (int) mapIndex, (int) active);
}
}
else {
nsImportGenericAddressBooks::ReportError( pName, &error);
*/
rv = pData->addressImport->ImportAddressBook( book,
proxyAddrDatabase, // destination
pData->fieldMap, // fieldmap
pData->bAddrLocInput,
&pError,
&pSuccess,
&fatalError);
if (pSuccess) {
success.Append( pSuccess);
nsCRT::free( pSuccess);
}
if (pError) {
error.Append( pError);
nsCRT::free( pError);
}
}
else {
nsImportGenericAddressBooks::ReportError( pName, &error);
}
nsCRT::free( pName);
nsCRT::free( pName);
pData->currentSize = 0;
pData->currentTotal += size;
pData->currentSize = 0;
pData->currentTotal += size;
if (!proxyAddrDatabase) {
proxyAddrDatabase->Close( PR_TRUE);
}
if (!proxyAddrDatabase) {
proxyAddrDatabase->Close( PR_TRUE);
}
if (fatalError) {
pData->fatalError = PR_TRUE;
break;
}
if (fatalError) {
pData->fatalError = PR_TRUE;
break;
}
}
}

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

@ -420,7 +420,6 @@ NS_IMETHODIMP nsImportGenericMail::WantsProgress(PRBool *_retval)
PRBool result = PR_FALSE;
if (m_pMailboxes) {
nsISupports * pSupports;
PRUint32 i;
PRBool import;
PRUint32 count = 0;
@ -430,20 +429,17 @@ NS_IMETHODIMP nsImportGenericMail::WantsProgress(PRBool *_retval)
rv = m_pMailboxes->Count( &count);
for (i = 0; i < count; i++) {
pSupports = m_pMailboxes->ElementAt( i);
if (pSupports) {
nsCOMPtr<nsISupports> interface( dont_AddRef( pSupports));
nsCOMPtr<nsIImportMailboxDescriptor> box( do_QueryInterface( pSupports));
if (box) {
import = PR_FALSE;
size = 0;
rv = box->GetImport( &import);
if (import) {
rv = box->GetSize( &size);
result = PR_TRUE;
}
totalSize += size;
nsCOMPtr<nsIImportMailboxDescriptor> box =
do_QueryElementAt(m_pMailboxes, i);
if (box) {
import = PR_FALSE;
size = 0;
rv = box->GetImport( &import);
if (import) {
rv = box->GetSize( &size);
result = PR_TRUE;
}
totalSize += size;
}
}
@ -460,19 +456,15 @@ NS_IMETHODIMP nsImportGenericMail::WantsProgress(PRBool *_retval)
void nsImportGenericMail::GetMailboxName( PRUint32 index, nsISupportsString *pStr)
{
if (m_pMailboxes) {
nsISupports *pSupports = m_pMailboxes->ElementAt( index);
if (pSupports) {
nsCOMPtr<nsISupports> iFace( dont_AddRef( pSupports));
nsCOMPtr<nsIImportMailboxDescriptor> box( do_QueryInterface( pSupports));
if (box) {
nsXPIDLString name;
box->GetDisplayName(getter_Copies(name));
if (!name.IsEmpty()) {
pStr->SetData(name);
}
nsCOMPtr<nsIImportMailboxDescriptor> box(do_QueryElementAt(m_pMailboxes, index));
if (box) {
nsXPIDLString name;
box->GetDisplayName(getter_Copies(name));
if (!name.IsEmpty()) {
pStr->SetData(name);
}
}
}
}
}
NS_IMETHODIMP nsImportGenericMail::BeginImport(nsISupportsString *successLog, nsISupportsString *errorLog, PRBool isAddrLocHome, PRBool *_retval)
@ -731,7 +723,6 @@ ImportMailThread( void *stuff)
PRUint32 count = 0;
rv = pData->boxes->Count( &count);
nsISupports * pSupports;
PRUint32 i;
PRBool import;
PRUint32 size;
@ -779,132 +770,129 @@ ImportMailThread( void *stuff)
// we combine both good and bad import status into one string (in var 'success').
for (i = 0; (i < count) && !(pData->abort); i++) {
pSupports = pData->boxes->ElementAt( i);
if (pSupports) {
nsCOMPtr<nsISupports> iFace( dont_AddRef( pSupports));
nsCOMPtr<nsIImportMailboxDescriptor> box( do_QueryInterface( pSupports));
if (box) {
pData->currentMailbox = i;
nsCOMPtr<nsIImportMailboxDescriptor> box =
do_QueryElementAt(pData->boxes, i);
if (box) {
pData->currentMailbox = i;
import = PR_FALSE;
size = 0;
rv = box->GetImport( &import);
if (import)
rv = box->GetSize( &size);
rv = box->GetDepth( &newDepth);
if (newDepth > depth) {
import = PR_FALSE;
size = 0;
rv = box->GetImport( &import);
if (import)
rv = box->GetSize( &size);
rv = box->GetDepth( &newDepth);
if (newDepth > depth) {
// OK, we are going to add a subfolder under the last/previous folder we processed, so
// find this folder (stored in 'lastName') who is going to be the new parent folder.
IMPORT_LOG1( "* Finding folder for child named: %s\n", lastName.get());
rv = curProxy->GetChildNamed( lastName.get(), getter_AddRefs( subFolder));
if (NS_FAILED( rv)) {
nsImportGenericMail::ReportError( IMPORT_ERROR_MB_FINDCHILD, lastName.get(), &success);
pData->fatalError = PR_TRUE;
break;
}
rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIMsgFolder),
subFolder, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs( curProxy));
if (NS_FAILED( rv)) {
nsImportStringBundle::GetStringByID( IMPORT_ERROR_MB_NOPROXY, error, bundle);
pData->fatalError = PR_TRUE;
break;
}
// Make sure this new parent folder obj has the correct subfolder list so far.
rv = curProxy->GetSubFolders(getter_AddRefs(enumerator));
IMPORT_LOG1( "Created proxy for new subFolder: 0x%lx\n", (long) rv);
}
else if (newDepth < depth) {
rv = NS_OK;
while ((newDepth < depth) && NS_SUCCEEDED( rv)) {
nsCOMPtr<nsIFolder> parFolder;
curProxy->GetParent( getter_AddRefs( parFolder));
rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIMsgFolder),
parFolder, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs( curProxy));
depth--;
}
if (NS_FAILED( rv)) {
nsImportStringBundle::GetStringByID( IMPORT_ERROR_MB_NOPROXY, error, bundle);
pData->fatalError = PR_TRUE;
break;
}
}
depth = newDepth;
pName = nsnull;
box->GetDisplayName( &pName);
if (pName) {
lastName = pName;
nsCRT::free( pName);
}
else
lastName.Assign(NS_LITERAL_STRING("Unknown!"));
exists = PR_FALSE;
rv = curProxy->ContainsChildNamed( lastName.get(), &exists);
if (exists) {
nsXPIDLString subName;
curProxy->GenerateUniqueSubfolderName( lastName.get(), nsnull, getter_Copies(subName));
if (!subName.IsEmpty())
lastName.Assign(subName);
}
IMPORT_LOG1( "* Creating new import folder: %s\n", lastName.get());
rv = curProxy->CreateSubfolder( lastName.get(),nsnull);
IMPORT_LOG1( "New folder created, rv: 0x%lx\n", (long) rv);
if (NS_SUCCEEDED( rv)) {
rv = curProxy->GetChildNamed( lastName.get(), getter_AddRefs( subFolder));
IMPORT_LOG1( "GetChildNamed for new folder returned rv: 0x%lx\n", (long) rv);
if (NS_SUCCEEDED( rv)) {
newFolder = do_QueryInterface( subFolder);
if (newFolder) {
newFolder->GetPath( getter_AddRefs( outBox));
IMPORT_LOG0( "Got path for newly created folder\n");
}
else {
IMPORT_LOG0( "Newly created folder not found\n");
}
}
}
IMPORT_LOG1( "* Finding folder for child named: %s\n", lastName.get());
rv = curProxy->GetChildNamed( lastName.get(), getter_AddRefs( subFolder));
if (NS_FAILED( rv)) {
nsImportGenericMail::ReportError( IMPORT_ERROR_MB_CREATE, lastName.get(), &success);
nsImportGenericMail::ReportError( IMPORT_ERROR_MB_FINDCHILD, lastName.get(), &success);
pData->fatalError = PR_TRUE;
break;
}
if (size && import && newFolder && outBox && NS_SUCCEEDED( rv)) {
PRBool fatalError = PR_FALSE;
pData->currentSize = size;
PRUnichar *pSuccess = nsnull;
PRUnichar *pError = nsnull;
rv = pData->mailImport->ImportMailbox( box, outBox, &pError, &pSuccess, &fatalError);
if (pError) {
error.Append( pError);
nsCRT::free( pError);
}
if (pSuccess) {
success.Append( pSuccess);
nsCRT::free( pSuccess);
}
rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIMsgFolder),
subFolder, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs( curProxy));
if (NS_FAILED( rv)) {
nsImportStringBundle::GetStringByID( IMPORT_ERROR_MB_NOPROXY, error, bundle);
pData->fatalError = PR_TRUE;
break;
}
pData->currentSize = 0;
pData->currentTotal += size;
// Make sure this new parent folder obj has the correct subfolder list so far.
rv = curProxy->GetSubFolders(getter_AddRefs(enumerator));
IMPORT_LOG1( "Created proxy for new subFolder: 0x%lx\n", (long) rv);
}
else if (newDepth < depth) {
rv = NS_OK;
while ((newDepth < depth) && NS_SUCCEEDED( rv)) {
nsCOMPtr<nsIFolder> parFolder;
curProxy->GetParent( getter_AddRefs( parFolder));
rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIMsgFolder),
parFolder, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs( curProxy));
depth--;
}
if (NS_FAILED( rv)) {
nsImportStringBundle::GetStringByID( IMPORT_ERROR_MB_NOPROXY, error, bundle);
pData->fatalError = PR_TRUE;
break;
}
}
depth = newDepth;
pName = nsnull;
box->GetDisplayName( &pName);
if (pName) {
lastName = pName;
nsCRT::free( pName);
}
else
lastName.Assign(NS_LITERAL_STRING("Unknown!"));
exists = PR_FALSE;
rv = curProxy->ContainsChildNamed( lastName.get(), &exists);
if (exists) {
nsXPIDLString subName;
curProxy->GenerateUniqueSubfolderName( lastName.get(), nsnull, getter_Copies(subName));
if (!subName.IsEmpty())
lastName.Assign(subName);
}
IMPORT_LOG1( "* Creating new import folder: %s\n", lastName.get());
rv = curProxy->CreateSubfolder( lastName.get(),nsnull);
IMPORT_LOG1( "New folder created, rv: 0x%lx\n", (long) rv);
if (NS_SUCCEEDED( rv)) {
rv = curProxy->GetChildNamed( lastName.get(), getter_AddRefs( subFolder));
IMPORT_LOG1( "GetChildNamed for new folder returned rv: 0x%lx\n", (long) rv);
if (NS_SUCCEEDED( rv)) {
newFolder = do_QueryInterface( subFolder);
if (newFolder) {
newFolder->GetPath( getter_AddRefs( outBox));
IMPORT_LOG0( "Got path for newly created folder\n");
}
else {
IMPORT_LOG0( "Newly created folder not found\n");
}
}
}
if (NS_FAILED( rv)) {
nsImportGenericMail::ReportError( IMPORT_ERROR_MB_CREATE, lastName.get(), &success);
}
if (size && import && newFolder && outBox && NS_SUCCEEDED( rv)) {
PRBool fatalError = PR_FALSE;
pData->currentSize = size;
PRUnichar *pSuccess = nsnull;
PRUnichar *pError = nsnull;
rv = pData->mailImport->ImportMailbox( box, outBox, &pError, &pSuccess, &fatalError);
if (pError) {
error.Append( pError);
nsCRT::free( pError);
}
if (pSuccess) {
success.Append( pSuccess);
nsCRT::free( pSuccess);
}
pData->currentSize = 0;
pData->currentTotal += size;
outBox->CloseStream();
outBox->CloseStream();
// OK, we've copied the actual folder/file over if the folder size is not 0
// (ie, the msg summary is no longer valid) so close the msg database so that
// when the folder is reopened the folder db can be reconstructed (which
// validates msg summary and forces folder to be reparsed).
newFolder->ForceDBClosed();
newFolder->ForceDBClosed();
if (fatalError) {
IMPORT_LOG1( "*** ImportMailbox returned fatalError, mailbox #%d\n", (int) i);
pData->fatalError = PR_TRUE;
break;
}
if (fatalError) {
IMPORT_LOG1( "*** ImportMailbox returned fatalError, mailbox #%d\n", (int) i);
pData->fatalError = PR_TRUE;
break;
}
}
}

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

@ -519,8 +519,7 @@ nsMsgLocalMailFolder::GetSubFolders(nsIEnumerator* *result)
nsCOMPtr<nsIEnumerator> enumerator;
for (PRUint32 i=0; i< cnt;i++)
{
nsCOMPtr<nsISupports> supports = getter_AddRefs(mSubFolders->ElementAt(i));
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports, &rv);
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(mSubFolders, i, &rv);
if (folder && NS_SUCCEEDED(rv))
{
rv = folder->GetSubFolders(getter_AddRefs(enumerator));
@ -1127,8 +1126,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::DeleteSubFolders(
if (NS_SUCCEEDED(rv))
{
// we don't allow multiple folder selection so this is ok.
nsCOMPtr<nsIMsgFolder> folder;
folders->QueryElementAt(0, NS_GET_IID(nsIMsgFolder), (void **) getter_AddRefs(folder));
nsCOMPtr<nsIMsgFolder> folder = do_QueryElementAt(folders, 0);
if (folder)
trashFolder->CopyFolder(folder, PR_TRUE, msgWindow, nsnull);
}
@ -2290,9 +2288,8 @@ nsresult nsMsgLocalMailFolder::WriteStartOfNewMessage()
nsresult rv;
nsCOMPtr <nsIMsgDBHdr> curSourceMessage;
nsCOMPtr<nsISupports> aSupport =
getter_AddRefs(mCopyState->m_messages->ElementAt(mCopyState->m_curCopyIndex));
curSourceMessage = do_QueryInterface(aSupport, &rv);
curSourceMessage = do_QueryElementAt(mCopyState->m_messages,
mCopyState->m_curCopyIndex, &rv);
char statusStrBuf[50];
if (curSourceMessage)
@ -2825,17 +2822,12 @@ nsresult nsMsgLocalMailFolder::CopyMessagesTo(nsISupportsArray *messages,
messages->Count(&numMessages);
for (PRUint32 i = 0; i < numMessages; i++)
{
nsCOMPtr<nsISupports> msgSupport;
msgSupport = getter_AddRefs(messages->ElementAt(i));
if (msgSupport)
nsCOMPtr<nsIMsgDBHdr> aMessage = do_QueryElementAt(messages, i, &rv);
if(NS_SUCCEEDED(rv) && aMessage)
{
nsCOMPtr<nsIMsgDBHdr> aMessage = do_QueryInterface(msgSupport, &rv);
if(NS_SUCCEEDED(rv) && aMessage)
{
nsMsgKey key;
aMessage->GetMessageKey(&key);
keyArray.Add(key);
}
nsMsgKey key;
aMessage->GetMessageKey(&key);
keyArray.Add(key);
}
}
keyArray.QuickSort();
@ -2980,10 +2972,7 @@ nsMsgLocalMailFolder::MarkMsgsOnPop3Server(nsISupportsArray *messages, PRBool de
{
/* get uidl for this message */
uidl = nsnull;
nsCOMPtr<nsISupports> aSupport =
getter_AddRefs(messages->ElementAt(i));
nsCOMPtr<nsIMsgDBHdr> msgDBHdr (do_QueryInterface(aSupport, &rv));
nsCOMPtr<nsIMsgDBHdr> msgDBHdr (do_QueryElementAt(messages, i, &rv));
PRUint32 flags = 0;

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

@ -97,10 +97,7 @@ static char *nsMailboxGetURI(const char *nativepath)
PRInt32 i;
for (i=0; i<count; i++) {
nsISupports* serverSupports = serverArray->ElementAt(i);
nsCOMPtr<nsIMsgIncomingServer> server =
do_QueryInterface(serverSupports);
NS_RELEASE(serverSupports);
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(serverArray, i);
if (!server) continue;

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

@ -431,10 +431,9 @@ nsresult nsMsgDownloadAllNewsgroups::AdvanceToNextServer(PRBool *done)
while (serverIndex < numServers)
{
nsCOMPtr <nsISupports> serverSupports = getter_AddRefs(m_allServers->ElementAt(serverIndex));
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryElementAt(m_allServers, serverIndex);
serverIndex++;
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(serverSupports);
nsCOMPtr <nsINntpIncomingServer> newsServer = do_QueryInterface(server);
if (!newsServer) // we're only looking for news servers
continue;

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

@ -950,8 +950,7 @@ nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWi
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(0));
nsCOMPtr<nsIMsgDBHdr> msgHdr(do_QueryInterface(msgSupports));
nsCOMPtr<nsIMsgDBHdr> msgHdr(do_QueryElementAt(messages, 0));
// for cancel, we need to
// turn "newsmessage://sspitzer@news.mozilla.org/netscape.test#5428"
@ -1704,16 +1703,14 @@ NS_IMETHODIMP nsMsgNewsFolder::DownloadMessagesForOffline(nsISupportsArray *mess
SetSaveArticleOffline(PR_TRUE); // ### TODO need to clear this when we've finished
PRUint32 count = 0;
PRUint32 i;
nsCOMPtr<nsISupports> msgSupports;
nsresult rv = messages->Count(&count);
NS_ENSURE_SUCCESS(rv, rv);
// build up message keys.
for (i = 0; i < count; i++)
{
msgSupports = getter_AddRefs(messages->ElementAt(i));
nsMsgKey key;
nsCOMPtr <nsIMsgDBHdr> msgDBHdr = do_QueryInterface(msgSupports, &rv);
nsCOMPtr <nsIMsgDBHdr> msgDBHdr = do_QueryElementAt(messages, i, &rv);
if (msgDBHdr)
rv = msgDBHdr->GetMessageKey(&key);
if (NS_SUCCEEDED(rv))

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

@ -438,7 +438,6 @@ nsNntpIncomingServer::CloseCachedConnections()
{
nsresult rv;
PRUint32 cnt;
nsCOMPtr<nsISupports> aSupport;
nsCOMPtr<nsINNTPProtocol> connection;
// iterate through the connection cache and close the connections.
@ -448,8 +447,7 @@ nsNntpIncomingServer::CloseCachedConnections()
if (NS_FAILED(rv)) return rv;
for (PRUint32 i = 0; i < cnt; i++)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(0));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, 0);
if (connection)
{
rv = connection->CloseConnection();
@ -547,7 +545,6 @@ nsNntpIncomingServer::GetNntpConnection(nsIURI * aUri, nsIMsgWindow *aMsgWindow,
*aNntpConnection = nsnull;
// iterate through the connection cache for a connection that can handle this url.
PRUint32 cnt;
nsCOMPtr<nsISupports> aSupport;
rv = m_connectionCache->Count(&cnt);
if (NS_FAILED(rv)) return rv;
@ -556,8 +553,7 @@ nsNntpIncomingServer::GetNntpConnection(nsIURI * aUri, nsIMsgWindow *aMsgWindow,
#endif
for (PRUint32 i = 0; i < cnt && isBusy; i++)
{
aSupport = getter_AddRefs(m_connectionCache->ElementAt(i));
connection = do_QueryInterface(aSupport);
connection = do_QueryElementAt(m_connectionCache, i);
if (connection)
rv = connection->GetIsBusy(&isBusy);
if (NS_FAILED(rv))