mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-03 21:22:47 +00:00
Add folder listener routines.
This commit is contained in:
parent
511b805dfa
commit
358cdf3322
@ -48,11 +48,19 @@ nsMsgMailSession::nsMsgMailSession():
|
|||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
m_accountManager->LoadAccounts();
|
m_accountManager->LoadAccounts();
|
||||||
|
|
||||||
|
mListeners = new nsVoidArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsMsgMailSession::~nsMsgMailSession()
|
nsMsgMailSession::~nsMsgMailSession()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(m_accountManager);
|
NS_IF_RELEASE(m_accountManager);
|
||||||
|
|
||||||
|
if (mListeners)
|
||||||
|
{
|
||||||
|
delete mListeners;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,3 +101,73 @@ nsresult nsMsgMailSession::GetAccountManager(nsIMsgAccountManager* *aAM)
|
|||||||
NS_IF_ADDREF(*aAM);
|
NS_IF_ADDREF(*aAM);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMsgMailSession::AddFolderListener(nsIFolderListener * listener)
|
||||||
|
{
|
||||||
|
mListeners->AppendElement(listener);
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMsgMailSession::RemoveFolderListener(nsIFolderListener * listener)
|
||||||
|
{
|
||||||
|
mListeners->RemoveElement(listener);
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMsgMailSession::NotifyFolderItemPropertyChanged(nsISupports *item, char *property, char* oldValue, char* newValue)
|
||||||
|
{
|
||||||
|
PRInt32 i;
|
||||||
|
for(i = 0; i < mListeners->Count(); i++)
|
||||||
|
{
|
||||||
|
//Folderlistener's aren't refcounted.
|
||||||
|
nsIFolderListener* listener =(nsIFolderListener*)mListeners->ElementAt(i);
|
||||||
|
listener->OnItemPropertyChanged(item, property, oldValue, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMsgMailSession::NotifyFolderItemPropertyFlagChanged(nsISupports *item, char *property,
|
||||||
|
PRUint32 oldValue, PRUint32 newValue)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMsgMailSession::NotifyFolderItemAdded(nsIFolder *folder, nsISupports *item)
|
||||||
|
{
|
||||||
|
PRInt32 i;
|
||||||
|
for(i = 0; i < mListeners->Count(); i++)
|
||||||
|
{
|
||||||
|
//Folderlistener's aren't refcounted.
|
||||||
|
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
|
||||||
|
listener->OnItemAdded(folder, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsMsgMailSession::NotifyFolderItemDeleted(nsIFolder *folder, nsISupports *item)
|
||||||
|
{
|
||||||
|
PRInt32 i;
|
||||||
|
for(i = 0; i < mListeners->Count(); i++)
|
||||||
|
{
|
||||||
|
//Folderlistener's aren't refcounted.
|
||||||
|
nsIFolderListener *listener = (nsIFolderListener*)mListeners->ElementAt(i);
|
||||||
|
listener->OnItemRemoved(folder, item);
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -46,8 +46,19 @@ public:
|
|||||||
NS_IMETHOD GetCurrentServer(nsIMsgIncomingServer **aServer);
|
NS_IMETHOD GetCurrentServer(nsIMsgIncomingServer **aServer);
|
||||||
NS_IMETHOD GetAccountManager(nsIMsgAccountManager* *aAM);
|
NS_IMETHOD GetAccountManager(nsIMsgAccountManager* *aAM);
|
||||||
|
|
||||||
|
NS_IMETHOD AddFolderListener(nsIFolderListener *listener);
|
||||||
|
NS_IMETHOD RemoveFolderListener(nsIFolderListener *listener);
|
||||||
|
NS_IMETHOD NotifyFolderItemPropertyChanged(nsISupports *item, char *property, char* oldValue, char* newValue);
|
||||||
|
NS_IMETHOD NotifyFolderItemPropertyFlagChanged(nsISupports *item, char *property, PRUint32 oldValue,
|
||||||
|
PRUint32 newValue);
|
||||||
|
NS_IMETHOD NotifyFolderItemAdded(nsIFolder *folder, nsISupports *item);
|
||||||
|
NS_IMETHOD NotifyFolderItemDeleted(nsIFolder *folder, nsISupports *item);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsIMsgAccountManager *m_accountManager;
|
nsIMsgAccountManager *m_accountManager;
|
||||||
|
nsVoidArray *mListeners;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsMsgMailSession_h__ */
|
#endif /* nsMsgMailSession_h__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user