|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIObserver; |
|
9 interface nsISimpleEnumerator; |
|
10 |
|
11 /** |
|
12 * nsIObserverService |
|
13 * |
|
14 * Service allows a client listener (nsIObserver) to register and unregister for |
|
15 * notifications of specific string referenced topic. Service also provides a |
|
16 * way to notify registered listeners and a way to enumerate registered client |
|
17 * listeners. |
|
18 */ |
|
19 |
|
20 [scriptable, uuid(D07F5192-E3D1-11d2-8ACD-00105A1B8860)] |
|
21 interface nsIObserverService : nsISupports |
|
22 { |
|
23 |
|
24 /** |
|
25 * AddObserver |
|
26 * |
|
27 * Registers a given listener for a notifications regarding the specified |
|
28 * topic. |
|
29 * |
|
30 * @param anObserve : The interface pointer which will receive notifications. |
|
31 * @param aTopic : The notification topic or subject. |
|
32 * @param ownsWeak : If set to false, the nsIObserverService will hold a |
|
33 * strong reference to |anObserver|. If set to true and |
|
34 * |anObserver| supports the nsIWeakReference interface, |
|
35 * a weak reference will be held. Otherwise an error will be |
|
36 * returned. |
|
37 */ |
|
38 void addObserver( in nsIObserver anObserver, in string aTopic, in boolean ownsWeak); |
|
39 |
|
40 /** |
|
41 * removeObserver |
|
42 * |
|
43 * Unregisters a given listener from notifications regarding the specified |
|
44 * topic. |
|
45 * |
|
46 * @param anObserver : The interface pointer which will stop recieving |
|
47 * notifications. |
|
48 * @param aTopic : The notification topic or subject. |
|
49 */ |
|
50 void removeObserver( in nsIObserver anObserver, in string aTopic ); |
|
51 |
|
52 /** |
|
53 * notifyObservers |
|
54 * |
|
55 * Notifies all registered listeners of the given topic. |
|
56 * |
|
57 * @param aSubject : Notification specific interface pointer. |
|
58 * @param aTopic : The notification topic or subject. |
|
59 * @param someData : Notification specific wide string. |
|
60 */ |
|
61 void notifyObservers( in nsISupports aSubject, |
|
62 in string aTopic, |
|
63 in wstring someData ); |
|
64 |
|
65 /** |
|
66 * enumerateObservers |
|
67 * |
|
68 * Returns an enumeration of all registered listeners. |
|
69 * |
|
70 * @param aTopic : The notification topic or subject. |
|
71 */ |
|
72 nsISimpleEnumerator enumerateObservers( in string aTopic ); |
|
73 |
|
74 |
|
75 }; |
|
76 |
|
77 |