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
Родитель 1526455072
Коммит 0b77d1dea1
3 изменённых файлов: 46 добавлений и 40 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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.

Просмотреть файл

@ -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));