michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * 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: interface nsIObserver; michael@0: michael@0: /** michael@0: * This interface lets you monitor how long the user has been 'idle', michael@0: * i.e. not used their mouse or keyboard. You can get the idle time directly, michael@0: * but in most cases you will want to register an observer for a predefined michael@0: * interval. The observer will get an 'idle' notification when the user is idle michael@0: * for that interval (or longer), and receive an 'active' notification when the michael@0: * user starts using their computer again. michael@0: */ michael@0: michael@0: [scriptable, uuid(cc52f19a-63ae-4a1c-9cc3-e79eace0b471)] michael@0: interface nsIIdleService : nsISupports michael@0: { michael@0: /** michael@0: * The amount of time in milliseconds that has passed michael@0: * since the last user activity. michael@0: * michael@0: * If we do not have a valid idle time to report, 0 is returned michael@0: * (this can happen if the user never interacted with the browser michael@0: * at all, and if we are also unable to poll for idle time manually). michael@0: */ michael@0: readonly attribute unsigned long idleTime; michael@0: michael@0: /** michael@0: * Add an observer to be notified when the user idles for some period of michael@0: * time, and when they get back from that. michael@0: * michael@0: * @param observer the observer to be notified michael@0: * @param time the amount of time in seconds the user should be idle before michael@0: * the observer should be notified. michael@0: * michael@0: * @note michael@0: * The subject of the notification the observer will get is always the michael@0: * nsIIdleService itself. michael@0: * When the user goes idle, the observer topic is "idle" and when he gets michael@0: * back, the observer topic is "active". michael@0: * The data param for the notification contains the current user idle time. michael@0: * michael@0: * @note michael@0: * You can add the same observer twice. michael@0: * @note michael@0: * Most implementations need to poll the OS for idle info themselves, michael@0: * meaning your notifications could arrive with a delay up to the length michael@0: * of the polling interval in that implementation. michael@0: * Current implementations use a delay of 5 seconds. michael@0: */ michael@0: void addIdleObserver(in nsIObserver observer, in unsigned long time); michael@0: michael@0: /** michael@0: * Remove an observer registered with addIdleObserver. michael@0: * @param observer the observer that needs to be removed. michael@0: * @param time the amount of time they were listening for. michael@0: * @note michael@0: * Removing an observer will remove it once, for the idle time you specify. michael@0: * If you have added an observer multiple times, you will need to remove it michael@0: * just as many times. michael@0: */ michael@0: void removeIdleObserver(in nsIObserver observer, in unsigned long time); michael@0: }; michael@0: michael@0: %{C++ michael@0: /** michael@0: * Observer topic notification for idle window: OBSERVER_TOPIC_IDLE. michael@0: * Observer topic notification for active window: OBSERVER_TOPIC_ACTIVE. michael@0: */ michael@0: michael@0: #define OBSERVER_TOPIC_IDLE "idle" michael@0: #define OBSERVER_TOPIC_ACTIVE "active" michael@0: #define OBSERVER_TOPIC_IDLE_DAILY "idle-daily" michael@0: %}