netwerk/mime/public/nsIMIMEInfo.idl
author ted.mielczarek@gmail.com
Tue, 24 Jul 2007 18:06:09 -0700
changeset 3908 0bc459662ce5209cb9f800b3961814e3ffd485d9
parent 3859 6f541636db02af0f2061c03c05b5a92a00522a68
child 3972 174773ed3d19dab7f70b1a51b35e6ae3dbe2e641
permissions -rw-r--r--
bug 382541 - Mozilla Crash Reporter supresses writing of Mac OS X crash log - short term workaround. r=mento

/* -*- 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):
 *   Dan Mosedale <dmose@mozilla.org>
 *
 * 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 ***** */

#include "nsISupports.idl"

interface nsIURI;
interface nsIFile;
interface nsIUTF8StringEnumerator;
interface nsIHandlerApp;

typedef long nsHandlerInfoAction;

/**
 * nsIHandlerInfo gives access to the information about how a given protocol
 * scheme or MIME-type is handled.
 */
[scriptable, uuid(2ec1216d-59e7-424c-aa1e-70aa3c897520)]
interface nsIHandlerInfo : nsISupports {
    /**
     * A human readable description of the handler type
     */
    attribute AString description;

    /**
     * The application the user has said they want associated with this content
     * type. This is not always guaranteed to be set!!
     */
    attribute nsIHandlerApp preferredApplicationHandler;

    /**
     * Indicates whether a default application handler exists,
     * i.e. whether launchWithFile with action = useSystemDefault is possible
     * and defaultDescription 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 URI, in a way that
     * depends on the value of preferredAction. preferredAction must be
     * useHelperApp or useSystemDefault.
     *
     * @param aURI The URI to launch this application with; this may or may
     *              not be a local file.
     *
     * @throw NS_ERROR_INVALID_ARG if action is not valid for this function.
     * Other exceptions may be thrown.
     */
    void launchWithURI(in nsIURI aURI);

    /**
     * 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; possible value constants
     * listed below
     */
    attribute nsHandlerInfoAction preferredAction;

    const long saveToDisk = 0;
    const long alwaysAsk = 1;
    const long useHelperApp = 2;
    const long handleInternally = 3;
    const long useSystemDefault = 4;

    /**
     * alwaysAskBeforeHandling: if true, we should always give the user a
     * dialog asking how to dispose of this content.
     */
    attribute boolean alwaysAskBeforeHandling;
};

/**
 * nsIMIMEInfo extends nsIHandlerInfo with a bunch of information specific to
 * MIME content-types. 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
 */
[scriptable, uuid(ba01eb13-c2fd-4652-94f8-b33c61e6d77e)]
interface nsIMIMEInfo : nsIHandlerInfo {
    /**
     * 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;

    /**
     * Mac Type and creator types
     */
    attribute PRUint32 macType;
    attribute PRUint32 macCreator;

    /**
     * Returns whether or not these two nsIMIMEInfos are logically
     * equivalent.
     *
     * @returns PR_TRUE if the two are considered equal
     */
    boolean equals(in nsIMIMEInfo aMIMEInfo);
};

/**
 * nsIHandlerApp represents an external application that can handle content
 * of some sort (either a MIME-type or a protocol).  Note that for theoretical
 * cleanliness, nsI{Local,Web}HandlerApp really ought to inherit from
 * nsIHandlerApp.  After that's done, we should also try and make
 * nsIWebContentHandlerInfo inherit from or possibly be replaced by
 * nsIWebHandlerApp.
 */
[scriptable, uuid(08a543dc-081f-4933-b325-252cf68d6ad9)]
interface nsIHandlerApp : nsISupports {

    /**
     * Human readable name for the handler
     */
    attribute AString name;
};

/**
 * nsILocalHandlerApp is a local OS-level executable
 */
[scriptable, uuid(e21f3d75-9103-490e-bfb9-1bf09cc3f103)]
interface nsILocalHandlerApp: nsISupports {

    /**
     * Pointer to the executable file used to handle content
     */
    attribute nsIFile executable;
};

/**
 * nsIWebHandlerApp is a web-based handler, as speced by the WhatWG HTML5
 * draft.  Currently, only GET-based handlers are supported.  At some point, 
 * we probably want to work with WhatWG to spec out and implement POST-based
 * handlers as well.
 */
[scriptable, uuid(065cd099-2f71-4ac8-9dab-17fc079e9647)]
interface nsIWebHandlerApp: nsISupports {

    /**
     * Template used to construct the URI to GET.  Template is expected to have
     * a %s in it, and the escaped URI to be handled is inserted in place of 
     * that %s, as per the HTML5 spec.
     */
    attribute AUTF8String uriTemplate;
};