/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * The contents of this file are subject to the Netscape Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/NPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 1998 Netscape Communications Corporation. All
 * Rights Reserved.
 *
 * Contributor(s): 
 */

#include "nsIStreamObserver.idl"

interface nsIInputStream;
interface nsIInputStream;
interface nsIOutputStream;
interface nsIEventQueue;

[scriptable, uuid(1a637020-1482-11d3-9333-00104ba0fd40)]
interface nsIStreamListener : nsIStreamObserver
{
    void onDataAvailable(in nsIChannel channel,
                         in nsISupports ctxt, 
                         in nsIInputStream inStr,
                         in unsigned long sourceOffset,
                         in unsigned long count);
};

/**
 * An asynchronous stream listener is used to ship data over to another thread specified
 * by the thread's event queue. The receiver stream listener is then used to receive
 * the notifications on the other thread. 
 *
 * This interface only provides the initialization needed after construction. Otherwise,
 * these objects are used simply as nsIStreamListener.
 */
[scriptable, uuid(1b012ade-91bf-11d3-8cd9-0060b0fc14a3)]
interface nsIAsyncStreamListener : nsIStreamListener
{
    /**
     * Initializes an nsIAsyncStreamListener. 
     * @param eventQueue - may be null indicating the calling thread's event queue
     */
    void init(in nsIStreamListener receiver,
              in nsIEventQueue eventQueue);
};

/**
 * A synchronous stream listener pushes data through a pipe that ends up
 * in an input stream to be read by another thread.
 *
 * This interface only provides the initialization needed after construction. Otherwise,
 * these objects are used simply as nsIStreamListener.
 */
[scriptable, uuid(1f9fb93e-91bf-11d3-8cd9-0060b0fc14a3)]
interface nsISyncStreamListener : nsIStreamListener
{
    /**
     * Initializes an nsISyncStreamListener. 
     */
    void init(out nsIInputStream inStream,
              out nsIOutputStream outStream);
};

%{C++

// Use this CID to construct an nsIAsyncStreamListener
#define NS_ASYNCSTREAMLISTENER_CID                   \
{ /* 60047bb2-91c0-11d3-8cd9-0060b0fc14a3 */         \
    0x60047bb2,                                      \
    0x91c0,                                          \
    0x11d3,                                          \
    {0x8c, 0xd9, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}

// Use this CID to construct an nsISyncStreamListener
#define NS_SYNCSTREAMLISTENER_CID                    \
{ /* 65fa5cb2-91c0-11d3-8cd9-0060b0fc14a3 */         \
    0x65fa5cb2,                                      \
    0x91c0,                                          \
    0x11d3,                                          \
    {0x8c, 0xd9, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}

%}
