Fixes 75289. If you want to listen to the ftp control traffic, here is your chance.

sr=darin
This commit is contained in:
dougt%netscape.com 2001-04-12 23:32:47 +00:00
parent 080db94711
commit d2c8917d51
5 changed files with 36 additions and 18 deletions

View File

@ -32,6 +32,13 @@ interface nsIFTPChannel : nsIChannel
readonly attribute PRBool UsingTransparentProxy;
};
[scriptable, uuid(455d4234-0330-43d2-bbfb-99afbecbfeb0)]
interface nsIFTPEventSink : nsISupports
{
void OnFTPControlLog(in boolean server, in string msg);
};
%{C++
#include "ftpCore.h"
%}

View File

@ -273,7 +273,7 @@ nsFTPChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
if (!mFTPState) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mFTPState);
}
rv = mFTPState->Init(this, mPrompter, mAuthPrompter);
rv = mFTPState->Init(this, mPrompter, mAuthPrompter, mFTPEventSink);
if (NS_FAILED(rv)) return rv;
rv = mFTPState->Connect();
@ -406,6 +406,9 @@ nsFTPChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallb
(void)mCallbacks->GetInterface(NS_GET_IID(nsIPrompt),
getter_AddRefs(mPrompter));
NS_ASSERTION ( mPrompter, "Channel doesn't have a prompt!!!" );
(void)mCallbacks->GetInterface(NS_GET_IID(nsIFTPEventSink),
getter_AddRefs(mFTPEventSink));
(void)mCallbacks->GetInterface(NS_GET_IID(nsIAuthPrompt),
getter_AddRefs(mAuthPrompter));

View File

@ -89,8 +89,11 @@ public:
protected:
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mURL;
// various callback interfaces
nsCOMPtr<nsIProgressEventSink> mEventSink;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIFTPEventSink> mFTPEventSink;
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;

View File

@ -324,16 +324,16 @@ nsFtpState::OnDataAvailable(nsIRequest *request,
}
buffer[aCount] = '\0';
#if defined(PR_LOGGING)
nsCString logString(buffer);
logString.ReplaceChar(CRLF, ' ');
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) reading %d bytes: \"%s\"", this, aCount, logString.get()));
#ifdef DEBUG_dougt
printf("!!! %s\n", logString.get());
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) reading %d bytes: \"%s\"", this, aCount, buffer));
#if 0 //#ifdef DEBUG_dougt
printf("!!! %s\n", buffer);
#endif
#endif
#endif
if (mFTPEventSink)
mFTPEventSink->OnFTPControlLog(PR_TRUE, buffer);
// get the response code out.
if (!mControlReadContinue && !mControlReadBrokenLine) {
@ -1929,12 +1929,15 @@ nsFtpState::SetLoadFlags(nsLoadFlags aLoadFlags)
nsresult
nsFtpState::Init(nsIFTPChannel* aChannel,
nsIPrompt* aPrompter,
nsIAuthPrompt* aAuthPrompter) {
nsIPrompt* aPrompter,
nsIAuthPrompt* aAuthPrompter,
nsIFTPEventSink* sink)
{
nsresult rv = NS_OK;
mKeepRunning = PR_TRUE;
mPrompter = aPrompter;
mFTPEventSink = sink;
mAuthPrompter = aAuthPrompter;
// parameter validation
@ -2360,15 +2363,15 @@ nsFtpState::SendFTPCommand(nsCString& command)
NS_ASSERTION(mControlConnection, "null control connection");
#if defined(PR_LOGGING)
nsCString logString(command);
logString.ReplaceChar(CRLF, ' ');
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) Writing \"%s\"\n", this, logString.get()));
#ifdef DEBUG_dougt
printf("!!! %s\n", logString.get());
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) Writing \"%s\"\n", this, command.get()));
#if 0 // #ifdef DEBUG_dougt
printf("!!! %s\n", command.get());
#endif
#endif
#endif
if (mFTPEventSink)
mFTPEventSink->OnFTPControlLog(PR_FALSE, command.get());
if (mControlConnection) {
return mControlConnection->Write(command, mWaitingForDConn);
}

View File

@ -106,7 +106,7 @@ public:
nsFtpState();
virtual ~nsFtpState();
nsresult Init(nsIFTPChannel *aChannel, nsIPrompt *aPrompter, nsIAuthPrompt *aAuthPrompter);
nsresult Init(nsIFTPChannel *aChannel, nsIPrompt *aPrompter, nsIAuthPrompt *aAuthPrompter, nsIFTPEventSink *sink);
// use this to provide a stream to be written to the server.
nsresult SetWriteStream(nsIInputStream* aInStream, PRUint32 aWriteCount);
@ -211,7 +211,9 @@ private:
PRBool mGenerateHTMLContent;
PRPackedBool mIPv6Checked;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIFTPEventSink> mFTPEventSink;
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
char *mIPv6ServerAddress; // Server IPv6 address; null if server not IPv6
// ***** control read gvars