2 fixes for directory listings: I added arguments to NewChannel which needed to be added in directory.js. Travis wacked nsHTTPIndexParser::OnStartRequest and didn't preserve the 'call once' stuff. r=waterson

This commit is contained in:
warren%netscape.com 1999-12-06 23:45:34 +00:00
parent c18859f93a
commit 0f39c4f921
3 changed files with 46 additions and 40 deletions

View File

@ -135,7 +135,9 @@ function ReadDirectory(url)
var uri = ios.newURI(url, null);
// Create a channel...
var channel = ios.newChannelFromURI('load', uri, null, null, Components.interfaces.nsIChannel.LOAD_NORMAL, null);
var channel = ios.newChannelFromURI('load', uri, null, null,
Components.interfaces.nsIChannel.LOAD_NORMAL,
null, 0, 0);
// ...so that we can pipe it into a new HTTPIndex listener to
// parse the directory's contents.

View File

@ -135,7 +135,9 @@ function ReadDirectory(url)
var uri = ios.newURI(url, null);
// Create a channel...
var channel = ios.newChannelFromURI('load', uri, null, null, Components.interfaces.nsIChannel.LOAD_NORMAL, null);
var channel = ios.newChannelFromURI('load', uri, null, null,
Components.interfaces.nsIChannel.LOAD_NORMAL,
null, 0, 0);
// ...so that we can pipe it into a new HTTPIndex listener to
// parse the directory's contents.

View File

@ -321,55 +321,57 @@ nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext)
{
nsresult rv;
// We need to undo the AddRef() on the nsHTTPIndex object that
// happened in nsDirectoryViewerFactory::CreateInstance(). We'll
// stuff it into an nsCOMPtr (because we _know_ it'll get release
// if any errors occur)...
nsCOMPtr<nsIHTTPIndex> httpindex = do_QueryInterface(mHTTPIndex);
// This should only run once...
if (mContainer) {
// We need to undo the AddRef() on the nsHTTPIndex object that
// happened in nsDirectoryViewerFactory::CreateInstance(). We'll
// stuff it into an nsCOMPtr (because we _know_ it'll get release
// if any errors occur)...
nsCOMPtr<nsIHTTPIndex> httpindex = do_QueryInterface(mHTTPIndex);
// ...and then _force_ a release here
mHTTPIndex->Release();
// ...and then _force_ a release here
mHTTPIndex->Release();
// Now get the content viewer container's script object.
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(mContainer));
NS_ENSURE_TRUE(scriptGlobal, NS_ERROR_FAILURE);
// Now get the content viewer container's script object.
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(mContainer));
NS_ENSURE_TRUE(scriptGlobal, NS_ERROR_FAILURE);
nsCOMPtr<nsIScriptContext> context;
rv = scriptGlobal->GetContext(getter_AddRefs(context));
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
nsCOMPtr<nsIScriptContext> context;
rv = scriptGlobal->GetContext(getter_AddRefs(context));
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
JSContext* jscontext = NS_REINTERPRET_CAST(JSContext*, context->GetNativeContext());
JSContext* jscontext = NS_REINTERPRET_CAST(JSContext*, context->GetNativeContext());
// Using XPConnect, wrap the HTTP index object...
static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID);
NS_WITH_SERVICE(nsIXPConnect, xpc, kXPConnectCID, &rv);
if (NS_FAILED(rv)) return rv;
// Using XPConnect, wrap the HTTP index object...
static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID);
NS_WITH_SERVICE(nsIXPConnect, xpc, kXPConnectCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
rv = xpc->WrapNative(jscontext,
httpindex,
nsCOMTypeInfo<nsIHTTPIndex>::GetIID(),
getter_AddRefs(wrapper));
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
rv = xpc->WrapNative(jscontext,
httpindex,
nsCOMTypeInfo<nsIHTTPIndex>::GetIID(),
getter_AddRefs(wrapper));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to xpconnect-wrap http-index");
if (NS_FAILED(rv)) return rv;
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to xpconnect-wrap http-index");
if (NS_FAILED(rv)) return rv;
JSObject* jsobj;
rv = wrapper->GetJSObject(&jsobj);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get jsobj from xpconnect wrapper");
if (NS_FAILED(rv)) return rv;
JSObject* jsobj;
rv = wrapper->GetJSObject(&jsobj);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get jsobj from xpconnect wrapper");
if (NS_FAILED(rv)) return rv;
jsval jslistener = OBJECT_TO_JSVAL(jsobj);
jsval jslistener = OBJECT_TO_JSVAL(jsobj);
// ...and stuff it into the global context
PRBool ok;
JSObject* global = JS_GetGlobalObject(jscontext);
ok = JS_SetProperty(jscontext, global, "HTTPIndex", &jslistener);
// ...and stuff it into the global context
PRBool ok;
JSObject* global = JS_GetGlobalObject(jscontext);
ok = JS_SetProperty(jscontext, global, "HTTPIndex", &jslistener);
NS_ASSERTION(ok, "unable to set Listener property");
if (! ok)
return NS_ERROR_FAILURE;
NS_ASSERTION(ok, "unable to set Listener property");
if (! ok)
return NS_ERROR_FAILURE;
}
// Save off some information about the stream we're about to parse.
rv = aChannel->GetURI(getter_AddRefs(mDirectoryURI));