зеркало из https://github.com/mozilla/pjs.git
Bug 434493 Drop more instances of nsISupportsArray in mailnews. r/sr=bienvenu
This commit is contained in:
Родитель
90d8d2f47f
Коммит
45c11277dd
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -132,22 +132,18 @@ nsMsgSearchSession::CreateTerm(nsIMsgSearchTerm **aResult)
|
|||
}
|
||||
|
||||
/* void RegisterListener (in nsIMsgSearchNotify listener); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::RegisterListener(nsIMsgSearchNotify *listener)
|
||||
NS_IMETHODIMP nsMsgSearchSession::RegisterListener(nsIMsgSearchNotify *aListener)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
if (!m_listenerList)
|
||||
ret = NS_NewISupportsArray(getter_AddRefs(m_listenerList));
|
||||
|
||||
if (NS_SUCCEEDED(ret) && m_listenerList)
|
||||
m_listenerList->AppendElement(listener);
|
||||
return ret;
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
m_listenerList.AppendElement(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void UnregisterListener (in nsIMsgSearchNotify listener); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::UnregisterListener(nsIMsgSearchNotify *listener)
|
||||
NS_IMETHODIMP nsMsgSearchSession::UnregisterListener(nsIMsgSearchNotify *aListener)
|
||||
{
|
||||
if (m_listenerList)
|
||||
m_listenerList->RemoveElement(listener);
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
m_listenerList.RemoveElement(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -258,23 +254,22 @@ nsMsgSearchSession::AddAllScopes(nsMsgSearchScopeValue attrib)
|
|||
/* void Search (); */
|
||||
NS_IMETHODIMP nsMsgSearchSession::Search(nsIMsgWindow *aWindow)
|
||||
{
|
||||
nsresult err = Initialize ();
|
||||
NS_ENSURE_SUCCESS(err,err);
|
||||
if (m_listenerList) {
|
||||
PRUint32 count;
|
||||
m_listenerList->Count(&count);
|
||||
for (PRUint32 i=0; i<count;i++) {
|
||||
nsCOMPtr<nsIMsgSearchNotify> listener;
|
||||
m_listenerList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchNotify),
|
||||
(void **)getter_AddRefs(listener));
|
||||
if (listener)
|
||||
listener->OnNewSearch();
|
||||
}
|
||||
}
|
||||
m_msgWindowWeak = do_GetWeakReference(aWindow);
|
||||
if (NS_SUCCEEDED(err))
|
||||
err = BeginSearching ();
|
||||
return err;
|
||||
nsresult rv = Initialize();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsTObserverArray<nsCOMPtr<nsIMsgSearchNotify> >::ForwardIterator iter(m_listenerList);
|
||||
nsCOMPtr<nsIMsgSearchNotify> listener;
|
||||
while (iter.HasMore())
|
||||
{
|
||||
listener = iter.GetNext();
|
||||
listener->OnNewSearch();
|
||||
}
|
||||
|
||||
m_msgWindowWeak = do_GetWeakReference(aWindow, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return BeginSearching();
|
||||
}
|
||||
|
||||
/* void InterruptSearch (); */
|
||||
|
@ -575,40 +570,27 @@ NS_IMETHODIMP nsMsgSearchSession::GetRunningAdapter (nsIMsgSearchAdapter **aSear
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddSearchHit(nsIMsgDBHdr *header, nsIMsgFolder *folder)
|
||||
NS_IMETHODIMP nsMsgSearchSession::AddSearchHit(nsIMsgDBHdr *aHeader,
|
||||
nsIMsgFolder *aFolder)
|
||||
{
|
||||
if (m_listenerList)
|
||||
nsTObserverArray<nsCOMPtr<nsIMsgSearchNotify> >::ForwardIterator iter(m_listenerList);
|
||||
nsCOMPtr<nsIMsgSearchNotify> listener;
|
||||
while (iter.HasMore())
|
||||
{
|
||||
PRUint32 count;
|
||||
m_listenerList->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIMsgSearchNotify> pListener;
|
||||
m_listenerList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchNotify),
|
||||
(void **)getter_AddRefs(pListener));
|
||||
if (pListener)
|
||||
pListener->OnSearchHit(header, folder);
|
||||
|
||||
}
|
||||
listener = iter.GetNext();
|
||||
listener->OnSearchHit(aHeader, aFolder);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgSearchSession::NotifyListenersDone(nsresult status)
|
||||
nsresult nsMsgSearchSession::NotifyListenersDone(nsresult aStatus)
|
||||
{
|
||||
if (m_listenerList)
|
||||
nsTObserverArray<nsCOMPtr<nsIMsgSearchNotify> >::ForwardIterator iter(m_listenerList);
|
||||
nsCOMPtr<nsIMsgSearchNotify> listener;
|
||||
while (iter.HasMore())
|
||||
{
|
||||
PRUint32 count;
|
||||
m_listenerList->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIMsgSearchNotify> pListener;
|
||||
m_listenerList->QueryElementAt(i, NS_GET_IID(nsIMsgSearchNotify),
|
||||
(void **)getter_AddRefs(pListener));
|
||||
if (pListener)
|
||||
pListener->OnSearchDone(status);
|
||||
|
||||
}
|
||||
listener = iter.GetNext();
|
||||
listener->OnSearchDone(aStatus);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsTObserverArray.h"
|
||||
|
||||
class nsMsgSearchAdapter;
|
||||
class nsMsgSearchBoolExpression;
|
||||
|
@ -81,7 +82,7 @@ protected:
|
|||
|
||||
nsMsgSearchScopeTermArray m_scopeList;
|
||||
nsCOMPtr <nsISupportsArray> m_termList;
|
||||
nsCOMPtr <nsISupportsArray> m_listenerList;
|
||||
nsTObserverArray<nsCOMPtr<nsIMsgSearchNotify> > m_listenerList;
|
||||
|
||||
nsMsgResultArray m_resultList;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -64,55 +64,44 @@ nsImapMoveCoalescer::~nsImapMoveCoalescer()
|
|||
nsresult nsImapMoveCoalescer::AddMove(nsIMsgFolder *folder, nsMsgKey key)
|
||||
{
|
||||
m_hasPendingMoves = PR_TRUE;
|
||||
if (!m_destFolders)
|
||||
NS_NewISupportsArray(getter_AddRefs(m_destFolders));
|
||||
if (m_destFolders)
|
||||
{
|
||||
nsCOMPtr <nsISupports> supports = do_QueryInterface(folder);
|
||||
if (supports)
|
||||
{
|
||||
PRInt32 folderIndex = m_destFolders->IndexOf(supports);
|
||||
nsTArray<nsMsgKey> *keysToAdd = nsnull;
|
||||
if (folderIndex >= 0)
|
||||
{
|
||||
keysToAdd = &(m_sourceKeyArrays[folderIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_destFolders->AppendElement(supports);
|
||||
keysToAdd = m_sourceKeyArrays.AppendElement();
|
||||
if (!keysToAdd)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (keysToAdd->IndexOf(key) == -1)
|
||||
keysToAdd->AppendElement(key);
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRInt32 folderIndex = m_destFolders.IndexOf(folder);
|
||||
nsTArray<nsMsgKey> *keysToAdd = nsnull;
|
||||
|
||||
if (folderIndex >= 0)
|
||||
keysToAdd = &(m_sourceKeyArrays[folderIndex]);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
{
|
||||
m_destFolders.AppendObject(folder);
|
||||
keysToAdd = m_sourceKeyArrays.AppendElement();
|
||||
if (!keysToAdd)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (keysToAdd->IndexOf(key) == -1)
|
||||
keysToAdd->AppendElement(key);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsImapMoveCoalescer::PlaybackMoves(PRBool doNewMailNotification /* = PR_FALSE */)
|
||||
{
|
||||
PRUint32 numFolders;
|
||||
PRInt32 numFolders = m_destFolders.Count();
|
||||
// Nothing to do, so don't change the member variables.
|
||||
if (numFolders == 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (!m_destFolders)
|
||||
return NS_OK; // nothing to do.
|
||||
m_hasPendingMoves = PR_FALSE;
|
||||
m_doNewMailNotification = doNewMailNotification;
|
||||
m_destFolders->Count(&numFolders);
|
||||
m_outstandingMoves = 0;
|
||||
for (PRUint32 i = 0; i < numFolders; i++)
|
||||
|
||||
for (PRInt32 i = 0; i < numFolders; ++i)
|
||||
{
|
||||
// XXX TODO
|
||||
// JUNK MAIL RELATED
|
||||
// is this the right place to make sure dest folder exists
|
||||
// (and has proper flags?), before we start copying?
|
||||
nsCOMPtr <nsIMsgFolder> destFolder(do_QueryElementAt(m_destFolders, i));
|
||||
nsCOMPtr <nsIMsgFolder> destFolder(m_destFolders[i]);
|
||||
nsCOMPtr<nsIImapService> imapService =
|
||||
do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#define _nsImapMoveCoalescer_H
|
||||
|
||||
#include "msgCore.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIMsgWindow.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "MailNewsTypes.h"
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
protected:
|
||||
// m_sourceKeyArrays and m_destFolders are parallel arrays.
|
||||
nsTArray<nsTArray<nsMsgKey> > m_sourceKeyArrays;
|
||||
nsCOMPtr <nsISupportsArray> m_destFolders;
|
||||
nsCOMArray<nsIMsgFolder> m_destFolders;
|
||||
nsCOMPtr <nsIMsgWindow> m_msgWindow;
|
||||
nsCOMPtr <nsIMsgFolder> m_sourceFolder;
|
||||
PRBool m_doNewMailNotification;
|
||||
|
|
|
@ -4158,107 +4158,103 @@ NS_IMETHODIMP nsMsgDBFolder::CopyDataDone()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBFolder::NotifyPropertyChanged(nsIAtom *property,
|
||||
const nsACString& oldValue, const nsACString& newValue)
|
||||
nsMsgDBFolder::NotifyPropertyChanged(nsIAtom *aProperty,
|
||||
const nsACString& aOldValue,
|
||||
const nsACString& aNewValue)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
//Folderlisteners aren't refcounted.
|
||||
nsIFolderListener* listener =(nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemPropertyChanged(this, property, nsCString(oldValue).get(), nsCString(newValue).get());
|
||||
}
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemPropertyChanged,
|
||||
(this, aProperty,
|
||||
nsCString(aOldValue).get(),
|
||||
nsCString(aNewValue).get()));
|
||||
|
||||
//Notify listeners who listen to every folder
|
||||
// Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return folderListenerManager->OnItemPropertyChanged(this, property, nsCString(oldValue).get(), nsCString(newValue).get());
|
||||
return folderListenerManager->OnItemPropertyChanged(this, aProperty,
|
||||
nsCString(aOldValue).get(),
|
||||
nsCString(aNewValue).get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBFolder::NotifyUnicharPropertyChanged(nsIAtom *property,
|
||||
const nsAString& oldValue,
|
||||
const nsAString& newValue)
|
||||
nsMsgDBFolder::NotifyUnicharPropertyChanged(nsIAtom *aProperty,
|
||||
const nsAString& aOldValue,
|
||||
const nsAString& aNewValue)
|
||||
{
|
||||
nsresult rv;
|
||||
for (PRInt32 i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
// folderlisteners aren't refcounted in the array
|
||||
nsIFolderListener* listener=(nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemUnicharPropertyChanged(this, property, nsString(oldValue).get(),
|
||||
nsString(newValue).get());
|
||||
}
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemUnicharPropertyChanged,
|
||||
(this, aProperty,
|
||||
nsString(aOldValue).get(),
|
||||
nsString(aNewValue).get()));
|
||||
|
||||
// Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return folderListenerManager->OnItemUnicharPropertyChanged(this,
|
||||
property,
|
||||
nsString(oldValue).get(),
|
||||
nsString(newValue).get());
|
||||
aProperty,
|
||||
nsString(aOldValue).get(),
|
||||
nsString(aNewValue).get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBFolder::NotifyIntPropertyChanged(nsIAtom *property, PRInt32 oldValue, PRInt32 newValue)
|
||||
nsMsgDBFolder::NotifyIntPropertyChanged(nsIAtom *aProperty, PRInt32 aOldValue,
|
||||
PRInt32 aNewValue)
|
||||
{
|
||||
//Don't send off count notifications if they are turned off.
|
||||
if (!mNotifyCountChanges && ((property == kTotalMessagesAtom) ||( property == kTotalUnreadMessagesAtom)))
|
||||
// Don't send off count notifications if they are turned off.
|
||||
if (!mNotifyCountChanges &&
|
||||
((aProperty == kTotalMessagesAtom) ||
|
||||
(aProperty == kTotalUnreadMessagesAtom)))
|
||||
return NS_OK;
|
||||
|
||||
for (PRInt32 i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
//Folderlisteners aren't refcounted.
|
||||
nsIFolderListener* listener =(nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemIntPropertyChanged(this, property, oldValue, newValue);
|
||||
}
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemIntPropertyChanged,
|
||||
(this, aProperty, aOldValue, aNewValue));
|
||||
|
||||
//Notify listeners who listen to every folder
|
||||
// Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return folderListenerManager->OnItemIntPropertyChanged(this, property, oldValue, newValue);
|
||||
return folderListenerManager->OnItemIntPropertyChanged(this, aProperty,
|
||||
aOldValue, aNewValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBFolder::NotifyBoolPropertyChanged(nsIAtom* property,
|
||||
PRBool oldValue, PRBool newValue)
|
||||
nsMsgDBFolder::NotifyBoolPropertyChanged(nsIAtom* aProperty,
|
||||
PRBool aOldValue, PRBool aNewValue)
|
||||
{
|
||||
for (PRInt32 i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
//Folderlisteners aren't refcounted.
|
||||
nsIFolderListener* listener =(nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemBoolPropertyChanged(this, property, oldValue, newValue);
|
||||
}
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemBoolPropertyChanged,
|
||||
(this, aProperty, aOldValue, aNewValue));
|
||||
|
||||
//Notify listeners who listen to every folder
|
||||
// Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return folderListenerManager->OnItemBoolPropertyChanged(this, property, oldValue, newValue);
|
||||
return folderListenerManager->OnItemBoolPropertyChanged(this, aProperty,
|
||||
aOldValue, aNewValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgDBFolder::NotifyPropertyFlagChanged(nsIMsgDBHdr *item, nsIAtom *property,
|
||||
PRUint32 oldValue, PRUint32 newValue)
|
||||
nsMsgDBFolder::NotifyPropertyFlagChanged(nsIMsgDBHdr *aItem, nsIAtom *aProperty,
|
||||
PRUint32 aOldValue, PRUint32 aNewValue)
|
||||
{
|
||||
PRInt32 i;
|
||||
for(i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
//Folderlistener's aren't refcounted.
|
||||
nsIFolderListener *listener = (nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemPropertyFlagChanged(item, property, oldValue, newValue);
|
||||
}
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemPropertyFlagChanged,
|
||||
(aItem, aProperty, aOldValue, aNewValue));
|
||||
|
||||
//Notify listeners who listen to every folder
|
||||
// Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return folderListenerManager->OnItemPropertyFlagChanged(item, property, oldValue, newValue);
|
||||
return folderListenerManager->OnItemPropertyFlagChanged(aItem, aProperty,
|
||||
aOldValue, aNewValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBFolder::NotifyItemAdded(nsISupports *aItem)
|
||||
|
@ -4268,15 +4264,11 @@ NS_IMETHODIMP nsMsgDBFolder::NotifyItemAdded(nsISupports *aItem)
|
|||
if (!notify)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 i;
|
||||
for(i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
//Folderlistener's aren't refcounted.
|
||||
nsIFolderListener *listener = (nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemAdded(this, aItem);
|
||||
}
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemAdded,
|
||||
(this, aItem));
|
||||
|
||||
//Notify listeners who listen to every folder
|
||||
// Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
|
@ -4284,32 +4276,26 @@ NS_IMETHODIMP nsMsgDBFolder::NotifyItemAdded(nsISupports *aItem)
|
|||
return folderListenerManager->OnItemAdded(this, aItem);
|
||||
}
|
||||
|
||||
nsresult nsMsgDBFolder::NotifyItemRemoved(nsISupports *item)
|
||||
nsresult nsMsgDBFolder::NotifyItemRemoved(nsISupports *aItem)
|
||||
{
|
||||
PRInt32 i;
|
||||
for(i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
//Folderlistener's aren't refcounted.
|
||||
nsIFolderListener *listener = (nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemRemoved(this, item);
|
||||
}
|
||||
//Notify listeners who listen to every folder
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemRemoved,
|
||||
(this, aItem));
|
||||
|
||||
// Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return folderListenerManager->OnItemRemoved(this, item);
|
||||
return folderListenerManager->OnItemRemoved(this, aItem);
|
||||
}
|
||||
|
||||
nsresult nsMsgDBFolder::NotifyFolderEvent(nsIAtom* aEvent)
|
||||
{
|
||||
PRInt32 i;
|
||||
for(i = 0; i < mListeners.Count(); i++)
|
||||
{
|
||||
//Folderlistener's aren't refcounted.
|
||||
nsIFolderListener *listener = (nsIFolderListener*)mListeners.ElementAt(i);
|
||||
listener->OnItemEvent(this, aEvent);
|
||||
}
|
||||
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mListeners, nsIFolderListener,
|
||||
OnItemEvent,
|
||||
(this, aEvent));
|
||||
|
||||
//Notify listeners who listen to every folder
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFolderListener> folderListenerManager =
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "nsIOutputStream.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsTObserverArray.h"
|
||||
class nsIMsgFolderCacheElement;
|
||||
class nsIJunkMailPlugin;
|
||||
class nsICollation;
|
||||
|
@ -190,8 +191,8 @@ protected:
|
|||
PRBool mNotifyCountChanges;
|
||||
PRUint32 mExpungedBytes;
|
||||
nsCOMPtr<nsISupportsArray> mSubFolders;
|
||||
nsVoidArray mListeners; //This can't be an nsISupportsArray because due to
|
||||
//ownership issues, listeners can't be AddRef'd
|
||||
// This can't be refcounted due to ownsership issues
|
||||
nsTObserverArray<nsIFolderListener*> mListeners;
|
||||
|
||||
PRBool mInitializedFromCache;
|
||||
nsISupports *mSemaphoreHolder; // set when the folder is being written to
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "nsCOMArray.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsTObserverArray.h"
|
||||
class ListContext;
|
||||
class nsMsgKeySet;
|
||||
class nsMsgThread;
|
||||
|
@ -243,7 +244,7 @@ protected:
|
|||
nsCString m_dbName;
|
||||
nsTArray<nsMsgKey> m_newSet; // new messages since last open.
|
||||
PRBool m_mdbTokensInitialized;
|
||||
nsCOMPtr <nsISupportsArray> m_ChangeListeners;
|
||||
nsTObserverArray<nsCOMPtr<nsIDBChangeListener> > m_ChangeListeners;
|
||||
mdb_token m_hdrRowScopeToken;
|
||||
mdb_token m_threadRowScopeToken;
|
||||
mdb_token m_hdrTableKindToken;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -555,169 +555,88 @@ nsMsgDatabase::CreateMsgHdr(nsIMdbRow* hdrRow, nsMsgKey key, nsIMsgDBHdr* *resul
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::AddListener(nsIDBChangeListener *listener)
|
||||
NS_IMETHODIMP nsMsgDatabase::AddListener(nsIDBChangeListener *aListener)
|
||||
{
|
||||
if (m_ChangeListeners == nsnull)
|
||||
{
|
||||
NS_NewISupportsArray(getter_AddRefs(m_ChangeListeners));
|
||||
if (!m_ChangeListeners)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
// check if this listener is already registered
|
||||
// if already registered, do nothing (not an error)
|
||||
else if (m_ChangeListeners->IndexOf(listener) != -1)
|
||||
return NS_OK;
|
||||
return m_ChangeListeners->AppendElement(listener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::RemoveListener(nsIDBChangeListener *listener)
|
||||
{
|
||||
if (m_ChangeListeners)
|
||||
m_ChangeListeners->RemoveElement(listener);
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
m_ChangeListeners.AppendElementUnlessExists(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::RemoveListener(nsIDBChangeListener *aListener)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
m_ChangeListeners.RemoveElement(aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX should we return rv for listener->propertyfunc_?
|
||||
#define NOTIFY_LISTENERS(propertyfunc_, params_) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsTObserverArray<nsCOMPtr<nsIDBChangeListener> >::ForwardIterator iter(m_ChangeListeners); \
|
||||
nsCOMPtr<nsIDBChangeListener> listener; \
|
||||
while (iter.HasMore()) { \
|
||||
listener = iter.GetNext(); \
|
||||
listener->propertyfunc_ params_; \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
// change announcer methods - just broadcast to all listeners.
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyHdrChangeAll(nsIMsgDBHdr *aHdrChanged, PRUint32 oldFlags, PRUint32 newFlags,
|
||||
nsIDBChangeListener *instigator)
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyHdrChangeAll(nsIMsgDBHdr *aHdrChanged,
|
||||
PRUint32 aOldFlags,
|
||||
PRUint32 aNewFlags,
|
||||
nsIDBChangeListener *aInstigator)
|
||||
{
|
||||
if (!m_ChangeListeners)
|
||||
return NS_OK;
|
||||
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIDBChangeListener> changeListener;
|
||||
m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
|
||||
|
||||
nsresult rv = changeListener->OnHdrChange(aHdrChanged, oldFlags, newFlags, instigator);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
NOTIFY_LISTENERS(OnHdrChange, (aHdrChanged, aOldFlags, aNewFlags, aInstigator));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyReadChanged(nsIDBChangeListener *instigator)
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyReadChanged(nsIDBChangeListener *aInstigator)
|
||||
{
|
||||
if (m_ChangeListeners == nsnull)
|
||||
return NS_OK;
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIDBChangeListener> changeListener;
|
||||
m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
|
||||
|
||||
nsresult rv = changeListener->OnReadChanged(instigator);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
NOTIFY_LISTENERS(OnReadChanged, (aInstigator));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyJunkScoreChanged(nsIDBChangeListener *instigator)
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyJunkScoreChanged(nsIDBChangeListener *aInstigator)
|
||||
{
|
||||
if (m_ChangeListeners == nsnull)
|
||||
return NS_OK;
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIDBChangeListener> changeListener;
|
||||
m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
|
||||
|
||||
nsresult rv = changeListener->OnJunkScoreChanged(instigator);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
NOTIFY_LISTENERS(OnJunkScoreChanged, (aInstigator));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyHdrDeletedAll(nsIMsgDBHdr *aHdrDeleted, nsMsgKey parentKey, PRInt32 flags,
|
||||
nsIDBChangeListener *instigator)
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyHdrDeletedAll(nsIMsgDBHdr *aHdrDeleted,
|
||||
nsMsgKey aParentKey,
|
||||
PRInt32 aFlags,
|
||||
nsIDBChangeListener *aInstigator)
|
||||
{
|
||||
if (m_ChangeListeners == nsnull)
|
||||
return NS_OK;
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIDBChangeListener> changeListener;
|
||||
m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
|
||||
nsresult rv = changeListener->OnHdrDeleted(aHdrDeleted, parentKey, flags, instigator);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
NOTIFY_LISTENERS(OnHdrDeleted, (aHdrDeleted, aParentKey, aFlags, aInstigator));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyHdrAddedAll(nsIMsgDBHdr *aHdrAdded, nsMsgKey parentKey, PRInt32 flags,
|
||||
nsIDBChangeListener *instigator)
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyHdrAddedAll(nsIMsgDBHdr *aHdrAdded,
|
||||
nsMsgKey aParentKey,
|
||||
PRInt32 aFlags,
|
||||
nsIDBChangeListener *aInstigator)
|
||||
{
|
||||
#ifdef DEBUG_bienvenu1
|
||||
printf("notifying add of %ld parent %ld\n", keyAdded, parentKey);
|
||||
#endif
|
||||
if (m_ChangeListeners == nsnull)
|
||||
return NS_OK;
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIDBChangeListener> changeListener;
|
||||
m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
|
||||
|
||||
nsresult rv = changeListener->OnHdrAdded(aHdrAdded, parentKey, flags, instigator);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
NOTIFY_LISTENERS(OnHdrAdded, (aHdrAdded, aParentKey, aFlags, aInstigator));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyParentChangedAll(nsMsgKey keyReparented, nsMsgKey oldParent, nsMsgKey newParent,
|
||||
nsIDBChangeListener *instigator)
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyParentChangedAll(nsMsgKey aKeyReparented,
|
||||
nsMsgKey aOldParent,
|
||||
nsMsgKey aNewParent,
|
||||
nsIDBChangeListener *aInstigator)
|
||||
{
|
||||
if (m_ChangeListeners == nsnull)
|
||||
return NS_OK;
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
|
||||
if (!count)
|
||||
return NS_OK;
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsIDBChangeListener> changeListener;
|
||||
m_ChangeListeners->QueryElementAt(i, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
|
||||
nsresult rv = changeListener->OnParentChanged(keyReparented, oldParent, newParent, instigator);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
NOTIFY_LISTENERS(OnParentChanged,
|
||||
(aKeyReparented, aOldParent, aNewParent, aInstigator));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgDatabase::NotifyAnnouncerGoingAway(void)
|
||||
{
|
||||
if (m_ChangeListeners == nsnull)
|
||||
return NS_OK;
|
||||
// run loop backwards because listeners remove themselves from the list
|
||||
// on this notification
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
|
||||
if (!count)
|
||||
return NS_OK;
|
||||
|
||||
for (PRUint32 i = count; i != 0 ; i--)
|
||||
{
|
||||
nsCOMPtr<nsIDBChangeListener> changeListener;
|
||||
m_ChangeListeners->QueryElementAt(i - 1, NS_GET_IID(nsIDBChangeListener), (void **) getter_AddRefs(changeListener));
|
||||
if (changeListener) {
|
||||
nsresult rv = changeListener->OnAnnouncerGoingAway(this);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
}
|
||||
NOTIFY_LISTENERS(OnAnnouncerGoingAway, (this));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -863,7 +782,7 @@ nsMsgDatabase::nsMsgDatabase()
|
|||
m_mdbEnv(nsnull), m_mdbStore(nsnull),
|
||||
m_mdbAllMsgHeadersTable(nsnull), m_mdbAllThreadsTable(nsnull),
|
||||
m_dbName(""),
|
||||
m_mdbTokensInitialized(PR_FALSE), m_ChangeListeners(nsnull),
|
||||
m_mdbTokensInitialized(PR_FALSE),
|
||||
m_hdrRowScopeToken(0),
|
||||
m_hdrTableKindToken(0),
|
||||
m_threadTableKindToken(0),
|
||||
|
@ -944,14 +863,9 @@ nsMsgDatabase::~nsMsgDatabase()
|
|||
m_mdbEnv->Release(); //??? is this right?
|
||||
m_mdbEnv = nsnull;
|
||||
}
|
||||
if (m_ChangeListeners)
|
||||
{
|
||||
//better not be any listeners, because we're going away.
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
NS_ASSERTION(count == 0, "shouldn't have any listeners");
|
||||
m_ChangeListeners = nsnull;
|
||||
}
|
||||
|
||||
// Better not be any listeners, because we're going away.
|
||||
NS_ASSERTION(m_ChangeListeners.IsEmpty(), "shouldn't have any listeners");
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMsgDatabase)
|
||||
|
@ -1305,13 +1219,10 @@ NS_IMETHODIMP nsMsgDatabase::ForceClosed()
|
|||
m_mdbStore->Release();
|
||||
m_mdbStore = nsnull;
|
||||
}
|
||||
if (m_ChangeListeners)
|
||||
{
|
||||
PRUint32 count;
|
||||
m_ChangeListeners->Count(&count);
|
||||
// better not be any listeners, because we're going away.
|
||||
NS_ASSERTION(count == 0, "shouldn't have any listeners left");
|
||||
}
|
||||
|
||||
// better not be any listeners, because we're going away.
|
||||
NS_ASSERTION(m_ChangeListeners.IsEmpty(), "shouldn't have any listeners left");
|
||||
|
||||
Release();
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,6 @@ static const PRInt32 kNumHdrsToXfer=10;
|
|||
|
||||
nsMsgImapHdrXferInfo::nsMsgImapHdrXferInfo()
|
||||
{
|
||||
m_hdrInfos = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
|
||||
m_nextFreeHdrInfo = 0;
|
||||
}
|
||||
|
||||
|
@ -145,10 +144,12 @@ NS_IMETHODIMP nsMsgImapHdrXferInfo::GetNumHeaders(PRInt32 *aNumHeaders)
|
|||
|
||||
NS_IMETHODIMP nsMsgImapHdrXferInfo::GetHeader(PRInt32 hdrIndex, nsIImapHeaderInfo **aResult)
|
||||
{
|
||||
if (m_hdrInfos)
|
||||
return m_hdrInfos->QueryElementAt(hdrIndex, NS_GET_IID(nsIImapHeaderInfo), (void **) aResult);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = m_hdrInfos.SafeObjectAt(hdrIndex);
|
||||
if (!*aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static const PRInt32 kInitLineHdrCacheSize = 512; // should be about right
|
||||
|
@ -160,7 +161,9 @@ nsresult nsMsgImapHdrXferInfo::GetFreeHeaderInfo(nsIImapHeaderInfo **aResult)
|
|||
*aResult = nsnull;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsresult rv = m_hdrInfos->QueryElementAt(m_nextFreeHdrInfo++, NS_GET_IID(nsIImapHeaderInfo), (void **) aResult);
|
||||
|
||||
*aResult = m_hdrInfos.SafeObjectAt(m_nextFreeHdrInfo++);
|
||||
nsresult rv = NS_OK;
|
||||
if (!*aResult && m_nextFreeHdrInfo - 1 < kNumHdrsToXfer)
|
||||
{
|
||||
nsMsgImapLineDownloadCache *lineCache = new nsMsgImapLineDownloadCache();
|
||||
|
@ -168,7 +171,7 @@ nsresult nsMsgImapHdrXferInfo::GetFreeHeaderInfo(nsIImapHeaderInfo **aResult)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = lineCache->GrowBuffer(kInitLineHdrCacheSize);
|
||||
NS_ADDREF(*aResult = lineCache);
|
||||
m_hdrInfos->AppendElement(lineCache);
|
||||
m_hdrInfos.AppendObject(lineCache);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -186,11 +189,11 @@ void nsMsgImapHdrXferInfo::FinishCurrentHdr()
|
|||
|
||||
void nsMsgImapHdrXferInfo::ResetAll()
|
||||
{
|
||||
nsCOMPtr <nsIImapHeaderInfo> hdrInfo;
|
||||
for (PRInt32 i = 0; i < kNumHdrsToXfer; i++)
|
||||
PRInt32 count = m_hdrInfos.Count();
|
||||
for (PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsresult rv = GetHeader(i, getter_AddRefs(hdrInfo));
|
||||
if (NS_SUCCEEDED(rv) && hdrInfo)
|
||||
nsIImapHeaderInfo *hdrInfo = m_hdrInfos[i];
|
||||
if (hdrInfo)
|
||||
hdrInfo->ResetCache();
|
||||
}
|
||||
m_nextFreeHdrInfo = 0;
|
||||
|
@ -198,7 +201,7 @@ void nsMsgImapHdrXferInfo::ResetAll()
|
|||
|
||||
void nsMsgImapHdrXferInfo::ReleaseAll()
|
||||
{
|
||||
m_hdrInfos->Clear();
|
||||
m_hdrInfos.Clear();
|
||||
m_nextFreeHdrInfo = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
#include "nsMsgLineBuffer.h" // we need this to use the nsMsgLineStreamBuffer helper class...
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIMsgIncomingServer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIImapMockChannel.h"
|
||||
|
@ -136,7 +136,7 @@ public:
|
|||
nsIImapHeaderInfo *GetCurrentHdrInfo();
|
||||
// call when we've finished adding lines to current hdr
|
||||
void FinishCurrentHdr();
|
||||
nsCOMPtr <nsISupportsArray> m_hdrInfos;
|
||||
nsCOMArray<nsIImapHeaderInfo> m_hdrInfos;
|
||||
PRInt32 m_nextFreeHdrInfo;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче