new files, not in build

This commit is contained in:
chuang%netscape.com 1999-07-07 00:06:01 +00:00
parent a8e4c3ea58
commit 7f1968a315
2 changed files with 149 additions and 0 deletions

View File

@ -0,0 +1,100 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCOMPtr.h"
#include "nsAddrBookSession.h"
#include "nsIAddrBookSession.h"
NS_IMPL_ISUPPORTS(nsAddrBookSession, nsCOMTypeInfo<nsIAddrBookSession>::GetIID());
nsAddrBookSession::nsAddrBookSession():
mRefCnt(0)
{
NS_INIT_REFCNT();
mListeners = new nsVoidArray();
}
nsAddrBookSession::~nsAddrBookSession()
{
if (mListeners)
{
delete mListeners;
}
}
// nsIAddrBookSession
NS_IMETHODIMP nsAddrBookSession::AddAddressBookListener(nsIAbListener * listener)
{
mListeners->AppendElement(listener);
return NS_OK;
}
NS_IMETHODIMP nsAddrBookSession::RemoveAddressBookListener(nsIAbListener * listener)
{
mListeners->RemoveElement(listener);
return NS_OK;
}
NS_IMETHODIMP nsAddrBookSession::NotifyItemPropertyChanged
(nsISupports *item, const char *property, const char* oldValue, const char* newValue)
{
PRInt32 i;
PRInt32 count = mListeners->Count();
for(i = 0; i < count; i++)
{
nsIAbListener* listener =(nsIAbListener*)mListeners->ElementAt(i);
listener->OnItemPropertyChanged(item, property, oldValue, newValue);
}
return NS_OK;
}
NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryItemAdded(nsIAbDirectory *directory, nsISupports *item)
{
PRInt32 i;
PRInt32 count = mListeners->Count();
for(i = 0; i < count; i++)
{
nsIAbListener *listener = (nsIAbListener*)mListeners->ElementAt(i);
listener->OnItemAdded(directory, item);
}
return NS_OK;
}
NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryItemDeleted(nsIAbDirectory *directory, nsISupports *item)
{
PRInt32 i;
PRInt32 count = mListeners->Count();
for(i = 0; i < count; i++)
{
nsIAbListener *listener = (nsIAbListener*)mListeners->ElementAt(i);
listener->OnItemRemoved(directory, item);
}
return NS_OK;
}

View File

@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsAddrBookSession_h___
#define nsAddrBookSession_h___
#include "nsIAddrBookSession.h"
#include "nsISupports.h"
#include "nsVoidArray.h"
class nsAddrBookSession : public nsIAddrBookSession
{
public:
nsAddrBookSession();
virtual ~nsAddrBookSession();
NS_DECL_ISUPPORTS
// nsIAddrBookSession support
NS_IMETHOD AddAddressBookListener(nsIAbListener *listener);
NS_IMETHOD RemoveAddressBookListener(nsIAbListener *listener);
NS_IMETHOD NotifyItemPropertyChanged(nsISupports *item, const char *property, const char* oldValue, const char* newValue);
NS_IMETHOD NotifyDirectoryItemAdded(nsIAbDirectory *directory, nsISupports *item);
NS_IMETHOD NotifyDirectoryItemDeleted(nsIAbDirectory *directory, nsISupports *item);
protected:
nsVoidArray *mListeners;
};
#endif /* nsAddrBookSession_h__ */