netwerk/mime/nsIMIMEService.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "nsISupports.idl"
     8 interface nsIFile;
     9 interface nsIMIMEInfo;
    10 interface nsIURI;
    12 %{C++
    13 #define NS_MIMESERVICE_CID                           \
    14 { /* 03af31da-3109-11d3-8cd0-0060b0fc14a3 */         \
    15     0x03af31da,                                      \
    16     0x3109,                                          \
    17     0x11d3,                                          \
    18     {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
    19 }
    20 %}
    22 /**
    23  * The MIME service is responsible for mapping file extensions to MIME-types
    24  * (see RFC 2045). It also provides access to nsIMIMEInfo interfaces and
    25  * acts as a general convenience wrapper of nsIMIMEInfo interfaces.
    26  *
    27  * The MIME service maintains a database with a <b>one</b> MIME type <b>to many</b>
    28  * file extensions rule. Adding the same file extension to multiple MIME types
    29  * is illegal and behavior is undefined.
    30  *
    31  * @see nsIMIMEInfo
    32  */
    33 [scriptable, uuid(5b3675a1-02db-4f8f-a560-b34736635f47)]
    34 interface nsIMIMEService : nsISupports {
    35     /**
    36      * Retrieves an nsIMIMEInfo using both the extension
    37      * and the type of a file. The type is given preference
    38      * during the lookup. One of aMIMEType and aFileExt
    39      * can be an empty string. At least one of aMIMEType and aFileExt
    40      * must be nonempty.
    41      */
    42     nsIMIMEInfo getFromTypeAndExtension(in ACString aMIMEType, in AUTF8String aFileExt);
    44     /**
    45      * Retrieves a ACString representation of the MIME type
    46      * associated with this file extension.
    47      *
    48      * @param  A file extension (excluding the dot ('.')).
    49      * @return The MIME type, if any.
    50      */
    51     ACString getTypeFromExtension(in AUTF8String aFileExt);
    53     /**
    54      * Retrieves a ACString representation of the MIME type
    55      * associated with this URI. The association is purely
    56      * file extension to MIME type based. No attempt to determine
    57      * the type via server headers or byte scanning is made.
    58      *
    59      * @param  The URI the user wants MIME info on.
    60      * @return The MIME type, if any.
    61      */
    62     ACString getTypeFromURI(in nsIURI aURI);
    64     //
    65     ACString getTypeFromFile(in nsIFile aFile);
    67     /**
    68      * Given a Type/Extension combination, returns the default extension
    69      * for this type. This may be identical to the passed-in extension.
    70      *
    71      * @param aMIMEType The Type to get information on. Must not be empty.
    72      * @param aFileExt  File Extension. Can be empty.
    73      */
    74     AUTF8String getPrimaryExtension(in ACString aMIMEType, in AUTF8String aFileExt);
    75 };

mercurial