|
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/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIInputStream; |
|
9 interface nsIStreamListener; |
|
10 |
|
11 %{C++ |
|
12 #define NS_ISTREAMCONVERTER_KEY "@mozilla.org/streamconv;1" |
|
13 %} |
|
14 |
|
15 /** |
|
16 * The nsIStreamConverterService is a higher level stream converter factory |
|
17 * responsible for locating and creating stream converters |
|
18 * (nsIStreamConverter). |
|
19 * |
|
20 * This service retrieves an interface that can convert data from a particular |
|
21 * MIME type, to a particular MIME type. It is responsible for any intermediary |
|
22 * conversion required in order to get from X to Z, assuming direct conversion |
|
23 * is not possible. |
|
24 * |
|
25 * @author Jud Valeski |
|
26 * @see nsIStreamConverter |
|
27 */ |
|
28 [scriptable, uuid(f2b1ab53-f0bd-4adb-9365-e59b1701a258)] |
|
29 interface nsIStreamConverterService : nsISupports { |
|
30 /** |
|
31 * Tests whether conversion between the two specified types is possible. |
|
32 * This is cheaper than calling convert()/asyncConvertData(); it is not |
|
33 * necessary to call this function before calling one of those, though. |
|
34 */ |
|
35 boolean canConvert(in string aFromType, in string aToType); |
|
36 |
|
37 /** |
|
38 * <b>SYNCHRONOUS VERSION</b> |
|
39 * Converts a stream of one type, to a stream of another type. |
|
40 * |
|
41 * Use this method when you have a stream you want to convert. |
|
42 * |
|
43 * @param aFromStream The stream representing the original/raw data. |
|
44 * @param aFromType The MIME type of aFromStream. |
|
45 * @param aToType The MIME type of the returned stream. |
|
46 * @param aContext Either an opaque context, or a converter specific |
|
47 * context (implementation specific). |
|
48 * @return The converted stream. NOTE: The returned stream |
|
49 * may not already be converted. An efficient stream |
|
50 * converter implementation will convert data on |
|
51 * demand rather than buffering the converted data |
|
52 * until it is used. |
|
53 */ |
|
54 nsIInputStream convert(in nsIInputStream aFromStream, |
|
55 in string aFromType, |
|
56 in string aToType, |
|
57 in nsISupports aContext); |
|
58 |
|
59 /** |
|
60 * <b>ASYNCHRONOUS VERSION</b> |
|
61 * Retrieves a nsIStreamListener that receives the original/raw data via its |
|
62 * nsIStreamListener::OnDataAvailable() callback, then converts and pushes |
|
63 * the data to aListener. |
|
64 * |
|
65 * Use this method when you want to proxy (and convert) nsIStreamListener |
|
66 * callbacks asynchronously. |
|
67 * |
|
68 * @param aFromType The MIME type of the original/raw data. |
|
69 * @param aToType The MIME type of the converted data. |
|
70 * @param aListener The listener that receives the converted data. |
|
71 * @param aCtxt Either an opaque context, or a converter specific |
|
72 * context (implementation specific). |
|
73 * @return A nsIStreamListener that receives data via its |
|
74 * OnDataAvailable() method. |
|
75 */ |
|
76 nsIStreamListener asyncConvertData(in string aFromType, |
|
77 in string aToType, |
|
78 in nsIStreamListener aListener, |
|
79 in nsISupports aContext); |
|
80 }; |