1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #include
"nsIInputStream.idl"
39 #include
"nsIStreamListener.idl"
42 #define NS_ISTREAMCONVERTER_KEY
"@mozilla.org/streamconv;1"
46 * The nsIStreamConverterService is a higher level stream converter factory
47 * responsible for locating and creating stream converters
48 * (nsIStreamConverter).
50 * This service retrieves an interface that can convert data from a particular
51 * MIME type, to a particular MIME type. It is responsible for any intermediary
52 * conversion required in order to get from X to Z, assuming direct conversion
56 * @see nsIStreamConverter
58 [scriptable
, uuid(f2b1ab53
-f0bd
-4adb
-9365-e59b1701a258
)]
59 interface nsIStreamConverterService
: nsISupports
{
61 * Tests whether conversion between the two specified types is possible.
62 * This is cheaper than calling convert()/asyncConvertData(); it is not
63 * necessary to call this function before calling one of those, though.
65 boolean canConvert
(in string aFromType
, in string aToType
);
68 * <b>SYNCHRONOUS VERSION</b>
69 * Converts a stream of one type, to a stream of another type.
71 * Use this method when you have a stream you want to convert.
73 * @param aFromStream The stream representing the original/raw data.
74 * @param aFromType The MIME type of aFromStream.
75 * @param aToType The MIME type of the returned stream.
76 * @param aContext Either an opaque context, or a converter specific
77 * context (implementation specific).
78 * @return The converted stream. NOTE: The returned stream
79 * may not already be converted. An efficient stream
80 * converter implementation will convert data on
81 * demand rather than buffering the converted data
84 nsIInputStream convert
(in nsIInputStream aFromStream
,
87 in nsISupports aContext
);
90 * <b>ASYNCHRONOUS VERSION</b>
91 * Retrieves a nsIStreamListener that receives the original/raw data via its
92 * nsIStreamListener::OnDataAvailable() callback, then converts and pushes
93 * the data to aListener.
95 * Use this method when you want to proxy (and convert) nsIStreamListener
96 * callbacks asynchronously.
98 * @param aFromType The MIME type of the original/raw data.
99 * @param aToType The MIME type of the converted data.
100 * @param aListener The listener that receives the converted data.
101 * @param aCtxt Either an opaque context, or a converter specific
102 * context (implementation specific).
103 * @return A nsIStreamListener that receives data via its
104 * OnDataAvailable() method.
106 nsIStreamListener asyncConvertData
(in string aFromType
,
108 in nsIStreamListener aListener
,
109 in nsISupports aContext
);