/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * 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 "nsIRequest.idl"

interface nsIChannel;
interface nsISimpleEnumerator;
interface nsIStreamObserver;
interface nsIStreamListener;
interface nsIInputStream;

[scriptable, uuid(60fdf550-5392-11d3-9a97-0080c7cb1080)]
interface nsILoadGroupListenerFactory : nsISupports
{
    nsIStreamListener createLoadGroupListener(in nsIStreamListener alistener);
};


/**
 * A load group maintains a collection of active URL requests. 
 */
[scriptable, uuid(19845248-29ab-11d3-8cce-0060b0fc14a3)]
interface nsILoadGroup : nsIRequest
{
    void init(in nsIStreamObserver observer);

    /**
     * Accesses the default load attributes for the group, returned as
     * a flag word. Setting the default load attributes will cause them
     * to be applied to each new channel inserted into the group.
     */
    attribute unsigned long defaultLoadAttributes;

    /**
     * Accesses the default load channel for the group.  Each time a number
     * of channels are added to a group, the DefaultLoadChannel may be set
     * to indicate that all of the channels are related to a particular URL.
     */
    attribute nsIChannel defaultLoadChannel;

    /**
     * Adds a new channel to the group. This will cause the default load
     * attributes to be applied to that channel. If the channel added is 
     * the first channel in the group, the group's observer's OnStartRequest
     * method is called.
     */
    void addChannel(in nsIChannel channel,
                    in nsISupports ctxt);

    /**
     * Removes a channel from the group. If the channel removed is 
     * the last channel in the group, the group's observer's OnStopRequest
     * method is called.
     */
    void removeChannel(in nsIChannel channel, 
                       in nsISupports ctxt,
                       in nsresult status,
                       in wstring statusArg);

    /**
     * Returns the channels contained directly in this group.
     * Enumerator element type: nsIChannel.
     */
    readonly attribute nsISimpleEnumerator channels;

    attribute nsIStreamObserver groupObserver;

    attribute nsILoadGroupListenerFactory groupListenerFactory;


	readonly attribute unsigned long activeCount;
};

%{C++

#define NS_LOADGROUP_CID                             \
{ /* e1c61582-2a84-11d3-8cce-0060b0fc14a3 */         \
    0xe1c61582,                                      \
    0x2a84,                                          \
    0x11d3,                                          \
    {0x8c, 0xce, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}

%}
