diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 28f3577819b..b9386601e40 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -78,6 +78,7 @@ #include "nsIPrincipal.h" #include "nsIHistoryEntry.h" #include "nsISHistoryListener.h" +#include "nsIDirectoryListing.h" // Editor-related #include "nsIEditingSession.h" @@ -4618,6 +4619,11 @@ nsresult nsDocShell::DoURILoad(nsIURI * aURI, httpChannel->SetReferrer(aReferrerURI, nsIHttpChannel::REFERRER_LINK_CLICK); } + // We want to use the pref for directory listings + nsCOMPtr dirList = do_QueryInterface(channel); + if (dirList) { + (void)dirList->SetListFormat(nsIDirectoryListing::FORMAT_PREF); + } // // Set the owner of the channel - only for javascript and data channels. // diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index 0145bf589a7..56142c888fe 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -440,7 +440,9 @@ pref("network.http.proxy.ssl.connect",true); // Idle timeout for ftp control connections - 5 minute default pref("network.ftp.idleConnectionTimeout", 300); -pref("network.dir.generate_html", true); +// directory listing format - constants are defined in nsIDirectoryListing.idl +// Do not set this to 0... +pref("network.dir.format", 2); // sspitzer: change this back to "news" when we get to beta. // for now, set this to news.mozilla.org because you can only diff --git a/mozilla/netwerk/base/public/MANIFEST_IDL b/mozilla/netwerk/base/public/MANIFEST_IDL index 92aa3e330bc..45f90d9677e 100644 --- a/mozilla/netwerk/base/public/MANIFEST_IDL +++ b/mozilla/netwerk/base/public/MANIFEST_IDL @@ -5,8 +5,9 @@ nsIAuthenticator.idl nsIAuthPrompt.idl nsIChannel.idl -nsIFileChannel.idl +nsIDirectoryListing.idl nsIDownloader.idl +nsIFileChannel.idl nsIFileTransportService.idl nsIMIMEInputStream.idl nsIPasswordManager.idl diff --git a/mozilla/netwerk/base/public/Makefile.in b/mozilla/netwerk/base/public/Makefile.in index 26671b60599..b24ee22bed6 100644 --- a/mozilla/netwerk/base/public/Makefile.in +++ b/mozilla/netwerk/base/public/Makefile.in @@ -32,8 +32,9 @@ XPIDLSRCS = \ nsIAuthenticator.idl \ nsIAuthPrompt.idl \ nsIChannel.idl \ - nsIFileChannel.idl \ + nsIDirectoryListing.idl \ nsIDownloader.idl \ + nsIFileChannel.idl \ nsIFileStreams.idl \ nsIFileTransportService.idl \ nsIIOService.idl \ diff --git a/mozilla/netwerk/base/public/makefile.win b/mozilla/netwerk/base/public/makefile.win index 5624f0a02aa..26158a4292f 100644 --- a/mozilla/netwerk/base/public/makefile.win +++ b/mozilla/netwerk/base/public/makefile.win @@ -32,9 +32,10 @@ EXPORTS = \ $(NULL) XPIDLSRCS = \ - .\nsIAuthenticator.idl \ + .\nsIAuthenticator.idl \ .\nsIAuthPrompt.idl \ .\nsIChannel.idl \ + .\nsIDirectoryListing.idl \ .\nsIFileChannel.idl \ .\nsIFileStreams.idl \ .\nsIFileTransportService.idl \ diff --git a/mozilla/netwerk/base/public/nsIDirectoryListing.idl b/mozilla/netwerk/base/public/nsIDirectoryListing.idl new file mode 100644 index 00000000000..d12c6c5346b --- /dev/null +++ b/mozilla/netwerk/base/public/nsIDirectoryListing.idl @@ -0,0 +1,68 @@ +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 Bradley Baetz + * Portions created by the Initial Developer are Copyright (C) 2001, 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bradley Baetz + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +/** This interface allows setting the output format for a directory listing + * Implementations of this interface should default to html, since that is the + * lowest common denominator which all places can deal with. + */ +[scriptable, uuid(a465d8ed-3661-483d-a6f1-a82a6bd617b3)] +interface nsIDirectoryListing : nsISupports { + /** Use the pref */ + const unsigned long FORMAT_PREF = 0; + + /** Raw format - exactly what comes off the network. It is very + * unlikely that you want this + */ + const unsigned long FORMAT_RAW = 1; + + /** HTML */ + const unsigned long FORMAT_HTML = 2; + + /** application/http-index-format + * This will end up at the code in xpfe/components/directory so if + * you explicitly set this, be sure that this dependancy is OK + */ + const unsigned long FORMAT_HTTP_INDEX = 3; + + /** The actual format + * If the given format is not supported, NS_ERROR_FAILURE is returned. + * The getter for this returns the actual value, having translated + * FORMAT_PREF into the current pref format + */ + attribute unsigned long listFormat; +}; diff --git a/mozilla/netwerk/base/src/nsDirectoryIndexStream.cpp b/mozilla/netwerk/base/src/nsDirectoryIndexStream.cpp index 82d1c056a5b..0262ce51a56 100644 --- a/mozilla/netwerk/base/src/nsDirectoryIndexStream.cpp +++ b/mozilla/netwerk/base/src/nsDirectoryIndexStream.cpp @@ -231,14 +231,14 @@ nsDirectoryIndexStream::Init(nsIFile* aDir) rv = pc->GetCharset(kPlatformCharsetSel_FileName, tmp); if (NS_FAILED(rv)) return rv; mFSCharset.Adopt(ToNewCString(tmp)); -#else - mFSCharset.Assign(NS_LITERAL_CSTRING("ISO-8859-1")); #endif } - - mBuf.Append("301: "); - mBuf.Append(mFSCharset); - mBuf.Append('\n'); + + if (!mFSCharset.IsEmpty()) { + mBuf.Append("301: "); + mBuf.Append(mFSCharset); + mBuf.Append('\n'); + } return NS_OK; } diff --git a/mozilla/netwerk/macbuild/netwerkIDL.xml b/mozilla/netwerk/macbuild/netwerkIDL.xml index 2b5c8ba1465..46bf392031a 100644 --- a/mozilla/netwerk/macbuild/netwerkIDL.xml +++ b/mozilla/netwerk/macbuild/netwerkIDL.xml @@ -1435,6 +1435,13 @@ Text + + Name + nsIDirectoryListing.idl + MacOS + Text + + @@ -1862,6 +1869,11 @@ nsIResumableEntityID.idl MacOS + + Name + nsIDirectoryListing.idl + MacOS + @@ -3239,6 +3251,13 @@ Text + + Name + nsIDirectoryListing.idl + MacOS + Text + + @@ -3661,6 +3680,11 @@ nsIResumableEntityID.idl MacOS + + Name + nsIDirectoryListing.idl + MacOS + @@ -4207,6 +4231,12 @@ nsIMultiPartChannel.idl MacOS + + headers + Name + nsIDirectoryListing.idl + MacOS + diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 1a9ed24372b..4bbc8082603 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -45,6 +45,7 @@ #include "nsMimeTypes.h" #include "nsIProxyObjectManager.h" #include "nsReadableUtils.h" +#include "nsIPref.h" #if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; @@ -77,6 +78,7 @@ PRTimeToSeconds(PRTime t_usec) nsFTPChannel::nsFTPChannel() : mIsPending(0), mLoadFlags(LOAD_NORMAL), + mListFormat(FORMAT_HTML), mSourceOffset(0), mAmount(0), mContentLength(-1), @@ -113,6 +115,7 @@ NS_INTERFACE_MAP_BEGIN(nsFTPChannel) NS_INTERFACE_MAP_ENTRY(nsIStreamListener) NS_INTERFACE_MAP_ENTRY(nsIRequestObserver) NS_INTERFACE_MAP_ENTRY(nsICacheListener) + NS_INTERFACE_MAP_ENTRY(nsIDirectoryListing) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChannel) NS_INTERFACE_MAP_END @@ -736,3 +739,40 @@ nsFTPChannel::SetUploadFile(nsIFile *file, const char *contentType, PRInt32 cont // set the stream on ourselves return SetUploadStream(stream, nsnull, -1); } + +NS_IMETHODIMP +nsFTPChannel::SetListFormat(PRUint32 format) { + if (format != FORMAT_PREF && + format != FORMAT_RAW && + format != FORMAT_HTML && + format != FORMAT_HTTP_INDEX) { + return NS_ERROR_FAILURE; + } + + // Convert the pref value + if (format == FORMAT_PREF) { + nsresult rv; + nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + PRInt32 sFormat; + rv = prefs->GetIntPref("network.dir.format", &sFormat); + if (NS_FAILED(rv)) + format = FORMAT_HTML; // default + else + format = sFormat; + + if (format == FORMAT_PREF) { + NS_WARNING("Who set the directory format pref to 'read from prefs'??"); + return NS_ERROR_FAILURE; + } + } + + mListFormat = format; + return NS_OK; +} + +NS_IMETHODIMP +nsFTPChannel::GetListFormat(PRUint32 *format) { + *format = mListFormat; + return NS_OK; +} diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h index 5f21b8457ce..437bb557c5a 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -62,6 +62,7 @@ #include "nsIProxyInfo.h" #include "nsIResumableChannel.h" #include "nsIResumableEntityID.h" +#include "nsIDirectoryListing.h" #include "nsICacheService.h" #include "nsICacheEntryDescriptor.h" @@ -82,7 +83,8 @@ class nsFTPChannel : public nsIFTPChannel, public nsIProgressEventSink, public nsIStreamListener, public nsICacheListener, - public nsIResumableChannel + public nsIResumableChannel, + public nsIDirectoryListing { public: NS_DECL_ISUPPORTS @@ -96,6 +98,7 @@ public: NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSICACHELISTENER NS_DECL_NSIRESUMABLECHANNEL + NS_DECL_NSIDIRECTORYLISTING // nsFTPChannel methods: nsFTPChannel(); @@ -129,6 +132,7 @@ protected: PRBool mIsPending; PRUint32 mLoadFlags; + PRUint32 mListFormat; PRUint32 mSourceOffset; PRInt32 mAmount; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index d031d02182d..85302f84769 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -416,13 +416,6 @@ nsFtpState::nsFtpState() { mDRequestForwarder = nsnull; mFileSize = PRUint32(-1); mModTime = -1; - - mGenerateRawContent = PR_FALSE; - nsresult rv; - nsCOMPtr pPref(do_GetService(kPrefCID, &rv)); - if (NS_SUCCEEDED(rv) || pPref) { - pPref->GetBoolPref("network.ftp.raw_output", &mGenerateRawContent); - } } nsFtpState::~nsFtpState() @@ -1402,15 +1395,31 @@ nsFtpState::R_mdtm() { nsresult nsFtpState::SetContentType() { - if (mGenerateRawContent) { - nsAutoString fromStr(NS_LITERAL_STRING("text/ftp-dir-")); - SetDirMIMEType(fromStr); + nsCOMPtr list = do_QueryInterface(mChannel); + NS_ASSERTION(list, "ftp channel isn't listable!"); + (void)list->GetListFormat(&mListFormat); + nsCAutoString contentType; + switch (mListFormat) { + case nsIDirectoryListing::FORMAT_RAW: + { + nsAutoString fromStr(NS_LITERAL_STRING("text/ftp-dir-")); + SetDirMIMEType(fromStr); - nsCAutoString contentType;contentType.AssignWithConversion(fromStr); - return mChannel->SetContentType(contentType.get()); + contentType.Assign("text/ftp-dir-"); + } + break; + default: + NS_WARNING("Unknown directory type"); + // fall through + case nsIDirectoryListing::FORMAT_HTML: + contentType.Assign(TEXT_HTML); + break; + case nsIDirectoryListing::FORMAT_HTTP_INDEX: + contentType.Assign(APPLICATION_HTTP_INDEX_FORMAT); + break; } - return mChannel->SetContentType("application/http-index-format"); + return mChannel->SetContentType(contentType.get()); } nsresult @@ -2315,16 +2324,38 @@ nsFtpState::BuildStreamConverter(nsIStreamListener** convertStreamListener) nsAutoString fromStr(NS_LITERAL_STRING("text/ftp-dir-")); SetDirMIMEType(fromStr); - if (mGenerateRawContent) { + switch (mListFormat) { + case nsIDirectoryListing::FORMAT_RAW: converterListener = listener; - } - else - { + break; + default: + // fall through + case nsIDirectoryListing::FORMAT_HTML: + // XXX - work arround bug 126417. We have to do the chaining + // manually so that we don't crash + { + nsCOMPtr tmpListener; + rv = scs->AsyncConvertData(NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(), + NS_LITERAL_STRING(TEXT_HTML).get(), + listener, + mURL, + getter_AddRefs(tmpListener)); + if (NS_FAILED(rv)) break; + rv = scs->AsyncConvertData(fromStr.get(), + NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(), + tmpListener, + mURL, + getter_AddRefs(converterListener)); + + } + break; + case nsIDirectoryListing::FORMAT_HTTP_INDEX: rv = scs->AsyncConvertData(fromStr.get(), NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(), listener, mURL, getter_AddRefs(converterListener)); + break; } if (NS_FAILED(rv)) { diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h index 464cfbec313..7e4480ab692 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.h @@ -221,10 +221,10 @@ private: nsCOMPtr mWriteStream; // This stream is written to the server. PRPackedBool mFireCallbacks; // Fire the listener callback. PRPackedBool mIPv6Checked; - PRBool mGenerateRawContent; nsCOMPtr mPrompter; nsCOMPtr mFTPEventSink; nsCOMPtr mAuthPrompter; + PRUint32 mListFormat; static PRUint32 mSessionStartTime; diff --git a/mozilla/netwerk/protocol/gopher/src/Makefile.in b/mozilla/netwerk/protocol/gopher/src/Makefile.in index 901ddfe7789..eb43b6bd6da 100644 --- a/mozilla/netwerk/protocol/gopher/src/Makefile.in +++ b/mozilla/netwerk/protocol/gopher/src/Makefile.in @@ -31,6 +31,7 @@ REQUIRES = xpcom \ necko \ string \ mimetype \ + pref \ $(NULL) CPPSRCS = \ diff --git a/mozilla/netwerk/protocol/gopher/src/makefile.win b/mozilla/netwerk/protocol/gopher/src/makefile.win index cef540b5dba..a229d5bb539 100644 --- a/mozilla/netwerk/protocol/gopher/src/makefile.win +++ b/mozilla/netwerk/protocol/gopher/src/makefile.win @@ -24,6 +24,7 @@ REQUIRES = xpcom \ string \ mimetype \ necko \ + pref \ $(NULL) LIBRARY_NAME=nkgopher_s diff --git a/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp b/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp index 37a1f9d3e0a..51908ff2589 100644 --- a/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp +++ b/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp @@ -39,6 +39,7 @@ #include "nsIProgressEventSink.h" #include "nsNetUtil.h" #include "prlog.h" +#include "nsIPref.h" static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID); @@ -54,6 +55,7 @@ extern PRLogModuleInfo* gGopherLog; nsGopherChannel::nsGopherChannel() : mContentLength(-1), mActAsObserver(PR_TRUE), + mListFormat(FORMAT_HTML), mType(-1), mStatus(NS_OK) { @@ -69,11 +71,12 @@ nsGopherChannel::~nsGopherChannel() #endif } -NS_IMPL_THREADSAFE_ISUPPORTS4(nsGopherChannel, +NS_IMPL_THREADSAFE_ISUPPORTS5(nsGopherChannel, nsIChannel, nsIRequest, nsIStreamListener, - nsIRequestObserver); + nsIRequestObserver, + nsIDirectoryListing); nsresult nsGopherChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo) @@ -326,7 +329,20 @@ nsGopherChannel::GetContentType(char* *aContentType) *aContentType = nsCRT::strdup(TEXT_HTML); break; case '1': - *aContentType = nsCRT::strdup(APPLICATION_HTTP_INDEX_FORMAT); + switch (mListFormat) { + case nsIDirectoryListing::FORMAT_RAW: + *aContentType = strdup("text/gopher-dir"); + break; + default: + NS_WARNING("Unknown directory type"); + // fall through + case nsIDirectoryListing::FORMAT_HTML: + *aContentType = strdup(TEXT_HTML); + break; + case nsIDirectoryListing::FORMAT_HTTP_INDEX: + *aContentType = strdup(APPLICATION_HTTP_INDEX_FORMAT); + break; + } break; case '2': // CSO search - unhandled, should not be selectable *aContentType = nsCRT::strdup(TEXT_HTML); @@ -511,11 +527,39 @@ nsGopherChannel::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, // What we now do depends on what type of file we have if (mType=='1' || mType=='7') { // Send the directory format back for a directory - rv = StreamConvService->AsyncConvertData(NS_LITERAL_STRING("text/gopher-dir").get(), - NS_LITERAL_STRING("application/http-index-format").get(), - this, - mUrl, - getter_AddRefs(converterListener)); + switch (mListFormat) { + case nsIDirectoryListing::FORMAT_RAW: + converterListener = this; + break; + default: + // fall through + case nsIDirectoryListing::FORMAT_HTML: + // XXX - work arround bug 126417. We have to do the chaining + // manually so that we don't crash + { + nsCOMPtr tmpListener; + rv = StreamConvService->AsyncConvertData( + NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(), + NS_LITERAL_STRING(TEXT_HTML).get(), + this, + mUrl, + getter_AddRefs(tmpListener)); + if (NS_FAILED(rv)) break; + rv = StreamConvService->AsyncConvertData(NS_LITERAL_STRING("text/gopher-dir").get(), + NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(), + tmpListener, + mUrl, + getter_AddRefs(converterListener)); + } + break; + case nsIDirectoryListing::FORMAT_HTTP_INDEX: + rv = StreamConvService->AsyncConvertData(NS_LITERAL_STRING("text/gopher-dir").get(), + NS_LITERAL_STRING(APPLICATION_HTTP_INDEX_FORMAT).get(), + this, + mUrl, + getter_AddRefs(converterListener)); + break; + } if (NS_FAILED(rv)) return rv; } else if (mType=='0') { // Convert general file @@ -648,3 +692,40 @@ nsGopherChannel::SendRequest(nsITransport* aTransport) return rv; } +NS_IMETHODIMP +nsGopherChannel::SetListFormat(PRUint32 format) { + if (format != FORMAT_PREF && + format != FORMAT_RAW && + format != FORMAT_HTML && + format != FORMAT_HTTP_INDEX) { + return NS_ERROR_FAILURE; + } + + // Convert the pref value + if (format == FORMAT_PREF) { + nsresult rv; + nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + PRInt32 sFormat; + rv = prefs->GetIntPref("network.dir.format", &sFormat); + if (NS_FAILED(rv)) + format = FORMAT_HTML; // default + else + format = sFormat; + + if (format == FORMAT_PREF) { + NS_WARNING("Who set the directory format pref to 'read from prefs'??"); + return NS_ERROR_FAILURE; + } + } + + mListFormat = format; + return NS_OK; +} + +NS_IMETHODIMP +nsGopherChannel::GetListFormat(PRUint32 *format) { + *format = mListFormat; + return NS_OK; +} + diff --git a/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.h b/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.h index 7194f5385ed..bfdec6d55a8 100644 --- a/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.h +++ b/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.h @@ -39,15 +39,18 @@ #include "nsIStreamListener.h" #include "nsITransport.h" #include "nsIProxyInfo.h" +#include "nsIDirectoryListing.h" class nsGopherChannel : public nsIChannel, - public nsIStreamListener { + public nsIStreamListener, + public nsIDirectoryListing { public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST NS_DECL_NSICHANNEL NS_DECL_NSISTREAMLISTENER NS_DECL_NSIREQUESTOBSERVER + NS_DECL_NSIDIRECTORYLISTING // nsGopherChannel methods: nsGopherChannel(); @@ -73,6 +76,7 @@ protected: PRUint32 mBufferSegmentSize; PRUint32 mBufferMaxSize; PRBool mActAsObserver; + PRUint32 mListFormat; nsXPIDLCString mHost; PRInt32 mPort; diff --git a/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp b/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp index 56fc37086e2..63da31ca0d1 100644 --- a/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/mozilla/xpfe/components/directory/nsDirectoryViewer.cpp @@ -89,6 +89,7 @@ #include "nsIDOMText.h" #include "nsIPref.h" #include "nsIStreamConverterService.h" +#include "nsIDirectoryListing.h" //---------------------------------------------------------------------- // @@ -1017,6 +1018,12 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure) } if (NS_SUCCEEDED(rv) && (channel)) { channel->SetNotificationCallbacks(httpIndex); + nsCOMPtr dirList = do_QueryInterface(channel); + NS_ASSERTION(dirList, "Directory listing doesn't impl nsIDirectoryListing"); + if (dirList) { + rv = dirList->SetListFormat(nsIDirectoryListing::FORMAT_HTTP_INDEX); + NS_ASSERTION(NS_SUCCEEDED(rv), "Could not set directory list format"); + } rv = channel->AsyncOpen(httpIndex, aSource); } } @@ -1363,8 +1370,12 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand, nsCOMPtr prefSrv = do_GetService(NS_PREF_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; - PRBool useHtml; - rv = prefSrv->GetBoolPref("network.dir.generate_html", &useHtml); + PRBool useXUL = PR_FALSE; + PRInt32 dirPref; + rv = prefSrv->GetIntPref("network.dir.format", &dirPref); + if (NS_SUCCEEDED(rv) && dirPref == nsIDirectoryListing::FORMAT_HTTP_INDEX) { + useXUL = PR_TRUE; + } // We need to disable html mode for file:///, at least for the moment // The charset coding isn't quite right for non ASCII systems @@ -1374,12 +1385,12 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand, if (NS_SUCCEEDED(rv)) { PRBool isFile; if (NS_SUCCEEDED(uri->SchemeIs("file", &isFile)) && isFile) - useHtml = PR_FALSE; + useXUL = PR_TRUE; } PRBool viewSource = (PL_strstr(aContentType,"view-source") != 0); - if ((NS_FAILED(rv) || !useHtml) && !viewSource) { + if ((NS_FAILED(rv) || useXUL) && !viewSource) { // This is where we shunt the HTTP/Index stream into our datasource, // and open the directory viewer XUL file as the content stream to @@ -1407,7 +1418,7 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand, aContainer, aExtraInfo, getter_AddRefs(listener), aDocViewerResult); if (NS_FAILED(rv)) return rv; - + rv = channel->AsyncOpen(listener, nsnull); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/xpfe/components/prefwindow/resources/content/pref-debug2.xul b/mozilla/xpfe/components/prefwindow/resources/content/pref-debug2.xul index bab54a39089..32e7a6161c8 100644 --- a/mozilla/xpfe/components/prefwindow/resources/content/pref-debug2.xul +++ b/mozilla/xpfe/components/prefwindow/resources/content/pref-debug2.xul @@ -31,7 +31,7 @@ @@ -46,8 +46,18 @@ prefstring="network.http.keep-alive"/> - + &dirFormat; + + + + + + + +