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 nsIFile;
michael@0: interface nsIMIMEInfo;
michael@0: interface nsIURI;
michael@0:
michael@0: %{C++
michael@0: #define NS_MIMESERVICE_CID \
michael@0: { /* 03af31da-3109-11d3-8cd0-0060b0fc14a3 */ \
michael@0: 0x03af31da, \
michael@0: 0x3109, \
michael@0: 0x11d3, \
michael@0: {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
michael@0: }
michael@0: %}
michael@0:
michael@0: /**
michael@0: * The MIME service is responsible for mapping file extensions to MIME-types
michael@0: * (see RFC 2045). It also provides access to nsIMIMEInfo interfaces and
michael@0: * acts as a general convenience wrapper of nsIMIMEInfo interfaces.
michael@0: *
michael@0: * The MIME service maintains a database with a one MIME type to many
michael@0: * file extensions rule. Adding the same file extension to multiple MIME types
michael@0: * is illegal and behavior is undefined.
michael@0: *
michael@0: * @see nsIMIMEInfo
michael@0: */
michael@0: [scriptable, uuid(5b3675a1-02db-4f8f-a560-b34736635f47)]
michael@0: interface nsIMIMEService : nsISupports {
michael@0: /**
michael@0: * Retrieves an nsIMIMEInfo using both the extension
michael@0: * and the type of a file. The type is given preference
michael@0: * during the lookup. One of aMIMEType and aFileExt
michael@0: * can be an empty string. At least one of aMIMEType and aFileExt
michael@0: * must be nonempty.
michael@0: */
michael@0: nsIMIMEInfo getFromTypeAndExtension(in ACString aMIMEType, in AUTF8String aFileExt);
michael@0:
michael@0: /**
michael@0: * Retrieves a ACString representation of the MIME type
michael@0: * associated with this file extension.
michael@0: *
michael@0: * @param A file extension (excluding the dot ('.')).
michael@0: * @return The MIME type, if any.
michael@0: */
michael@0: ACString getTypeFromExtension(in AUTF8String aFileExt);
michael@0:
michael@0: /**
michael@0: * Retrieves a ACString representation of the MIME type
michael@0: * associated with this URI. The association is purely
michael@0: * file extension to MIME type based. No attempt to determine
michael@0: * the type via server headers or byte scanning is made.
michael@0: *
michael@0: * @param The URI the user wants MIME info on.
michael@0: * @return The MIME type, if any.
michael@0: */
michael@0: ACString getTypeFromURI(in nsIURI aURI);
michael@0:
michael@0: //
michael@0: ACString getTypeFromFile(in nsIFile aFile);
michael@0:
michael@0: /**
michael@0: * Given a Type/Extension combination, returns the default extension
michael@0: * for this type. This may be identical to the passed-in extension.
michael@0: *
michael@0: * @param aMIMEType The Type to get information on. Must not be empty.
michael@0: * @param aFileExt File Extension. Can be empty.
michael@0: */
michael@0: AUTF8String getPrimaryExtension(in ACString aMIMEType, in AUTF8String aFileExt);
michael@0: };