/* -*- 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): * * 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 ***** */ /** * An nsIMIMEInfo gives a user access to mime information. * 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 */ #include "nsISupports.idl" interface nsIURI; interface nsIFile; interface nsIUTF8StringEnumerator; typedef long nsMIMEInfoHandleAction; [scriptable, uuid(1448b42f-cf0d-466e-9a15-64e876ebe857)] interface nsIMIMEInfo : nsISupports { /** * 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. */ readonly attribute ACString MIMEType; /** * A human readable description of the MIME info. * * @return The description */ attribute AString description; /** * Mac Type and creator types */ attribute PRUint32 macType; attribute PRUint32 macCreator; /** * Returns whether or not these two MIME infos are logically * equivalent maintaining the one-to-many relationship between * MIME types and file extensions. * * @returns TRUE if the two are considered equal */ boolean equals(in nsIMIMEInfo aMIMEInfo); /** * Returns a nsIFile that points to the application the user has said * they want associated with this content type. This is not always * guaranteed to be set!! */ attribute nsIFile preferredApplicationHandler; /** * A pretty name description of the preferred application. */ attribute AString applicationDescription; /** * Indicates whether a default application handler exists, * i.e. whether launchWithFile with action = useSystemDefault is possible * and applicationDescription 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; /** * 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); const long saveToDisk = 0; const long alwaysAsk = 1; const long useHelperApp = 2; const long handleInternally = 3; const long useSystemDefault = 4; /** * 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. */ attribute nsMIMEInfoHandleAction preferredAction; /** * alwaysAskBeforeHandling: if true, we should always give the user a * dialog asking how to dispose of this content. */ attribute boolean alwaysAskBeforeHandling; };