michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: michael@0: #include "nsISupports.idl" michael@0: #include "nsIObserver.idl" michael@0: michael@0: interface nsIPrincipal; michael@0: michael@0: [scriptable, uuid(160e87e1-d57d-456b-b6ea-17826f6ea7a8)] michael@0: interface nsIAlertsService : nsISupports michael@0: { michael@0: /** michael@0: * Displays a sliding notification window. michael@0: * michael@0: * @param imageUrl A URL identifying the image to put in the alert. michael@0: * The OS X implemenation limits the amount of time it michael@0: * will wait for an icon to load to six seconds. After michael@0: * that time the alert will show with no icon. michael@0: * @param title The title for the alert. michael@0: * @param text The contents of the alert. michael@0: * @param textClickable If true, causes the alert text to look like a link michael@0: * and notifies the listener when user attempts to michael@0: * click the alert text. michael@0: * @param cookie A blind cookie the alert will pass back to the michael@0: * consumer during the alert listener callbacks. michael@0: * @param alertListener Used for callbacks. May be null if the caller michael@0: * doesn't care about callbacks. michael@0: * @param name The name of the notification. This is currently only michael@0: * used on Android and OS X. On Android the name is michael@0: * hashed and used as a notification ID. Notifications michael@0: * will replace previous notifications with the same name. michael@0: * @param dir Bidi override for the title. Valid values are michael@0: * "auto", "ltr" or "rtl". Only available on supported michael@0: * platforms. michael@0: * @param lang Language of title and text of the alert. Only available michael@0: * on supported platforms. michael@0: * @throws NS_ERROR_NOT_AVAILABLE If the notification cannot be displayed. michael@0: * michael@0: * The following arguments will be passed to the alertListener's observe() michael@0: * method: michael@0: * subject - null michael@0: * topic - "alertfinished" when the alert goes away michael@0: * "alertclickcallback" when the text is clicked michael@0: * "alertshow" when the alert is shown michael@0: * data - the value of the cookie parameter passed to showAlertNotification. michael@0: * michael@0: * @note Depending on current circumstances (if the user's in a fullscreen michael@0: * application, for instance), the alert might not be displayed at all. michael@0: * In that case, if an alert listener is passed in it will receive the michael@0: * "alertfinished" notification immediately. michael@0: */ michael@0: void showAlertNotification(in AString imageUrl, michael@0: in AString title, michael@0: in AString text, michael@0: [optional] in boolean textClickable, michael@0: [optional] in AString cookie, michael@0: [optional] in nsIObserver alertListener, michael@0: [optional] in AString name, michael@0: [optional] in AString dir, michael@0: [optional] in AString lang, michael@0: [optional] in nsIPrincipal principal); michael@0: michael@0: /** michael@0: * Close alerts created by the service. michael@0: * michael@0: * @param name The name of the notification to close. If no name michael@0: * is provided then only a notification created with michael@0: * no name (if any) will be closed. michael@0: */ michael@0: void closeAlert([optional] in AString name, michael@0: [optional] in nsIPrincipal principal); michael@0: }; michael@0: michael@0: [scriptable, uuid(df1bd4b0-3a8c-40e6-806a-203f38b0bd9f)] michael@0: interface nsIAlertsProgressListener : nsISupports michael@0: { michael@0: /** michael@0: * Called to notify the alert service that progress has occurred for the michael@0: * given notification previously displayed with showAlertNotification(). michael@0: * michael@0: * @param name The name of the notification displaying the michael@0: * progress. On Android the name is hashed and used michael@0: * as a notification ID. michael@0: * @param progress Numeric value in the range 0 to progressMax michael@0: * indicating the current progress. michael@0: * @param progressMax Numeric value indicating the maximum progress. michael@0: * @param text The contents of the alert. If not provided, michael@0: * the percentage will be displayed. michael@0: */ michael@0: void onProgress(in AString name, michael@0: in long long progress, michael@0: in long long progressMax, michael@0: [optional] in AString text); michael@0: michael@0: /** michael@0: * Called to cancel and hide the given notification previously displayed michael@0: * with showAlertNotification(). michael@0: * michael@0: * @param name The name of the notification. michael@0: */ michael@0: void onCancel(in AString name); michael@0: }; michael@0: