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 "nsIStreamListener.idl" michael@0: michael@0: interface nsIInputStream; michael@0: michael@0: /** michael@0: * nsIStreamConverter provides an interface to implement when you have code michael@0: * that converts data from one type to another. michael@0: * michael@0: * Suppose you had code that converted plain text into HTML. You could implement michael@0: * this interface to allow everyone else to use your conversion logic using a michael@0: * standard api. michael@0: *
michael@0: * STREAM CONVERTER USERS michael@0: * michael@0: * There are currently two ways to use a stream converter: michael@0: *
michael@0: * michael@0: * STREAM CONVERTER SUPPLIERS michael@0: * michael@0: * Registering a stream converter: michael@0: * Stream converter registration is a two step process. First of all the stream michael@0: * converter implementation must register itself with the component manager using michael@0: * a contractid in the format below. Second, the stream converter must add the contractid michael@0: * to the registry. michael@0: * michael@0: * Stream converter contractid format (the stream converter root key is defined in this michael@0: * file): michael@0: * michael@0: *
@mozilla.org/streamconv;1?from=FROM_MIME_TYPE&to=TO_MIME_TYPEmichael@0: * michael@0: * @author Jud Valeski michael@0: * @see nsIStreamConverterService michael@0: */ michael@0: michael@0: [scriptable, uuid(0b6e2c69-5cf5-48b0-9dfd-c95950e2cc7b)] michael@0: interface nsIStreamConverter : nsIStreamListener { michael@0: michael@0: /** michael@0: * SYNCRONOUS VERSION michael@0: * Converts a stream of one type, to a stream of another type. michael@0: * michael@0: * Use this method when you have a stream you want to convert. michael@0: * michael@0: * @param aFromStream The stream representing the original/raw data. michael@0: * @param aFromType The MIME type of aFromStream. michael@0: * @param aToType The MIME type of the returned stream. michael@0: * @param aCtxt Either an opaque context, or a converter specific context michael@0: * (implementation specific). michael@0: * @return The converted stream. NOTE: The returned stream may not michael@0: * already be converted. An efficient stream converter michael@0: * implementation will converter data on demand rather than michael@0: * buffering the converted data until it is used. michael@0: */ michael@0: nsIInputStream convert(in nsIInputStream aFromStream, michael@0: in string aFromType, michael@0: in string aToType, michael@0: in nsISupports aCtxt); michael@0: michael@0: /** michael@0: * ASYNCRONOUS VERSION michael@0: * Converts data arriving via the converter's nsIStreamListener::OnDataAvailable() michael@0: * method from one type to another, pushing the converted data out to the caller michael@0: * via aListener::OnDataAvailable(). michael@0: * michael@0: * Use this method when you want to proxy (and convert) nsIStreamListener callbacks michael@0: * asynchronously. michael@0: * michael@0: * @param aFromType The MIME type of the original/raw data. michael@0: * @param aToType The MIME type of the converted data. michael@0: * @param aListener The listener who receives the converted data. michael@0: * @param aCtxt Either an opaque context, or a converter specific context michael@0: * (implementation specific). michael@0: */ michael@0: void asyncConvertData(in string aFromType, michael@0: in string aToType, michael@0: in nsIStreamListener aListener, michael@0: in nsISupports aCtxt); michael@0: }; michael@0: michael@0: %{C++ michael@0: #define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1" michael@0: %}