2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2007-07-05 12:31:44 -07:00
|
|
|
* Dan Mosedale <dmose@mozilla.org>
|
2007-09-04 13:45:57 -07:00
|
|
|
* Myk Melez <myk@mozilla.org>
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
interface nsIURI;
|
|
|
|
interface nsIFile;
|
|
|
|
interface nsIUTF8StringEnumerator;
|
2007-07-05 12:31:44 -07:00
|
|
|
interface nsIHandlerApp;
|
2007-08-13 13:41:34 -07:00
|
|
|
interface nsIMutableArray;
|
2007-09-02 21:44:25 -07:00
|
|
|
interface nsIInterfaceRequestor;
|
2007-07-05 12:31:44 -07:00
|
|
|
|
|
|
|
typedef long nsHandlerInfoAction;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsIHandlerInfo gives access to the information about how a given protocol
|
|
|
|
* scheme or MIME-type is handled.
|
|
|
|
*/
|
2007-10-03 23:10:47 -07:00
|
|
|
[scriptable, uuid(325e56a7-3762-4312-aec7-f1fcf84b4145)]
|
2007-07-05 12:31:44 -07:00
|
|
|
interface nsIHandlerInfo : nsISupports {
|
2007-07-25 13:40:41 -07:00
|
|
|
/**
|
|
|
|
* The type of this handler info. For MIME handlers, this is the MIME type.
|
|
|
|
* For protocol handlers, it's the scheme.
|
|
|
|
*
|
|
|
|
* @return String representing the type.
|
|
|
|
*/
|
|
|
|
readonly attribute ACString type;
|
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
/**
|
|
|
|
* A human readable description of the handler type
|
|
|
|
*/
|
|
|
|
attribute AString description;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The application the user has said they want associated with this content
|
|
|
|
* type. This is not always guaranteed to be set!!
|
|
|
|
*/
|
|
|
|
attribute nsIHandlerApp preferredApplicationHandler;
|
|
|
|
|
2007-08-13 13:41:34 -07:00
|
|
|
/**
|
|
|
|
* Applications that can handle this content type.
|
|
|
|
*
|
|
|
|
* The list will include the preferred handler, if any. Elements of this
|
|
|
|
* array are nsIHandlerApp objects, and this attribute will always reference
|
|
|
|
* an array, whether or not there are any possible handlers. If there are
|
|
|
|
* no possible handlers, the array will contain no elements, so just check
|
|
|
|
* its length (nsIArray::length) to see if there are any possible handlers.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIMutableArray possibleApplicationHandlers;
|
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
/**
|
|
|
|
* Indicates whether a default application handler exists,
|
|
|
|
* i.e. whether launchWithFile with action = useSystemDefault is possible
|
|
|
|
* and defaultDescription will contain usable information.
|
|
|
|
*/
|
|
|
|
readonly attribute boolean hasDefaultHandler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A pretty name description of the associated default application. Only
|
|
|
|
* usable if hasDefaultHandler is true.
|
|
|
|
*/
|
|
|
|
readonly attribute AString defaultDescription;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
/**
|
2007-07-17 15:59:58 -07:00
|
|
|
* Launches the application with the specified URI, in a way that
|
2007-07-05 12:31:44 -07:00
|
|
|
* depends on the value of preferredAction. preferredAction must be
|
|
|
|
* useHelperApp or useSystemDefault.
|
2007-08-20 17:47:47 -07:00
|
|
|
*
|
|
|
|
* @note Only the URI scheme is used to determine how to launch. This is
|
|
|
|
* essentially a pass-by-value operation. This means that in the case of
|
|
|
|
* a file: URI, the handler that is registered for file: will be launched
|
|
|
|
* and our code will not make any decision based on the content-type or
|
|
|
|
* extension, though the invoked file: handler is free to do so.
|
2007-07-05 12:31:44 -07:00
|
|
|
*
|
2007-09-02 21:44:25 -07:00
|
|
|
* @param aURI
|
|
|
|
* The URI to launch this application with
|
2007-07-05 12:31:44 -07:00
|
|
|
*
|
2007-09-02 21:44:25 -07:00
|
|
|
* @param aWindowContext
|
|
|
|
* The window to parent the dialog against, and, if a web handler
|
|
|
|
* is chosen, it is loaded in this window as well. This parameter
|
|
|
|
* may be ultimately passed nsIURILoader.openURI in the case of a
|
|
|
|
* web handler, and aWindowContext is null or not present, web
|
|
|
|
* handlers will fail. We need to do better than that; bug 394483
|
|
|
|
* filed in order to track.
|
|
|
|
*
|
|
|
|
* @throw NS_ERROR_INVALID_ARG if preferredAction is not valid for this
|
|
|
|
* call. Other exceptions may be thrown.
|
2007-07-05 12:31:44 -07:00
|
|
|
*/
|
2007-09-02 21:44:25 -07:00
|
|
|
void launchWithURI(in nsIURI aURI,
|
|
|
|
[optional] in nsIInterfaceRequestor aWindowContext);
|
2007-07-05 12:31:44 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* preferredAction is how the user specified they would like to handle
|
|
|
|
* this content type: save to disk, use specified helper app, use OS
|
|
|
|
* default handler or handle using navigator; possible value constants
|
|
|
|
* listed below
|
|
|
|
*/
|
|
|
|
attribute nsHandlerInfoAction preferredAction;
|
|
|
|
|
|
|
|
const long saveToDisk = 0;
|
2007-07-30 16:33:16 -07:00
|
|
|
/**
|
|
|
|
* Used to indicate that we know nothing about what to do with this. You
|
|
|
|
* could consider this to be not initialized.
|
|
|
|
*/
|
2007-07-05 12:31:44 -07:00
|
|
|
const long alwaysAsk = 1;
|
|
|
|
const long useHelperApp = 2;
|
|
|
|
const long handleInternally = 3;
|
|
|
|
const long useSystemDefault = 4;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* alwaysAskBeforeHandling: if true, we should always give the user a
|
|
|
|
* dialog asking how to dispose of this content.
|
|
|
|
*/
|
|
|
|
attribute boolean alwaysAskBeforeHandling;
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
/**
|
|
|
|
* nsIMIMEInfo extends nsIHandlerInfo with a bunch of information specific to
|
|
|
|
* MIME content-types. There is a one-to-many relationship between MIME types
|
|
|
|
* and file extensions. This means that a MIMEInfo object may have multiple
|
|
|
|
* file extensions associated with it. However, the reverse is not true.
|
|
|
|
*
|
|
|
|
* MIMEInfo objects are generally retrieved from the MIME Service
|
|
|
|
* @see nsIMIMEService
|
|
|
|
*/
|
2007-08-20 17:47:47 -07:00
|
|
|
[scriptable, uuid(a4011016-81a1-47d9-b01e-19a2272ae89b)]
|
2007-07-05 12:31:44 -07:00
|
|
|
interface nsIMIMEInfo : nsIHandlerInfo {
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Gives you an array of file types associated with this type.
|
|
|
|
*
|
|
|
|
* @return Number of elements in the array.
|
|
|
|
* @return Array of extensions.
|
|
|
|
*/
|
|
|
|
nsIUTF8StringEnumerator getFileExtensions();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set File Extensions. Input is a comma delimited list of extensions.
|
|
|
|
*/
|
|
|
|
void setFileExtensions(in AUTF8String aExtensions);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the given extension is
|
|
|
|
* associated with this MIME info.
|
|
|
|
*
|
|
|
|
* @return TRUE if the association exists.
|
|
|
|
*/
|
|
|
|
boolean extensionExists(in AUTF8String aExtension);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append a given extension to the set of extensions
|
|
|
|
*/
|
|
|
|
void appendExtension(in AUTF8String aExtension);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the first extension association in
|
|
|
|
* the internal set of extensions.
|
|
|
|
*
|
|
|
|
* @return The first extension.
|
|
|
|
*/
|
|
|
|
attribute AUTF8String primaryExtension;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The MIME type of this MIMEInfo.
|
|
|
|
*
|
|
|
|
* @return String representing the MIME type.
|
2007-07-25 13:40:41 -07:00
|
|
|
*
|
|
|
|
* @deprecated use nsIHandlerInfo::type instead.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
readonly attribute ACString MIMEType;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mac Type and creator types
|
|
|
|
*/
|
|
|
|
attribute PRUint32 macType;
|
|
|
|
attribute PRUint32 macCreator;
|
|
|
|
|
|
|
|
/**
|
2007-07-05 12:31:44 -07:00
|
|
|
* Returns whether or not these two nsIMIMEInfos are logically
|
|
|
|
* equivalent.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2007-07-05 12:31:44 -07:00
|
|
|
* @returns PR_TRUE if the two are considered equal
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
boolean equals(in nsIMIMEInfo aMIMEInfo);
|
2007-08-20 17:47:47 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Launches the application with the specified file, in a way that
|
|
|
|
* depends on the value of preferredAction. preferredAction must be
|
|
|
|
* useHelperApp or useSystemDefault.
|
|
|
|
*
|
|
|
|
* @param aFile The file to launch this application with.
|
|
|
|
*
|
|
|
|
* @throw NS_ERROR_INVALID_ARG if action is not valid for this function.
|
|
|
|
* Other exceptions may be thrown.
|
|
|
|
*/
|
|
|
|
void launchWithFile(in nsIFile aFile);
|
2007-07-05 12:31:44 -07:00
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
/**
|
|
|
|
* nsIHandlerApp represents an external application that can handle content
|
2007-09-04 13:45:57 -07:00
|
|
|
* of some sort (either a MIME type or a protocol).
|
|
|
|
*
|
|
|
|
* FIXME: now that we've made nsIWebHandlerApp inherit from nsIHandlerApp,
|
|
|
|
* we should also try to make nsIWebContentHandlerInfo inherit from or possibly
|
|
|
|
* be replaced by nsIWebHandlerApp (bug 394710).
|
2007-07-05 12:31:44 -07:00
|
|
|
*/
|
2007-10-03 23:10:47 -07:00
|
|
|
[scriptable, uuid(8d298761-0963-4c90-99e2-6ea498825e82)]
|
2007-07-05 12:31:44 -07:00
|
|
|
interface nsIHandlerApp : nsISupports {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2007-07-05 12:31:44 -07:00
|
|
|
* Human readable name for the handler
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2007-07-05 12:31:44 -07:00
|
|
|
attribute AString name;
|
2007-09-04 13:45:57 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the given handler app is logically equivalent to the
|
|
|
|
* invokant (i.e. they represent the same app).
|
|
|
|
*
|
|
|
|
* Two apps are the same if they are both either local or web handlers
|
|
|
|
* and their executables/URI templates are the same in a string comparison.
|
|
|
|
*
|
|
|
|
* @param aHandlerApp the handler app to compare to the invokant
|
|
|
|
*
|
|
|
|
* @returns true if the two are logically equivalent, false otherwise
|
|
|
|
*/
|
|
|
|
boolean equals(in nsIHandlerApp aHandlerApp);
|
2007-10-03 23:10:47 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Launches the application with the specified URI.
|
|
|
|
*
|
|
|
|
* @param aURI
|
|
|
|
* The URI to launch this application with
|
|
|
|
*
|
|
|
|
* @param aWindowContext
|
|
|
|
* Required for web handlers; is passed through to
|
|
|
|
* nsIURILoader.openURI, but see bug 394483 for info on
|
|
|
|
* how this needs to evolve.
|
|
|
|
*/
|
|
|
|
void launchWithURI(in nsIURI aURI,
|
|
|
|
[optional] in nsIInterfaceRequestor aWindowContext);
|
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
/**
|
|
|
|
* nsILocalHandlerApp is a local OS-level executable
|
|
|
|
*/
|
2007-08-14 09:47:41 -07:00
|
|
|
[scriptable, uuid(9812be73-273c-478c-8170-c3e0db08ae7c)]
|
|
|
|
interface nsILocalHandlerApp : nsIHandlerApp {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2007-07-05 12:31:44 -07:00
|
|
|
* Pointer to the executable file used to handle content
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2007-07-05 12:31:44 -07:00
|
|
|
attribute nsIFile executable;
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-05 12:31:44 -07:00
|
|
|
/**
|
|
|
|
* nsIWebHandlerApp is a web-based handler, as speced by the WhatWG HTML5
|
|
|
|
* draft. Currently, only GET-based handlers are supported. At some point,
|
|
|
|
* we probably want to work with WhatWG to spec out and implement POST-based
|
|
|
|
* handlers as well.
|
|
|
|
*/
|
2007-08-14 09:47:41 -07:00
|
|
|
[scriptable, uuid(7521a093-c498-45ce-b462-df7ba0d882f6)]
|
|
|
|
interface nsIWebHandlerApp : nsIHandlerApp {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2007-07-05 12:31:44 -07:00
|
|
|
* Template used to construct the URI to GET. Template is expected to have
|
|
|
|
* a %s in it, and the escaped URI to be handled is inserted in place of
|
|
|
|
* that %s, as per the HTML5 spec.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2007-07-05 12:31:44 -07:00
|
|
|
attribute AUTF8String uriTemplate;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|