Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | interface nsIObserver; |
michael@0 | 9 | |
michael@0 | 10 | /** |
michael@0 | 11 | * This interface lets you monitor how long the user has been 'idle', |
michael@0 | 12 | * i.e. not used their mouse or keyboard. You can get the idle time directly, |
michael@0 | 13 | * but in most cases you will want to register an observer for a predefined |
michael@0 | 14 | * interval. The observer will get an 'idle' notification when the user is idle |
michael@0 | 15 | * for that interval (or longer), and receive an 'active' notification when the |
michael@0 | 16 | * user starts using their computer again. |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | [scriptable, uuid(cc52f19a-63ae-4a1c-9cc3-e79eace0b471)] |
michael@0 | 20 | interface nsIIdleService : nsISupports |
michael@0 | 21 | { |
michael@0 | 22 | /** |
michael@0 | 23 | * The amount of time in milliseconds that has passed |
michael@0 | 24 | * since the last user activity. |
michael@0 | 25 | * |
michael@0 | 26 | * If we do not have a valid idle time to report, 0 is returned |
michael@0 | 27 | * (this can happen if the user never interacted with the browser |
michael@0 | 28 | * at all, and if we are also unable to poll for idle time manually). |
michael@0 | 29 | */ |
michael@0 | 30 | readonly attribute unsigned long idleTime; |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * Add an observer to be notified when the user idles for some period of |
michael@0 | 34 | * time, and when they get back from that. |
michael@0 | 35 | * |
michael@0 | 36 | * @param observer the observer to be notified |
michael@0 | 37 | * @param time the amount of time in seconds the user should be idle before |
michael@0 | 38 | * the observer should be notified. |
michael@0 | 39 | * |
michael@0 | 40 | * @note |
michael@0 | 41 | * The subject of the notification the observer will get is always the |
michael@0 | 42 | * nsIIdleService itself. |
michael@0 | 43 | * When the user goes idle, the observer topic is "idle" and when he gets |
michael@0 | 44 | * back, the observer topic is "active". |
michael@0 | 45 | * The data param for the notification contains the current user idle time. |
michael@0 | 46 | * |
michael@0 | 47 | * @note |
michael@0 | 48 | * You can add the same observer twice. |
michael@0 | 49 | * @note |
michael@0 | 50 | * Most implementations need to poll the OS for idle info themselves, |
michael@0 | 51 | * meaning your notifications could arrive with a delay up to the length |
michael@0 | 52 | * of the polling interval in that implementation. |
michael@0 | 53 | * Current implementations use a delay of 5 seconds. |
michael@0 | 54 | */ |
michael@0 | 55 | void addIdleObserver(in nsIObserver observer, in unsigned long time); |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Remove an observer registered with addIdleObserver. |
michael@0 | 59 | * @param observer the observer that needs to be removed. |
michael@0 | 60 | * @param time the amount of time they were listening for. |
michael@0 | 61 | * @note |
michael@0 | 62 | * Removing an observer will remove it once, for the idle time you specify. |
michael@0 | 63 | * If you have added an observer multiple times, you will need to remove it |
michael@0 | 64 | * just as many times. |
michael@0 | 65 | */ |
michael@0 | 66 | void removeIdleObserver(in nsIObserver observer, in unsigned long time); |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | %{C++ |
michael@0 | 70 | /** |
michael@0 | 71 | * Observer topic notification for idle window: OBSERVER_TOPIC_IDLE. |
michael@0 | 72 | * Observer topic notification for active window: OBSERVER_TOPIC_ACTIVE. |
michael@0 | 73 | */ |
michael@0 | 74 | |
michael@0 | 75 | #define OBSERVER_TOPIC_IDLE "idle" |
michael@0 | 76 | #define OBSERVER_TOPIC_ACTIVE "active" |
michael@0 | 77 | #define OBSERVER_TOPIC_IDLE_DAILY "idle-daily" |
michael@0 | 78 | %} |