michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsdirectoryviewer__h____ michael@0: #define nsdirectoryviewer__h____ michael@0: michael@0: #include "nsNetUtil.h" michael@0: #include "nsIStreamListener.h" michael@0: #include "nsIContentViewer.h" michael@0: #include "nsIHTTPIndex.h" michael@0: #include "nsIRDFService.h" michael@0: #include "nsIRDFDataSource.h" michael@0: #include "nsIRDFLiteral.h" michael@0: #include "nsIDocumentLoaderFactory.h" michael@0: #include "nsITimer.h" michael@0: #include "nsISupportsArray.h" michael@0: #include "nsXPIDLString.h" michael@0: #include "nsIDirIndexListener.h" michael@0: #include "nsIFTPChannel.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: michael@0: class nsDirectoryViewerFactory : public nsIDocumentLoaderFactory michael@0: { michael@0: public: michael@0: nsDirectoryViewerFactory(); michael@0: virtual ~nsDirectoryViewerFactory(); michael@0: michael@0: // nsISupports interface michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIDOCUMENTLOADERFACTORY michael@0: }; michael@0: michael@0: class nsHTTPIndex : public nsIHTTPIndex, michael@0: public nsIRDFDataSource, michael@0: public nsIStreamListener, michael@0: public nsIDirIndexListener, michael@0: public nsIInterfaceRequestor, michael@0: public nsIFTPEventSink michael@0: { michael@0: private: michael@0: michael@0: // note: these are NOT statics due to the native of nsHTTPIndex michael@0: // where it may or may not be treated as a singleton michael@0: michael@0: nsCOMPtr kNC_Child; michael@0: nsCOMPtr kNC_Comment; michael@0: nsCOMPtr kNC_Loading; michael@0: nsCOMPtr kNC_URL; michael@0: nsCOMPtr kNC_Description; michael@0: nsCOMPtr kNC_ContentLength; michael@0: nsCOMPtr kNC_LastModified; michael@0: nsCOMPtr kNC_ContentType; michael@0: nsCOMPtr kNC_FileType; michael@0: nsCOMPtr kNC_IsContainer; michael@0: nsCOMPtr kTrueLiteral; michael@0: nsCOMPtr kFalseLiteral; michael@0: michael@0: nsCOMPtr mDirRDF; michael@0: michael@0: protected: michael@0: // We grab a reference to the content viewer container (which michael@0: // indirectly owns us) so that we can insert ourselves as a global michael@0: // in the script context _after_ the XUL doc has been embedded into michael@0: // content viewer. We'll know that this has happened once we receive michael@0: // an OnStartRequest() notification michael@0: michael@0: nsCOMPtr mInner; michael@0: nsCOMPtr mConnectionList; michael@0: nsCOMPtr mNodeList; michael@0: nsCOMPtr mTimer; michael@0: nsCOMPtr mParser; michael@0: nsCString mBaseURL; michael@0: nsCString mEncoding; michael@0: bool mBindToGlobalObject; michael@0: nsIInterfaceRequestor* mRequestor; // WEAK michael@0: nsCOMPtr mDirectory; michael@0: michael@0: nsHTTPIndex(nsIInterfaceRequestor* aRequestor); michael@0: nsresult CommonInit(void); michael@0: nsresult Init(nsIURI* aBaseURL); michael@0: void GetDestination(nsIRDFResource* r, nsXPIDLCString& dest); michael@0: bool isWellknownContainerURI(nsIRDFResource *r); michael@0: nsresult AddElement(nsIRDFResource *parent, nsIRDFResource *prop, michael@0: nsIRDFNode *child); michael@0: michael@0: static void FireTimer(nsITimer* aTimer, void* aClosure); michael@0: michael@0: public: michael@0: nsHTTPIndex(); michael@0: virtual ~nsHTTPIndex(); michael@0: nsresult Init(void); michael@0: michael@0: static nsresult Create(nsIURI* aBaseURI, nsIInterfaceRequestor* aContainer, michael@0: nsIHTTPIndex** aResult); michael@0: michael@0: // nsIHTTPIndex interface michael@0: NS_DECL_NSIHTTPINDEX michael@0: michael@0: // NSIRDFDataSource interface michael@0: NS_DECL_NSIRDFDATASOURCE michael@0: michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: michael@0: NS_DECL_NSIDIRINDEXLISTENER michael@0: NS_DECL_NSIINTERFACEREQUESTOR michael@0: NS_DECL_NSIFTPEVENTSINK michael@0: michael@0: // nsISupports interface michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHTTPIndex, nsIHTTPIndex) michael@0: }; michael@0: michael@0: // {82776710-5690-11d3-BE36-00104BDE6048} michael@0: #define NS_DIRECTORYVIEWERFACTORY_CID \ michael@0: { 0x82776710, 0x5690, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } michael@0: michael@0: #endif // nsdirectoryviewer__h____