michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIObserver; michael@0: interface nsISimpleEnumerator; michael@0: michael@0: /** michael@0: * nsIObserverService michael@0: * michael@0: * Service allows a client listener (nsIObserver) to register and unregister for michael@0: * notifications of specific string referenced topic. Service also provides a michael@0: * way to notify registered listeners and a way to enumerate registered client michael@0: * listeners. michael@0: */ michael@0: michael@0: [scriptable, uuid(D07F5192-E3D1-11d2-8ACD-00105A1B8860)] michael@0: interface nsIObserverService : nsISupports michael@0: { michael@0: michael@0: /** michael@0: * AddObserver michael@0: * michael@0: * Registers a given listener for a notifications regarding the specified michael@0: * topic. michael@0: * michael@0: * @param anObserve : The interface pointer which will receive notifications. michael@0: * @param aTopic : The notification topic or subject. michael@0: * @param ownsWeak : If set to false, the nsIObserverService will hold a michael@0: * strong reference to |anObserver|. If set to true and michael@0: * |anObserver| supports the nsIWeakReference interface, michael@0: * a weak reference will be held. Otherwise an error will be michael@0: * returned. michael@0: */ michael@0: void addObserver( in nsIObserver anObserver, in string aTopic, in boolean ownsWeak); michael@0: michael@0: /** michael@0: * removeObserver michael@0: * michael@0: * Unregisters a given listener from notifications regarding the specified michael@0: * topic. michael@0: * michael@0: * @param anObserver : The interface pointer which will stop recieving michael@0: * notifications. michael@0: * @param aTopic : The notification topic or subject. michael@0: */ michael@0: void removeObserver( in nsIObserver anObserver, in string aTopic ); michael@0: michael@0: /** michael@0: * notifyObservers michael@0: * michael@0: * Notifies all registered listeners of the given topic. michael@0: * michael@0: * @param aSubject : Notification specific interface pointer. michael@0: * @param aTopic : The notification topic or subject. michael@0: * @param someData : Notification specific wide string. michael@0: */ michael@0: void notifyObservers( in nsISupports aSubject, michael@0: in string aTopic, michael@0: in wstring someData ); michael@0: michael@0: /** michael@0: * enumerateObservers michael@0: * michael@0: * Returns an enumeration of all registered listeners. michael@0: * michael@0: * @param aTopic : The notification topic or subject. michael@0: */ michael@0: nsISimpleEnumerator enumerateObservers( in string aTopic ); michael@0: michael@0: michael@0: }; michael@0: michael@0: