Bug 226270 Rationalization of folder listeners, part 3: search listener can cut out the middle man r=bienvenu sr=mscott

This commit is contained in:
neil%parkwaycc.co.uk 2004-04-28 12:48:58 +00:00
parent df9ede2b39
commit efbcf0bf61
5 changed files with 4 additions and 108 deletions

View File

@ -114,13 +114,11 @@ function removeListeners()
function removeGlobalListeners()
{
removeListeners();
gSearchSession.removeFolderListener(folderListener);
gSearchSession.unregisterListener(gSearchNotificationListener);
}
function initializeGlobalListeners()
{
gSearchSession.addFolderListener(folderListener);
// Setup the javascript object as a listener on the search results
gSearchSession.registerListener(gSearchNotificationListener);
}

View File

@ -38,7 +38,6 @@
#include "nsISupports.idl"
#include "nsMsgSearchCore.idl"
#include "nsIMsgSearchValue.idl"
#include "nsIFolderListener.idl"
interface nsMsgResultElement;
interface nsIMsgSearchAdapter;
@ -133,7 +132,4 @@ interface nsIMsgSearchSession : nsISupports {
/* these longs are all actually of type nsMsgSearchBooleanOp */
const long BooleanOR=0;
const long BooleanAND=1;
void addFolderListener(in nsIFolderListener listener);
void removeFolderListener(in nsIFolderListener listener);
};

View File

@ -278,8 +278,7 @@ function searchOnUnload()
gSearchSession.unregisterListener(gViewSearchListener);
gSearchSession.unregisterListener(gSearchNotificationListener);
gMailSession.RemoveFolderListener(gSearchSessionFolderListener);
gSearchSession.removeFolderListener(gFolderListener);
gMailSession.RemoveFolderListener(gFolderListener);
if (gSearchView) {
gSearchView.close();
@ -526,12 +525,11 @@ function setupDatasource() {
gMailSession = Components.classes[mailSessionContractID].getService(Components.interfaces.nsIMsgMailSession);
var nsIFolderListener = Components.interfaces.nsIFolderListener;
var notifyFlags = nsIFolderListener.event;
gMailSession.AddFolderListener(gSearchSessionFolderListener, notifyFlags);
gMailSession.AddFolderListener(gFolderListener, notifyFlags);
// the datasource is a listener on the search results
gViewSearchListener = gSearchView.QueryInterface(Components.interfaces.nsIMsgSearchNotify);
gSearchSession.registerListener(gViewSearchListener);
gSearchSession.addFolderListener(gFolderListener);
}

View File

@ -51,7 +51,7 @@
#include "nsMsgFolderFlags.h"
#include "nsMsgLocalSearch.h"
NS_IMPL_ISUPPORTS4(nsMsgSearchSession, nsIMsgSearchSession, nsIUrlListener, nsIFolderListener, nsISupportsWeakReference)
NS_IMPL_ISUPPORTS3(nsMsgSearchSession, nsIMsgSearchSession, nsIUrlListener, nsISupportsWeakReference)
nsMsgSearchSession::nsMsgSearchSession()
{
@ -720,99 +720,6 @@ nsMsgSearchSession::EnableFolderNotifications(PRBool aEnable)
}
}
NS_IMETHODIMP
nsMsgSearchSession::AddFolderListener(nsIFolderListener *listener)
{
return m_folderListenerList.AppendObject(listener) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMsgSearchSession::RemoveFolderListener(nsIFolderListener *listener)
{
m_folderListenerList.RemoveObject(listener);
return NS_OK;
}
// nsIFolderListener methods.
NS_IMETHODIMP
nsMsgSearchSession::OnItemEvent(nsIMsgFolder *aFolder,
nsIAtom *aEvent)
{
PRInt32 count = m_folderListenerList.Count();
for(PRInt32 i = 0; i < count; i++)
{
nsIFolderListener* listener = m_folderListenerList[i];
if(listener)
listener->OnItemEvent(aFolder, aEvent);
}
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::OnItemAdded(nsIRDFResource *parentItem,
nsISupports *item)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::OnItemRemoved(nsIRDFResource *parentItem,
nsISupports *item)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::OnItemPropertyChanged(nsIRDFResource *item,
nsIAtom *property,
const char* oldValue,
const char* newValue)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::OnItemIntPropertyChanged(nsIRDFResource *item,
nsIAtom *property,
PRInt32 oldValue,
PRInt32 newValue)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::OnItemBoolPropertyChanged(nsIRDFResource *item,
nsIAtom *property,
PRBool oldValue,
PRBool newValue)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::OnItemUnicharPropertyChanged(nsIRDFResource *item,
nsIAtom *property,
const PRUnichar* oldValue,
const PRUnichar* newValue)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchSession::OnItemPropertyFlagChanged(nsISupports *item,
nsIAtom *property,
PRUint32 oldValue,
PRUint32 newValue)
{
return NS_OK;
}
//this method is used for adding new hdrs to quick search view
NS_IMETHODIMP
nsMsgSearchSession::MatchHdr(nsIMsgDBHdr *aMsgHdr, nsIMsgDatabase *aDatabase, PRBool *aResult)

View File

@ -42,7 +42,6 @@
#include "nsMsgSearchCore.h"
#include "nsIMsgSearchSession.h"
#include "nsIUrlListener.h"
#include "nsIFolderListener.h"
#include "nsIMsgWindow.h"
#include "nsITimer.h"
#include "nsMsgSearchArray.h"
@ -52,13 +51,12 @@
class nsMsgSearchAdapter;
class nsMsgSearchSession : public nsIMsgSearchSession, public nsIUrlListener, public nsIFolderListener, public nsSupportsWeakReference
class nsMsgSearchSession : public nsIMsgSearchSession, public nsIUrlListener, public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMSGSEARCHSESSION
NS_DECL_NSIURLLISTENER
NS_DECL_NSIFOLDERLISTENER
nsMsgSearchSession();
virtual ~nsMsgSearchSession();
@ -84,7 +82,6 @@ protected:
nsMsgSearchScopeTermArray m_scopeList;
nsCOMPtr <nsISupportsArray> m_termList;
nsCOMPtr <nsISupportsArray> m_listenerList;
nsCOMArray<nsIFolderListener> m_folderListenerList;
nsMsgResultArray m_resultList;