xpcom/ds/nsIObserverService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/ds/nsIObserverService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +interface nsIObserver;
    1.12 +interface nsISimpleEnumerator;
    1.13 +
    1.14 +/**
    1.15 + * nsIObserverService
    1.16 + * 
    1.17 + * Service allows a client listener (nsIObserver) to register and unregister for 
    1.18 + * notifications of specific string referenced topic. Service also provides a 
    1.19 + * way to notify registered listeners and a way to enumerate registered client 
    1.20 + * listeners.
    1.21 + */
    1.22 +
    1.23 +[scriptable, uuid(D07F5192-E3D1-11d2-8ACD-00105A1B8860)]
    1.24 +interface nsIObserverService : nsISupports 
    1.25 +{
    1.26 +
    1.27 +    /**
    1.28 +     * AddObserver
    1.29 +     *
    1.30 +     * Registers a given listener for a notifications regarding the specified
    1.31 +     * topic.
    1.32 +     *
    1.33 +     * @param anObserve : The interface pointer which will receive notifications.
    1.34 +     * @param aTopic    : The notification topic or subject.
    1.35 +     * @param ownsWeak  : If set to false, the nsIObserverService will hold a 
    1.36 +     *                    strong reference to |anObserver|.  If set to true and 
    1.37 +     *                    |anObserver| supports the nsIWeakReference interface,
    1.38 +     *                    a weak reference will be held.  Otherwise an error will be
    1.39 +     *                    returned.
    1.40 +     */
    1.41 + 	void addObserver( in nsIObserver anObserver, in string aTopic, in boolean ownsWeak);
    1.42 +
    1.43 +    /**
    1.44 +     * removeObserver
    1.45 +     *
    1.46 +     * Unregisters a given listener from notifications regarding the specified
    1.47 +     * topic.
    1.48 +     *
    1.49 +     * @param anObserver : The interface pointer which will stop recieving
    1.50 +     *                     notifications.
    1.51 +     * @param aTopic     : The notification topic or subject.
    1.52 +     */
    1.53 +    void removeObserver( in nsIObserver anObserver, in string aTopic );
    1.54 +
    1.55 +    /**
    1.56 +     * notifyObservers
    1.57 +     *
    1.58 +     * Notifies all registered listeners of the given topic.
    1.59 +     *
    1.60 +     * @param aSubject : Notification specific interface pointer.
    1.61 +     * @param aTopic   : The notification topic or subject.
    1.62 +     * @param someData : Notification specific wide string.
    1.63 +     */
    1.64 +    void notifyObservers( in nsISupports aSubject, 
    1.65 +                          in string aTopic, 
    1.66 +                          in wstring someData );
    1.67 +
    1.68 +    /**
    1.69 +     * enumerateObservers
    1.70 +     *
    1.71 +     * Returns an enumeration of all registered listeners.
    1.72 +     *
    1.73 +     * @param aTopic   : The notification topic or subject.
    1.74 +     */
    1.75 +	nsISimpleEnumerator enumerateObservers( in string aTopic );
    1.76 +
    1.77 +
    1.78 +};
    1.79 +
    1.80 +

mercurial