Bug 473045 - Update to nsIHandlerApp for win7 jump lists (plus tests). r=bz
[mozilla-central.git] / netwerk / mime / public / nsIMIMEInfo.idl
blob4ea6e737195dd3d07509265c617cae5e4ca8d63e
1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Dan Mosedale <dmose@mozilla.org>
24 * Myk Melez <myk@mozilla.org>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #include "nsISupports.idl"
42 interface nsIURI;
43 interface nsIFile;
44 interface nsIUTF8StringEnumerator;
45 interface nsIHandlerApp;
46 interface nsIArray;
47 interface nsIMutableArray;
48 interface nsIInterfaceRequestor;
50 typedef long nsHandlerInfoAction;
52 /**
53 * nsIHandlerInfo gives access to the information about how a given protocol
54 * scheme or MIME-type is handled.
56 [scriptable, uuid(8E726396-3E02-467C-855E-5900E562BA42)]
57 interface nsIHandlerInfo : nsISupports {
58 /**
59 * The type of this handler info. For MIME handlers, this is the MIME type.
60 * For protocol handlers, it's the scheme.
62 * @return String representing the type.
64 readonly attribute ACString type;
66 /**
67 * A human readable description of the handler type
69 attribute AString description;
71 /**
72 * The application the user has said they want associated with this content
73 * type. This is not always guaranteed to be set!!
75 attribute nsIHandlerApp preferredApplicationHandler;
77 /**
78 * Applications that can handle this content type.
80 * The list will include the preferred handler, if any. Elements of this
81 * array are nsIHandlerApp objects, and this attribute will always reference
82 * an array, whether or not there are any possible handlers. If there are
83 * no possible handlers, the array will contain no elements, so just check
84 * its length (nsIArray::length) to see if there are any possible handlers.
86 readonly attribute nsIMutableArray possibleApplicationHandlers;
88 /**
89 * Indicates whether a default application handler exists,
90 * i.e. whether launchWithFile with action = useSystemDefault is possible
91 * and defaultDescription will contain usable information.
93 readonly attribute boolean hasDefaultHandler;
95 /**
96 * A pretty name description of the associated default application. Only
97 * usable if hasDefaultHandler is true.
99 readonly attribute AString defaultDescription;
102 * Launches the application with the specified URI, in a way that
103 * depends on the value of preferredAction. preferredAction must be
104 * useHelperApp or useSystemDefault.
106 * @note Only the URI scheme is used to determine how to launch. This is
107 * essentially a pass-by-value operation. This means that in the case of
108 * a file: URI, the handler that is registered for file: will be launched
109 * and our code will not make any decision based on the content-type or
110 * extension, though the invoked file: handler is free to do so.
112 * @param aURI
113 * The URI to launch this application with
115 * @param aWindowContext
116 * The window to parent the dialog against, and, if a web handler
117 * is chosen, it is loaded in this window as well. See
118 * nsIHandlerApp.launchWithURI for more details.
120 * @throw NS_ERROR_INVALID_ARG if preferredAction is not valid for this
121 * call. Other exceptions may be thrown.
123 void launchWithURI(in nsIURI aURI,
124 [optional] in nsIInterfaceRequestor aWindowContext);
127 * preferredAction is how the user specified they would like to handle
128 * this content type: save to disk, use specified helper app, use OS
129 * default handler or handle using navigator; possible value constants
130 * listed below
132 attribute nsHandlerInfoAction preferredAction;
134 const long saveToDisk = 0;
136 * Used to indicate that we know nothing about what to do with this. You
137 * could consider this to be not initialized.
139 const long alwaysAsk = 1;
140 const long useHelperApp = 2;
141 const long handleInternally = 3;
142 const long useSystemDefault = 4;
145 * alwaysAskBeforeHandling: if true, we should always give the user a
146 * dialog asking how to dispose of this content.
148 attribute boolean alwaysAskBeforeHandling;
152 * nsIMIMEInfo extends nsIHandlerInfo with a bunch of information specific to
153 * MIME content-types. There is a one-to-many relationship between MIME types
154 * and file extensions. This means that a MIMEInfo object may have multiple
155 * file extensions associated with it. However, the reverse is not true.
157 * MIMEInfo objects are generally retrieved from the MIME Service
158 * @see nsIMIMEService
160 [scriptable, uuid(cd7083f8-5fe9-4248-bb09-0b0e2982fde8)]
161 interface nsIMIMEInfo : nsIHandlerInfo {
163 * Gives you an array of file types associated with this type.
165 * @return Number of elements in the array.
166 * @return Array of extensions.
168 nsIUTF8StringEnumerator getFileExtensions();
171 * Set File Extensions. Input is a comma delimited list of extensions.
173 void setFileExtensions(in AUTF8String aExtensions);
176 * Returns whether or not the given extension is
177 * associated with this MIME info.
179 * @return TRUE if the association exists.
181 boolean extensionExists(in AUTF8String aExtension);
184 * Append a given extension to the set of extensions
186 void appendExtension(in AUTF8String aExtension);
189 * Returns the first extension association in
190 * the internal set of extensions.
192 * @return The first extension.
194 attribute AUTF8String primaryExtension;
197 * The MIME type of this MIMEInfo.
199 * @return String representing the MIME type.
201 * @deprecated use nsIHandlerInfo::type instead.
203 readonly attribute ACString MIMEType;
206 * Returns whether or not these two nsIMIMEInfos are logically
207 * equivalent.
209 * @returns PR_TRUE if the two are considered equal
211 boolean equals(in nsIMIMEInfo aMIMEInfo);
213 /**
214 * Returns a list of nsILocalHandlerApp objects containing
215 * handlers associated with this mimeinfo. Implemented per
216 * platform using information in this object to generate the
217 * best list. Typically used for an "open with" style user
218 * option.
220 * @return nsIArray of nsILocalHandlerApp
222 readonly attribute nsIArray possibleLocalHandlers;
225 * Launches the application with the specified file, in a way that
226 * depends on the value of preferredAction. preferredAction must be
227 * useHelperApp or useSystemDefault.
229 * @param aFile The file to launch this application with.
231 * @throw NS_ERROR_INVALID_ARG if action is not valid for this function.
232 * Other exceptions may be thrown.
234 void launchWithFile(in nsIFile aFile);
238 * nsIHandlerApp represents an external application that can handle content
239 * of some sort (either a MIME type or a protocol).
241 * FIXME: now that we've made nsIWebHandlerApp inherit from nsIHandlerApp,
242 * we should also try to make nsIWebContentHandlerInfo inherit from or possibly
243 * be replaced by nsIWebHandlerApp (bug 394710).
245 [scriptable, uuid(8BDF20A4-9170-4548-AF52-78311A44F920)]
246 interface nsIHandlerApp : nsISupports {
249 * Human readable name for the handler
251 attribute AString name;
254 * Detailed description for this handler. Suitable for
255 * a tooltip or short informative sentence.
257 attribute AString detailedDescription;
260 * Whether or not the given handler app is logically equivalent to the
261 * invokant (i.e. they represent the same app).
263 * Two apps are the same if they are both either local or web handlers
264 * and their executables/URI templates and command line parameters are
265 * the same.
267 * @param aHandlerApp the handler app to compare to the invokant
269 * @returns true if the two are logically equivalent, false otherwise
271 boolean equals(in nsIHandlerApp aHandlerApp);
274 * Launches the application with the specified URI.
276 * @param aURI
277 * The URI to launch this application with
279 * @param aWindowContext
281 * Currently only relevant to web-handler apps. If given, this
282 * represents the docshell to load the handler in and is passed
283 * through to nsIURILoader.openURI. If this parameter is null or
284 * not present, the web handler app implementation will attempt to
285 * find/create a place to load the handler and do so. As of this
286 * writing, it tries to load the web handler in a new window using
287 * nsIBrowserDOMWindow.openURI. In the future, it may attempt to
288 * have a more comprehensive strategy which could include handing
289 * off to the system default browser (bug 394479).
291 void launchWithURI(in nsIURI aURI,
292 [optional] in nsIInterfaceRequestor aWindowContext);
297 * nsILocalHandlerApp is a local OS-level executable
299 [scriptable, uuid(D36B6329-52AE-4f45-80F4-B2536AE5F8B2)]
300 interface nsILocalHandlerApp : nsIHandlerApp {
303 * Pointer to the executable file used to handle content
305 attribute nsIFile executable;
308 * Returns the current number of command line parameters.
310 readonly attribute unsigned long parameterCount;
313 * Clears the current list of command line parameters.
315 void clearParameters();
318 * Appends a command line parameter to the command line
319 * parameter list.
321 * @param param the parameter to add.
323 void appendParameter(in AString param);
326 * Retrieves a specific command line parameter.
328 * @param param the index of the parameter to return.
330 * @return the parameter string.
332 * @throw NS_ERROR_INVALID_ARG if the index is out of range.
334 AString getParameter(in unsigned long parameterIndex);
337 * Checks to see if a parameter exists in the command line
338 * parameter list.
340 * @param param the parameter to search for.
342 * @return TRUE if the parameter exists in the current list.
344 boolean parameterExists(in AString param);
348 * nsIWebHandlerApp is a web-based handler, as speced by the WhatWG HTML5
349 * draft. Currently, only GET-based handlers are supported. At some point,
350 * we probably want to work with WhatWG to spec out and implement POST-based
351 * handlers as well.
353 [scriptable, uuid(7521a093-c498-45ce-b462-df7ba0d882f6)]
354 interface nsIWebHandlerApp : nsIHandlerApp {
357 * Template used to construct the URI to GET. Template is expected to have
358 * a %s in it, and the escaped URI to be handled is inserted in place of
359 * that %s, as per the HTML5 spec.
361 attribute AUTF8String uriTemplate;
365 * nsIDBusHandlerApp represents local applications launched by DBus a message
366 * invoking a method taking a single string argument descibing a URI
368 [scriptable, uuid(1ffc274b-4cbf-4bb5-a635-05ad2cbb6534)]
369 interface nsIDBusHandlerApp : nsIHandlerApp {
372 * Service defines the dbus service that should handle this protocol.
373 * If its not set, NS_ERROR_FAILURE will be returned by LaunchWithURI
375 attribute AUTF8String service;
378 * Objpath defines the object path of the dbus service that should handle
379 * this protocol. If its not set, NS_ERROR_FAILURE will be returned
380 * by LaunchWithURI
382 attribute AUTF8String objectPath;
385 * DBusInterface defines the interface of the dbus service that should
386 * handle this protocol. If its not set, NS_ERROR_FAILURE will be
387 * returned by LaunchWithURI
389 attribute AUTF8String dBusInterface;
392 * Method defines the dbus method that should be invoked to handle this
393 * protocol. If its not set, NS_ERROR_FAILURE will be returned by
394 * LaunchWithURI
396 attribute AUTF8String method;