michael@0: /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 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: michael@0: interface nsIURI; michael@0: interface nsIFile; michael@0: interface nsIUTF8StringEnumerator; michael@0: interface nsIHandlerApp; michael@0: interface nsIArray; michael@0: interface nsIMutableArray; michael@0: interface nsIInterfaceRequestor; michael@0: michael@0: typedef long nsHandlerInfoAction; michael@0: michael@0: /** michael@0: * nsIHandlerInfo gives access to the information about how a given protocol michael@0: * scheme or MIME-type is handled. michael@0: */ michael@0: [scriptable, uuid(325e56a7-3762-4312-aec7-f1fcf84b4145)] michael@0: interface nsIHandlerInfo : nsISupports { michael@0: /** michael@0: * The type of this handler info. For MIME handlers, this is the MIME type. michael@0: * For protocol handlers, it's the scheme. michael@0: * michael@0: * @return String representing the type. michael@0: */ michael@0: readonly attribute ACString type; michael@0: michael@0: /** michael@0: * A human readable description of the handler type michael@0: */ michael@0: attribute AString description; michael@0: michael@0: /** michael@0: * The application the user has said they want associated with this content michael@0: * type. This is not always guaranteed to be set!! michael@0: */ michael@0: attribute nsIHandlerApp preferredApplicationHandler; michael@0: michael@0: /** michael@0: * Applications that can handle this content type. michael@0: * michael@0: * The list will include the preferred handler, if any. Elements of this michael@0: * array are nsIHandlerApp objects, and this attribute will always reference michael@0: * an array, whether or not there are any possible handlers. If there are michael@0: * no possible handlers, the array will contain no elements, so just check michael@0: * its length (nsIArray::length) to see if there are any possible handlers. michael@0: */ michael@0: readonly attribute nsIMutableArray possibleApplicationHandlers; michael@0: michael@0: /** michael@0: * Indicates whether a default application handler exists, michael@0: * i.e. whether launchWithFile with action = useSystemDefault is possible michael@0: * and defaultDescription will contain usable information. michael@0: */ michael@0: readonly attribute boolean hasDefaultHandler; michael@0: michael@0: /** michael@0: * A pretty name description of the associated default application. Only michael@0: * usable if hasDefaultHandler is true. michael@0: */ michael@0: readonly attribute AString defaultDescription; michael@0: michael@0: /** michael@0: * Launches the application with the specified URI, in a way that michael@0: * depends on the value of preferredAction. preferredAction must be michael@0: * useHelperApp or useSystemDefault. michael@0: * michael@0: * @note Only the URI scheme is used to determine how to launch. This is michael@0: * essentially a pass-by-value operation. This means that in the case of michael@0: * a file: URI, the handler that is registered for file: will be launched michael@0: * and our code will not make any decision based on the content-type or michael@0: * extension, though the invoked file: handler is free to do so. michael@0: * michael@0: * @param aURI michael@0: * The URI to launch this application with michael@0: * michael@0: * @param aWindowContext michael@0: * The window to parent the dialog against, and, if a web handler michael@0: * is chosen, it is loaded in this window as well. See michael@0: * nsIHandlerApp.launchWithURI for more details. michael@0: * michael@0: * @throw NS_ERROR_INVALID_ARG if preferredAction is not valid for this michael@0: * call. Other exceptions may be thrown. michael@0: */ michael@0: void launchWithURI(in nsIURI aURI, michael@0: [optional] in nsIInterfaceRequestor aWindowContext); michael@0: michael@0: /** michael@0: * preferredAction is how the user specified they would like to handle michael@0: * this content type: save to disk, use specified helper app, use OS michael@0: * default handler or handle using navigator; possible value constants michael@0: * listed below michael@0: */ michael@0: attribute nsHandlerInfoAction preferredAction; michael@0: michael@0: const long saveToDisk = 0; michael@0: /** michael@0: * Used to indicate that we know nothing about what to do with this. You michael@0: * could consider this to be not initialized. michael@0: */ michael@0: const long alwaysAsk = 1; michael@0: const long useHelperApp = 2; michael@0: const long handleInternally = 3; michael@0: const long useSystemDefault = 4; michael@0: michael@0: /** michael@0: * alwaysAskBeforeHandling: if true, we should always give the user a michael@0: * dialog asking how to dispose of this content. michael@0: */ michael@0: attribute boolean alwaysAskBeforeHandling; michael@0: }; michael@0: michael@0: /** michael@0: * nsIMIMEInfo extends nsIHandlerInfo with a bunch of information specific to michael@0: * MIME content-types. There is a one-to-many relationship between MIME types michael@0: * and file extensions. This means that a MIMEInfo object may have multiple michael@0: * file extensions associated with it. However, the reverse is not true. michael@0: * michael@0: * MIMEInfo objects are generally retrieved from the MIME Service michael@0: * @see nsIMIMEService michael@0: */ michael@0: [scriptable, uuid(1c21acef-c7a1-40c6-9d40-a20480ee53a1)] michael@0: interface nsIMIMEInfo : nsIHandlerInfo { michael@0: /** michael@0: * Gives you an array of file types associated with this type. michael@0: * michael@0: * @return Number of elements in the array. michael@0: * @return Array of extensions. michael@0: */ michael@0: nsIUTF8StringEnumerator getFileExtensions(); michael@0: michael@0: /** michael@0: * Set File Extensions. Input is a comma delimited list of extensions. michael@0: */ michael@0: void setFileExtensions(in AUTF8String aExtensions); michael@0: michael@0: /** michael@0: * Returns whether or not the given extension is michael@0: * associated with this MIME info. michael@0: * michael@0: * @return TRUE if the association exists. michael@0: */ michael@0: boolean extensionExists(in AUTF8String aExtension); michael@0: michael@0: /** michael@0: * Append a given extension to the set of extensions michael@0: */ michael@0: void appendExtension(in AUTF8String aExtension); michael@0: michael@0: /** michael@0: * Returns the first extension association in michael@0: * the internal set of extensions. michael@0: * michael@0: * @return The first extension. michael@0: */ michael@0: attribute AUTF8String primaryExtension; michael@0: michael@0: /** michael@0: * The MIME type of this MIMEInfo. michael@0: * michael@0: * @return String representing the MIME type. michael@0: * michael@0: * @deprecated use nsIHandlerInfo::type instead. michael@0: */ michael@0: readonly attribute ACString MIMEType; michael@0: michael@0: /** michael@0: * Returns whether or not these two nsIMIMEInfos are logically michael@0: * equivalent. michael@0: * michael@0: * @returns PR_TRUE if the two are considered equal michael@0: */ michael@0: boolean equals(in nsIMIMEInfo aMIMEInfo); michael@0: michael@0: /** michael@0: * Returns a list of nsILocalHandlerApp objects containing michael@0: * handlers associated with this mimeinfo. Implemented per michael@0: * platform using information in this object to generate the michael@0: * best list. Typically used for an "open with" style user michael@0: * option. michael@0: * michael@0: * @return nsIArray of nsILocalHandlerApp michael@0: */ michael@0: readonly attribute nsIArray possibleLocalHandlers; michael@0: michael@0: /** michael@0: * Launches the application with the specified file, in a way that michael@0: * depends on the value of preferredAction. preferredAction must be michael@0: * useHelperApp or useSystemDefault. michael@0: * michael@0: * @param aFile The file to launch this application with. michael@0: * michael@0: * @throw NS_ERROR_INVALID_ARG if action is not valid for this function. michael@0: * Other exceptions may be thrown. michael@0: */ michael@0: void launchWithFile(in nsIFile aFile); michael@0: }; michael@0: michael@0: /** michael@0: * nsIHandlerApp represents an external application that can handle content michael@0: * of some sort (either a MIME type or a protocol). michael@0: * michael@0: * FIXME: now that we've made nsIWebHandlerApp inherit from nsIHandlerApp, michael@0: * we should also try to make nsIWebContentHandlerInfo inherit from or possibly michael@0: * be replaced by nsIWebHandlerApp (bug 394710). michael@0: */ michael@0: [scriptable, uuid(8BDF20A4-9170-4548-AF52-78311A44F920)] michael@0: interface nsIHandlerApp : nsISupports { michael@0: michael@0: /** michael@0: * Human readable name for the handler michael@0: */ michael@0: attribute AString name; michael@0: michael@0: /** michael@0: * Detailed description for this handler. Suitable for michael@0: * a tooltip or short informative sentence. michael@0: */ michael@0: attribute AString detailedDescription; michael@0: michael@0: /** michael@0: * Whether or not the given handler app is logically equivalent to the michael@0: * invokant (i.e. they represent the same app). michael@0: * michael@0: * Two apps are the same if they are both either local or web handlers michael@0: * and their executables/URI templates and command line parameters are michael@0: * the same. michael@0: * michael@0: * @param aHandlerApp the handler app to compare to the invokant michael@0: * michael@0: * @returns true if the two are logically equivalent, false otherwise michael@0: */ michael@0: boolean equals(in nsIHandlerApp aHandlerApp); michael@0: michael@0: /** michael@0: * Launches the application with the specified URI. michael@0: * michael@0: * @param aURI michael@0: * The URI to launch this application with michael@0: * michael@0: * @param aWindowContext michael@0: * michael@0: * Currently only relevant to web-handler apps. If given, this michael@0: * represents the docshell to load the handler in and is passed michael@0: * through to nsIURILoader.openURI. If this parameter is null or michael@0: * not present, the web handler app implementation will attempt to michael@0: * find/create a place to load the handler and do so. As of this michael@0: * writing, it tries to load the web handler in a new window using michael@0: * nsIBrowserDOMWindow.openURI. In the future, it may attempt to michael@0: * have a more comprehensive strategy which could include handing michael@0: * off to the system default browser (bug 394479). michael@0: */ michael@0: void launchWithURI(in nsIURI aURI, michael@0: [optional] in nsIInterfaceRequestor aWindowContext); michael@0: michael@0: }; michael@0: michael@0: /** michael@0: * nsILocalHandlerApp is a local OS-level executable michael@0: */ michael@0: [scriptable, uuid(D36B6329-52AE-4f45-80F4-B2536AE5F8B2)] michael@0: interface nsILocalHandlerApp : nsIHandlerApp { michael@0: michael@0: /** michael@0: * Pointer to the executable file used to handle content michael@0: */ michael@0: attribute nsIFile executable; michael@0: michael@0: /** michael@0: * Returns the current number of command line parameters. michael@0: */ michael@0: readonly attribute unsigned long parameterCount; michael@0: michael@0: /** michael@0: * Clears the current list of command line parameters. michael@0: */ michael@0: void clearParameters(); michael@0: michael@0: /** michael@0: * Appends a command line parameter to the command line michael@0: * parameter list. michael@0: * michael@0: * @param param the parameter to add. michael@0: */ michael@0: void appendParameter(in AString param); michael@0: michael@0: /** michael@0: * Retrieves a specific command line parameter. michael@0: * michael@0: * @param param the index of the parameter to return. michael@0: * michael@0: * @return the parameter string. michael@0: * michael@0: * @throw NS_ERROR_INVALID_ARG if the index is out of range. michael@0: */ michael@0: AString getParameter(in unsigned long parameterIndex); michael@0: michael@0: /** michael@0: * Checks to see if a parameter exists in the command line michael@0: * parameter list. michael@0: * michael@0: * @param param the parameter to search for. michael@0: * michael@0: * @return TRUE if the parameter exists in the current list. michael@0: */ michael@0: boolean parameterExists(in AString param); michael@0: }; michael@0: michael@0: /** michael@0: * nsIWebHandlerApp is a web-based handler, as speced by the WhatWG HTML5 michael@0: * draft. Currently, only GET-based handlers are supported. At some point, michael@0: * we probably want to work with WhatWG to spec out and implement POST-based michael@0: * handlers as well. michael@0: */ michael@0: [scriptable, uuid(7521a093-c498-45ce-b462-df7ba0d882f6)] michael@0: interface nsIWebHandlerApp : nsIHandlerApp { michael@0: michael@0: /** michael@0: * Template used to construct the URI to GET. Template is expected to have michael@0: * a %s in it, and the escaped URI to be handled is inserted in place of michael@0: * that %s, as per the HTML5 spec. michael@0: */ michael@0: attribute AUTF8String uriTemplate; michael@0: }; michael@0: michael@0: /** michael@0: * nsIDBusHandlerApp represents local applications launched by DBus a message michael@0: * invoking a method taking a single string argument descibing a URI michael@0: */ michael@0: [scriptable, uuid(1ffc274b-4cbf-4bb5-a635-05ad2cbb6534)] michael@0: interface nsIDBusHandlerApp : nsIHandlerApp { michael@0: michael@0: /** michael@0: * Service defines the dbus service that should handle this protocol. michael@0: * If its not set, NS_ERROR_FAILURE will be returned by LaunchWithURI michael@0: */ michael@0: attribute AUTF8String service; michael@0: michael@0: /** michael@0: * Objpath defines the object path of the dbus service that should handle michael@0: * this protocol. If its not set, NS_ERROR_FAILURE will be returned michael@0: * by LaunchWithURI michael@0: */ michael@0: attribute AUTF8String objectPath; michael@0: michael@0: /** michael@0: * DBusInterface defines the interface of the dbus service that should michael@0: * handle this protocol. If its not set, NS_ERROR_FAILURE will be michael@0: * returned by LaunchWithURI michael@0: */ michael@0: attribute AUTF8String dBusInterface; michael@0: michael@0: /** michael@0: * Method defines the dbus method that should be invoked to handle this michael@0: * protocol. If its not set, NS_ERROR_FAILURE will be returned by michael@0: * LaunchWithURI michael@0: */ michael@0: attribute AUTF8String method; michael@0: michael@0: }; michael@0: