Bug 292350 Document nsIAbListener and part of nsIAddrBookSession. Also move some constants to a more logical location r=dmose,sr=bienvenu,a=asa

git-svn-id: svn://10.0.0.236/trunk@176346 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bugzilla%standard8.demon.co.uk 2005-07-20 18:57:24 +00:00
parent 80b80340c6
commit 23fb9648fd
9 changed files with 113 additions and 22 deletions

View File

@ -146,8 +146,10 @@ function AbPanelLoad()
// selected directory's name is modified
var addrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
// this listener only cares when a directory is removed or modified
addrbookSession.addAddressBookListener(gAddressBookPanelAbListener,
Components.interfaces.nsIAbListener.directoryRemoved | Components.interfaces.nsIAbListener.changed);
addrbookSession.addAddressBookListener(
gAddressBookPanelAbListener,
Components.interfaces.nsIAddrBookSession.directoryRemoved |
Components.interfaces.nsIAddrBookSession.changed);
gSearchInput = document.getElementById("searchInput");
}

View File

@ -214,8 +214,8 @@ function delayedOnLoadAddressBook()
// interested in mailing list changes and not cards but we have to have both.
addrbookSession.addAddressBookListener(
gAddressBookAbListener,
Components.interfaces.nsIAbListener.directoryRemoved |
Components.interfaces.nsIAbListener.directoryItemRemoved);
Components.interfaces.nsIAddrBookSession.directoryRemoved |
Components.interfaces.nsIAddrBookSession.directoryItemRemoved);
var dirTree = GetDirTree();
dirTree.addEventListener("click",DirPaneClick,true);

View File

@ -41,17 +41,60 @@
typedef unsigned long abListenerNotifyFlagValue;
[scriptable, uuid(1920E484-0709-11d3-A2EC-001083003D0C)]
/**
* nsIAbListener
*
* Implement this interface to receive notifications of address book
* items being added, removed or changed with loaded address books.
*
* Subscribe to events by using nsIAddrBookSession. See nsIAddrBookSession.idl
* for details of individual types of events that may be subscribed to.
*
*/
[scriptable, uuid(8c5b1f3d-983a-4854-a0e2-3719dba1a920)]
interface nsIAbListener : nsISupports {
const abListenerNotifyFlagValue added = 0x1;
/**
* Called when an address book item (book, card or list) is added
*
* @param parentDir The parent of the item being added.
*
* @param item The item being added to the database (a
* directory or card).
*
*/
void onItemAdded(in nsISupports parentDir, in nsISupports item);
const abListenerNotifyFlagValue directoryItemRemoved = 0x2;
const abListenerNotifyFlagValue directoryRemoved = 0x4;
/**
* Called when an address book, mailing list or card is removed. This
* is partially configurable when setting up the listener via
* nsIAddrBookSession
*
* @param parentDir The parent of the item being removed, this
* may be an empty directory in the case of a
* top level address book.
*
* @param item The item being removed from the database.
*
*/
void onItemRemoved(in nsISupports parentDir, in nsISupports item);
const abListenerNotifyFlagValue changed = 0x8;
/**
* Called when an address book item is changed. Note the current
* implementation means that property is either the literal string "DirName"
* or null, with oldValue and newValue being specified if the property is
* "DirName" otherwise they are null.
*
* @param item The item being updated (a directory or a
* card).
*
* @param property The property of the item being changed.
*
* @param oldValue The old value of the item property being
* changed if it is known, null otherwise.
*
* @param newValue The new value of the item property being
* changed.
*
*/
void onItemPropertyChanged(in nsISupports item, in string property, in wstring oldValue, in wstring newValue);
const abListenerNotifyFlagValue all = 0xFFFFFFFF;
};

View File

@ -53,9 +53,53 @@
interface nsILocalFile;
[scriptable, uuid(957abaa8-5cef-49d0-84a5-ce43da384990)]
[scriptable, uuid(90533607-7205-473f-b688-ffb50eeb5d57)]
interface nsIAddrBookSession : nsISupports {
/**
* Adds a nsIAbListener to receive notifications of address book updates
* according to the specified notifyFlags.
*
* @param listener The listener that is to receive updates.
*
* @param notifyFlags A bitwise-or of abListenerNotifyFlagValue items
* specifying which notifications to receive.
*
*/
void addAddressBookListener(in nsIAbListener listener, in abListenerNotifyFlagValue notifyFlags);
/**
* These flags specify when to receive notifications of address book updates
* to be passed to addAddressBookListener.
*/
/**
* An address book, mailing list or card is added.
*/
const abListenerNotifyFlagValue added = 0x1;
/**
* A mailing list or card is removed from an address book.
*/
const abListenerNotifyFlagValue directoryItemRemoved = 0x2;
/**
* An address book is removed
*/
const abListenerNotifyFlagValue directoryRemoved = 0x4;
/**
* An address book, mailing list or card is changed.
*/
const abListenerNotifyFlagValue changed = 0x8;
/**
* All of the above notifications are to be received.
*/
const abListenerNotifyFlagValue all = 0xFFFFFFFF;
/**
* Removes a nsIAbListener from receive notifications of address book
* updates.
*
* @param listener The listener that is to no longer receive updates.
*
*/
void removeAddressBookListener(in nsIAbListener listener);
void notifyItemPropertyChanged(in nsISupports item,
in string property,

View File

@ -102,8 +102,10 @@ function AbPanelLoad()
// selected directory's name is modified
var addrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
// this listener only cares when a directory is removed or modified
addrbookSession.addAddressBookListener(gAddressBookPanelAbListener,
Components.interfaces.nsIAbListener.directoryRemoved | Components.interfaces.nsIAbListener.changed);
addrbookSession.addAddressBookListener(
gAddressBookPanelAbListener,
Components.interfaces.nsIAddrBookSession.directoryRemoved |
Components.interfaces.nsIAddrBookSession.changed);
gSearchInput = document.getElementById("searchInput");

View File

@ -211,8 +211,8 @@ function OnLoadAddressBook()
// interested in mailing list changes and not cards but we have to have both.
addrbookSession.addAddressBookListener(
gAddressBookAbListener,
Components.interfaces.nsIAbListener.directoryRemoved |
Components.interfaces.nsIAbListener.directoryItemRemoved);
Components.interfaces.nsIAddrBookSession.directoryRemoved |
Components.interfaces.nsIAddrBookSession.directoryItemRemoved);
var dirTree = GetDirTree();
dirTree.addEventListener("click",DirPaneClick,true);

View File

@ -261,7 +261,7 @@ NS_IMETHODIMP nsAbView::Init(const char *aURI, PRBool aSearchView, nsIAbViewList
NS_ENSURE_SUCCESS(rv,rv);
// this listener cares about all events
rv = abSession->AddAddressBookListener(this, nsIAbListener::all);
rv = abSession->AddAddressBookListener(this, nsIAddrBookSession::all);
NS_ENSURE_SUCCESS(rv,rv);
if (mAbViewListener && !mSuppressCountChange) {

View File

@ -99,7 +99,7 @@ NS_IMETHODIMP nsAddrBookSession::NotifyItemPropertyChanged(nsISupports *item, co
NS_ENSURE_SUCCESS(rv, rv);
for(i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIAbListener::changed) {
if (mListenerNotifyFlags[i] & changed) {
nsCOMPtr<nsIAbListener> listener;
mListeners->QueryElementAt(i, NS_GET_IID(nsIAbListener), (void **) getter_AddRefs(listener));
NS_ASSERTION(listener, "listener is null");
@ -120,7 +120,7 @@ NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryItemAdded(nsIAbDirectory *direct
NS_ENSURE_SUCCESS(rv, rv);
for(i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIAbListener::added) {
if (mListenerNotifyFlags[i] & added) {
nsCOMPtr<nsIAbListener> listener;
mListeners->QueryElementAt(i, NS_GET_IID(nsIAbListener), (void **) getter_AddRefs(listener));
NS_ASSERTION(listener, "listener is null");
@ -143,7 +143,7 @@ NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryItemDeleted(nsIAbDirectory *dire
NS_ENSURE_SUCCESS(rv, rv);
for(i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIAbListener::directoryItemRemoved) {
if (mListenerNotifyFlags[i] & directoryItemRemoved) {
nsCOMPtr<nsIAbListener> listener;
mListeners->QueryElementAt(i, NS_GET_IID(nsIAbListener), (void **) getter_AddRefs(listener));
NS_ASSERTION(listener, "listener is null");
@ -165,7 +165,7 @@ NS_IMETHODIMP nsAddrBookSession::NotifyDirectoryDeleted(nsIAbDirectory *director
NS_ENSURE_SUCCESS(rv, rv);
for(i = 0; i < count; i++)
{
if (mListenerNotifyFlags[i] & nsIAbListener::directoryRemoved) {
if (mListenerNotifyFlags[i] & directoryRemoved) {
nsCOMPtr<nsIAbListener> listener;
mListeners->QueryElementAt(i, NS_GET_IID(nsIAbListener), (void **) getter_AddRefs(listener));
NS_ASSERTION(listener, "listener is null");

View File

@ -131,7 +131,7 @@ nsAbDirectoryDataSource::Init()
NS_ENSURE_SUCCESS(rv,rv);
// this listener cares about all events
rv = abSession->AddAddressBookListener(this, nsIAbListener::all);
rv = abSession->AddAddressBookListener(this, nsIAddrBookSession::all);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1", &rv);