/* -*- 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 "nsIProtocolHandler.idl"

interface nsISimpleEnumerator;
native nsCStringArrayPtr(nsCStringArray*);

%{C++
#include "nsVoidArray.h"

#define NS_RESPROTOCOLHANDLER_CID                    \
{ /* e64f152a-9f07-11d3-8cda-0060b0fc14a3 */         \
    0xe64f152a,                                      \
    0x9f07,                                          \
    0x11d3,                                          \
    {0x8c, 0xda, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}

%}

[scriptable, uuid(d12c08c6-9ef6-11d3-8cda-0060b0fc14a3)]
interface nsIResProtocolHandler : nsIProtocolHandler
{
    /**
     * Registers a new substitution for root key, e.g.:
     *   res://<root>/<path> ==> <url>/<path>
     * This substitution is put at the beginning of the list
     * so that it overrides existing substitutions.
     */
    void prependSubstitution(in string root, in string url);

    /**
     * Registers a new substitution for root key, e.g.:
     *   res://<root>/<path> ==> <url>/<path>
     * This substitution is put at the end of the list
     * so that it doesn't override existing substitutions.
     */
    void appendSubstitution(in string root, in string url);

    /**
     * Unregisters a previously registered substitution. If the
     * specified root is not found, or if the url string doesn't match
     * any registered entries, an error is returned. 
     */
    void removeSubstitution(in string root, in string url);

    /**
     * Returns a string array containing all substitutions currently
     * registered for the root. This array is a snapshot of the 
     * registered entries so it can be iterated over without fear of
     * thread-safety concerns.
     */
    [noscript] nsCStringArrayPtr getSubstitutions(in string root);
};
