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 nsIInputStream; michael@0: interface nsIStreamListener; michael@0: michael@0: %{C++ michael@0: #define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1" michael@0: %} michael@0: michael@0: /** michael@0: * The nsIStreamConverterService is a higher level stream converter factory michael@0: * responsible for locating and creating stream converters michael@0: * (nsIStreamConverter). michael@0: * michael@0: * This service retrieves an interface that can convert data from a particular michael@0: * MIME type, to a particular MIME type. It is responsible for any intermediary michael@0: * conversion required in order to get from X to Z, assuming direct conversion michael@0: * is not possible. michael@0: * michael@0: * @author Jud Valeski michael@0: * @see nsIStreamConverter michael@0: */ michael@0: [scriptable, uuid(f2b1ab53-f0bd-4adb-9365-e59b1701a258)] michael@0: interface nsIStreamConverterService : nsISupports { michael@0: /** michael@0: * Tests whether conversion between the two specified types is possible. michael@0: * This is cheaper than calling convert()/asyncConvertData(); it is not michael@0: * necessary to call this function before calling one of those, though. michael@0: */ michael@0: boolean canConvert(in string aFromType, in string aToType); michael@0: michael@0: /** michael@0: * SYNCHRONOUS 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 aContext Either an opaque context, or a converter specific michael@0: * context (implementation specific). michael@0: * @return The converted stream. NOTE: The returned stream michael@0: * may not already be converted. An efficient stream michael@0: * converter implementation will convert data on michael@0: * demand rather than buffering the converted data michael@0: * 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 aContext); michael@0: michael@0: /** michael@0: * ASYNCHRONOUS VERSION michael@0: * Retrieves a nsIStreamListener that receives the original/raw data via its michael@0: * nsIStreamListener::OnDataAvailable() callback, then converts and pushes michael@0: * the data to aListener. michael@0: * michael@0: * Use this method when you want to proxy (and convert) nsIStreamListener michael@0: * callbacks 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 that receives the converted data. michael@0: * @param aCtxt Either an opaque context, or a converter specific michael@0: * context (implementation specific). michael@0: * @return A nsIStreamListener that receives data via its michael@0: * OnDataAvailable() method. michael@0: */ michael@0: nsIStreamListener asyncConvertData(in string aFromType, michael@0: in string aToType, michael@0: in nsIStreamListener aListener, michael@0: in nsISupports aContext); michael@0: };