netwerk/mime/nsIMIMEService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/mime/nsIMIMEService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +interface nsIFile;
    1.12 +interface nsIMIMEInfo;
    1.13 +interface nsIURI;
    1.14 +
    1.15 +%{C++
    1.16 +#define NS_MIMESERVICE_CID                           \
    1.17 +{ /* 03af31da-3109-11d3-8cd0-0060b0fc14a3 */         \
    1.18 +    0x03af31da,                                      \
    1.19 +    0x3109,                                          \
    1.20 +    0x11d3,                                          \
    1.21 +    {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
    1.22 +}
    1.23 +%}
    1.24 +
    1.25 +/**
    1.26 + * The MIME service is responsible for mapping file extensions to MIME-types
    1.27 + * (see RFC 2045). It also provides access to nsIMIMEInfo interfaces and
    1.28 + * acts as a general convenience wrapper of nsIMIMEInfo interfaces.
    1.29 + *
    1.30 + * The MIME service maintains a database with a <b>one</b> MIME type <b>to many</b>
    1.31 + * file extensions rule. Adding the same file extension to multiple MIME types
    1.32 + * is illegal and behavior is undefined.
    1.33 + *
    1.34 + * @see nsIMIMEInfo
    1.35 + */
    1.36 +[scriptable, uuid(5b3675a1-02db-4f8f-a560-b34736635f47)]
    1.37 +interface nsIMIMEService : nsISupports {
    1.38 +    /**
    1.39 +     * Retrieves an nsIMIMEInfo using both the extension
    1.40 +     * and the type of a file. The type is given preference
    1.41 +     * during the lookup. One of aMIMEType and aFileExt
    1.42 +     * can be an empty string. At least one of aMIMEType and aFileExt
    1.43 +     * must be nonempty.
    1.44 +     */
    1.45 +    nsIMIMEInfo getFromTypeAndExtension(in ACString aMIMEType, in AUTF8String aFileExt);
    1.46 +
    1.47 +    /**
    1.48 +     * Retrieves a ACString representation of the MIME type
    1.49 +     * associated with this file extension.
    1.50 +     *
    1.51 +     * @param  A file extension (excluding the dot ('.')).
    1.52 +     * @return The MIME type, if any.
    1.53 +     */
    1.54 +    ACString getTypeFromExtension(in AUTF8String aFileExt);
    1.55 +
    1.56 +    /**
    1.57 +     * Retrieves a ACString representation of the MIME type
    1.58 +     * associated with this URI. The association is purely
    1.59 +     * file extension to MIME type based. No attempt to determine
    1.60 +     * the type via server headers or byte scanning is made.
    1.61 +     *
    1.62 +     * @param  The URI the user wants MIME info on.
    1.63 +     * @return The MIME type, if any.
    1.64 +     */
    1.65 +    ACString getTypeFromURI(in nsIURI aURI);
    1.66 +    
    1.67 +    //
    1.68 +    ACString getTypeFromFile(in nsIFile aFile);
    1.69 +
    1.70 +    /**
    1.71 +     * Given a Type/Extension combination, returns the default extension
    1.72 +     * for this type. This may be identical to the passed-in extension.
    1.73 +     *
    1.74 +     * @param aMIMEType The Type to get information on. Must not be empty.
    1.75 +     * @param aFileExt  File Extension. Can be empty.
    1.76 +     */
    1.77 +    AUTF8String getPrimaryExtension(in ACString aMIMEType, in AUTF8String aFileExt);
    1.78 +};

mercurial