This commit is contained in:
dougt%netscape.com 2001-04-14 21:10:14 +00:00
Родитель 5a70dbb536
Коммит 6eaef4a960
2 изменённых файлов: 117 добавлений и 117 удалений

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

@ -167,17 +167,17 @@ function Init()
{ {
debug("append traiing slash to FTP directory URL\n"); debug("append traiing slash to FTP directory URL\n");
baseURI += "/"; baseURI += "/";
} }
// Lets also enable the loggin window. // Lets also enable the loggin window.
var node = document.getElementById("main-splitter"); var node = document.getElementById("main-splitter");
node.setAttribute("hidden", false); node.setAttribute("hidden", false);
node = document.getElementById("logbox"); node = document.getElementById("logbox");
node.setAttribute("hidden", false); node.setAttribute("hidden", false);
} }
if (baseURI && (baseURI.indexOf("file://") != 0)) { if (baseURI && (baseURI.indexOf("file://") != 0)) {
// Note: DON'T add the HTTPIndex datasource into the tree // Note: DON'T add the HTTPIndex datasource into the tree
// for file URLs, only do it for FTP/Gopher/etc URLs; the "rdf:files" // for file URLs, only do it for FTP/Gopher/etc URLs; the "rdf:files"
@ -225,7 +225,7 @@ function DoUnload()
var tree = document.getElementById("tree"); var tree = document.getElementById("tree");
if (tree) if (tree)
{ {
tree.database.RemoveDatasource(HTTPIndex); tree.database.RemoveDatasource(HTTPIndex);
tree.database.RemoveObserver(RDF_observer); tree.database.RemoveObserver(RDF_observer);
debug("Directory: removed observer\n"); debug("Directory: removed observer\n");
} }
@ -392,28 +392,28 @@ function BeginDragTree ( event )
return(!dragStarted); return(!dragStarted);
} }
function scrollDown() function scrollDown()
{ {
window.frames[0].scrollTo(0, window.frames[0].document.height); window.frames[0].scrollTo(0, window.frames[0].document.height);
} }
function OnFTPControlLog( server, msg ) function OnFTPControlLog( server, msg )
{ {
var logdoc = frames[0].document; var logdoc = frames[0].document;
var logdocDiv = logdoc.getElementById("logboxDiv"); var logdocDiv = logdoc.getElementById("logboxDiv");
var div = document.createElementNS("http://www.w3.org/1999/xhtml", var div = document.createElementNS("http://www.w3.org/1999/xhtml",
"html:div"); "html:div");
if (server) if (server)
div.setAttribute("class", "server"); div.setAttribute("class", "server");
else else
div.setAttribute("class", "client"); div.setAttribute("class", "client");
div.appendChild (document.createTextNode(msg)); div.appendChild (document.createTextNode(msg));
logdocDiv.appendChild(div); logdocDiv.appendChild(div);
scrollDown(); scrollDown();
} }

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- on/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* *
* The contents of this file are subject to the Netscape Public * The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file * License Version 1.1 (the "License"); you may not use this file
@ -61,13 +61,13 @@
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsITextToSubURI.h" #include "nsITextToSubURI.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIFTPChannel.h" #include "nsIFTPChannel.h"
#include "nsIWindowWatcher.h" #include "nsIWindowWatcher.h"
#include "nsIPrompt.h" #include "nsIPrompt.h"
#include "nsIAuthPrompt.h" #include "nsIAuthPrompt.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsIDOMWindowInternal.h" #include "nsIDOMWindowInternal.h"
#include "nsIDOMWindowCollection.h" #include "nsIDOMWindowCollection.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
@ -161,7 +161,7 @@ protected:
// embedded and the global object won't get clobbered. // embedded and the global object won't get clobbered.
PRBool mBindToGlobalObject; PRBool mBindToGlobalObject;
nsCOMPtr<nsISupports> mContainer; nsCOMPtr<nsISupports> mContainer;
public: public:
static nsresult Create(nsHTTPIndex* aHTTPIndex, static nsresult Create(nsHTTPIndex* aHTTPIndex,
nsISupports* aContainer, nsISupports* aContainer,
@ -354,7 +354,7 @@ nsHTTPIndexParser::Create(nsHTTPIndex* aHTTPIndex,
*aResult = result; *aResult = result;
return NS_OK; return NS_OK;
} }
NS_IMPL_THREADSAFE_ISUPPORTS4(nsHTTPIndexParser, NS_IMPL_THREADSAFE_ISUPPORTS4(nsHTTPIndexParser,
nsIStreamListener, nsIStreamListener,
nsIRequestObserver, nsIRequestObserver,
@ -369,76 +369,76 @@ nsHTTPIndexParser::GetInterface(const nsIID &anIID, void **aResult )
*aResult = NS_STATIC_CAST(nsIFTPEventSink*, this); *aResult = NS_STATIC_CAST(nsIFTPEventSink*, this);
NS_ADDREF(this); NS_ADDREF(this);
return NS_OK; return NS_OK;
} }
if (anIID.Equals(NS_GET_IID(nsIPrompt))) { if (anIID.Equals(NS_GET_IID(nsIPrompt))) {
nsCOMPtr<nsIInterfaceRequestor> requestor = do_QueryInterface(mContainer); nsCOMPtr<nsIInterfaceRequestor> requestor = do_QueryInterface(mContainer);
if (!requestor) if (!requestor)
return NS_ERROR_NO_INTERFACE; return NS_ERROR_NO_INTERFACE;
nsCOMPtr<nsIDOMWindow> aDOMWindow = do_GetInterface(requestor); nsCOMPtr<nsIDOMWindow> aDOMWindow = do_GetInterface(requestor);
if (!aDOMWindow) if (!aDOMWindow)
return NS_ERROR_NO_INTERFACE; return NS_ERROR_NO_INTERFACE;
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
return wwatch->GetNewPrompter(aDOMWindow, (nsIPrompt**)aResult); return wwatch->GetNewPrompter(aDOMWindow, (nsIPrompt**)aResult);
} }
if (anIID.Equals(NS_GET_IID(nsIAuthPrompt))) { if (anIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
nsCOMPtr<nsIInterfaceRequestor> requestor = do_QueryInterface(mContainer); nsCOMPtr<nsIInterfaceRequestor> requestor = do_QueryInterface(mContainer);
if (!requestor) if (!requestor)
return NS_ERROR_NO_INTERFACE; return NS_ERROR_NO_INTERFACE;
nsCOMPtr<nsIDOMWindow> aDOMWindow = do_GetInterface(requestor); nsCOMPtr<nsIDOMWindow> aDOMWindow = do_GetInterface(requestor);
if (!aDOMWindow) if (!aDOMWindow)
return NS_ERROR_NO_INTERFACE; return NS_ERROR_NO_INTERFACE;
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
return wwatch->GetNewAuthPrompter(aDOMWindow, (nsIAuthPrompt**)aResult); return wwatch->GetNewAuthPrompter(aDOMWindow, (nsIAuthPrompt**)aResult);
} }
return NS_ERROR_NO_INTERFACE; return NS_ERROR_NO_INTERFACE;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsHTTPIndexParser::OnFTPControlLog(PRBool server, const char *msg) nsHTTPIndexParser::OnFTPControlLog(PRBool server, const char *msg)
{ {
NS_ENSURE_TRUE(mContainer, NS_OK); NS_ENSURE_TRUE(mContainer, NS_OK);
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(mContainer)); nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_GetInterface(mContainer));
NS_ENSURE_TRUE(scriptGlobal, NS_OK); NS_ENSURE_TRUE(scriptGlobal, NS_OK);
nsCOMPtr<nsIScriptContext> context; nsCOMPtr<nsIScriptContext> context;
nsresult rv = scriptGlobal->GetContext(getter_AddRefs(context)); nsresult rv = scriptGlobal->GetContext(getter_AddRefs(context));
NS_ENSURE_TRUE(context, NS_OK); NS_ENSURE_TRUE(context, NS_OK);
JSContext* jscontext = NS_REINTERPRET_CAST(JSContext*, JSContext* jscontext = NS_REINTERPRET_CAST(JSContext*,
context->GetNativeContext()); context->GetNativeContext());
JSObject* global = JS_GetGlobalObject(jscontext); JSObject* global = JS_GetGlobalObject(jscontext);
if (!jscontext || !global) return NS_OK; if (!jscontext || !global) return NS_OK;
jsval params[2]; jsval params[2];
nsString unicodeMsg; nsString unicodeMsg;
unicodeMsg.AssignWithConversion(msg); unicodeMsg.AssignWithConversion(msg);
JSString* jsMsgStr = JS_NewUCStringCopyZ(jscontext, (jschar*) unicodeMsg.GetUnicode()); JSString* jsMsgStr = JS_NewUCStringCopyZ(jscontext, (jschar*) unicodeMsg.GetUnicode());
params[0] = BOOLEAN_TO_JSVAL(server); params[0] = BOOLEAN_TO_JSVAL(server);
params[1] = STRING_TO_JSVAL(jsMsgStr); params[1] = STRING_TO_JSVAL(jsMsgStr);
jsval val; jsval val;
JS_CallFunctionName(jscontext, JS_CallFunctionName(jscontext,
global, global,
"OnFTPControlLog", "OnFTPControlLog",
2, 2,
params, params,
&val); &val);
return NS_OK; return NS_OK;
} }
@ -497,16 +497,16 @@ nsHTTPIndexParser::OnStartRequest(nsIRequest *request, nsISupports* aContext)
NS_ASSERTION(ok, "unable to set Listener property"); NS_ASSERTION(ok, "unable to set Listener property");
if (! ok) if (! ok)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// Get the directory from the context // Get the directory from the context
mDirectory = do_QueryInterface(aContext); mDirectory = do_QueryInterface(aContext);
if (!mDirectory) { if (!mDirectory) {
request->Cancel(NS_BINDING_ABORTED); request->Cancel(NS_BINDING_ABORTED);
return NS_BINDING_ABORTED; return NS_BINDING_ABORTED;
} }
// Mark the directory as "loading" // Mark the directory as "loading"
rv = mDataSource->Assert(mDirectory, kHTTPIndex_Loading, rv = mDataSource->Assert(mDirectory, kHTTPIndex_Loading,
@ -562,12 +562,12 @@ nsHTTPIndexParser::OnDataAvailable(nsIRequest *request,
nsIInputStream* aStream, nsIInputStream* aStream,
PRUint32 aSourceOffset, PRUint32 aSourceOffset,
PRUint32 aCount) PRUint32 aCount)
{ {
// If mDirectory isn't set, then we should just bail. Either an // If mDirectory isn't set, then we should just bail. Either an
// error occurred and OnStartRequest() never got called, or // error occurred and OnStartRequest() never got called, or
// something exploded in OnStartRequest(). // something exploded in OnStartRequest().
if (! mDirectory) if (! mDirectory)
return NS_BINDING_ABORTED; return NS_BINDING_ABORTED;
// Make sure there's some data to process... // Make sure there's some data to process...
if (aCount < 1) if (aCount < 1)
@ -1904,7 +1904,7 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand,
// Now shanghai the stream into our http-index parsing datasource // Now shanghai the stream into our http-index parsing datasource
// wrapper beastie. // wrapper beastie.
rv = httpindex->CreateListener(aDocListenerResult); rv = httpindex->CreateListener(aDocListenerResult);
return rv; return rv;
} }