widget/nsIIdleService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/nsIIdleService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsISupports.idl"
    1.11 +interface nsIObserver;
    1.12 +
    1.13 +/**
    1.14 + * This interface lets you monitor how long the user has been 'idle',
    1.15 + * i.e. not used their mouse or keyboard. You can get the idle time directly,
    1.16 + * but in most cases you will want to register an observer for a predefined
    1.17 + * interval. The observer will get an 'idle' notification when the user is idle
    1.18 + * for that interval (or longer), and receive an 'active' notification when the
    1.19 + * user starts using their computer again.
    1.20 + */
    1.21 +
    1.22 +[scriptable, uuid(cc52f19a-63ae-4a1c-9cc3-e79eace0b471)]
    1.23 +interface nsIIdleService : nsISupports
    1.24 +{
    1.25 +    /**
    1.26 +     * The amount of time in milliseconds that has passed
    1.27 +     * since the last user activity.
    1.28 +     *
    1.29 +     * If we do not have a valid idle time to report, 0 is returned
    1.30 +     * (this can happen if the user never interacted with the browser
    1.31 +     * at all, and if we are also unable to poll for idle time manually).
    1.32 +     */
    1.33 +    readonly attribute unsigned long idleTime;
    1.34 +
    1.35 +    /**
    1.36 +     * Add an observer to be notified when the user idles for some period of
    1.37 +     * time, and when they get back from that.
    1.38 +     *
    1.39 +     * @param observer the observer to be notified
    1.40 +     * @param time the amount of time in seconds the user should be idle before
    1.41 +     *             the observer should be notified.
    1.42 +     *
    1.43 +     * @note
    1.44 +     * The subject of the notification the observer will get is always the
    1.45 +     * nsIIdleService itself.
    1.46 +     * When the user goes idle, the observer topic is "idle" and when he gets
    1.47 +     * back, the observer topic is "active".
    1.48 +     * The data param for the notification contains the current user idle time.
    1.49 +     *
    1.50 +     * @note
    1.51 +     * You can add the same observer twice.
    1.52 +     * @note
    1.53 +     * Most implementations need to poll the OS for idle info themselves,
    1.54 +     * meaning your notifications could arrive with a delay up to the length
    1.55 +     * of the polling interval in that implementation.
    1.56 +     * Current implementations use a delay of 5 seconds.
    1.57 +     */
    1.58 +    void addIdleObserver(in nsIObserver observer, in unsigned long time);
    1.59 +
    1.60 +    /**
    1.61 +     * Remove an observer registered with addIdleObserver.
    1.62 +     * @param observer the observer that needs to be removed.
    1.63 +     * @param time the amount of time they were listening for.
    1.64 +     * @note
    1.65 +     * Removing an observer will remove it once, for the idle time you specify. 
    1.66 +     * If you have added an observer multiple times, you will need to remove it
    1.67 +     * just as many times.
    1.68 +     */
    1.69 +    void removeIdleObserver(in nsIObserver observer, in unsigned long time);
    1.70 +};
    1.71 +
    1.72 +%{C++  
    1.73 +    /**
    1.74 +     * Observer topic notification for idle window: OBSERVER_TOPIC_IDLE.
    1.75 +     * Observer topic notification for active window: OBSERVER_TOPIC_ACTIVE.
    1.76 +     */
    1.77 +    
    1.78 +    #define OBSERVER_TOPIC_IDLE "idle"
    1.79 +    #define OBSERVER_TOPIC_ACTIVE "active"
    1.80 +    #define OBSERVER_TOPIC_IDLE_DAILY "idle-daily"
    1.81 +%}

mercurial