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
"nsIStreamListener.idl"
39 #include
"nsIInputStream.idl"
43 * nsIStreamConverter provides an interface to implement when you have code
44 * that converts data from one type to another.
46 * Suppose you had code that converted plain text into HTML. You could implement
47 * this interface to allow everyone else to use your conversion logic using a
50 * <b>STREAM CONVERTER USERS</b>
52 * There are currently two ways to use a stream converter:
54 * <li> <b>SYNCHRONOUS</b> Stream to Stream
55 * You can supply the service with a stream of type X
56 * and it will convert it to your desired output type and return
57 * a converted (blocking) stream to you.</li>
59 * <li> <b>ASYNCHRONOUS</b> nsIStreamListener to nsIStreamListener
60 * You can supply data directly to the converter by calling it's
61 * nsIStreamListener::OnDataAvailable() method. It will then
62 * convert that data from type X to your desired output type and
63 * return converted data to you via the nsIStreamListener you passed
64 * in by calling its OnDataAvailable() method.</li>
68 * <b>STREAM CONVERTER SUPPLIERS</b>
70 * Registering a stream converter:
71 * Stream converter registration is a two step process. First of all the stream
72 * converter implementation must register itself with the component manager using
73 * a contractid in the format below. Second, the stream converter must add the contractid
76 * Stream converter contractid format (the stream converter root key is defined in this
79 * <pre>@mozilla.org/streamconv;1?from=FROM_MIME_TYPE&to=TO_MIME_TYPE</pre>
82 * @see nsIStreamConverterService
85 [scriptable
, uuid(0b6e2c69
-5cf5
-48b0
-9dfd
-c95950e2cc7b
)]
86 interface nsIStreamConverter
: nsIStreamListener
{
89 * <b>SYNCRONOUS VERSION</b>
90 * Converts a stream of one type, to a stream of another type.
92 * Use this method when you have a stream you want to convert.
94 * @param aFromStream The stream representing the original/raw data.
95 * @param aFromType The MIME type of aFromStream.
96 * @param aToType The MIME type of the returned stream.
97 * @param aCtxt Either an opaque context, or a converter specific context
98 * (implementation specific).
99 * @return The converted stream. NOTE: The returned stream may not
100 * already be converted. An efficient stream converter
101 * implementation will converter data on demand rather than
102 * buffering the converted data until it is used.
104 nsIInputStream convert
(in nsIInputStream aFromStream
,
107 in nsISupports aCtxt
);
110 * <b>ASYNCRONOUS VERSION</b>
111 * Converts data arriving via the converter's nsIStreamListener::OnDataAvailable()
112 * method from one type to another, pushing the converted data out to the caller
113 * via aListener::OnDataAvailable().
115 * Use this method when you want to proxy (and convert) nsIStreamListener callbacks
118 * @param aFromType The MIME type of the original/raw data.
119 * @param aToType The MIME type of the converted data.
120 * @param aListener The listener who receives the converted data.
121 * @param aCtxt Either an opaque context, or a converter specific context
122 * (implementation specific).
124 void asyncConvertData
(in string aFromType
,
126 in nsIStreamListener aListener
,
127 in nsISupports aCtxt
);
131 #define NS_ISTREAMCONVERTER_KEY
"@mozilla.org/streamconv;1"